diff --git a/src/modbus.c b/src/modbus.c index 68a28a3..4810cfe 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -208,6 +208,11 @@ static int send_msg(modbus_t *ctx, uint8_t *msg, int msg_length) } int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length) +{ + return modbus_send_raw_request_tid(ctx, raw_req, raw_req_length, 0); +} + +int modbus_send_raw_request_tid(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length, int tid) { sft_t sft; uint8_t req[MAX_MESSAGE_LENGTH]; @@ -229,7 +234,7 @@ int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_l sft.slave = raw_req[0]; sft.function = raw_req[1]; /* The t_id is left to zero */ - sft.t_id = 0; + sft.t_id = tid; /* This response function only set the header so it's convenient here */ req_length = ctx->backend->build_response_basis(&sft, req); diff --git a/src/modbus.h b/src/modbus.h index fbe20bc..8b3c675 100644 --- a/src/modbus.h +++ b/src/modbus.h @@ -228,6 +228,7 @@ MODBUS_API modbus_mapping_t* modbus_mapping_new(int nb_bits, int nb_input_bits, MODBUS_API void modbus_mapping_free(modbus_mapping_t *mb_mapping); MODBUS_API int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length); +MODBUS_API int modbus_send_raw_request_tid(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length, int tid); MODBUS_API int modbus_receive(modbus_t *ctx, uint8_t *req);