====== ImodbusRTUMem() ====== ''ImodbusRTUMem()'' sets the sizes of M and D memory used by the Slave. {{:en-us_commands:reference:imodbusrtumem.svg?900|ImodbusRTUMem command operation flow}} ''void ImodbusRTUMem(uint16_t m_size, uint16_t d_size)'' ===== Commands ===== ^ Command ^ Arguments ^ Return Value ^ Operation ^ | ''ImodbusRTUMem(m_size, d_size)'' | ''uint16_t m_size''\\ ''uint16_t d_size'' | ''void'' | Sets the sizes of M and D memory used by the Slave. | ===== 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 ''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 Commands in the Same Category ===== * [[:en-us_commands:reference:imodbusrtuadr|ImodbusRTUAdr() View detailed description]] * [[:en-us_commands:reference:imodbusrtuinit|ImodbusRTUInit() View detailed description]] * [[:en-us_commands:reference:imodbusrtu|ImodbusRTU() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]