ElegantSeries.SerialPort 1.0.5

dotnet add package ElegantSeries.SerialPort --version 1.0.5                
NuGet\Install-Package ElegantSeries.SerialPort -Version 1.0.5                
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="ElegantSeries.SerialPort" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ElegantSeries.SerialPort --version 1.0.5                
#r "nuget: ElegantSeries.SerialPort, 1.0.5"                
#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.
// Install ElegantSeries.SerialPort as a Cake Addin
#addin nuget:?package=ElegantSeries.SerialPort&version=1.0.5

// Install ElegantSeries.SerialPort as a Cake Tool
#tool nuget:?package=ElegantSeries.SerialPort&version=1.0.5                

ElegantSeries.SerialPort

This is a .Net System.IO.Ports extension library, designed to help simplify packet reading.

Download

Package is available at NuGet:

Nuget

Using the code

  • Read fixed length data.
SerialPort serialPort = new SerialPort();
byte[] bytes = new byte[10];
// default timeout 5000ms
serialPort.Read(bytes);
// custom timeout 1000ms
serialPort.Read(bytes, 1000);
  • Read fixed length data, specify the first few bytes.
SerialPort serialPort = new SerialPort();
byte[] bytes = new byte[10];
byte[] first = new byte[2];
first[0] = 0x0A;
first[1] = 0x0B;
serialPort.Read(bytes, first);
  • Read fixed length data, specify the first few bytes and the last few bytes.
SerialPort serialPort = new SerialPort();
byte[] bytes = new byte[10];
byte[] first = new byte[2];
first[0] = 0x0A;
first[1] = 0x0B;
byte[] last = new byte[2];
last[0] = 0xA0;
last[1] = 0xB0;
serialPort.Read(bytes, first, last);
  • Cancel reading data.
CancellationTokenSource cts = new CancellationTokenSource();
CancellationToken token = cts.Token;
SerialPort serialPort = new SerialPort();
byte[] bytes = new byte[10];
serialPort.Read(bytes, token:token);

// Execute on other thread
cts.Cancel();

Using the Utilities

  • ReuseBuffer Class.
    Multiplex the same packet. e.g., different methods use the same packet for data parsing.
ReuseBuffer reuseBuffer = new() { Number = 2 };
SerialPort serialPort = new SerialPort();
byte[] bytes = new byte[10];
serialPort.Read(bytes);
reuseBuffer.Data = bytes;
var bytes1 = reuseBuffer.Data;
var bytes2 = reuseBuffer.Data;
var bytes3 = reuseBuffer.Data;
// bytes1 == bytes2 == bytes, bytes3 == null.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.5 183 1/9/2024
1.0.4 266 3/7/2023
1.0.3 241 3/1/2023
1.0.2 390 10/27/2022
1.0.1 397 10/7/2022
1.0.0 431 9/26/2022

.Net SerialPort Extensions