Re: ReadFile API suddenly starts returning 0 bytes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Some things to consider:-

Do you have confidence in the serial port driver? It could be a problem in the input buffer of the driver, eg improper synchronisation of reads (from ReadFile) and writes (from the driver IST)?

Do you know if the serial port driver IST is still running - can you get a scope on the IRQ line?

Do you have source code for the serial device driver? Can you debug it/enable any debug zones?

Tony

Karan Khanna wrote:
Hi, I am facing a peculiar problem. Here is how it goes:

Set-up: WinCE 5.0 on x86 based 500 MHz SBC.

Application: We have developed an application that must perform upto 5 modbus like transections on serial port at 57600 baud every 200 ms. The thread therefore runs at a priority of 245 - higest amongst all threads in application.

Problem:
Normally every thing works fine. Occasionally however, ReadFile() API starts returning number of bytes read as 0 (with a return status of TRUE). At this point, I stop my debugger (without formally closing the serial port) and again run the application with debugger. The ReadFile is still stubborn and does'nt return a single byte what so ever. Now I must re-cycle power to the device to get the ReadFile() behave correctly. I can see the correct data being recieved by my SBC using a scope.

Serial port timeouts:
ReadIntervalTimeout = 10;
ReadTotalTimeoutMultiplier = 0; ReadTotalTimeoutConstant = 35;
WriteTotalTimeoutConstant = 35;
WriteTotalTimeoutMultiplier = 0;

The largest reply of all is not longer than 3.1 ms at 57600 baud.

calling sequence:

1. Flush Input/Output buffers of serial port driver
2. Send query using WriteFile()
3. Call ReadFile()
4. A nominal wait
5. Reapeat the steps 1 through 4 for four more similar queries 6. Repeat steps 1 Through 5 every 200 ms

Can anyone suggest me, why ReadFile() could work normal, and then suddenly start returning 0 bytes?
.



Relevant Pages

  • RE: difference of SerialPort class between CE5 and WM6
    ... I think that the most-likely cause for this is the serial port driver in your ... standard calls to check the RX buffer level, uses ReadFileto read the data ... My company is developping a RFID Reader embedded in a device (M3 ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: HEADS UP: sio(4) -> uart(4)
    ... Make uartthe default serial port driver, ... in your kernel configuration file. ... When the machine boots I get: ...
    (freebsd-current)
  • HEADS UP: sio(4) -> uart(4)
    ... Make uartthe default serial port driver, ... in your kernel configuration file. ... | uses different names for its device nodes. ...
    (freebsd-current)
  • Re: Can I read data simultaneously from same serial port?
    ... then what you need is a virtual serial port driver. ... Search in the Windows CE newsgroups for more on virtual serial port drivers. ... to COMx), Now I need to open COMx also to read data. ...
    (microsoft.public.windowsce.embedded.vc)
  • Simple serial port
    ... I'm looking for a way to implement a simple functionality in my serial port ... serial port while the first thread is waiting in the readfile function. ... all works very well on the Pocket PC! ... specified in the COMMTIMEOUT structure. ...
    (microsoft.public.dotnet.languages.csharp)