-
Notifications
You must be signed in to change notification settings - Fork 3k
Complete mbed_retarget FileHandle rework #5571
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
036507d
to
c14e8ce
Compare
FYI @tommikas |
c14e8ce
to
e48b359
Compare
68d1231
to
1a4f881
Compare
+2. Overriding standard output is a recurring theme, recently there have been at least two PRs related to it. This PR would ease the effort on customer and remove need for patching Mbed OS locally. |
@sg- You may wish to take a look at this... |
I'm interested in Is there a target mbed OS version # for having this completed and merged? |
Sorry I haven't been able to give this a good review yet. From a high-level it looks good though! One big request: Would it be possible to add tests that check if we're at least retargeting these functions correctly? (A dummy filesystem that sets a flag might be the easiest method). This would also catch conflicting function definitions with the toolchains. Making sure the retargeting stuff actually works on all of the toolchains is a big hole that may become a problem. |
bd0c523
to
ccae00f
Compare
Rework so that everything is a FileHandle, including stdin/stdout/stderr. Provide legacy functionality of calling serial_getc and serial_putc as an internal "DirectSerial" FileHandle. Add a JSON option to use UARTSerial instead. Add hooks for target and application to provide custom FileHandles. Allow for CRLF conversion to work on any FileHandle that isatty(), as stdin/stdout or any other FILE. Optimise the conversion so it doesn't force all write calls to be 1 byte. Limit the conversion to the stdio layer, so that read() and write() work the same as the FileHandle methods - this seems less confusing.
/morph build |
Build : SUCCESSBuild number : 1069 Triggering tests/morph test |
Test : SUCCESSBuild number : 877 |
/morph uvisor-test |
Exporter Build : SUCCESSBuild number : 747 |
/morph uvisor-test |
Locally tested this PR with #5895, green for all compilers (used k64f target) |
tests were integrated, restarting CI /morph build |
Build : SUCCESSBuild number : 1081 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 758 |
Test : SUCCESSBuild number : 888 |
To complete the move to POSIX-ness and FileHandle-ness, close the loop by reworking mbed_retarget.cpp so that everything is a
FileHandle
.This adds:
open
/close
/read
/write
/lseek
/isatty
/fsync
/fstat
/fdopen
/poll
.stdin
/stdout
usingUARTSerial
with a simple JSON change.FileHandle
by overriding weak functions..isatty()
stream, not just stdin/stdout/stderr.