en-us_commands:reference:imodbusrtumasteradd
This is an old revision of the document!
Table of Contents
ImodbusRTUmasterAdd()
ImodbusRTUmasterAdd() registers a Master request for repeated execution.
bool ImodbusRTUmasterAdd(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 |
|---|---|---|---|
ImodbusRTUmasterAdd(serialPort, slaveId, functionCode, address, quantity, data, timeoutMs) | HardwareSerial& serialPort — Serial port connected to RS-485uint8_t slaveId — Slave addressuint8_t functionCodeuint16_t addressuint16_t quantityuint16_t* datauint16_t timeoutMs = 100 | bool | Registers a Master request for repeated execution. |
Example
uint16_t data[2]; bool added = ImodbusRTUmasterAdd( Serial2, 1, 3, 0, 2, data, 200);
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/imodbusrtumasteradd.1788785567.txt.gz · Last modified: by 127.0.0.1
