telegraf
telegraf copied to clipboard
[inputs.modbus] read multiple coils with higher address gives wrong result
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:
- take the config above
- 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 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.
Im using a TROVIS 5579 over mbusd ( https://github.com/3cky/mbusd )But I don’t think this depends on the device because it can be read with every other modbus software/library expect telegraf.On 25.05.2021, at 22:44, Samantha Wang @.> @. 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.—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
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!
@rwalli do you mind to test PR #12408 with your device and let me know if this can replace the tedious manual filling!?