-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Configurable serial ports v2 #10337
Configurable serial ports v2 #10337
Conversation
Looking good from what I've seen so far. I'll give it a try later. To be honest I still think it would be easier and more scalable to have modules directly read their own configuration (parameters per instance), but it looks like you've found a good compromise. |
TEL1:/dev/ttyS1 | ||
TEL2:/dev/ttyS2) | ||
|
||
set(px4_constrained_flash_build 1) |
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.
We might want to look at cmake options for this kind of thing.
https://cmake.org/cmake/help/v3.0/command/option.html
@@ -473,8 +475,12 @@ add_custom_target(metadata_airframes | |||
USES_TERMINAL | |||
) | |||
|
|||
file(GLOB_RECURSE yaml_config_files ${PX4_SOURCE_DIR}/src/modules/*.yaml |
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.
It's worth getting rid of all cmake globbing to avoid possible surprises with incremental builds.
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.
Absolutely. This was just the quickest way to achieve it. Essentially I want to tell cmake 'give me all module configs for all possible modules'. And adding a new config with all modules does not seem right for that.
Just curious, but did you consider toml (vs json vs yaml)? |
Very cool! I need to quickly go with you through it, but it looks very scalable and per-airframe accurate now. |
Tools/serial/generate_config.py
Outdated
"index": 6, | ||
"default_baudrate": 57600, | ||
}, | ||
"URT3": { # for Omnibus |
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'll end up needing the full range of generic names (especially for the linux boards).
Yes briefly. It's a valid alternative, but it's just not as wide-spread used (yet), also in terms of tooling. And nested structures seem to be better supported in YAML. |
src/lib/parameters/CMakeLists.txt
Outdated
--xml ${parameters_xml} | ||
--inject-xml ${CMAKE_CURRENT_SOURCE_DIR}/parameters_injected.xml | ||
--overrides ${PARAM_DEFAULT_OVERRIDES} | ||
--board ${BOARD} | ||
#--verbose | ||
DEPENDS | ||
${param_src_files} | ||
${generated_params_dir}/serial_params.c |
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.
Use the same variable as the custom command OUTPUT - ${generated_serial_params_file}
Tools/serial/rc.serial.jinja
Outdated
|
||
# make sure all baudrates are marked as used | ||
param touch | ||
{%- for serial_device in serial_devices %} SER_{{ serial_device.tag }}_BAUD |
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 could be skipped so that it's only visible to the user when on an appropriate config.
For example frsky telem, iridum, syslink, etc shouldn't present a configurable baudrate.
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 a per-port setting, e.g. SER_TEL1_BAUD. It will make it a bit easier to use.
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.
Yes and they'll still be there if you have anything (Mavlink, GPS, etc) enabled on that port. In the cases where it's not used we can hide it, skip the sync, and close one more little hole where users are able to try doing something that doesn't make any sense. Since all of these parameters set via command line are reboot_required I don't really see the problem (set mavlink, reboot, serial mavlink baudrate param available).
This is a case where handling the param in the module itself could actually be a lot better as it would enable runtime changes.
…thon packages Required for PX4/PX4-Autopilot#10337
1b42c63
to
b8a7080
Compare
This is now in a working state, ready for review and CI tests. TestingI tested these boards:
Compatibility
Breaking Changes
Depends on PX4/PX4-containers#133 |
@bkueng There will probably result in quite a lot of docs updates. I'm thinking about
Lets talk them through when this gets accepted. Is TELEM2 disabled by default on everything or just FMUv2? |
…thon packages (#133) Required for PX4/PX4-Autopilot#10337
param set MAV_1_CONFIG 2 | ||
param set MAV_1_RATE 1000 | ||
param set MAV_1_MODE 3 | ||
param set SER_TEL2_BAUD 57600 |
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.
In my opinion this should be dropped. There's nothing about a TBS caipirinha that requires a specific telemetry 2 configuration. The airframe can easily be kept generic.
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.
Agreed, dropped.
Tools/serial/generate_config.py
Outdated
"index": 6, | ||
"default_baudrate": 0, | ||
}, | ||
"URT6": { # for Omnibus |
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.
There are boards that just have a range of generic uarts. Should we add them here now?
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'd add them as needed.
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.
It includes boards we already have in tree (navio2, av-x, nucleos, etc). If we add the full range initially we can keep the index simple and consistent.
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.
Ok feel free to add them and push to the branch.
b8a7080
to
a84fea5
Compare
…thon packages (#133) Required for PX4/PX4-Autopilot#10337
@hamishwillee yes all of these need to be updated. |
Completely agree - part of the problem with SYS_COMPANION was that it always had to be disabled or set in order to use the port. What I don't understand yet is how the user would enable it. I think from the discussion this would be done using per-module (?) parameter(s) appropriate to that port. I guess that is what your docs will answer :-) |
Yes there's a per-module param. For example for FrSky telemetry there's a parameter |
a84fea5
to
9467639
Compare
bf88a39
to
1d1d5ee
Compare
Replaced with the more general serial config params.
Replaced with the more generic serial config params. rc.mavlink contains automatic transition support that can be removed after the next release.
Can be reverted if needed later on...
This is because NuttX uses a different assignment for variables.
92b459c
to
69b098b
Compare
@@ -681,6 +682,11 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name, bool force_flow_ | |||
case 1500000: speed = B1500000; break; | |||
#endif | |||
|
|||
#ifdef B2000000 |
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.
Where is this missing?
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 not all Linux/Posix systems have it.
Looks good to me. Let's regroup after this settles in master and note what's still needed.
|
Thanks for the review @dagar. @PX4/testflights can you test this? You don't need to fly, just make sure all UARTs are working as expected on different boards: telemetry link, gps, serial sensors etc. |
I tested on pixhawk 4 and pixhawk 2.1 the two FC works properly. |
looks to be working on the pixracer |
Thanks @Avysuarez and @santiago3dr. Let's merge. |
Anything QGC needs to do here? |
@DonLakeFlyer short term getting the metadata to auto update would be a helpful improvement. #9615 (comment) It doesn't need to happen immediately, but I'd also like to get a QGC configure screen for the serial ports (per board metadata) that pulls together all the possible options for each port. We should probably discuss this on a call. |
@dagar Can you start QGC issue for the serial port page and a separate one for parameter meta data auto-update? |
Serial port configuration page - mavlink/qgroundcontrol#6905 |
Rebased and reworked version of #9615. Differences:
per-module vs. per-port config params
Personally I don't see strong arguments for either way, both have their drawbacks:
per-port (previous PR)
per-module (this PR)
In any case we have now both versions.
Module Config Files
Modules now need a config file to register a startup command, and configure the parameters. I decided to go for YAML, because:
Here's an example to register a serial command (see the mavlink config for an example of using multiple instances):
These config files can also be used for parameter definitions. MAVLink already uses them to generate multiple instances. These are then translated into the existing C-style parameter definitions. This allows us to transition all files step by step and eventually remove the translation layer.
In addition it allows us to do schema validation, to ensure that the configs will conform to the expectations. I added a script that uses cerberus (see commit 1b42c63). The schema is also a good place to document all possible options.
Once there's consensus, I'll continue here, there's still quite a bit left to do.