Solved

Listening the serial port

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

16 Experts available now in Live!

Get 1:1 Help Now