Menu

com0com works fine, real device does not

Help
2009-06-05
2013-05-20
  • Gili Tzabari

    Gili Tzabari - 2009-06-05

    Hi,

    I am running the same application against com0com and a real hardware device. Sending bytes to com0com's port works fine, but blocks against the real hardware. That is, the write operation never completes.

    If I use Putty against the device it works just fine so I am assuming something is wrong with my application. The odd thing is that (as far as I can tell) my application is using an *identical* configuration as Putty: 9600 8-N-1 with no flow control.

    I tried invoking ClearCommError() but it indicates there are no errors, so I'm stumped. Any ideas on why the outbound write would hang?

    Thanks,
    Gili

     
    • Gili Tzabari

      Gili Tzabari - 2009-06-05

      I just found the com0com trace file, which is very useful, thanks! What win32 functions correspond to the following lines?

      2009/06/05 10:22:11.215 COM6/FP c0cIoControl GET_BAUD_RATE
      2009/06/05 10:22:11.216 COM6/FP FdoPortIoCtl GET_BAUD_RATE BaudRate=9600, status=SUCCESS
      2009/06/05 10:22:11.216 COM6/FP c0cIoControl GET_LINE_CONTROL
      2009/06/05 10:22:11.217 COM6/FP FdoPortIoCtl GET_LINE_CONTROL StopBits=0 Parity=0 WordLength=8, status=SUCCESS
      2009/06/05 10:22:11.218 COM6/FP c0cIoControl GET_CHARS
      2009/06/05 10:22:11.218 COM6/FP FdoPortIoCtl GET_CHARS EofChar=0x0 ErrorChar=0x0 BreakChar=0x0 EventChar=0x0 XonChar=0x11 XoffChar=0x13, status=SUCCESS
      2009/06/05 10:22:11.219 COM6/FP c0cIoControl GET_HANDFLOW
      2009/06/05 10:22:11.219 COM6/FP FdoPortIoCtl GET_HANDFLOW Hand[DTR_CONTROL] Flow[RTS_CONTROL] XonLim=2048 XoffLim=512, status=SUCCESS
      2009/06/05 10:22:11.220 COM6/FP c0cIoControl GET_BAUD_RATE
      2009/06/05 10:22:11.220 COM6/FP FdoPortIoCtl GET_BAUD_RATE BaudRate=9600, status=SUCCESS
      2009/06/05 10:22:11.221 COM6/FP c0cIoControl GET_LINE_CONTROL
      2009/06/05 10:22:11.222 COM6/FP FdoPortIoCtl GET_LINE_CONTROL StopBits=0 Parity=0 WordLength=8, status=SUCCESS
      2009/06/05 10:22:11.222 COM6/FP c0cIoControl GET_CHARS
      2009/06/05 10:22:11.223 COM6/FP FdoPortIoCtl GET_CHARS EofChar=0x0 ErrorChar=0x0 BreakChar=0x0 EventChar=0x0 XonChar=0x11 XoffChar=0x13, status=SUCCESS
      2009/06/05 10:22:11.223 COM6/FP c0cIoControl GET_HANDFLOW
      2009/06/05 10:22:11.224 COM6/FP FdoPortIoCtl GET_HANDFLOW Hand[DTR_CONTROL] Flow[RTS_CONTROL] XonLim=2048 XoffLim=512, status=SUCCESS
      2009/06/05 10:22:11.224 COM6/FP c0cIoControl SET_BAUD_RATE BaudRate=300
      2009/06/05 10:22:11.225 COM6/FP c0cIoControl SET_RTS
      2009/06/05 10:22:11.225 COM6/FP c0cIoControl SET_DTR
      2009/06/05 10:22:11.226 COM6/FP c0cIoControl SET_LINE_CONTROL StopBits=0 Parity=0 WordLength=8
      2009/06/05 10:22:11.226 COM6/FP c0cIoControl SET_CHARS EofChar=0x0 ErrorChar=0x0 BreakChar=0x0 EventChar=0x0 XonChar=0x11 XoffChar=0x13
      2009/06/05 10:22:11.227 COM6/FP c0cIoControl SET_HANDFLOW Hand[DTR_CONTROL] Flow[RTS_CONTROL] XonLim=2048 XoffLim=512
      2009/06/05 10:22:11.227 COM6/FP c0cIoControl SET_TIMEOUTS Read[Interval=1 Multiplier=0 Constant=0] Write[Multiplier=0 Constant=0]

      I've got a trace log for Putty and another one for my application. I would like to reverse engineer what functions Putty is invoking and doing the same myself.

      Thanks,
      Gili

       
      • Gili Tzabari

        Gili Tzabari - 2009-06-05

        I figured it out!

        When flow control was disabled I was setting:

        dcb.fDtrControl = DTR_CONTROL_DISABLE;
        dcb.fRtsControl = RTS_CONTROL_DISABLE;

        but the code should be:

        dcb.fDtrControl = DTR_CONTROL_ENABLE;
        dcb.fRtsControl = RTS_CONTROL_ENABLE;

        Thanks again for com0com. It's truly a great piece of software!

        Gili

         

Log in to post a comment.