Hi,
I'm looking for a way to implement a simple functionality in my serial port
C# wrapper. I'm making a program that must run on both a Pocket PC and a
"normal" PC. The application is quite simple:
A calling thread is blocked untill Readfile returns with "bytesToRead"
numbers of bytes or untill "TotalTimeout" specified in the "COMMTIMEOUT"
struct has been exceeded. Another thread must be able to write to the same
serial port while the first thread is waiting in the readfile function. This
all works very well on the Pocket PC! But on the desktop PC the writefile is
prevented to be executed until the readfile has finished. I have tried
setting the Overlapped to true in createfile and applied both readfile and
writefile with an overlapped struct - This makes however the readfile return
immediately no matter if any characters are received and whatever is
specified in the COMMTIMEOUT structure. The COMMTIMEOUT struct is specified
as this:
CommPort.ReadIntervalTimeout = 5000;
CommPort.ReadTotalTimeoutMultiplier = 0;
CommPort.ReadTotalTimeoutConstant = 5000;
CommPort.WriteTotalTimeoutMultiplier = 0;
CommPort.WriteTotalTimeoutConstant = 1000;
Does anyone knows a proper way to handle this??? Any help is highly
appreciated!
I don't use WaitCommEvents and all that stuff and would prefer not to (it
shouldn't be neccesary as the application is quite simple). I have had a
look at the Serial Class from OpenNetCF but it is far to heavy for my
application.
Thanks
Ole