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

Modbus Plugin - read every field separately #12071

Closed
DasCapschen opened this issue Oct 20, 2022 · 4 comments · Fixed by #12235
Closed

Modbus Plugin - read every field separately #12071

DasCapschen opened this issue Oct 20, 2022 · 4 comments · Fixed by #12235
Assignees
Labels
area/modbus feature request Requests for new plugin and for new features to existing plugins plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins

Comments

@DasCapschen
Copy link

DasCapschen commented Oct 20, 2022

Use Case

I'm trying to communicate with an external Modbus, and it fails to respond with multiple registers at once.
Every field I request is a UINT16 (2 bytes, 1 register).
Telegraf usually asks Modbus for multiple registers at once and then seems to split it into the fields I requested.
Because the Modbus I'm communicating with fails to respond with more than 1 register, every second field I request is 0.

Expected behavior

Be able to tell Telegraf to request every field individually and not combine reads of adjacent registers.

Actual behavior

Telegraf asks for multiple registers and splits them into the fields I requested, which breaks when the Modbus I'm communicating with fails to respond with more than 1 register.

Additional info

Telegraf 1.22.4

Yes, I have reported the bug to the third party whose Modbus is broken, but they said it won't be fixed soon, so a workaround in Telegraf would be nice :)

@DasCapschen DasCapschen added the feature request Requests for new plugin and for new features to existing plugins label Oct 20, 2022
@DasCapschen DasCapschen changed the title [[inputs.modbus.request]] - read only 1 register at a time Modbus Plugin - read every field separately Oct 21, 2022
@DasCapschen
Copy link
Author

I thought I had found a workaround for Telegraf always asking for 2 registers by using byte_order = "CDAB" and type="UINT32" to read my UINT16 fields. This fixed most of my issues, but now I have observed in Wireshark that Telegraf sometimes asks for 4 registers! So this still breaks some of the fields I am querying. (although less than before)

I tried using register mode instead of request mode, but then I observed Telegraf asking even for 8 adjacent registers, so that also does not work.
I really need to be able to request every register individually.

@srebhan
Copy link
Member

srebhan commented Oct 27, 2022

@DasCapschen can you try to use configuration_type = "request" and create an individual [[inputs.modbus.request]] section for every field? This would tell Telegraf to create a new request per field. Anyhow, if the problem is that we are reading two registers for a uint32 value this won't help...

@srebhan srebhan self-assigned this Oct 27, 2022
@srebhan srebhan added area/modbus plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Oct 27, 2022
@DasCapschen
Copy link
Author

Creating an individual [[inputs.modbus.request]] for each field seems to have worked, thank you.

@srebhan
Copy link
Member

srebhan commented Nov 14, 2022

@DasCapschen I've implemented a workaround for your device. When now setting one_request_per_field = true in the [inputs.modbus.workarounds] section for your device, the plugin will create one request per field you specify.

Can you please test this with your device? Furthermore, can you please let me know your device type/model so I can add this to the documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/modbus feature request Requests for new plugin and for new features to existing plugins plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants