User Tools

Site Tools


en-us_commands:reference:imodbusrtumasterrun

This is an old revision of the document!


ImodbusRTUmasterRun()

ImodbusRTUmasterRun() executes a registered request or the specified single request.

ImodbusRTUmasterRun command operation flow

uint8_t ImodbusRTUmasterRun()
uint8_t ImodbusRTUmasterRun(HardwareSerial& serialPort, uint8_t slaveId, uint8_t functionCode, uint16_t address, uint16_t quantity, uint16_t* data, uint16_t timeoutMs = 100)

Commands

Command Arguments Return Value Operation
ImodbusRTUmasterRun() None uint8_t Executes a registered request or the specified single request.

Example

void loop() {
  uint8_t state = ImodbusRTUmasterRun();
  if (state != IMODBUS_RTU_SUCCESS &&
      state != IMODBUS_RTU_BUSY &&
      state != IMODBUS_RTU_IDLE) {
    debugln(state, HEX);
  }
}

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/imodbusrtumasterrun.1788785567.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki