Solved

Listening the serial port

Posted on 2009-05-19
1
250 Views
Last Modified: 2012-05-07
Hello,

I have a vb.net 2008 application. I am sending the following data to serial port: 01, AA, 02, 03, 09, CS. After sending 01 I wait for nearly 1 ms and then send AA, again wait for 1 ms and then send other set of data and so on. Now following is my query:
After I send the last data CS, I want to wait for 4 ms and then go into listen mode to listen and read any data that comes to serial port. How do I achieve this?
0
Comment
Question by:vj_mi
1 Comment
 
LVL 15

Accepted Solution

by:
ChloesDad earned 500 total points
ID: 24428938
The serial port control has a datareceived event, so you can do one of two things

1 Have the event handler always connected, and use a timer to ignore andything received before the 4ma are up, or
2 add the handler programmatically after the 4ms are up
option 1
 
private serialport_dataReceived(sender as object, e as eventargs) handles serialport.datareceived
 
if i'm_ready_for_data then
' read data from port
endif
 
end sub
 
option 2
 
after the 4ms wait add
 
addhandler serialport.datareceived, addressof serialport_dataReceived
 
the code for the eventhandler becomes
 
private serialport_dataReceived(sender as object, e as eventargs) 
 
' read data from port
 
end sub

Open in new window

0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question