You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serial port (RS-232) communication with optional frame-based protocol support, auto-reconnection, and message queuing.
✨ Features
Feature
Description
🔌 RS-232 Support
Full serial port configuration — baud rate, data bits, parity
📐 Frame Protocol
Optional header/footer framing via FramedSerialLink
🔄 Auto-Reconnect
Automatically recovers from serial port errors
📦 Message Queuing
Incoming data queued FIFO (up to 100 messages)
🔒 Thread-Safe
All operations protected with locks
🔔 Event-Driven
Connection changes, data arrival, and error events
🎛️ Enable/Disable
Pause and resume without closing the port
📦 Installation
dotnet add package ThreeByte.LinkLib.SerialLink
or via the NuGet Package Manager:
Install-Package ThreeByte.LinkLib.SerialLink
🚀 Quick Start
Raw Serial Communication
usingThreeByte.LinkLib.SerialLink;// Open a serial port at 9600 baudvarserial=newSerialLink("COM3",baudRate:9600);// Subscribe to eventsserial.IsConnectedChanged+=(s,connected)=>Console.WriteLine(connected?"✅ Port open":"❌ Port closed");serial.DataReceived+=(s,e)=>{byte[]?data=serial.GetMessage();if(data!=null)Console.WriteLine($"Received {data.Length} bytes");};// Send raw bytesbyte[]command=newbyte[]{0x01,0x02,0x03};serial.SendData(command);// Check for queued datawhile(serial.HasData){byte[]?response=serial.GetMessage();}serial.Dispose();
Framed Serial Communication
Use FramedSerialLink when your device protocol uses header/footer delimiters:
usingThreeByte.LinkLib.SerialLink;varframed=newFramedSerialLink("COM4",baudRate:115200);// Configure frame delimitersframed.SendFrame=newSerialFrame{Header=newbyte[]{0x02},// STXFooter=newbyte[]{0x03}// ETX};framed.ReceiveFrame=newSerialFrame{Header=newbyte[]{0x02},Footer=newbyte[]{0x03}};// Send a framed message — header/footer added automaticallyframed.SendMessage("STATUS?");// Wire: [0x02] S T A T U S ? [0x03]// Receive complete framed messagesframed.DataReceived+=(s,e)=>{string?response=framed.GetMessage();Console.WriteLine($"Device says: {response}");};framed.Dispose();