Commit 3e4cce546f56f679cb40a9bfa45f1a23fc1d7acf
1 parent
64e21cce
Documentation of modbus_mapping_new and modbus_mapping_free
Showing
5 changed files
with
106 additions
and
2 deletions
NEWS
| @@ -10,7 +10,7 @@ libmodbus 2.9.5 (2011-06-XX) | @@ -10,7 +10,7 @@ libmodbus 2.9.5 (2011-06-XX) | ||
| 10 | * modbus_read_and_write_registers -> modbus_write_and_read_registers | 10 | * modbus_read_and_write_registers -> modbus_write_and_read_registers |
| 11 | The function name was confusing because the write operation is performed | 11 | The function name was confusing because the write operation is performed |
| 12 | before the read. Take care to swap the arguments in the migration process. | 12 | before the read. Take care to swap the arguments in the migration process. |
| 13 | -- Documentation of modbus_write_and_read_registers | 13 | +- Documentation of modbus_write_and_read_registers, modbus_mapping_new/free |
| 14 | 14 | ||
| 15 | libmodbus 2.9.4 (2011-06-05) | 15 | libmodbus 2.9.4 (2011-06-05) |
| 16 | ============================ | 16 | ============================ |
doc/Makefile.am
| @@ -7,6 +7,8 @@ MAN3 = \ | @@ -7,6 +7,8 @@ MAN3 = \ | ||
| 7 | modbus_get_header_length.3 \ | 7 | modbus_get_header_length.3 \ |
| 8 | modbus_get_socket.3 \ | 8 | modbus_get_socket.3 \ |
| 9 | modbus_get_response_timeout.3 \ | 9 | modbus_get_response_timeout.3 \ |
| 10 | + modbus_mapping_free.3 \ | ||
| 11 | + modbus_mapping_new.3 \ | ||
| 10 | modbus_new_rtu.3 \ | 12 | modbus_new_rtu.3 \ |
| 11 | modbus_new_tcp_pi.3 \ | 13 | modbus_new_tcp_pi.3 \ |
| 12 | modbus_new_tcp.3 \ | 14 | modbus_new_tcp.3 \ |
doc/libmodbus.txt
| @@ -166,7 +166,11 @@ Server | @@ -166,7 +166,11 @@ Server | ||
| 166 | ~~~~~~ | 166 | ~~~~~~ |
| 167 | The server is waiting for request from clients and must answer when it is | 167 | The server is waiting for request from clients and must answer when it is |
| 168 | concerned by the request. The libmodbus offers the following functions to | 168 | concerned by the request. The libmodbus offers the following functions to |
| 169 | -receive and reply: | 169 | +handle requests: |
| 170 | + | ||
| 171 | +Data mapping: | ||
| 172 | + linkmb:modbus_mapping_new[3] | ||
| 173 | + linkmb:modbus_mapping_free[3] | ||
| 170 | 174 | ||
| 171 | Receive:: | 175 | Receive:: |
| 172 | linkmb:modbus_receive[3] | 176 | linkmb:modbus_receive[3] |
doc/modbus_mapping_free.txt
0 → 100644
| 1 | +modbus_mapping_free(3) | ||
| 2 | +===================== | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +NAME | ||
| 6 | +---- | ||
| 7 | +modbus_mapping_free - free a modbus_mapping_t structure | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +SYNOPSIS | ||
| 11 | +-------- | ||
| 12 | +*void modbus_mapping_free(modbus_mapping_t *'mb_mapping')* | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +DESCRIPTION | ||
| 16 | +----------- | ||
| 17 | +The _modbus_mapping_free()_ function shall free the four arrays of mb_mapping_t | ||
| 18 | +structure and finally the mb_mapping_t referenced by 'mb_mapping'. | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +RETURN VALUE | ||
| 22 | +------------ | ||
| 23 | +There is no return values. | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +SEE ALSO | ||
| 27 | +-------- | ||
| 28 | +linkmb:modbus_mapping_new[3] | ||
| 29 | + | ||
| 30 | + | ||
| 31 | +AUTHORS | ||
| 32 | +------- | ||
| 33 | +The libmodbus documentation was written by Stéphane Raimbault | ||
| 34 | +<stephane.raimbault@gmail.com> |
doc/modbus_mapping_new.txt
0 → 100644
| 1 | +modbus_mapping_new(3) | ||
| 2 | +===================== | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +NAME | ||
| 6 | +---- | ||
| 7 | +modbus_mapping_new - allocate four arrays of bits and registers | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +SYNOPSIS | ||
| 11 | +-------- | ||
| 12 | +*modbus_mapping_t* modbus_mapping_new(int 'nb_bits', int 'nb_input_bits', int 'nb_registers', int 'nb_input_registers')* | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +DESCRIPTION | ||
| 16 | +----------- | ||
| 17 | +The _modbus_mapping_new()_ function shall allocate four arrays to store bits, | ||
| 18 | +input bits, registers and inputs registers. The pointers are stored in | ||
| 19 | +modbus_mapping_t structure. All values of the arrays are initialized to zero. | ||
| 20 | + | ||
| 21 | +If it isn't necessary to allocate an array for a specific type of data, you can | ||
| 22 | +pass the zero value in argument, the associated pointer will be NULL. | ||
| 23 | + | ||
| 24 | +This function is convenient to handle requests in a Modbus server/slave. | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +RETURN VALUE | ||
| 28 | +------------ | ||
| 29 | +The _modbus_mapping_new()_ function shall return the new allocated structure if | ||
| 30 | +successful. Otherwise it shall return NULL and set errno. | ||
| 31 | + | ||
| 32 | + | ||
| 33 | +ERRORS | ||
| 34 | +------ | ||
| 35 | +ENOMEM:: | ||
| 36 | +Not enough memory | ||
| 37 | + | ||
| 38 | + | ||
| 39 | +EXAMPLE | ||
| 40 | +------- | ||
| 41 | +[source,c] | ||
| 42 | +------------------- | ||
| 43 | +/* The fist value of each array is accessible from the 0 address. */ | ||
| 44 | +mb_mapping = modbus_mapping_new(BITS_ADDRESS + BITS_NB, | ||
| 45 | + INPUT_BITS_ADDRESS + INPUT_BITS_NB, | ||
| 46 | + REGISTERS_ADDRESS + REGISTERS_NB, | ||
| 47 | + INPUT_REGISTERS_ADDRESS + INPUT_REGISTERS_NB); | ||
| 48 | +if (mb_mapping == NULL) { | ||
| 49 | + fprintf(stderr, "Failed to allocate the mapping: %s\n", | ||
| 50 | + modbus_strerror(errno)); | ||
| 51 | + modbus_free(ctx); | ||
| 52 | + return -1; | ||
| 53 | +} | ||
| 54 | +------------------- | ||
| 55 | + | ||
| 56 | +SEE ALSO | ||
| 57 | +-------- | ||
| 58 | +linkmb:modbus_mapping_free[3] | ||
| 59 | + | ||
| 60 | + | ||
| 61 | +AUTHORS | ||
| 62 | +------- | ||
| 63 | +The libmodbus documentation was written by Stéphane Raimbault | ||
| 64 | +<stephane.raimbault@gmail.com> |