views:

649

answers:

2

We have a scenario where multiple devices are connected to one com port. Each device has an access code, which is manually defined within the device.

Can I access all the connected devices with/by access code in C#?. Does anybody have any idea as to how to do this?

In my case multiple devices are connected with single port but slave addresses are different..how can i access all the slave address in C# code for restricting that another device shudnot have same slave address?

+2  A: 

Take a look at an article - Serial post in C# and Tutorial

adatapost
in my case multiple devices are connected with single port but slave addresses are different..how can i access all the slave address in C# code for restricting that another device shudnot have same slave address?
Jaswant Agarwal
A: 

Jaswant,

Where I work, we have some devices that are accessed over RS232 via a .net forms app. We have multiple devices connected via the same serial line at the same time.

As long as the devices on the end of the cable:

a) respond when spoken to (i.e. directly addressed) - and at no other time

b) use connectionless serial communications (i.e. no handshaking)

then I doubt that you will have a problem doing this with your devices.

I'm assuming you will have to 'address' your device like we do, i.e. every block of data sent down the line is in a specific format (bit like a TCP header) e.g.

byte description
---- -----------
  00 command
  01 address
>=02 data

All devices receive all comms, but only act upon instructions and respond if the address in the data matches the address on the device.

Bryan
As for actually implementing the code to do this, refer to adatapost's answer.
Bryan
hmm..this solution is near by similer to my req..i need to find the access code given to the device in our source code in C#
Jaswant Agarwal
Out of interest, what are the devices you are talking to? A bit of a long shot, but if they are identical, I'll let you have a look at my source code.
Bryan
i have some electric meter devices connected through a single port having multiple slave addresses
Jaswant Agarwal