1MODBUS_MAPPING_NEW(3)          Libmodbus Manual          MODBUS_MAPPING_NEW(3)
2
3
4

NAME

6       modbus_mapping_new - allocate four arrays of bits and registers
7

SYNOPSIS

9       modbus_mapping_t modbus_mapping_new(int nb_bits, int nb_input_bits, int
10       nb_registers, int nb_input_registers);*
11

DESCRIPTION

13       The modbus_mapping_new() function shall allocate four arrays to store
14       bits, input bits, registers and inputs registers. The pointers are
15       stored in modbus_mapping_t structure. All values of the arrays are
16       initialized to zero.
17
18       If it isn’t necessary to allocate an array for a specific type of data,
19       you can pass the zero value in argument, the associated pointer will be
20       NULL.
21
22       This function is convenient to handle requests in a Modbus
23       server/slave.
24

RETURN VALUE

26       The modbus_mapping_new() function shall return the new allocated
27       structure if successful. Otherwise it shall return NULL and set errno.
28

ERRORS

30       ENOMEM
31           Not enough memory
32

EXAMPLE

34           /* The fist value of each array is accessible from the 0 address. */
35           mb_mapping = modbus_mapping_new(BITS_ADDRESS + BITS_NB,
36                                           INPUT_BITS_ADDRESS + INPUT_BITS_NB,
37                                           REGISTERS_ADDRESS + REGISTERS_NB,
38                                           INPUT_REGISTERS_ADDRESS + INPUT_REGISTERS_NB);
39           if (mb_mapping == NULL) {
40               fprintf(stderr, "Failed to allocate the mapping: %s\n",
41                       modbus_strerror(errno));
42               modbus_free(ctx);
43               return -1;
44           }
45

SEE ALSO

47       modbus_mapping_free(3)
48

AUTHORS

50       The libmodbus documentation was written by Stéphane Raimbault
51       <stephane.raimbault@gmail.com[1]>
52

NOTES

54        1. stephane.raimbault@gmail.com
55           mailto:stephane.raimbault@gmail.com
56
57
58
59libmodbus 3.0.8                   07/31/2019             MODBUS_MAPPING_NEW(3)
Impressum