-
Notifications
You must be signed in to change notification settings - Fork 3k
Cellular: Improve ATHandler AT debug traces #10121
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
Conversation
@kivaisan, thank you for your changes. |
@kivaisan , please fix the a-style issues |
a-style issues are now fixed. |
@@ -1225,30 +1222,41 @@ void ATHandler::flush() | |||
} | |||
} | |||
|
|||
void ATHandler::debug_print(const char *p, int len) | |||
void ATHandler::debug_print(const char *p, int len, ATType type) |
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 really don't like that we have this precedent of internal/external APIs, and which are alright to change in a patch, but so it goes.
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.
Especially since this a debug function.
if (isprint(c)) { | ||
*pbuf++ = c; | ||
} else if (c == '\r') { | ||
sprintf(pbuf, "<cr>"); |
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.
Thanks for the commit message. Made it really easy to tell why \r
and \n
were changed.
Anyone else want to review the PR? @mbed-os-wan @AriParkkila @mirelachirica @jarvte |
This fixes the problems mentioned in the description but it seems to be quite verbose, which is likely to cause timing issues. For example, instead of
AT debug prints are very useful when running Mbed OS Greentea TESTS. It seems that |
#endif | ||
char c; | ||
const int buf_size = len * 4; // x4 -> reserve space for extra characters | ||
char *buffer = (char *)malloc(buf_size); |
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.
Check for NULL or use nothrow.
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.
Fixed
mbed_cellular_trace::mutex_wait(); | ||
#endif | ||
char c; | ||
const int buf_size = len * 4; // x4 -> reserve space for extra characters |
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.
len * 4 + 1
where +1 for sprintf zero termination.
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.
Fixed
@AriParkkila timing issue is true but that is really problematic in our current mbed-os tracing system which uses UART on traces. On the other hand those time traces are really useful in some debugging cases so that's why I'd like to use it. And we get extra overhead especially for RX traces as modems tend to send responses in multiple pieces and there is nothing we can do for it. TX we could maybe improve in future to construct full command before sending. Also |
For what it's worth, I pulled in these changes and was able to diagnose cell module communication issues much easier. This PR is a great idea. |
CI started |
Test run: FAILEDSummary: 1 of 13 test jobs failed Failed test jobs:
|
Restarted jenkins-ci/greentea-test |
@AriParkkila are you happy with the changes on this PR after review ? |
@kivaisan do you have any idea how to avoid timing issues. I tried this with some real world applications and they tend to fail when this new logging is enabled - That's likely because debug prints take so much time that data from a modem is lost. @SeppoTakalo do you think we could enable |
One workaround is to increase baud rate on boards which support bigger baud rates for UART. This (PDMC) seems to work on WISE-1570 with 230400 baud rate, but as long as we use UART, these all are workarounds and we cannot guarantee any trace print is not causing timing issues. |
Enabling mbed-trace would require code changes and test cases are not using mbed-trace. |
} | ||
|
||
delete buffer; |
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.
You get the buffer from malloc()
and free it by calling delete
. This is a bit inconstant.
Use malloc()/free()
pair or new/delete
pair.
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.
Good catch. Fixed.
Original AT traces had several issue: - Can be overwritten by other traces (printf/mbed-trace) - No way to know which direction message was going (TX or RX) - <cr> and <ln> characters were not visible in trace etc. This commit addresses those issues using mbed-trace and showing separately each filehandle write and read.
CI started @AriParkkila Please leave the review feedback |
Test run: FAILEDSummary: 1 of 13 test jobs failed Failed test jobs:
|
CI was restarted, all green |
Description
Original AT debug traces had several issues:
etc.
This commit addresses those issues using mbed-trace and showing separately
each filehandle write and read.
Pull request type
Reviewers
@AriParkkila @mirelachirica @jarvte
Release Notes