Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ TXT3 = \
modbus_read_input_bits.txt \
modbus_read_input_registers.txt \
modbus_read_registers.txt \
modbus_read_file_record.txt \
modbus_receive_confirmation.txt \
modbus_receive.txt \
modbus_reply_exception.txt \
Expand Down Expand Up @@ -60,6 +61,7 @@ TXT3 = \
modbus_write_bits.txt \
modbus_write_bit.txt \
modbus_write_registers.txt \
modbus_write_file_record.txt \
modbus_write_register.txt
TXT7 = libmodbus.txt

Expand Down
12 changes: 8 additions & 4 deletions doc/modbus_mapping_new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ modbus_mapping_new - allocate four arrays of bits and registers

SYNOPSIS
--------
*modbus_mapping_t* modbus_mapping_new(int 'nb_bits', int 'nb_input_bits', int 'nb_registers', int 'nb_input_registers');*
*modbus_mapping_t* modbus_mapping_new(int 'nb_bits', int 'nb_input_bits',
int 'nb_registers', int 'nb_input_registers',
int 'nb_files', int 'nb_records', int 'record_size');*


DESCRIPTION
-----------
The *modbus_mapping_new()* function shall allocate four arrays to store bits,
input bits, registers and inputs registers. The pointers are stored in
The *modbus_mapping_new()* function shall allocate six arrays to store bits,
input bits, registers, inputs registers, files and file records. The pointers are stored in
modbus_mapping_t structure. All values of the arrays are initialized to zero.

This function is equivalent to a call of the
Expand Down Expand Up @@ -48,7 +50,9 @@ EXAMPLE
mb_mapping = modbus_mapping_new(BITS_ADDRESS + BITS_NB,
INPUT_BITS_ADDRESS + INPUT_BITS_NB,
REGISTERS_ADDRESS + REGISTERS_NB,
INPUT_REGISTERS_ADDRESS + INPUT_REGISTERS_NB);
INPUT_REGISTERS_ADDRESS + INPUT_REGISTERS_NB,
FILES_ADDRESS + FILES_NB,
RECORDS_NB, RECORDS_SIZE);
if (mb_mapping == NULL) {
fprintf(stderr, "Failed to allocate the mapping: %s\n",
modbus_strerror(errno));
Expand Down
17 changes: 11 additions & 6 deletions doc/modbus_mapping_new_start_address.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ SYNOPSIS
*modbus_mapping_t* modbus_mapping_new_start_address(int 'start_bits', int 'nb_bits',
int 'start_input_bits', int 'nb_input_bits',
int 'start_registers', int 'nb_registers',
int 'start_input_registers', int 'nb_input_registers');*
int 'start_input_registers', int 'nb_input_registers',
int 'start_files', int 'nb_files',
int 'nb_records', int 'record_size');*


DESCRIPTION
-----------
The _modbus_mapping_new_start_address()_ function shall allocate four arrays to
store bits, input bits, registers and inputs registers. The pointers are stored
in modbus_mapping_t structure. All values of the arrays are initialized to zero.
The _modbus_mapping_new_start_address()_ function shall allocate six arrays to
store bits, input bits, registers, inputs registers, files and file records.
The pointers are stored in modbus_mapping_t structure. All values of the arrays
are initialized to zero.

The different starting adresses make it possible to place the mapping at any
address in each address space. This way, you can give access to values stored
Expand All @@ -28,7 +31,7 @@ make available registers from 10000 to 10009, you can use:

[source,c]
-------------------
mb_mapping = modbus_mapping_new_start_address(0, 0, 0, 0, 10000, 10, 0, 0);
mb_mapping = modbus_mapping_new_start_address(0, 0, 0, 0, 10000, 10, 0, 0, 0, 0, 0, 0);
-------------------

With this code, only 10 registers (`uint16_t`) are allocated.
Expand Down Expand Up @@ -60,7 +63,9 @@ EXAMPLE
mb_mapping = modbus_mapping_new_start_address(BITS_ADDRESS, BITS_NB,
INPUT_BITS_ADDRESS, INPUT_BITS_NB,
REGISTERS_ADDRESS, REGISTERS_NB,
INPUT_REGISTERS_ADDRESS, INPUT_REGISTERS_NB);
INPUT_REGISTERS_ADDRESS, INPUT_REGISTERS_NB,
FILES_ADDRESS, FILES_NB,
RECORDS_NB, RECORDS_SIZE);
if (mb_mapping == NULL) {
fprintf(stderr, "Failed to allocate the mapping: %s\n",
modbus_strerror(errno));
Expand Down
42 changes: 42 additions & 0 deletions doc/modbus_read_file_record.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
modbus_read_file_record(3)
==========================


NAME
----
modbus_read_file_record - read many input registers


SYNOPSIS
--------
*int modbus_read_file_record(modbus_t *'ctx', int 'addr', int 'sub_addr', int 'nb', uint16_t *'dest');*


DESCRIPTION
-----------
The *modbus_read_registers()* function shall read the content of the _nb_
registers stored in a record at _sub_addr_ in a file at _addr_ of the remote device.
The result of reading is stored in _dest_ array as word values (16 bits).

You must take care to allocate enough memory to store the results in _dest_
(at least _nb_ * sizeof(uint16_t)).

The function uses the Modbus function code 0x14 (read file record).


RETURN VALUE
------------
The function shall return the number of read registers if
successful. Otherwise it shall return -1 and set errno.


SEE ALSO
--------
linkmb:modbus_write_file_record[3]


AUTHORS
-------
Kamil Wcislo <mek.xgt@gmail.com>
The libmodbus documentation was written by Stéphane Raimbault
<stephane.raimbault@gmail.com>
37 changes: 37 additions & 0 deletions doc/modbus_write_file_record.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
modbus_write_file_record(3)
===========================


NAME
----
modbus_write_file_record - read registers from record in a file


SYNOPSIS
--------
*int modbus_write_file_record(modbus_t *'ctx', int 'addr', int 'sub_addr', int 'nb', const uint16_t *'src');*

DESCRIPTION
-----------
The *modbus_write_file_record()* function shall write the content of the _nb_
holding registers from the array _src_ to record at _sub_addr_ of the file at
address _addr_ of the remote device.

The function uses the Modbus function code 0x15 (write file record).

RETURN VALUE
------------
The function shall return the number of written registers if
successful. Otherwise it shall return -1 and set errno.


SEE ALSO
--------
linkmb:modbus_read_file_record[3]


AUTHORS
-------
Kamil Wcislo <mek.xgt@gmail.com>
The libmodbus documentation was written by Stéphane Raimbault
<stephane.raimbault@gmail.com>
1 change: 1 addition & 0 deletions src/modbus-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct _modbus {
void _modbus_init_common(modbus_t *ctx);
void _error_print(modbus_t *ctx, const char *context);
int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type);
void _modbus_free_files(modbus_file_t *files, int nb_files);

#ifndef HAVE_STRLCPY
size_t strlcpy(char *dest, const char *src, size_t dest_size);
Expand Down
Loading