USB Serial Communication, ReadFile() returns zero bytes read RRS feed

  • Question

  • I am trying to implement serial communication (Wince device <-> PC) by using USB function serial client. On PC side, I am using WinUSB, on Device/WinCE side, CreateFile on COM port and using ReadFile/WriteFile. On WinCE, I can open COM port, ReadFile succeeds, but it always returns 0 for "NumberOfBytesRead".

    Device does seem to receive data, because I can see this in debug window when sending data from PC:

    3936716 PID:400002 TID:1fb0002 [d0491a90]OUT Transfer : 0x200 bytes received
    3936716 PID:400002 TID:1fb0002 [0xd0491a90]m_state = EPT_IDLE;
    3936716 PID:400002 TID:1fb0002 UsbFnMdd!CPipeBase::TransferComplete: Completing transfer 0xd04966d0 on pipe at address 2 (0xd0492390)
    3936716 PID:400002 TID:1fb0002 [d0491a90] Issue transfer OUT begin for 0x200 bytes
    3936717 PID:400002 TID:100000a UsbFnMdd!CPipeBase::CloseTransfer: Closing transfer 0xd04966d0 on pipe at address 2 (0xd0492390)
    3936718 PID:400002 TID:100000a UsbFnMdd!CPipeBase::FreeTransfer: Placing transfer 0xd04966d0 on free list
    3936718 PID:400002 TID:100000a UsbFnMdd!CPipeBase::IssueTransfer: Issuing OUT transfer (0xd04966d0) on ep 2 (0x02) for 512 bytes

     However, that data never reaches my application... If I open USB as "COM4:", ReadFile succeeds. If I open as "UFN1:", ReadFile fails with error code 50 (The request is not supported). In both cases NumberOfBytesRead is always zero.

    Registry on device:


        "FriendlyName"="USB Cable Connection"
        "Manufacturer"="Generic Manufacturer (PROTOTYPE--Remember to change idVendor)"
        "Product"="Generic Serial (PROTOTYPE--Remember to change idVendor)"


        "Manufacturer"="Generic Manufacturer (PROTOTYPE--Remember to change idVendor)"
        "Product"="Generic Serial (PROTOTYPE--Remember to change idVendor)"



    1. Can I use "serialusbfn.dll" for this purpose or I have to write my own driver?

    2. Do I have to include activesync in BSP?

    3. Is there anything else I am missing here?


    Friday, November 19, 2010 11:42 AM


  • I found the problem. I wasn't calling SetCommState(), and DCB structure was left uninitialized. Problem was actually caused by fDsrSensitivity member which was not set to FALSE, and any received data was ignored.

    • Marked as answer by Bulma Tuesday, November 23, 2010 8:36 AM
    Monday, November 22, 2010 8:38 AM