Interface IModbusRtuSerialPort
- Namespace
- FluentModbus
- Assembly
- FluentModbus.dll
A serial port for Modbus RTU communication.
public interface IModbusRtuSerialPort
Properties
IsOpen
Gets a value indicating the open or closed status of the serial port object.
bool IsOpen { get; }
Property Value
PortName
Gets the port for communications, including but not limited to all available COM ports.
string PortName { get; }
Property Value
Methods
Close()
Closes the port connection, sets the IsOpen property to true, and disposes of the internal Stream object.
void Close()
Open()
Opens a new serial port connection.
void Open()
Read(byte[], int, int)
Reads a number of bytes from the serial port input buffer and writes those bytes into a byte array at the specified offset.
int Read(byte[] buffer, int offset, int count)
Parameters
bufferbyte[]The byte array to write the input to.
offsetintThe offset in
bufferat which to write the bytes.countintThe maximum number of bytes to read. Fewer bytes are read if
countis greater than the number of bytes in the input buffer.
Returns
- int
The number of bytes read.
ReadAsync(byte[], int, int, CancellationToken)
Asynchronously reads a number of bytes from the serial port input buffer and writes those bytes into a byte array at the specified offset.
Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken token)
Parameters
bufferbyte[]The byte array to write the input to.
offsetintThe offset in
bufferat which to write the bytes.countintThe maximum number of bytes to read. Fewer bytes are read if
countis greater than the number of bytes in the input buffer.tokenCancellationTokenA token to cancel the current operation.
Returns
Write(byte[], int, int)
Writes a specified number of bytes to the serial port using data from a buffer.
void Write(byte[] buffer, int offset, int count)
Parameters
bufferbyte[]The byte array that contains the data to write to the port.
offsetintThe zero-based byte offset in the
bufferparameter at which to begin copying bytes to the port.countintThe number of bytes to write.
WriteAsync(byte[], int, int, CancellationToken)
Asynchronously writes a specified number of bytes to the serial port using data from a buffer.
Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken token)
Parameters
bufferbyte[]The byte array that contains the data to write to the port.
offsetintThe zero-based byte offset in the
bufferparameter at which to begin copying bytes to the port.countintThe number of bytes to write.
tokenCancellationTokenA token to cancel the current operation.