Solved

Listening the serial port

Posted on 2009-05-19
1
247 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

930 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now