User Tools

Site Tools


en-us_commands:reference:imodbusrtumasterinit

This is an old revision of the document!


ImodbusRTUmasterInit()

ImodbusRTUmasterInit() sets the Master communication port and baud rate.

ImodbusRTUmasterInit command operation flow

void ImodbusRTUmasterInit(HardwareSerial& serialPort, long baudrate)
void ImodbusRTUmasterInit(HardwareSerial& serialPort, long baudrate, uint8_t config)

Commands

Command Arguments Return Value Operation
ImodbusRTUmasterInit(serialPort, baudrate) HardwareSerial& serialPort — Serial port connected to RS-485
long baudrate — Baud rate
void Sets the Master communication port and baud rate.

Example

ImodbusRTUmasterInit(Serial2, 9600, SERIAL_8N1);

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 M and D with Cnet/MC Protocol, define a single final size and initialization order. Do not call ImodbusRTUMem() or ICnetMem() again at runtime.
  • Memory allocation functions do not return success status. For nonzero sizes, verify that M and D are not nullptr before accessing them in user code.

← Built-in Command List

en-us_commands/reference/imodbusrtumasterinit.1788785567.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki