Re: ReadFile API suddenly starts returning 0 bytes
- From: Tony Hedge <tonyatbenthicsciencesdotcodotuk>
- Date: Wed, 11 Mar 2009 16:10:25 +0000
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?
- References:
- ReadFile API suddenly starts returning 0 bytes
- From: Karan Khanna
- ReadFile API suddenly starts returning 0 bytes
- Prev by Date: Re: ReadFile API suddenly starts returning 0 bytes
- Next by Date: Re: WLAN Card for Windows CE 6.0
- Previous by thread: Re: ReadFile API suddenly starts returning 0 bytes
- Index(es):
Relevant Pages
|