See
MSDN: SerialPort Class[
^] for an example on serial port handling in C#.
There is no data protocol defined on serial port - this is pure bit stream with some rudimentary synchronization and error detection (start/stop bits, parity). You are not exposed to that in C#. What you get is a byte stream.
You need to specify how the sender/receiver encode data, e.g. how an integer is to be interpreted:
- size of the int (1,2,4 bytes)?
- endian-ness (little/big endian)?
- signed/unsigned?
- ...
In addition to that, you may also have some other data than
int
only.
I assume you have some "protocol" specification that tells what messages are transfered over the serial line.
Once you have that specification, you write a message parser. Please provide that specification (or part of it) so that we can give more specific advise.
Cheers
Andi