stephane/libmodbus — Issue #33: server: static implementation of mappings - memory inefficiency
Author: mvalsasna
Created: 2011-10-19 13:21:04+00:00
State: open

Hi,

I'm evaluating a modbus stack for a new application (TCP server).

If I read the code correctly, if I'm writing a modbus server and need to support reading from registers with address up to N, I must allocate an uint16_t[0..N] array.
This might be very inefficient, if the register address space is sparse, i.e. only a few registers are used, but some of them have high addresses. In the worst case, I might need to allocate 2^16 * 2byte = 128MB only for reading registers.
Is this correct?

To make it worse, it looks like many implementation artificially divide the 16 bit address range into subranges dedicated to input/output coils/registers (http://www.control.com/thread/1026238596), so a large part of those arrays would be always wasted.

is there any plan to improve the mapping implementation to better address sparse register address spaces, for example with an hashtable, or by specifying starting offset for the arrays (i.e., modbus_mapping_new would accept 4 new parameters do define the base for each data type)?

Thank you and Best Regards

MAtteo Valsasna