bruceb33
Posts: 5
Joined: Tue Dec 21, 2010 7:37 pm

Possible bug: Event fires but no data

Tue Dec 21, 2010 8:35 pm

I have used SerialTools to write an emulator for a piece of hardware. When accessing the hardware from another application, that application works fine. If instead I access the emulator from the application I found that the standard Microsoft serial port DataReceived event is firing with no data being available (BytesToRead is zero). If I just ignore the event then it does NOT fire again (until more data arrives). If however I loop/sleep until BytesToRead is not zero then the data is available - this usually only takes a few milliseconds.

This could be a bug in the dotNET serial port driver, however I am using dotNET 4.0 and I would have thought such a major bug would have been picked up by now. It could also be particular to the hardware we are using in the way it sets the control lines. I thought however it was worth posting this as I have found no way around it and have had to stop using SerialTools as a result.

Note that the problem is not with the emulator code - it is every application that is calling it. If I change the application from using the emulator (with its virtual port) to use the physical com port for the actual hardware then the application works fine. There was nothing I could do in the emulator to fix or even affect this problem. I obviously can't change all my applications (and other people's) to cater for this.

For info, the error I received in the application was "The I/O operation has been aborted because of either a thread exit or an application request." which seems to suggest that the virtual port has temporarily disappeared.

This problem occurs with SerialTools running on Windows-7 32-bit. I have not tested to see if it occurs on other platforms. The problem only occured after I moved to Win-7 so this suggests it is specific to that platform, but I am not sure of this.

Hope this is of help to someone.

Return to “SerialTools”