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

fix: reading multiple holding registers in modbus input plugin #8628

Merged
merged 6 commits into from
Feb 26, 2021

Conversation

garciaolais
Copy link
Contributor

Required for all PRs:

if you try to read multiple consecutive addresses , modbus return error "quantity 346 must be between 1 and 125".
this happens because we have a limitation with the number of registers that we can retrieve, 125 for holding registers and Input registers and 2000 for discrete inputs and coils

@garciaolais garciaolais changed the title Bufix/7227 Bugfix/7227 Dec 30, 2020
Copy link
Contributor

@ivorybilled ivorybilled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks good to me

@helenosheaa
Copy link
Member

Looks good @garciaolais thanks for opening up another PR!

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good basically, but I'd prefer to have the checking for max grouped registers in an else-if to make it obvious that it is exclusive.

@srebhan srebhan self-assigned this Jan 3, 2021
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect thanks!

@srebhan srebhan added area/modbus fix pr to fix corresponding bug ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. labels Jan 4, 2021
Comment on lines 244 to 245
ii++
registersRange = append(registersRange, registerRange{start, end - start + 1})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I'm pretty sure that the additional i++ here means we should change end-start+1 to end-start!? However, I would feel much more safe if we remove the additional i++ and keep the range calculation as is... :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove i++ but the other change end-start+1 to end-start brake some test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @srebhan

Do you have any other comments about this issue?

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the register-range changed. Could you please check my comment in the code!?

@srebhan srebhan removed the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jan 6, 2021
@srebhan
Copy link
Member

srebhan commented Jan 19, 2021

@garciaolais can you please comment on my question above regarding the new increment of end!?

@garciaolais
Copy link
Contributor Author

@srebhan sorry for the delay but I really doesn't have free time to check this. Let me chance to retake it and I hope to test it this week.

@sjwang90 sjwang90 changed the title Bugfix/7227 fix: reading multiple holding registers in modbus input plugin Jan 20, 2021
@srebhan
Copy link
Member

srebhan commented Jan 20, 2021

@garciaolais sure, just wanted to make sure it is not forgotten. Please let me know about the results of your tests!

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me assuming that you tested the code @garciaolais ... :-)

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Feb 1, 2021
Copy link
Contributor

@ssoroka ssoroka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good. One ask is that the tests don't validate the generated metric. It's possible that it runs without errors but doesn't give you the response you'd expect.
Does it make sense to add some lines to at least one of the tests to make sure the metric was generated as expected?

Copy link
Contributor

@ssoroka ssoroka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, would still be great to get a test showing the expected metrics are generated properly.

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@helenosheaa helenosheaa merged commit 7ed98c7 into influxdata:master Feb 26, 2021
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/modbus fix pr to fix corresponding bug ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error while reading multiple holding registers on modbus input plugin
5 participants