Serial port communications

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!
Is that possible to scan multiple ports for incoming data with
Sax.Communications.Community library control)?

Let's say PC has 3 available ports(com1, com2, com3). Also there is three
scan guns plugged to those ports.
I want to have some kind of event that will fired up if data arrives to any
of the ports. Can I open multiple connections with the single control? Or I
need to have separate control for each port?

I know that sax control has 'Data Available' event, but I can't make it work.

Thanks for help,

Valk
 
What you want to do is create a "Control Array" of the Sax ActiveX.
Drop the control into a form.
Right click on the control and select Edit -Copy in the VB main menu.
Click on the form and select Edit - Paste to paste in a copy of the
control.
When VB asks you if you want to create a control array, click Yes.
Repeat the process for the third control
You should have three instances of the Sax control on your form all
with the same name. All three controls will also use the same event
handlers however each control will now have its own "Index" value that
will identify which control is which.
The first control will have an Index value of 1, the second will have
an index value of 2 and the third will have an index value of 3.

For example, when the OnComm event fires for any of the controls, an
Index value will be passed into the OnComm Event as a parameter that
will identify which control generated the event.
You also need to use the index value when referring to a specific
instance of the control.
For example, when you want to read the Input property from a
particular port you would use the syntax:
MyData = SaxComm1(Index).Input

You still set the properties of each of the three controls
independently of each other however if you do this using code, then
you need to reference the particular control using an index value.
For example,
SaxComm1(1).Settings = "9600,N,8,1"
SaxComm1(2).Settings = "9600,N,8,1"
SaxComm1(3).Settings = "9600,N,8,1"


For more serial I/O tips, tricks and free utilities visit
www.taltech.com
 
Thank you very much Thomas.
Wow... Very nice explanation. I got it. Everything works fine.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top