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.checkRegisterValue wrong cast? #48

Open
civic9 opened this issue Mar 1, 2020 · 1 comment
Open

Modbus.checkRegisterValue wrong cast? #48

civic9 opened this issue Mar 1, 2020 · 1 comment

Comments

@civic9
Copy link

civic9 commented Mar 1, 2020

return checkRange((short)value, 0, Modbus.MAX_REGISTER_VALUE);

Why value is casted to short?
Short is signed in java, and with such castings this method returns false for values above 32767.
Is there any reason? I am not sure if I can fix this by removing that cast.

@djlabbe
Copy link

djlabbe commented May 8, 2020

It looks like this was put in to fix a different reported bug where someone was trying to use this method for values between Short.MIN and Short.MAX instead of 0 to Modbus.MAX_REGISTER_VALUE. It definitely doesn't work to cast to short, and then check range between 0 and 65535.

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

2 participants