Skip to content

Commit 180da3e

Browse files
cedricboudinetstephane
authored andcommitted
adding modbus_send_raw_request_tid
1 parent 4d033a8 commit 180da3e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/modbus.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static int send_msg(modbus_t *ctx, uint8_t *msg, int msg_length)
220220
return rc;
221221
}
222222

223-
int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length)
223+
int modbus_send_raw_request_tid(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length, long tid)
224224
{
225225
sft_t sft;
226226
uint8_t req[MAX_MESSAGE_LENGTH];
@@ -242,7 +242,7 @@ int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_l
242242
sft.slave = raw_req[0];
243243
sft.function = raw_req[1];
244244
/* The t_id is left to zero */
245-
sft.t_id = 0;
245+
sft.t_id = tid;
246246
/* This response function only set the header so it's convenient here */
247247
req_length = ctx->backend->build_response_basis(&sft, req);
248248

@@ -255,6 +255,11 @@ int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_l
255255
return send_msg(ctx, req, req_length);
256256
}
257257

258+
int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length)
259+
{
260+
return modbus_send_raw_request_tid(ctx, raw_req, raw_req_length, 0);
261+
}
262+
258263
/*
259264
* ---------- Request Indication ----------
260265
* | Client | ---------------------->| Server |

src/modbus.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ MODBUS_API void modbus_mapping_free(modbus_mapping_t *mb_mapping);
257257
MODBUS_API int
258258
modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length);
259259

260+
MODBUS_API int
261+
modbus_send_raw_request_tid(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length, long tid);
262+
260263
MODBUS_API int modbus_receive(modbus_t *ctx, uint8_t *req);
261264

262265
MODBUS_API int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp);

0 commit comments

Comments
 (0)