Skip to content

AFRL-ARES/Ares.Toolkit.Serial

Repository files navigation

Ares.Toolkit.Serial

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.

Features

  • 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)

Install

dotnet add package Ares.Toolkit.Serial

Quick Start

using 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());

Target Framework

  • net10.0

Development

From the Ares.Toolkit.Serial directory:

dotnet build
dotnet test

About

ARES serial toolkit designed to help in the implementation of serial devices in ARES.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages