Which USART ports are connected to which TELEM ports

Introduction

I think in general the serial port configuration in PX4 is quite confusing. According to this documentation: Serial Port Configuration | PX4 User Guide (main), we can select which serial ports to use for MAVLink telemetry, GPS, OSD, etc. by their conceptual “TELEM x” (x being 1, 2, 3, or 4) ports.

Confusion

However, as you can check in the parameter reference, we can also select “GPS x” (x = 1, 2, or 3), or even Radio Controller, Wifi Port, and EXT2.

image

I can understand that “TELEM x” and “GPS x” ports are quite intuitive, at least on Pixhawk boards where the corresponding ports are correctly marked.

However, regarding the “Radio Controller”, “Wifi port”, and “EXT2”, they definitely are confusing (e.g. I am guessing Radio Controller corresponds to the “RC/SBUS” on Pixhawk boards?).

Also, the exact matching between the “TELEM x” (PX4) and the actual “USART x” (STM32, for example) is quite vague, as the only common connection between those concept is the “/dev/ttySx” naming (NuttX convention):

And, the “/dev/ttySx” seems to be ordered automatically in the NuttX code:

And this is actually all documented here: Serial Port Mapping | PX4 User Guide (main)

Question

So well, I was in general just very confused about how the whole UARTx, TELEM x, MAV_x_CONFIG concepts are all related, but it seems like I have answered my question myself.

To summarize:

  1. USART index for each “/dev/ttyS{x}” equals to the "x+1"th USART configured to use in nuttx-config/nsh/defconfig file
  2. Each “/dev/ttyS{x}” is connected to certain conceptual functions (e.g. TELEM port, GPS port) in the default.px4board file
  3. When you select the TELEM / GPS / RC ‘port’ for the MAV_x_CONFIG parameters, it is essentially directly mapping the corresponding USART port, that can be traced back via the point 1 above.

Other

Note, some ideas on hiding the confusing MAV_x_CONFIG parameters were raised in Configurable serial ports · Issue #6905 · mavlink/qgroundcontrol · GitHub.

Also, all the ‘serial port names’ seems to be determined via this script:

Confusion solved by myself, check the post above

The UART/USART mapping is a little more complicated - it is covered here: Serial Port Mapping | PX4 User Guide

A bit time consuming to work out, so we show the mapping in the FC docs under heading “Serial port mapping”, such as Holybro Pixhawk 5X | PX4 User Guide

Otherwise you’re right. What a physical UART is used for, such as GPS, MAVLink, RC, are defined in terms of abstract configuration parameters. So if you want to configure GPS_1 to be a particular UART, you use the GPS_1_CONFIG and assign it to that port. If you want to use the port for something else you’d use the abstract MAVLINK X config.

I’ll have a look at the docs and see if they need to be improved.

1 Like

PS I updated the docs to make all this a bit clearer, and better cross link them: IMprove MAVLink and serial config docs by hamishwillee · Pull Request #2663 · PX4/PX4-user_guide · GitHub

1 Like