Elapsed: 0 s
FC 16 bulk-write 64 words 0ā¦63FC 03 bulk-read verifyFC 06 single-write each word (reverse order)FC 03 read back in 8-word chunks verify
FC 04 one-shot read all 64FC 04 8-word chunk reads (8 Ć 8)FC 04 64 single-word reads (1 Ć 64) ā compare all three results
FC 0F write-multiple T F T F ⦠patternFC 01 bulk-read verify patternFC 05 toggle each coil individuallyFC 01 8-byte chunk reads verify new pattern
FC 02 one-shot read all 64FC 02 8-byte chunk reads (8 Ć 8)FC 02 64 single-bit reads ā compare all three results
#include <ModbusRTUSlave.h>
constexpr uint8_t SLAVE_ID = 1;
constexpr uint32_t BAUD = 9600;
/* 64-word / 64-bit data areas */
uint16_t holdingRegs[64];
uint16_t inputRegs [64];
bool coils [64];
bool discretes [64];
ModbusRTUSlave mb(SLAVE_ID);
void setup() {
Serial.begin(BAUD);
while (!Serial) { } // wait for USB-CDC
mb.configureHoldingRegisters(holdingRegs, 64);
mb.configureInputRegisters (inputRegs, 64);
mb.configureCoils (coils, 64);
mb.configureDiscreteInputs (discretes, 64);
mb.begin(Serial, BAUD);
}
void loop() {
mb.poll(); // service Modbus RTU
}