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

Comparison instead of assignment. Issue in display_bafang.cpp #34

Open
ben5en opened this issue Nov 28, 2020 · 2 comments
Open

Comparison instead of assignment. Issue in display_bafang.cpp #34

ben5en opened this issue Nov 28, 2020 · 2 comments

Comments

@ben5en
Copy link

ben5en commented Nov 28, 2020

Hi all, I think there is a typo in display_bafang.cpp.
Sure it shouldn't be a comparison instead of an assignment. Line 115 in the else branch.
// Search for Start Code
if(BF_ctx->RxState == RXSTATE_STARTCODE) //waiting for start code
{
if(BF_ctx->SerialPort->available())
{
BF_ctx->LastRx = millis();
BF_ctx->RxBuff[0]=BF_ctx->SerialPort->read();
if(BF_ctx->RxBuff[0]==BF_CMD_STARTREQUEST) //valid request startcode detected
{
BF_ctx->RxCnt = 1;
BF_ctx->RxState = RXSTATE_REQUEST;
}
else if(BF_ctx->RxBuff[0]==BF_CMD_STARTINFO) //valid info startcode detected
{
BF_ctx->RxCnt = 1;
BF_ctx->RxState = RXSTATE_INFO;
}
else
{
BF_ctx->RxState == RXSTATE_WAITGAP;
}
}
}

@jenkie
Copy link
Owner

jenkie commented Nov 29, 2020

Yes you are right, does not make sense - have you checked if the bug has any effect in the current code (because the displays are working) and have you checked if it is still working with the assignment? We should correct it then.

@ben5en
Copy link
Author

ben5en commented Nov 29, 2020

I believe the path is only called in one exception. So there has been hardly any feedback so far. I only noticed it through a compiler warning. The code is currently being executed with the changed assignment and a SW102 reacts as desired. No matter how, a comparison makes no sense at this point, so it should be changed.

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