This is a generic C# device driver for RS232 serial device.
- com0com (or similar program) to simulate RS232 devices (see picture below for configuration settings)
System.IO.Ports
Nuget package- Microsoft Visual Studio 2019 Community Edition
- Open the solution in Microsoft Visual Studio 2019 Community Edition
- Run the
DeviceSimulation
project without debugging- Note: you can set this project to be the default startup project.
- Once that is up and running, run the unit tests project (
DriverTests
) which will test the driver, which is in theRS232_Device_Driver
project.
The DeviceSimulation
project simulates a simple RS232 serial device.
The commands that are sent to the device are of format:
commandname <parameter 1> <value 1> <parameter 2> <value 2> ...<CR>
The response to a valid command has the following format:
<CR><LF>ok [<paramter 1> <value 1> [<paramter 2> <value 2> ...]]<CR><LF>
The response to an invalid command could be one of the following:
<CR><LF>err "Invalid Value"<CR><LF>
<CR><LF>err "Invalid Parameter"<CR><LF>
<CR><LF>err "Missing Parameter"<CR><LF>
<CR><LF>err<CR><LF>
The resources I used include:
- com0com
- System.IO.Ports namespace
- C# SerialPort Class