Skip to content

Commit

Permalink
Merge pull request #1903 from hxy7yx/v2.6-1
Browse files Browse the repository at this point in the history
plugin(modbus): fix modbus rtu slave check
  • Loading branch information
fengzeroz authored Mar 13, 2024
2 parents 07ff044 + f0fbfa6 commit b8890b7
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 @@ -698,7 +698,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 b8890b7

Please sign in to comment.