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

wrong order of if statement? #56

Open
IgorYbema opened this issue Feb 22, 2023 · 2 comments
Open

wrong order of if statement? #56

IgorYbema opened this issue Feb 22, 2023 · 2 comments

Comments

@IgorYbema
Copy link

Should this be the other way around?

if(!readSingleReg(SOFAR_SLAVE_ID, SOFAR_REG_GRIDW, &rs))
p = ((rs.data[0] << 8) | rs.data[1]);
else
Serial.println("modbus error");

@cmcgerty
Copy link
Owner

Quite possibly. It certainly looks like p would only be set if readSingleReg fails. Do you have one connected with a serial console open? Does it constantly log “modbus error” when in battery save mode? I’ll take a look when I get a chance.

@IgorYbema
Copy link
Author

Not using batterysave but I just noticed it while modifying the code a bit to suit my own situation

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