-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
New platform independent UART interface #21723
Conversation
Its seems that on all non-Qurt targets the flash usage roughly increases by 2KB @dagar you might want to update bloaty on the CI since on many boards it gets an integer overflow. PX4 pretty much assumes it's using POSIX based UART and uses termios to change settings. |
Thanks @PetervdPerk-NXP, I'm going to update the containers to 22.04 + latest tools soon.
That was one idea I proposed initially, but after some discussion with @katzfey and my own pain with subtle differences in POSIX between NuttX/Linux/MacOS I actually thought this could be a nice opportunity to simplify/optimize the vast majority of our serial usage with an API that's easier to use, harder to misuse.
The immediate goal in this PR was to get to an acceptable MVP to unblock QuRT progress and leave room to continue some of the other ideas in the future. Happy to discuss further before we fully commit to anything. |
0d2e6c7
to
1b92db9
Compare
I just come up with some other functionality requirements related to UART:
Just gave up reading the mavlink module for its size XD Not sure what requirement is needed for those complex, software throttling enabled modules. The temporary increased code size will be reduced once drivers switching to new API for sure... Just noticed so many redundant occurrences... |
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.
@dagar is it necessary to split the driver into the common and nuttx (and POSIX?) layer or can it all be lumped at the px4 common layer? Serial.cpp needs to be linked with SerialImp.cpp to resolve linking errors it seems.
@SalimTerryLi The idea with this PR is to get started with GPS only. So the new API has enough functionality for only what GPS needs and GPS is updated to use the new API. This is actually a pretty standard configuration so it should be usable by most other drivers. But as more drivers get updated to use the new API any missing additional functionality or settings that they need will need to be added to the Serial driver at that time. This will especially be true for the RC drivers as they have a bunch of oddball requirements. |
|
||
int ret = poll(fds, sizeof(fds) / sizeof(fds[0]), remaining_time); | ||
|
||
if (ret > 0) { |
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.
Once even a single byte is available (but < character_count) isn't this just going to spin constantly?
Was there a problem with the sleep that was here originally?
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.
Oh, I didn't mean to change anything. Let me take a look.
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 put them back in
Oh this went in? |
@PetervdPerk-NXP Yes, those will be coming in as well. The idea was to add enough functionality for the drivers being ported over. Initially this is just GPS where those other features are not used. But today I am working on PR 22917 which requires flush, Tx / Rx swap, and single wire. So those will be added in that PR. Next on the list is UART distance sensor and RC Library which should bring in all the rest of the needed UART functions. |
This unfortunately breaks Septentrino GPS with the warnings:
|
Fix in #22936. |
Solved Problem
There are multiple copies of UART configuration and use code that are not platform independent. The Qurt platform, in particular, is quite different in terms of UART usage. This is a proposal for a new platform independent UART API that hides all of the implementation details in platform specific files and provides a generic API for all platforms. The GPS, RC, and UART based ESC drivers will important beneficiaries of this new API.