TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sam
NA
166
0
RS232 port reading technics
Oct 28 2010 10:09 AM
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.
Reply
Answers (
0
)
Thread.Sleep issue
how to send a "spacebar" press bar to remote device?