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

queston about eMBFuncReadInputRegister #16

Open
glct12fsl opened this issue Dec 9, 2019 · 2 comments
Open

queston about eMBFuncReadInputRegister #16

glct12fsl opened this issue Dec 9, 2019 · 2 comments

Comments

@glct12fsl
Copy link

at line 71 of mbfuncinput.c there is an increment of usRegAddress variable
before calling at line 96 the function eMBRegInputCB().
i think, the function eMBRegInputCB() will read the next register address of the desired.

George

@yannickasselin
Copy link

I noticed the same thing. Every read/write functions have this increment of usRegAddress. So when testing modbus TCP using Codesys I always end up reading/writing the wrong registers (Offset by 1 more than desired). I know some modbus device registers start at 1 others starts at 0. This may be the reason why but I don't quite understand. Can anybody give an explanation?

@karlp
Copy link

karlp commented May 5, 2020

freemodbus does this +1 to just hard code all values to be "register numbers" ie, 1 based. If you want to work with "register addresses" ie, 0 based, you must subtract one in the beginning of your user callbacks. Should this be configurable? Maybe. Would it perhaps have been simpler to not do the +1? Maybe, but that's how it is.

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

3 participants