MODBUS_REPORT_SLAVE_(3)
π MODBUS_REPORT_SLAVE_ID π
okay bestie, so this is a page from the libmodbus Manual and it's about modbus_report_slave_id β literally the function that goes "hey controller, who ARE you? describe yourself for me" β¨ and then writes the answer into your buffer. Let's get into it π¦
πΈ NAME πΈ
modbus_report_slave_id β returns a description of the controller π
β¨ SYNOPSIS β¨
int modbus_report_slave_id(modbus_t *ctx, int max_dest, uint8_t *dest);
π DESCRIPTION π
So modbus_report_slave_id() sends a request over to the controller asking it to describe itself. That's it, that's the whole vibe. π«Ά
The response lands in dest, and bestie, it's got a few things in it:
- the slave ID β and here's the tea β, this "unique" ID is in reality not unique at all, so you literally cannot depend on it to figure out how the information is packed in the response. Not even a little. π
- the run indicator status (
0x00= OFF,0xFF= ON) π - additional data specific to each controller. For example, libmodbus returns the version of the library as a string. cute, right? π
The function writes at most max_dest bytes from the response into dest, so you must make sure dest is big enough. No cap, please check. π
π₯ RETURN VALUE π₯
If everything's slaying, the function returns the number of read data. β¨
If the output got truncated because of the max_dest limit, then the return value is the number of bytes that would have been written to dest if enough space had been available. So if you get a return value greater than max_dest, that means the response data was truncated. Periodt. π
Otherwise it returns -1 and sets errno. π
π EXAMPLE π
uint8_t tab_bytes[MODBUS_MAX_PDU_LENGTH];
...
rc = modbus_report_slave_id(ctx, MODBUS_MAX_PDU_LENGTH, tab_bytes);
if (rc > 1) {
printf("Run Status Indicator: %s\n", tab_bytes[1] ? "ON" : "OFF");
}
π AUTHORS π
The libmodbus documentation was written by StΓ©phane Raimbault <stephane.raimbault@gmail.com> π«Ά
and that's the whole page bestie, you ate π this was libmodbus v3.1.6, dated 11/17/2025, and it's giving main character energy from the MODBUS_REPORT_SLAVE_(3) page itself πΈβ¨ mwah π
π¦ where this page comes from
- debian bookworm: libmodbus-dev 3.1.6-2.1+deb12u1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms