Closed ram469 closed 1 year ago
What value do you use for start_registers
?
How many registers did you allocate?
Hi Stephane,
Sorry for the late reply, I use any random value rather than 0 and <= 65535. I have allocated 10 registers.
Thanks, Ramakrishna
The next documentation will include a better explanation:
The different starting addresses make it possible to place the mapping at any address in each address space. This way, you can give access to the clients at values stored at high addresses without allocating memory from the address zero, for eg. to make available registers from 340 to 349, you can use:
mb_mapping = modbus_mapping_new_start_address(0, 0, 0, 0, 340, 10, 0, 0);
The newly created mb_mapping
will have the following arrays:
tab_bits
set to NULLtab_input_bits
set to NULLtab_input_registers
allocated to store 10 registers (uint16_t
)tab_registers
set to NULL.The clients can read the first register by using the address 340 in its request. On the server side, you should use the first index of the array to set the value at this client address:
mb_mapping->tab_registers[0] = 42;
I think your documentation has an error. parameter 5 and 6 are for holding registers, not input registers. I think your documentation on libmodbus.org should be:
_The newly created mb_mapping will have the following arrays:
tab_bits set to NULL tab_input_bits set to NULL tab_registers allocated to store 10 registers (uint16_t) tab_inputregisters set to NULL.
Unless I'm missing something fundamental, but I've looked into your modbus.c code and it clearly shows parameters 5 and 6 are for nb_registers, NOT nb_input_registers
Please update the documentation because this is SUPER confusing.
Hi,
I am using the below statement to create a memory with different start addresses.
then I tried to initialize this memory like below
mb_memory_section ->tab_registers[ start_registers ] = 555;
I tried to get the value using the client at start_registers address but it is zero.Worked case: When I initialized the memory like below it is working
mb_memory_section ->tab_registers[0] = 555;
I tried to get the value using the client at thisstart_registers
address and it is 555Is this the expected behavior? or a bug.
Hardware: NVIDIA Jetson Xavier NX board OS: Ubuntu libmodbus version: latest (built from sources)
Thanks, Ramakrishna