Skip to content
Serial Port libray for .Net / Mono
C#
Branch: master
Clone or download
Pull request Compare This branch is 37 commits behind genielabs:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SerialPortLib
Test.Serial
packages
.gitignore
LICENSE
README.md
SerialPortLib.sln

README.md

Serial Port libray for .Net

Features

  • Easy to use
  • Event driven
  • Hot plug
  • Automatically restabilish connection on error/disconnect
  • Compatible with Mono
  • It overcomes the lack of DataReceived event in Mono

NuGet Package

SerialPortLib is available as a NuGet package.

Run Install-Package SerialPortLib in the Package Manager Console or search for “SerialPortLib” in your IDE’s package management plug-in.

Example usage

using SerialPortLib;
...
var serialPort = new SerialPortInput();

// Listen to Serial Port events

serialPort.ConnectionStatusChanged += delegate(object sender, ConnectionStatusChangedEventArgs args) 
{
    Console.WriteLine("Connected = {0}", args.Connected);
};

serialPort.MessageReceived += delegate(object sender, MessageReceivedEventArgs args)
{
    Console.WriteLine("Received message: {0}", BitConverter.ToString(args.Data));
};

// Set port options
serialPort.SetPort("/dev/ttyUSB0", 115200);

// Connect the serial port
serialPort.Connect();

// Send a message
var message = System.Text.Encoding.UTF8.GetBytes("Hello World!");
serialPort.SendMessage(message);

License

SerialPortLib is open source software, licensed under the terms of GNU GPLV3 license. See the LICENSE file for details.

You can’t perform that action at this time.