Overview
Most registers are written / read by address, but other registers are a special kind of register known as a Buffer Register. Buffer Registers are for cases when multiple values must be written / read, but the number of values are able to change. Buffer Registers produce multiple values when being read from and consume all values being written. Buffer registers allow users to write a sequence of values to a single Modbus address. Typically buffer registers have a companion _SIZE register that defines how many sequential values are about to be sent to or read from a buffer register. Some would call them array registers, because you basically define the array size, and then pass the array of data into a single Modbus address.
For example, consider the difference between AIN0 and FILE_IO_PATH_READ:
Normal register:
- AIN0 is at address 0 and is followed by AIN1 at address 2
- AIN0 is a normal register
- Reading an array of 4 registers starting at address 0 would read 2 registers from AIN0 and 2 registers AIN1 (AIN values are FLOAT32, which each consist of 2 registers)
Buffer register:
- FILE_IO_PATH_READ is at address 60652 and is followed by FILE_IO_WRITE at address 60654
- FILE_IO_PATH_READ is a Buffer Register
- Reading an array of 4 registers starting at address 60652 would read 4 registers from FILE_IO_PATH_READ. FILE_IO_WRITE would not be read.
- Note that users would first designate that 8 bytes are about to be read by writing a value of 8 to FILE_IO_PATH_READ_LEN_BYTES.
In practice, the important differences are:
- You don't need to know what registers follow a Buffer Register, you can simply write / read without worrying about colliding with other registers
- You can only write / read values sequentially. E.g. you cannot modify previously written values.
- Define how much data to send/receive to/from the buffer register using the associated _NUM_BYTES, or _SIZE, or _LEN register.
- Often it is necessary to complete the transaction with an action register, such as _GO, or _OPEN, or _ENABLE.
Buffer Registers, and their size definitions:
Serial Comm Systems
- ASYNCH_DATA_RX
- ASYNCH_DATA_TX
- ASYNCH_NUM_BYTES_RX
- ASYNCH_NUM_BYTES_TX
- I2C_DATA_RX
- I2C_DATA_TX
- I2C_NUM_BYTES_RX
- I2C_NUM_BYTES_TX
- ONEWIRE_DATA_RX
- ONEWIRE_DATA_TX
- ONEWIRE_NUM_BYTES_RX
- ONEWIRE_NUM_BYTES_TX
- SPI_DATA_RX
- SPI_DATA_TX
- SPI_NUM_BYTES
File IO System
- FILE_IO_PATH_READ
- FILE_IO_PATH_WRITE
- FILE_IO_PATH_READ_LEN_BYTES
- FILE_IO_PATH_WRITE_LEN_BYTES
- FILE_IO_READ
- FILE_IO_WRITE
- FILE_IO_SIZE_BYTES
Lua Scripts/Debug Info
- LUA_SOURCE_WRITE
- LUA_SOURCE_SIZE
- LUA_DEBUG_DATA
- LUA_DEBUG_NUM_BYTES
Stream Out System
- STREAM_OUT#(0:3)_BUFFER_F32
- STREAM_OUT#(0:3)_BUFFER_U16
- STREAM_OUT#(0:3)_BUFFER_U32
- STREAM_OUT#(0:3)_BUFFER_ALLOCATE_NUM_BYTES
User RAM FIFOs
- USER_RAM_FIFO#(0:3)_DATA_F32
- USER_RAM_FIFO#(0:3)_DATA_I32
- USER_RAM_FIFO#(0:3)_DATA_U16
- USER_RAM_FIFO#(0:3)_DATA_U32
- USER_RAM_FIFO#(0:3)_ALLOCATE_NUM_BYTES
WIFI
- WIFI_SCAN_DATA
- WIFI_SCAN_NUM_BYTES
Internal Flash
- INTERNAL_FLASH_READ
- INTERNAL_FLASH_WRITE
Buffer registers can be identified using the Modbus Map tool. Expand the details button to see whether a register is a buffer register, and other details.
LJM
When using the LJM library, the ByteArray or Array functions should be used to read or write buffer buffer registers:
- Non-BYTE registers: LJM_eReadAddressArray, LJM_eReadNameArray, LJM_eWriteAddressArray, or LJM_eWriteNameArray
- BYTE-type registers: LJM_eReadAddressByteArray, LJM_eReadNameByteArray, LJM_eWriteAddressByteArray, or LJM_eWriteNameByteArray
Reading buffer registers with the wrong LJM function can result in error LJME_FUNCTION_DOES_NOT_SUPPORT_THIS_TYPE.