I need to implement a serial protocol to communicate with a device using .NET (C#). This implementation should be a library (.dll) to be used in different projects.
I have the datasheet that describe the protocol (baudrate, stop bits, message protocol, commands, etc.) and I know that I need to use
SerialPort class from
But I have some doubts on how to struture/organize the code.
Here are some questions:
- Should I be concern about thread management or this aspect should be managed by how is using the library?
- Can I manage received/sent data using strings or should I use bytes?
- Commands and fixed contents should be stored using
constantsor something else?
Maybe those questions could be subjectives, but I would like to have some feedback from someone with more experience than me.
If someone has some examples, tips, best pratices, etc. on this subject, I will be very grateful.