Skip to content

Commit ea6a047

Browse files
author
Cedric Boudinet
committed
adding get_query_function
1 parent dd45f19 commit ea6a047

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/modbus.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,16 @@ int modbus_get_header_length(modbus_t *ctx)
18561856
return ctx->backend->header_length;
18571857
}
18581858

1859+
int modbus_get_query_function(modbus_t *ctx, const uint8_t * req)
1860+
{
1861+
if (ctx == NULL) {
1862+
errno = EINVAL;
1863+
return -1;
1864+
}
1865+
1866+
return req[ctx->backend->header_length];
1867+
}
1868+
18591869
int modbus_enable_quirks(modbus_t *ctx, uint32_t quirks_mask)
18601870
{
18611871
if (ctx == NULL) {

src/modbus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ MODBUS_API int
206206
modbus_set_indication_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec);
207207

208208
MODBUS_API int modbus_get_header_length(modbus_t *ctx);
209+
int modbus_get_query_function(modbus_t *ctx, const uint8_t * req);
209210

210211
MODBUS_API int modbus_connect(modbus_t *ctx);
211212
MODBUS_API void modbus_close(modbus_t *ctx);

0 commit comments

Comments
 (0)