en-us_commands:reference:imodbusrtuinit
This is an old revision of the document!
Table of Contents
ImodbusRTUInit()
ImodbusRTUInit() sets the communication port, station number and baud rate.
void ImodbusRTUInit(HardwareSerial& serialPort, uint8_t slaveId, long baudrate)
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
ImodbusRTUInit(serialPort, slaveId, baudrate) | HardwareSerial& serialPort — Serial port connected to RS-485uint8_t slaveId — Slave addresslong baudrate — Baud rate | void | Sets the communication port, station number and baud rate. |
Example
ImodbusRTUInit(Serial2, 1, 9600); // MPAINO RS-485
Precautions
- Keep calling the Slave or Master execution function in
loop(). - The data array size must be at least the requested quantity.
- Do not treat return codes BUSY and IDLE as communication failures.
- When sharing
MandDwith Cnet/MC Protocol, define a single final size and initialization order. Do not callImodbusRTUMem()orICnetMem()again at runtime. - Memory allocation functions do not return success status. For nonzero sizes, verify that
MandDare notnullptrbefore accessing them in user code.
en-us_commands/reference/imodbusrtuinit.1788785567.txt.gz · Last modified: by 127.0.0.1
