-
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
Fix issues in setting radio access technology #12020
Conversation
Thanks to @marcuschangarm for spotting and identifying most of the issues addressed in this PR. |
@linlingao, thank you for your changes. |
@@ -48,7 +48,7 @@ class FileHandle; | |||
extern const char *OK; | |||
extern const char *CRLF; | |||
|
|||
#define BUFF_SIZE 32 | |||
#define BUFF_SIZE 128 |
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.
Any specific reason for this?
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.
Some AT commands such as AT+CGDCONT have longer than 32-character responses. When AT debug is turned on, you'll see AT ERR instead of AT RX. See the trace below:
Increasing the buffer to 128 eliminates these errors and makes debug easier. I feel like it's a good tradeoff to show most commonly used AT commands with minimal RAM usage increase.
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.
Could you check if you have made any changes in ATHandler
? The ERR print should be from fill_buffer
, but it prints first "AT overflow" which is missing in the log above.
BUFF_SIZE
is actually needed to read just the prefix, that's +CGDCONT:
in the log above, so it should be large enough to hold the longest prefix and 32 should be enough here.
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.
I didn't make other changes. With the increased BUFF_SIZE, the AT ERR goes away.
BUFF_SIZE is used in ATHandler::read_int()
int32_t ATHandler::read_int()
{
if (!ok_to_proceed() || !_stop_tag || _stop_tag->found) {
return -1;
}
char buff[BUFF_SIZE];
if (read_string(buff, sizeof(buff)) == 0) {
return -1;
}
which is called by ATHandler::at_cmd_int() while reading response.
resp = read_int();
resp_stop();
return unlock_return_error();
The code above indicates BUFF_SIZE is also used in reading response.
If you look at AT_CellularContext::get_context(), _at.read_int() is called in response to AT+CGDCONT?. This explains why the increase of BUFF_SIZE eliminates AT ERR.
I do see BUFF_SIZE is used for prefix as well as you said.
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.
@linlingao Can you share the code how you are reading the CGDCONT
response, that might be missing something like while (_at.info_resp())
?
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.
@linlingao The reason I want clean logs just with the codes from master to see if the modem response is missing <cr><ln>
, which would explain buffer overflows. Those can be seen in your log but not in the log above.
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.
Are you convinced this fix is good? Is there anything else you'd like me to investigate pertaining to this fix?
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.
@linlingao I'd still like to understand the root cause, otherwise it's possible that increasing BUFF_SIZE
does not fix the problem but it just hides the ERR prints.
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.
@AriParkkila Would you like me to revert this change (other than the errors seen in the trace, there doesn't seem to be significant issues) while you continue to investigate? I'd like to get the other more important fixes in.
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.
@linlingao That sounds good since BUFF_SIZE
is not directly related to this PR. If you can repeat the BUFF_SIZE
problem and get the AT logs at DEBUG level with master codes (without any changes) we should be able to reproduce the problem to study it further.
} else { | ||
return _at.at_cmd_discard("+COPS", "=1,2", "%s", plmn); | ||
return _at.at_cmd_discard("+COPS", "=4,2,", "%s", plmn); |
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 changes network selection to be first manual and then automatic (mode=4). Do you have some specific reason for this change? Currently, if PLMN is defined only that PLMN is allowed for to avoid any unexpected costs, e.g. due to roaming.
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.
The purpose of having the auto fallback is to increase the chance of connecting to a network. I also noticed this is the setting used in AT command tester from M2Msupport. I wasn't aware that roaming cost was a factor. I can change it back to 1 if you think cost outweighs connectivity.
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.
Do you think COPS mode could be a configuration option in mbed_lib.json?
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.
Not all modems support COPS mode 4, so that should also be defined for each modem as CellularProperty.
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.
I can add a config in mbed_lib.json to COPS mode. There're only two modes to select from:manual and manual then automatic. Do you have preference on the name of the config?
Yes, I can add COPS mode 4 to CellularProperty. Let me know if you have preference on the name of the enum.
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.
I added a config in mbed_lib.json for choosing either manual or manual then automatic.
WRT adding a property in CellularProperty, I checked all the modems supported in our stack except RiotMicro RM1000 (I can't find their AT commands online), they all support mode 4. Do you still want me to add a property?
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.
BC95 supports just COPS =0, =1 and =2. That may have changed in some of the latest release?
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.
Most likely. According to their spec, 4 is supported.
https://www.quectel.com/UploadImage/Downlad/Quectel_BC95_AT_Commands_Manual_V1.9.pdf
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.
However, there is still a note that Only =0, =1 and =2 are supported. on the page 33.
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.
I missed the note. They shouldn't have listed 3 and 4 in parameters if they're not supported. Good catch.
@linlingao please address the comments, also a rebase will be needed by the looks of it. |
I have incorporated review comments and rebased. |
Needs another rebase, I'm afraid. @AriParkkila, can you review changes? |
@linlingao Can you remove |
… reliability. Fix a syntax error when RAT is set
…manual operator selection
Incorporated new comments and rebased again. |
CI started |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
CI restarted |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
@linlingao we missed this at the time, but is this adding an internal only implementation or is this new API exposed to the user ? In which case it should be a feature updated not a patch.... |
It added a new config value to targets config. Please @linlingao confirm. |
@linlingao yes but does this change anything in the way the user needs to configure things? |
@adbridge This PR doesn't "change" anything in the way the user configures RAT. I added "plmn-fallback-auto" in json to allow the user to fine tune RAT. Prior to this PR, when manual is selected via json, network search would be limited to the specified network only. If the user wishes to limit to the specified network but this network doesn't work, now the user has a way to fall back to automatic selection. Do we consider addition to JSON an API change or new API? If so, we can mark this "feature update". This PR also fixes a bug, should I mark both "feature update" and "patch update"? |
@linlingao For future reference it isn't good practice to add bug fixes and additional changes in the same PR. Anything that changes the user experience or means they need or can do anything different to what they did before is not just a 'bug fix' (unless the change is a direct result of something that was known to be wrong already according to technical spec or the documentation). Even changes to JSON files could be considered as a functionality change (in some instances). In this case you are adding additional configuration which can be used so I would suggest this counts as functionality change - so PR type should be changed accordingly. I don't think any additional documentation is required though. Impact of changes and migration is only mandatory for major changes. |
Summary of changes
Fix a missing comma when radio access technology is specified. This missing comma causes modem to return syntax error.
Add implementation for setting radio access technology for Telit ME910. Without this, RAT is set back to UNKNOWN.
Add configuration in JSON to allow PLMN fallback to auto if manual selection fails.
Impact of changes
Migration actions required
Documentation
None
Pull request type
Test results
Reviewers