DotSerial 1.1.0
dotnet add package DotSerial --version 1.1.0
NuGet\Install-Package DotSerial -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotSerial" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotSerial" Version="1.1.0" />
<PackageReference Include="DotSerial" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotSerial --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DotSerial, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotSerial@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotSerial&version=1.1.0
#tool nuget:?package=DotSerial&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
๐ DotSerial
DotSerial is a modern, cross-platform .NET serial port library that works identically on Windows, Linux, macOS, Android, and iOS. It provides a clean interface for both classic byte-level I/O and stream-based communication, with built-in logging and full dependency injection support.
โจ Features
- ๐ Cross-platform โ Windows, Linux, macOS, Android, iOS
- ๐ Classic & Stream I/O โ
Write/ReadandStream-based access - โก Async-first โ full
async/awaitsupport withCancellationToken - ๐ Dependency Injection โ works with
Microsoft.Extensions.DependencyInjection - ๐ Logging โ built-in
Microsoft.Extensions.Loggingintegration - ๐งช Testable โ interface-based design; fully mockable
- ๐ฏ SOLID โ clean abstractions, single-responsibility, open for extension
๐ฆ Installation
dotnet add package DotSerial
๐ Quick Start
Classic I/O
using DotSerial;
using DotSerial.Models;
var factory = new SerialPortFactory(LoggerFactory.Create(b => b.AddConsole()));
using var port = factory.Create(new SerialPortSettings
{
PortName = "COM3",
BaudRate = 115200,
DataBits = 8,
});
port.Open();
port.WriteLine("Hello, Serial!");
string response = port.ReadLine();
port.Close();
Stream-based I/O
port.Open();
var stream = port.BaseStream;
using var writer = new StreamWriter(stream, leaveOpen: true);
using var reader = new StreamReader(stream, leaveOpen: true);
await writer.WriteLineAsync("AT");
string? reply = await reader.ReadLineAsync();
Dependency Injection
builder.Services.AddLogging();
builder.Services.AddDotSerial();
public class MyService(ISerialPortFactory factory)
{
public void Send(string portName, string data)
{
using var port = factory.Create(new SerialPortSettings { PortName = portName });
port.Open();
port.WriteLine(data);
}
}
๐ฅ๏ธ Supported Platforms
| Platform | Support | Notes |
|---|---|---|
| Windows | โ Full | COM1โฆCOMn via System.IO.Ports |
| Linux | โ Full | /dev/ttyUSB*, /dev/ttyS* |
| macOS | โ Full | /dev/cu.* |
| Android | ๐ง Planned | USB Host Mode, requires android.permission.USB_PERMISSION |
| iOS | ๐ง Planned | External Accessory (MFi accessories only) |
๐ก Events
port.DataReceived += (s, e) => Console.WriteLine($"Data: {e.EventType}");
port.ErrorReceived += (s, e) => Console.WriteLine($"Error: {e.ErrorType}");
port.PinChanged += (s, e) => Console.WriteLine($"Pin: {e.EventType}");
๐ Port Discovery
var factory = new SerialPortFactory(loggerFactory);
var ports = factory.GetPortNames();
foreach (var name in ports) Console.WriteLine(name);
๐งช Running Tests
# Unit tests
dotnet test tests/DotSerial.Tests.Unit
# Single test
dotnet test tests/DotSerial.Tests.Unit --filter "FullyQualifiedName~SerialPortSettingsTests"
# Integration tests (requires a real or virtual COM port)
dotnet test tests/DotSerial.Tests.Integration
๐ค Contributing
Please read CONTRIBUTING.md before opening a pull request.
๐ License
MIT ยฉ Piergiorgio Vagnozzi
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-android36.0 is compatible. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- System.IO.Ports (>= 10.0.7)
-
net10.0-android36.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 104 | 5/1/2026 |