Class Rs485Connector
Represents a connector for RS485 (serial) communication
Assembly: Meadow.Contracts.dll
View Source
public abstract class Rs485Connector : IConnector, IPinController
Implements:
Meadow.IConnector, Meadow.Hardware.IPinController
Properties
Name
The Connector's name
View Source
public string Name { get; }
SerialPortName
The serial port name
View Source
public SerialPortName SerialPortName { get; }
Pins
The pins in the Connector
View Source
public IPinDefinitions Pins { get; }
Methods
CreateSerialPort(int, int, Parity, StopBits, int)
Creates and initializes a serial port with the specified configuration parameters.
View Source
public virtual ISerialPort CreateSerialPort(int baudRate = 9600, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One, int readBufferSize = 1024)
Returns
Meadow.Hardware.ISerialPort: An instance of Meadow.Hardware.ISerialPort representing the configured serial port.
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | baudRate | The baud rate for the serial port communication. Defaults to 9600. |
System.Int32 | dataBits | The number of data bits per byte in the communication. Defaults to 8. |
| Meadow.Hardware.Parity | parity | The parity-checking protocol to use for the communication. Defaults to Meadow.Hardware.Parity.None. |
| Meadow.Hardware.StopBits | stopBits | The number of stop bits to use in the communication. Defaults to Meadow.Hardware.StopBits.One. |
System.Int32 | readBufferSize | The size, in bytes, of the buffer used for reading data from the serial port. Defaults to 1024. |
Exceptions
System.ArgumentException
Thrown if the serial port is already open with a different baud rate.
CreateModbusBusRtuClient(int, int, Parity, StopBits)
Creates a Modbus RTU client configured with the specified serial communication parameters.
View Source
public abstract IModbusBusClient CreateModbusBusRtuClient(int baudRate = 19200, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One)
Returns
Meadow.Modbus.IModbusBusClient: An instance of Meadow.Modbus.IModbusBusClient configured for Modbus RTU communication.
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | baudRate | The baud rate for the serial communication. Defaults to 19200. Must be a positive integer. |
System.Int32 | dataBits | The number of data bits per byte in the communication. Defaults to 8. Typical values are 7 or 8. |
| Meadow.Hardware.Parity | parity | The parity-checking protocol to use for error detection. Defaults to Meadow.Hardware.Parity.None. |
| Meadow.Hardware.StopBits | stopBits | The number of stop bits to use in the communication. Defaults to Meadow.Hardware.StopBits.One. |
CreateModbusBusRtuServer(int, int, Parity, StopBits)
Creates a Modbus RTU server instance configured with the specified serial communication parameters.
View Source
public abstract IModbusServer CreateModbusBusRtuServer(int baudRate = 19200, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One)
Returns
Meadow.Modbus.IModbusServer: An instance of Meadow.Modbus.IModbusServer configured for Modbus RTU communication.
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | baudRate | The baud rate for the serial communication. Defaults to 19200. Must be a positive integer. |
System.Int32 | dataBits | The number of data bits per byte in the communication. Defaults to 8. Valid values are typically 7 or 8. |
| Meadow.Hardware.Parity | parity | The parity checking mode for the communication. Defaults to Meadow.Hardware.Parity.None. |
| Meadow.Hardware.StopBits | stopBits | The number of stop bits used in the communication. Defaults to Meadow.Hardware.StopBits.One. |