First of all, do
all the serial port activity in a separate thread. Also, use
BeginInvoke
, instead
Invoke
. For some understanding, please see my past answers:
(screwed up, please see below),
Problem with Treeview Scanner And MD5[
^].
(Sorry, we are experiencing a problem with CodeProject link postings. My first link was screwed up. Please use:
"http://www.codeproject.com/Answers/159125/Control-Invoke-vs-Control-BeginInvoke#answer1".
Sorry for the inconvenience.)
I don't know all the detail. Functionality always depends on what you have on the other end of your RS-232 cable. In some devices, the control is not well implemented, and the data can be lost on the other side: the messages could be lost if you don't send timely confirmation, delay reading from the port or something like that. If that happens, experiment with a very fast application, without UI. You can even boost thread/process priority and use
thread affinity to dedicate your serial communication thread to a fixed CPU code. If you do that and spot any difference in the rate of lost messages, my guess is correct. If not, there is a flaw in some logic, again, either on your side, or the side of the device connected to a serial port.
—SA