Skip to content

Commit 6094e00

Browse files
committed
modbus_proxy: clarify transaction ID handling in comments
The backend request deliberately uses tid 0, matched by the confirmation pre-check; sft.t_id only restores the frontend tid
1 parent 3e2de62 commit 6094e00

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/modbus.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,13 +1357,16 @@ int modbus_proxy(modbus_t *frontend_ctx,
13571357
memcpy(backend_req, req + frontend_header_length - 1, pdu_length + 1);
13581358
backend_req_length = pdu_length + 1;
13591359

1360-
/* Preserve the transaction ID from the frontend request */
1360+
/* Keep the transaction ID of the frontend request to restore it in the
1361+
response sent to the frontend */
13611362
sft.slave = backend_req[0];
13621363
sft.function = backend_req[1];
13631364
sft.t_id = frontend_ctx->backend->get_response_tid(req);
13641365

13651366
/* Send the request to the backend device using raw request.
1366-
modbus_send_raw_request_tid wraps the PDU into the backend framing. */
1367+
modbus_send_raw_request_tid wraps the PDU into the backend framing.
1368+
The backend request uses transaction ID 0 and the pre-check of the
1369+
confirmation below relies on it (check_sft.t_id) */
13671370
rc = modbus_send_raw_request_tid(
13681371
backend_ctx, backend_req, backend_req_length, 0);
13691372
if (rc == -1) {

0 commit comments

Comments
 (0)