Skip to content

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

Merged
helenosheaa merged 6 commits intoinfluxdata:masterfrom
garciaolais:bufix/7227
Feb 26, 2021
Merged

fix: reading multiple holding registers in modbus input plugin#8628
helenosheaa merged 6 commits intoinfluxdata:masterfrom
garciaolais:bufix/7227

Conversation

@garciaolais
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Looks good @garciaolais thanks for opening up another PR!

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

srebhan commented Jan 19, 2021

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

@garciaolais
Copy link
Copy Markdown
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
@garciaolais garciaolais requested a review from srebhan January 20, 2021 04:37
@srebhan
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@garciaolais garciaolais requested a review from ssoroka February 21, 2021 06:22
Copy link
Copy Markdown
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