Simple .NET serial communication toolkit used in ARES to streamline serial device development.
Can also be used as a general "programmer friendly" way of making serial device integrations.
- Hardware serial connection support (
AresHardwareConnection) - Fluent connection builder (
SerialConnectionBuilder) - Simple line-based command/response helper (
SendLine) - Raw command helpers (
SendRaw,SendString) - Simulation base class for tests (
AresSerialSimConnection) - Custom command/response creation (
SerialCommand,SerialCommandWithResponse,SerialResponse)
dotnet add package Ares.Toolkit.Serialusing Ares.Toolkit.Serial;
var connection = new SerialConnectionBuilder()
.WithPort("COM3")
.WithBaudRate(115200)
.WithTimeout(TimeSpan.FromSeconds(5))
.Build();
connection.AttemptOpen();
var response = await connection.SendLine("PING");
Console.WriteLine(response);
connection.Close();You can also create new custom commands by extending the abstract classes such as SerialCommand and SerialCommandWithResponse. That way you could specify strongly typed contracts.
class MyCommand : SerialCommandWithResponse<MyResponse>
{
...
}
MyResponse response = await connection.Send(new MyCommand());net10.0
From the Ares.Toolkit.Serial directory:
dotnet build
dotnet test