Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a requirement where I need to design a code of an application for the Master Slave communication via serial ports.I got the idea how to send and read data via serial ports in VB
but i got stuck about how to code the logic so that Master will throw data packet over the channel
and it will be listening to all the slaves but data will be actually received by the particular slave which Slave ID is mentioned and ignored by the all other Slaves.

What I have tried:

I have tried for Two COM ports one for master and another for Slave but not getting for the multiple Slaves.
Posted
Updated 17-Apr-17 1:10am

Pretty much, you can't - not with standard COM ports.
COM ports connect via RS232, which is a hardware specification and it defined to be point-to-point where what you need is multidrop. PtP connections are only designed to support one device at each end of the cable, and while sometimes you can "get away" with putting three or even four devices on it, you have to have good control of your hardware from your software (which you don't have in VB) and a lot of luck with the hardware suppliers of your physical COM ports. Some will work, some won't. And you won;t know until you try them - and worse, some will work today, but not tomorrow ... because the weather is different, and that affects electronics once you go outside specification. Because the PSU is busy and the 5V rail is a little low. Because ... loads of things, all outside your control.

You need to look at a multidrop hardware environment - I'd suggest LAN or WLAN since they already exist in most environments, or go directly to via the internet / cloud.

But using standard COM ports? Doomed from the start unless you have one COM port on the server for each separate slave device, and that's a PITA to physically organise.
 
Share this answer
 
If you really want to do this with Serialport's you need to have a RS232 to RS485 Converter.
The RS485 allows you to have more than one listening attendee to the wire. All attendee's "hear" the message but only this one, who has the right ID (or is requested) answers - but you should realize that each part of the communication is allways accessible by each attendee ...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900