RS232 port reading technics
Hello,
I LOVE this forum. I (almost) always get the right answer from very good friends.
I hope the day will come when I can help others....still learning.
In my application I read RS232 port with arbitrary data streams.
Each message ends with double LF/NL "\r\n\r\n" which I use as my messae end label.
I first used the msg = comPort.ReadExisting(); that I parsed programatically, but then I found out that I can let the prot do the work, and changed to:
msg = comPort.ReadTo("\r\n\r\n");
reading goes perfect, and I was happy until I found out that more often than not, when closing the port I get an error from the prot.
"The I/O operation has been aborted because of either a thread exit or an application request."
I assume it is due to incomplete reading of the message, which I don't really care about (I am closing the port, am I not?).
I can easily ignore the error by throughing an exception and returning from the catch, which works well, but, I am sure this is the wrong way to go.
Any good idea on how to make it right?
Thanks.