You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
856 B
27 lines
856 B
|
1 week ago
|
namespace IOModuleTestBlazor.Services;
|
||
|
|
|
||
|
|
public interface ISerialPortService
|
||
|
|
{
|
||
|
|
bool IsOpen { get; }
|
||
|
|
string PortName { get; }
|
||
|
|
|
||
|
|
/// <summary>Returns available COM port names.</summary>
|
||
|
|
IReadOnlyList<string> GetPortNames();
|
||
|
|
|
||
|
|
/// <summary>Opens the specified port at the given baud rate.</summary>
|
||
|
|
void Open(string portName, int baudRate);
|
||
|
|
|
||
|
|
/// <summary>Closes the port if open.</summary>
|
||
|
|
void Close();
|
||
|
|
|
||
|
|
/// <summary>Sends a line to the port (appends \r\n).</summary>
|
||
|
|
void WriteLine(string command);
|
||
|
|
|
||
|
|
/// <summary>Returns buffered terminal lines (last 200, oldest first).
|
||
|
|
/// Each line is prefixed with "> " (sent) or "< " (received).</summary>
|
||
|
|
IReadOnlyList<string> GetLines();
|
||
|
|
|
||
|
|
/// <summary>Fired on the SerialPort receive thread when new lines arrive.</summary>
|
||
|
|
event Action? DataReceived;
|
||
|
|
}
|