Menu

Timing issue

Help
2008-01-25
2013-05-20
  • Glen Lauridsen

    Glen Lauridsen - 2008-01-25

    Hi I was wondering if you could point me in the right direction to fix my problem described below.

    I'm creating a intermediate software that is put in between an existing application and some hardware. The idea is for the intermediate software to emulate the hardware devices so that is can control the communication travelling between the existing software and the devices.
    To create the communication link between the intermediate software and the existing application I use the com0com driver - but I'm having some difficulties achieving the network initialization timing. The existing application has some strict timing settings that works as followed:

    The application first sends a reset command (0x7E078000).
    Shortly after the application sends a init command (0x3F).
    The application then expects to receive an acknowledge command (0x012A0D0A) within the next 100 ms.
    If it doesn't receive the data within these 100 ms it closes the port.

    In 30% of the tries it actually works but in the rest it fails - which isn't fairly good enough. I reckon the problem is that the virtual port waits to see whether more data is being transmitted or something like that.

    By looking at the log I can see that when it succeeds the 0x3F byte is written and read at the same ms:
    - 2008/01/24 14:40:33.500 COM10/FP FdoPortRead READ 1: 3F * ? *, status=SUCCESS
    - 2008/01/24 14:40:33.500 COM11/FP FdoPortWrite WRITE 1: 3F * ? *, status=SUCCESS
    When it fails it look like this:
    - 2008/01/24 14:26:46.875 COM11/FP FdoPortWrite WRITE 1: 3F * ? *, status=SUCCESS
    - 2008/01/24 14:26:46.875 COM11/FP c0cRead READ length=2048
    - 2008/01/24 14:26:46.875 COM11/FP FdoPortRead READ 0: *  *, status=SUCCESS
       ...
    - 2008/01/24 14:26:46.906 COM11/FP c0cRead READ length=2048
    - 2008/01/24 14:26:46.906 COM11/FP FdoPortRead READ 0: *  *, status=SUCCESS
    - 2008/01/24 14:26:46.906 COM10/FP c0cIoControl WAIT_ON_MASK [RXCHAR|RXFLAG|CTS|DSR|RLSD|BREAK|ERR|RING]
    - 2008/01/24 14:26:46.921 COM10/FP c0cIoControl GET_COMMSTATUS
    - 2008/01/24 14:26:46.921 COM10/FP IOCTL_WAIT_ON_MASK, status=PENDING
    - 2008/01/24 14:26:46.921 COM10/FP FdoPortIoCtl GET_COMMSTATUS { AmountInInQueue=1 }, status=SUCCESS
    - 2008/01/24 14:26:46.921 COM10/FP c0cIoControl GET_COMMSTATUS
    - 2008/01/24 14:26:46.921 COM10/FP FdoPortIoCtl GET_COMMSTATUS { AmountInInQueue=1 }, status=SUCCESS
    - 2008/01/24 14:26:46.921 COM10/FP c0cIoControl GET_COMMSTATUS
    - 2008/01/24 14:26:46.921 COM10/FP FdoPortIoCtl GET_COMMSTATUS { AmountInInQueue=1 }, status=SUCCESS
    - 2008/01/24 14:26:46.921 COM10/FP c0cRead READ length=1
    - 2008/01/24 14:26:46.921 COM10/FP FdoPortRead READ 1: 3F * ? *, status=SUCCESS

    I'll be thankful for any help!

     
    • Vyacheslav Frolov

      I sent you my direct e-mail.
      Send me the total log file.

       
    • Vyacheslav Frolov

      IMO the problem is because Aplication wastes 100% CPU for
      poling COM11 so Intermediate Software does not have enough CPU time.
      Try to change priority of Aplication or Intermediate Software.

      ------

      *** Aplication puts a char to COM11:

      2008/01/24 14:26:46.875 COM11/FP c0cWrite WRITE length=1

      *** A char transfered from COM11 to COM10 and driver puts to Intermediate Software RXCHAR event:

      2008/01/24 14:26:46.875 COM10/FP complete WAIT_ON_MASK [RXCHAR], status=SUCCESS

      *** Driver return control to Aplication:

      2008/01/24 14:26:46.875 COM11/FP FdoPortWrite WRITE 1: 3F * ? *, status=SUCCESS

      *** Aplication wastes 100% CPU for poling COM11

      2008/01/24 14:26:46.875 COM11/FP c0cRead READ length=2048
      2008/01/24 14:26:46.875 COM11/FP FdoPortRead READ 0: *  *, status=SUCCESS
      ........................
      2008/01/24 14:26:46.906 COM11/FP c0cRead READ length=2048
      2008/01/24 14:26:46.906 COM11/FP FdoPortRead READ 0: *  *, status=SUCCESS

      *** Intermediate Software sometimes gets CPU to work

      2008/01/24 14:26:46.906 COM10/FP c0cIoControl WAIT_ON_MASK [RXCHAR|RXFLAG|CTS|DSR|RLSD|BREAK|ERR|RING]
      2008/01/24 14:26:46.921 COM10/FP c0cIoControl GET_COMMSTATUS
      2008/01/24 14:26:46.921 COM10/FP IOCTL_WAIT_ON_MASK, status=PENDING
      2008/01/24 14:26:46.921 COM10/FP FdoPortIoCtl GET_COMMSTATUS { AmountInInQueue=1 }, status=SUCCESS
      2008/01/24 14:26:46.921 COM10/FP c0cIoControl GET_COMMSTATUS
      2008/01/24 14:26:46.921 COM10/FP FdoPortIoCtl GET_COMMSTATUS { AmountInInQueue=1 }, status=SUCCESS
      2008/01/24 14:26:46.921 COM10/FP c0cIoControl GET_COMMSTATUS
      2008/01/24 14:26:46.921 COM10/FP FdoPortIoCtl GET_COMMSTATUS { AmountInInQueue=1 }, status=SUCCESS
      2008/01/24 14:26:46.921 COM10/FP c0cRead READ length=1
      2008/01/24 14:26:46.921 COM10/FP FdoPortRead READ 1: 3F * ? *, status=SUCCESS

      *** Aplication wastes 100% CPU for poling COM11

      2008/01/24 14:26:46.921 COM11/FP c0cRead READ length=2048
      2008/01/24 14:26:46.921 COM11/FP FdoPortRead READ 0: *  *, status=SUCCESS
      ........................
      2008/01/24 14:26:46.953 COM11/FP c0cRead READ length=2048
      2008/01/24 14:26:46.953 COM11/FP FdoPortRead READ 0: *  *, status=SUCCESS

      *** Aplication stops

      2008/01/24 14:26:46.968 COM11/FP c0cIoControl GET_BAUD_RATE

       
    • Glen Lauridsen

      Glen Lauridsen - 2008-01-25

      Your absolutely right. By lowering the priority of the existing application everything works.
      Thank you very much :-)

       

Log in to post a comment.