55 lines
2.2 KiB
C#
55 lines
2.2 KiB
C#
namespace Common.Hardware.Ports
|
|
{
|
|
using System;
|
|
|
|
/// <summary>
|
|
/// Interface that exposes the <see cref="System.IO.Ports.SerialPort"/> features.
|
|
/// </summary>
|
|
public interface ISerialPort
|
|
{
|
|
/// <summary>
|
|
/// Occurs every time a <see cref="System.Exception"/> is thrown.
|
|
/// </summary>
|
|
event Action<string, Exception> Exception;
|
|
|
|
/// <summary>
|
|
/// Safely closes the serial port. Exceptions are thrown through the <see cref="Common.Hardware.Ports.ISerialPort.Exception"/> event.
|
|
/// </summary>
|
|
void Close();
|
|
|
|
/// <summary>
|
|
/// Returns whether the serial port exists and is open. Exceptions are thrown through the <see cref="Common.Hardware.Ports.ISerialPort.Exception"/> event.
|
|
/// </summary>
|
|
bool IsOpen();
|
|
|
|
/// <summary>
|
|
/// Safely opens the serial port. Exceptions are thrown through the <see cref="Common.Hardware.Ports.ISerialPort.Exception"/> event.
|
|
/// </summary>
|
|
void Open();
|
|
|
|
/// <summary>
|
|
/// Safely reads the incomming bytes into <see cref="System.Byte"/>[] if any, by default returns empty array.
|
|
/// Exceptions are thrown through the <see cref="Common.Hardware.Ports.ISerialPort.Exception"/> event.
|
|
/// </summary>
|
|
byte[] ReadBytes();
|
|
|
|
/// <summary>
|
|
/// Safely reads a <see cref="System.String"/> if any, by default returns <see cref="System.String.Empty"/>.
|
|
/// Exceptions are thrown through the <see cref="Common.Hardware.Ports.ISerialPort.Exception"/> event.
|
|
/// </summary>
|
|
string ReadLine();
|
|
|
|
/// <summary>
|
|
/// Safely writes the provided <see cref="System.Byte"/>[] to the serial port.
|
|
/// Exceptions are thrown through the <see cref="Common.Hardware.Ports.ISerialPort.Exception"/> event.
|
|
/// </summary>
|
|
void WriteBytes(params byte[] bytes);
|
|
|
|
/// <summary>
|
|
/// Safely writes the provided <see cref="System.String"/> to the serial port.
|
|
/// Exceptions are thrown through the <see cref="Common.Hardware.Ports.ISerialPort.Exception"/> event.
|
|
/// </summary>
|
|
void WriteLine(string line);
|
|
}
|
|
}
|