Modbus-Serial
|
Modbus over serial line Class. More...
Inherits Modbus.
Public Member Functions | |
ModbusSerial (Stream &port, byte slaveId, int txenPin=-1) | |
Constructor. More... | |
void | config (unsigned long baud) |
Configure ModbusSerial object. More... | |
void | task () |
Task that performs all operations on MODBUS. More... | |
void | setSlaveId (byte slaveId) |
Change the value of slave identifier. More... | |
byte | getSlaveId () |
Return slave identifier. | |
Static Public Attributes | |
static const byte | BroadcastAddress = 0 |
Broadcast address. | |
Modbus over serial line Class.
ModbusSerial::ModbusSerial | ( | Stream & | port, |
byte | slaveId, | ||
int | txenPin = -1 |
||
) |
Constructor.
port | serial port to use |
txenPin | if an RS485 circuit is used, this corresponds to the pin number connected to the transmit enable (DE) and receive disable (/RE) pin. -1 if not used. |
void ModbusSerial::config | ( | unsigned long | baud | ) |
Configure ModbusSerial object.
configures txenPin on output if necessary and calculates the times of the RTU frame.
begin()
function of the serial port passed to the constructor must be called BEFORE calling this function.baud | baudrate in accordance with that used by the serial port |
void ModbusSerial::setSlaveId | ( | byte | slaveId | ) |
Change the value of slave identifier.
slaveId | identifier 1-247 |
void ModbusSerial::task | ( | ) |
Task that performs all operations on MODBUS.
Call once inside loop(), all magic here !