Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[inputs.modbus] read multiple coils with higher address gives wrong result #8905

Closed
rwalli opened this issue Feb 25, 2021 · 4 comments · Fixed by #12408
Closed

[inputs.modbus] read multiple coils with higher address gives wrong result #8905

rwalli opened this issue Feb 25, 2021 · 4 comments · Fixed by #12408
Assignees
Labels
area/modbus bug unexpected problem or unintended behavior

Comments

@rwalli
Copy link

rwalli commented Feb 25, 2021

Relevant telegraf.conf:

[[inputs.modbus]]
name = "test0"
name_override = "test0"
tagexclude = ["name", "type","host"]
slave_id = 1
controller = "tcp://10.0.0.113:502"

coils = [
{ name = "C0"   , address = [0]},
{ name = "C1"   , address = [1]},
{ name = "C2"   , address = [2]},
{ name = "C3"   , address = [3]},
]

[[inputs.modbus]]
name = "test1"
name_override = "test1"
tagexclude = ["name", "type","host"]
slave_id = 1
controller = "tcp://10.0.0.113:502"

coils = [
{ name = "C4"   , address = [4]},
{ name = "C5"   , address = [5]},
{ name = "C6"   , address = [6]},
{ name = "C7"   , address = [7]},
]


System info:

Telegraf 1.17.1, 1.17.2, 1.17,3
GNU/Linux aarch64, x86_64, armv7, 18.7.0 Darwin
client side: https://github.com/3cky/mbusd

Steps to reproduce:

  1. take the config above
  2. set some coils to "1"

eg.:
1 (ad 00000): 0
2 (ad 00001): 0
3 (ad 00002): 1
4 (ad 00003): 0
5 (ad 00004): 0
6 (ad 00005): 0
7 (ad 00006): 1
8 (ad 00007): 0

Expected behavior:

Get the right coils

Actual behavior:

with modbus address starting from 0 (test0) telegraf returns the right coils.
higher adresses (test1) give wrong values.

2021-02-25T07:43:13Z I! Starting Telegraf 1.17.1

test0 C0=0i,C1=0i,C2=1i,C3=0i 1614238994000000000
test1 C4=0i,C5=0i,C6=0i,C7=0i 1614238994000000000

Additional info:

the returend values seems to be ok with a modbus testing-tool:

test0:

Tx: [5A 7F 00 00 00 06 01] 01 00 00 00 04
Rx: [5A 7F 00 00 00 04 01] 01 01 04

test1:

Tx: [8F 69 00 00 00 06 01] 01 00 04 00 04
Rx: [8F 69 00 00 00 04 01] 01 01 04

(I also verified return values with tcpdump)

@rwalli rwalli added the bug unexpected problem or unintended behavior label Feb 25, 2021
@rwalli rwalli changed the title modbus read multiple coils with higher address gives wrong result [inputs.modbus] read multiple coils with higher address gives wrong result Feb 25, 2021
@sjwang90
Copy link
Contributor

@rwalli Can you describe what type of devices you are using? We are currently trying to understand what hardware devices may require a workaround for enforcing bit-register reads from zero and if such a workaround would cover the issue you're running into.

@rwalli
Copy link
Author

rwalli commented May 26, 2021 via email

@srebhan srebhan self-assigned this Nov 30, 2021
@srebhan
Copy link
Member

srebhan commented Nov 30, 2021

As discussed on slack, for some devices you need to specify all coil registers starting from address zero as those devices do not allow reading from an offset.
We hope to come up with a workaround, taking away that tedious workaround-work from the user. PRs beating me on this are appreciated!

@srebhan
Copy link
Member

srebhan commented Dec 16, 2022

@rwalli do you mind to test PR #12408 with your device and let me know if this can replace the tedious manual filling!?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/modbus bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants