-
Notifications
You must be signed in to change notification settings - Fork 3k
Tests: USBSerial: Handle minimal printf limitations #12805
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
Tests: USBSerial: Handle minimal printf limitations #12805
Conversation
@fkjagodzinski, thank you for your changes. |
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 think we should have the same test for minimal-printf and standard C printf and change the test assertion TEST_ASSERT_EQUAL_INT(LINE_CODING_STRLEN, rc);
You could test that rc is between a minimal value and LINE_CODING_STRLEN.
44ce551
to
616405c
Compare
I can see I forgot to mention the reasoning behind the fixed-size USBSerial payloads. Sorry about that. Commit message and code comment already updated. Actually, it is the host side that requires fixed-size payloads. Please see mbed-os/TESTS/host_tests/usb_device_serial.py Lines 272 to 281 in f0d04c8
Thanks for the review @evedon. |
Actually, I can see we could use https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.read_until on the host side. |
It would be better to change the host side not to expect fixed-size USBSerial payloads. |
In a line coding test, host changes the line coding based on data received from DUT via the USBSerial::printf(). A fixed-size payload, equal to LINE_CODING_STRLEN, is required by the host side. When the minimal printf is used, fixed-width messages can not be easily generated on the fly. Zero-fill or width specifiers are not supported by the minimal printf. Update the host side to stop reading on a defined payload delimiter and allow variable-width messages.
616405c
to
9066e67
Compare
@evedon I updated the patch as discussed. |
@rajkan01 could you also review, please? |
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.
Minor comment but code change looks good.
Thanks!
#define USB_RECONNECT_DELAY_MS 1 | ||
|
||
#define LINE_CODING_STRLEN 13 // 6 + 2 + 1 + 1 + 3 * comma | ||
#define LINE_CODING_SEP (',') |
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 not needed in this file
Test run: SUCCESSSummary: 4 of 4 test jobs passed |
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.
LGTM
Will be merged as soon as we have 6.0.0 beta1 released |
Summary of changes
In a line coding test, host changes the line coding based on data received from DUT via the
USBSerial::printf()
. A fixed-size payload, equal toLINE_CODING_STRLEN
, is required by the host side. When the minimal printf is used, fixed-width messages can not be easily generated on the fly. Zero-fill or width specifiers are not supported by the minimal printf.Update the host side to stop reading on a defined payload delimiter and allow variable-width messages.
For more details, please see a related issue #12718.
Impact of changes
Migration actions required
Documentation
None
Pull request type
Test results
Reviewers
@jamesbeyond, @evedon, @maciejbocianski