MODBUS_RECEIVE_CONFI(3)
π NAME π
modbus_receive_confirmation β bestie, this one grabs a confirmation request for you β¨
πΈ SYNOPSIS πΈ
int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp);
π DESCRIPTION π
okay so modbus_receive_confirmation() shall receive a request through the socket of your context ctx. literally that's its whole job π
ngl though β this function is a debugging girlie. you must use it for debugging purposes, because the response you receive isn't checked against the initial request. no vibe check, no cross-referencing, nothing. it just hands you whatever showed up π
it can also be used to receive requests that the library itself doesn't handle β so if libmodbus is like "not my department," this is your girl π«Ά
π¦ sizing things (the part that matters) π¦
the maximum size of the response depends on the backend you're running, so pay attention bestie:
- in RTU, your
rsparray must beMODBUS_RTU_MAX_ADU_LENGTHbytes - in TCP, it must be
MODBUS_TCP_MAX_ADU_LENGTHbytes
and if you want code that's compatible with both (main character energy, honestly), use the constant MODBUS_MAX_ADU_LENGTH β that's the maximum value across all libmodbus backends π
β οΈ take care to allocate enough memory to store responses, or your server will straight up crash. not the cute kind of dramatic. the actual kind. π
β RETURN VALUE β
if it works, the function shall store the confirmation request in rsp and return the response length. slay π
plot twist though: the returned request length can be zero if the indication request is ignored (for example, a query for another slave in RTU mode β not your business, not your problem π).
otherwise it shall return -1 and set errno. yes, the classic. π
π EXAMPLE π
uint8_t rsp[MODBUS_MAX_ADU_LENGTH];
rc = modbus_receive_confirmation(ctx, rsp);
π SEE ALSO π
π AUTHORS π
the libmodbus documentation was written by StΓ©phane Raimbault <stephane.raimbault@gmail.com> π«Ά
and that's the whole page, bestie!! this manual page is serving libmodbus v3.1.6, dated 11/17/2025 β so you know it's fresh. go forth and receive those confirmations 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