en-us_commands:reference:imodbusrtuadr
This is an old revision of the document!
Table of Contents
ImodbusRTUAdr()
ImodbusRTUAdr() sets the start addresses of M and D memory.
void ImodbusRTUAdr(uint16_t m_offset, uint16_t d_offset)
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
ImodbusRTUAdr(m_offset, d_offset) | uint16_t m_offsetuint16_t d_offset | void | Sets the start addresses of M and D memory. |
Example
void setup() { ImodbusRTUMem(100, 200); // Set the M·D memory sizes used by the Slave. ImodbusRTUAdr(0, 0); // Set the start addresses of M·D memory. ImodbusRTUInit(Serial1, 1, 115200); // Set the communication port, station number and baud rate. } void loop() { ImodbusRTU(); // Check incoming requests and process Slave responses. D[0] = 100; D[3] = 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/imodbusrtuadr.1788791734.txt.gz · Last modified: by 127.0.0.1
