Add project files.

This commit is contained in:
Daniel Clark
2022-11-01 15:26:08 +00:00
parent daa7b59f22
commit 7e4f880821
408 changed files with 16863 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
using System.IO.Ports;
namespace TheXamlGuy.Framework.Serial;
public class SerialConnection : ISerialConnection
{
private readonly SerialPort serialPort;
public SerialConnection(SerialPort serialPort)
{
this.serialPort = serialPort;
}
public bool IsOpen { get; private set; }
public void Close()
{
if (IsOpen)
{
try
{
serialPort.Close();
}
catch
{
}
IsOpen = serialPort.IsOpen;
}
}
public bool Open()
{
if (!IsOpen)
{
try
{
serialPort.Open();
serialPort.DiscardInBuffer();
serialPort.DiscardOutBuffer();
}
catch
{
}
IsOpen = serialPort.IsOpen;
}
return IsOpen;
}
}