1MODBUS_REPORT_SLAVE_(3)        libmodbus Manual        MODBUS_REPORT_SLAVE_(3)
2
3
4

NAME

6       modbus_report_slave_id - returns a description of the controller
7

SYNOPSIS

9       int modbus_report_slave_id(modbus_t *ctx, int max_dest, uint8_t *dest);
10

DESCRIPTION

12       The modbus_report_slave_id() function shall send a request to the
13       controller to obtain a description of the controller.
14
15       The response stored in dest contains:
16
17       •   the slave ID, this unique ID is in reality not unique at all so
18           it’s not possible to depend on it to know how the information are
19           packed in the response.
20
21       •   the run indicator status (0x00 = OFF, 0xFF = ON)
22
23       •   additional data specific to each controller. For example, libmodbus
24           returns the version of the library as a string.
25
26       The function writes at most max_dest bytes from the response to dest so
27       you must ensure that dest is large enough.
28

RETURN VALUE

30       The function shall return the number of read data if successful.
31
32       If the output was truncated due to the max_dest limit then the return
33       value is the number of bytes which would have been written to dest if
34       enough space had been available. Thus, a return value greater than
35       max_dest means that the response data was truncated.
36
37       Otherwise it shall return -1 and set errno.
38

EXAMPLE

40           uint8_t tab_bytes[MODBUS_MAX_PDU_LENGTH];
41
42           ...
43
44           rc = modbus_report_slave_id(ctx, MODBUS_MAX_PDU_LENGTH, tab_bytes);
45           if (rc > 1) {
46               printf("Run Status Indicator: %s\n", tab_bytes[1] ? "ON" : "OFF");
47           }
48

AUTHORS

50       The libmodbus documentation was written by Stéphane Raimbault
51       <stephane.raimbault@gmail.com>
52
53
54
55libmodbus v3.1.7                  07/20/2023           MODBUS_REPORT_SLAVE_(3)
Impressum