Skip to main content

Interface ISerialProtocol

Protocol interface for Brainboxes Ethernet-to-Serial devices (ES-series). Provides encoding-aware send/receive methods for text-based serial communication. Implements System.ICloneable so that each Brainboxes.IO.BBSerialPort on a multi-port device gets its own protocol instance with independent state.

Assembly: Brainboxes.IO.dll
View Source
Declaration
public interface ISerialProtocol : IProtocol, ICloneable

Properties

Encoding

The character encoding used to send and receive data. Default is UTF-8.

View Source
Declaration
Encoding Encoding { get; }

DataAvailable

Indicates whether data is available to read. Returns 0 if no data, or a positive value indicating bytes are available.

View Source
Declaration
int DataAvailable { get; }

Methods

Send(string)

Sends a message string through the serial port, encoded with Brainboxes.IO.ISerialProtocol.Encoding. The terminating characters are appended automatically.

View Source
Declaration
void Send(string message)
Parameters
TypeNameDescription
System.StringmessageThe text message to send.
Exceptions

System.InvalidOperationException
The device is not connected.

Receive()

Receives a message from the serial port, decoded with Brainboxes.IO.ISerialProtocol.Encoding. Blocks until the terminating characters are received or the timeout expires.

View Source
Declaration
string Receive()
Returns

System.String: The received message string with terminating characters stripped.

Exceptions

System.InvalidOperationException
The device is not connected. System.TimeoutException
No complete response received within the timeout period.