Jaswant Agarwal
Jaswant Agarwal

Reputation: 4905

Serial port communications in C#

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?

Upvotes: 2

Views: 3225

Answers (2)

user142914
user142914

Reputation:

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.

Upvotes: 0

KV Prajapati
KV Prajapati

Reputation: 94645

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

Upvotes: 3

Related Questions