MODBUS_RECEIVE_CONFI(3)

πŸ“¦
version 3.1.6 Β· 3 versions
, in debian bookworm

πŸ’– 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 rsp array must be MODBUS_RTU_MAX_ADU_LENGTH bytes
  • in TCP, it must be MODBUS_TCP_MAX_ADU_LENGTH bytes

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 πŸ‘‘

modbus_send_raw_request(3)


πŸ’œ 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