Skip to content

Commit

Permalink
plugin(modbus): fix modbus rtu slave check
Browse files Browse the repository at this point in the history
  • Loading branch information
hxy7yx committed Mar 13, 2024
1 parent e07ea4a commit a0289e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugins/modbus/modbus_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ static int process_protocol_buf(neu_plugin_t *plugin, uint8_t slave_id,
plog_recv_protocol(plugin, recv_buf, ret);
}
neu_protocol_unpack_buf_init(&pbuf, recv_buf, ret);
int ret_s = modbus_stack_recv(plugin->stack, 0, &pbuf);
int ret_s = modbus_stack_recv(plugin->stack, slave_id, &pbuf);
if (ret_s == MODBUS_DEVICE_ERR) {
ret = ret_s;
} else {
Expand Down
6 changes: 2 additions & 4 deletions plugins/modbus/modbus_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ int modbus_stack_recv(modbus_stack_t *stack, uint8_t slave_id,
return -1;
}

if (stack->protocol == MODBUS_PROTOCOL_TCP) {
if (code.slave_id != slave_id) {
return -1;
}
if (code.slave_id != slave_id) {
return -1;
}

switch (code.function) {
Expand Down

0 comments on commit a0289e5

Please sign in to comment.