modbus.setData()

modbus.setData(buffer)

Backs the device Modbus slave register table with a script-managed bin buffer.

Points the device's Modbus TCP slave data table at a buffer allocated with bin.alloc(). Remote clients then read and write your table; your script updates it through the buffer's seek/read/write methods, guarded by modbus.setLock().

Arguments

NameTypeRequiredDefaultDescription
buffer bin buffer yes Buffer from bin.alloc(bytes) sized for your registers (4 bytes per 32-bit value).

Example

let mbData = bin.alloc(20*4);  // room for float registers
modbus.setData(mbData);        // expose as the slave data table