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

start reference is off by -1 #51

Open
randy- opened this issue Nov 13, 2021 · 5 comments
Open

start reference is off by -1 #51

randy- opened this issue Nov 13, 2021 · 5 comments

Comments

@randy-
Copy link

randy- commented Nov 13, 2021

Hello,

Testing mbpoll with Victron Energry Color GX. The Victron Energry Color GX error logs shows
mbpoll 1.0-0 (Debian 1.4.11+dfsg-2~bpo10+1) starting reference (-r) is off by -1.
Example: ./mbpoll -1 -a 100 -t 3 -r 840 -c 1 192.168.10.180
mbpoll will starts at 839 not 840.

Fix source file mbpoll.c
change line 952~
iStartReg = ctx.piStartRef[j] - ctx.iPduOffset;
to
iStartReg = ctx.piStartRef[j];

@splatch
Copy link

splatch commented Aug 2, 2022

Modbus spec in early days was not clear on that hence -1 and +1 errors are happening. Its all about how end device index registers - if it does it from 0 or from 1, then its matter of client if he assumes any offsets. Its a feature of a protocol.
Switching it might help you with that device but break dozen of others.

@syadnom
Copy link

syadnom commented May 26, 2023

splatch, thank you sir. I didn't come here for that specific question but I couldn't get any data out of a mikrotik knot modbus tcp bridge to a mean well DRS-480-24 unit. I didn't know the +/- 1 issue existed.

For anyone else that ends up searching and finding this, do hex to decimal and add 1 for the register address.

(modbus mikrotik knot meanwell mean well DRS)

@the78mole
Copy link

I also see the -1 offset. If you enable debugging output (option -v), you can see, that it requests a different register address than the user requests on the command line. I think that is more confusing than it helps.

image

@git-developer
Copy link
Contributor

I believe this behavior is defined by the Modbus specification (didn't look it up, though). mbpoll has command line argument -0 to shift the reference adresses from 1-based to 0-based.

@cowo78
Copy link

cowo78 commented Nov 15, 2024

IMHO it's worth making this situation clearer in the help message: -r is the OFFSET from register 1 (or register 0 if -0 is specified)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants