MODBUS_REPLY_EXCEPTI(3)
β¨ MODBUS_REPLY_EXCEPTI β¨
okay bestie, pull up a chair, we're diving into libmodbus's modbus_reply_exception π this one lives in section 3 of the manual and it's genuinely so useful, no cap.
πΈ NAME πΈ
modbus_reply_exception β bestie, this thing sends an exception response π
π SYNOPSIS π
int modbus_reply_exception(modbus_t *ctx, const uint8_t *req, unsigned
int exception_code);
π¦ DESCRIPTION π¦
so like, the modbus_reply_exception() function shall send an exception response based on the exception_code you hand it in the argument. that's the whole vibe. you give it a code, it throws that exception back at whoever asked. iconic behavior honestly β¨
libmodbus comes stocked with these exception codes, and you will be using them:
MODBUS_EXCEPTION_ILLEGAL_FUNCTION(1)MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS(2)MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE(3)MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE(4)MODBUS_EXCEPTION_ACKNOWLEDGE(5)MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY(6)MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE(7)MODBUS_EXCEPTION_MEMORY_PARITY(8)MODBUS_EXCEPTION_NOT_DEFINED(9)MODBUS_EXCEPTION_GATEWAY_PATH(10)MODBUS_EXCEPTION_GATEWAY_TARGET(11)
also, lowkey important: the initial request req is required to build a valid response. like, you literally cannot skip it. no req, no response, that's the rule π«Ά
π RETURN VALUE π
if everything slays? the function shall return the length of the response sent β that's your success signal, periodt π
but if it doesn't work out? it shall return -1 and set errno. not the vibe, but at least you know why π
π ERRORS π
EINVALβ the exception code is invalid. bestie. the code. it's not a real one. check yourself π
π SEE ALSO π
π AUTHORS π
the libmodbus documentation was written by StΓ©phane Raimbault <stephane.raimbault@gmail.com> β absolute legend, we stan π«Ά
and that's the whole page bestie!! this was libmodbus v3.1.6, dated 11/17/2025 β go forth and handle your exceptions responsibly π β¨π
π¦ 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