Hello,
I'm trying to implement a modbus TCP/RTU gateway by using this library and I notice that having a more generic version of the function modbus_send_raw_request() can be very useful! Below is what I mean:
diff --git a/src/modbus.c b/src/modbus.c
index f1da5c6..70b9a06 100644
--- a/src/modbus.c
+++ b/src/modbus.c
@@ -207,7 +207,8 @@ static int send_msg(modbus_t *ctx, uint8_t *msg, int msg_length)
return rc;
}
-int modbus_send_raw_request(modbus_t *ctx, uint8_t *raw_req, int raw_req_length)
+int modbus_send_raw_request(modbus_t *ctx, uint16_t t_id,
+ uint8_t *raw_req, int raw_req_length)
{
sft_t sft;
uint8_t req[MAX_MESSAGE_LENGTH];
@@ -228,8 +229,7 @@ int modbus_send_raw_request(modbus_t *ctx, uint8_t *raw_req, int raw_req_length)
sft.slave = raw_req[0];
sft.function = raw_req[1];
- /* The t_id is left to zero */
- sft.t_id = 0;
+ sft.t_id = t_id;
/* This response function only set the header so it's convenient here */
req_length = ctx->backend->build_response_basis(&sft, req);
Of course doing as above will break the current API so I'd like proposing the patch below to resolve the issue. Please let me know if it could be acceptable.
Thanks in advance,
Rodolfo