-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Cellular: Fix for AT handler consume to tag #8350
Conversation
@@ -926,16 +926,14 @@ bool ATHandler::consume_to_tag(const char *tag, bool consume_tag) | |||
int c = get_char(); | |||
if (c == -1) { | |||
break; | |||
} else if (c == tag[match_pos]) { | |||
} else if (c == tag[match_pos] || (match_pos = 1 && c == tag[--match_pos])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AnttiKauppila there is compile warning about the "match_pos = 1": operation on 'match_pos' may be undefined. Is that something we have to avoid?
The alternative way which I tried to avoid is an else branch that in case c == tag[0] would have to do same operations as in this branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding parenthesis around "match_pos = 1" cancels the warning. I updated and added explanatory comments also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still causing a warning when compiling with IAR. Could be that we are using version 8 of IAR. Anyway, you could also do the assignment directly which does solve the warning for IAR:
} else if (c == tag[match_pos] || c == tag[match_pos = 0]) {
8757902
to
59f3193
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix looks good but the commit msg could have details from Description
If sequence from buffer contains tag and a symbol before tag coincides with zero symbol of the tag, then the tag won't be detected. For example, if it consumes to a tag "\r\n" in a sequence "\r\r\nOK", the tag won't be found."
To answer question - how this fixes the tag
If sequence from buffer contains tag but symbol before tag is same as first symbol of the tag, then the tag wasn't detected. For example, "\r\n" tag was not found from "\r\r\nOK" sequence.
59f3193
to
31f153a
Compare
LGTM (cant approve as github is having issues), will start CI /morph build |
Build : SUCCESSBuild number : 3426 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 3049 |
Test : SUCCESSBuild number : 3218 |
Description
This PR addresses: #8308
"I'm trying to make a driver for a sim5320 using cellular framework, but ATHandler doesn't parse some responses correctly. After some investigation, I found that problem is caused by ATHandler::consume_to_tag method.
If sequence from buffer contains tag and a symbol before tag coincides with zero symbol of the tag, then the tag won't be detected. For example, if it consumes to a tag "\r\n" in a sequence "\r\r\nOK", the tag won't be found."
Pull request type