1 # modbus_receive_confirmation
5 modbus_receive_confirmation - receive a confirmation request
10 int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp);
15 The *modbus_receive_confirmation()* function shall receive a request via the
16 socket of the context `ctx`. This function must be used for debugging purposes
17 because the received response isn't checked against the initial request. This
18 function can be used to receive request not handled by the library.
20 The maximum size of the response depends on the used backend, in RTU the `rsp`
21 array must be `MODBUS_RTU_MAX_ADU_LENGTH` bytes and in TCP it must be
22 `MODBUS_TCP_MAX_ADU_LENGTH` bytes. If you want to write code compatible with
23 both, you can use the constant `MODBUS_MAX_ADU_LENGTH` (maximum value of all
24 libmodbus backends). Take care to allocate enough memory to store responses to
25 avoid crashes of your server.
29 The function shall store the confirmation request in `rsp` and return the
30 response length if successful. The returned request length can be zero if the
31 indication request is ignored (eg. a query for another slave in RTU
32 mode). Otherwise it shall return -1 and set errno.
37 uint8_t rsp[MODBUS_MAX_ADU_LENGTH];
38 rc = modbus_receive_confirmation(ctx, rsp);
43 - [modbus_send_raw_request](modbus_send_raw_request.md)