QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PX4SerialPortConfig Namespace Reference

Classes

struct  Port
struct  Function
struct  ParamWrite

Functions

bool isFunctionParam (const QVariantList &enumValues)
 true: the enum values are a PX4 serial port selection, which makes the parameter a port function
QString baudParamName (int portId)
 Baud rate parameter for a port, empty if the port has none (Ethernet, unknown ports).
QString functionLabel (const QString &paramName, const QString &shortDescription)
 Display label from a PX4 "Serial Configuration for <label>" short description.
Function makeFunction (const QString &paramName, const QString &shortDescription, const QVariantList &enumValues, const QStringList &enumStrings, int value)
 value is the function parameter's value. currentPortId is defaultPortId when it is Disabled.
QList< Port > ports (const QList< Function > &functions)
 Every port any function can run on, in port id order.
QStringList functionsOnPort (const QList< Function > &functions, int portId)
QList< Function > functionsForPort (const QList< Function > &functions, int portId)
QList< ParamWrite > assignPort (const QList< Function > &functions, int portId, const QString &functionParamName)
QList< ParamWrite > removeFromPort (const QList< Function > &functions, int portId, const QString &functionParamName)
 Writes which take functionParamName off portId. Empty if it isn't on the port, or the port is its default port.
bool isSharedPort (int portId)
QStringList optionParamNames (const QString &functionParamName, int portId)
 Extra settings shown for a function when it runs on portId.

Variables

constexpr int kDisabledPortId = 0
constexpr int kEthernetPortId = 1000

Detailed Description

PX4 assigns serial ports per function: each function has a parameter (MAV_0_CONFIG, GPS_1_CONFIG, ...) whose value is the port it runs on. These helpers invert that into a per-port view, working only from parameter metadata and values so they can be tested without a vehicle.

Function Documentation

◆ assignPort()

QList< ParamWrite > PX4SerialPortConfig::assignPort ( const QList< Function > & functions,
int portId,
const QString & functionParamName )

Writes which put functionParamName on portId. On a port which isn't shared it becomes the only function there, and an empty functionParamName clears the port. A function is never cleared from its default port, since Disabled would leave it running there. Empty if nothing changes or the function can't run on the port.

Definition at line 183 of file PX4SerialPortConfig.cc.

References isSharedPort(), and kDisabledPortId.

Referenced by PX4SerialPortsController::setPortFunction(), and PX4SerialPortsController::setPortFunctionEnabled().

◆ baudParamName()

QString PX4SerialPortConfig::baudParamName ( int portId)

Baud rate parameter for a port, empty if the port has none (Ethernet, unknown ports).

Definition at line 89 of file PX4SerialPortConfig.cc.

◆ functionLabel()

QString PX4SerialPortConfig::functionLabel ( const QString & paramName,
const QString & shortDescription )

Display label from a PX4 "Serial Configuration for <label>" short description.

Definition at line 95 of file PX4SerialPortConfig.cc.

Referenced by makeFunction().

◆ functionsForPort()

QList< Function > PX4SerialPortConfig::functionsForPort ( const QList< Function > & functions,
int portId )

The functions allowed on a port, with the port's usual functions (GPS on a GPS port, MAVLink on a TELEM port, ...) first. Order is otherwise kept.

Definition at line 163 of file PX4SerialPortConfig.cc.

Referenced by PX4SerialPortsController::PX4SerialPortsController().

◆ functionsOnPort()

QStringList PX4SerialPortConfig::functionsOnPort ( const QList< Function > & functions,
int portId )

Parameter names of the functions assigned to a port. More than one on a port which isn't shared is a conflict: PX4 starts only one of them.

Definition at line 147 of file PX4SerialPortConfig.cc.

References kDisabledPortId.

◆ isFunctionParam()

bool PX4SerialPortConfig::isFunctionParam ( const QVariantList & enumValues)

true: the enum values are a PX4 serial port selection, which makes the parameter a port function

Definition at line 65 of file PX4SerialPortConfig.cc.

References kDisabledPortId, and kEthernetPortId.

Referenced by PX4SerialPortsComponent::functionFacts().

◆ isSharedPort()

bool PX4SerialPortConfig::isSharedPort ( int portId)

true: several functions can run on the port at once. Only Ethernet: PX4 stops a second function from opening a serial port, but network functions each use their own UDP port.

Definition at line 220 of file PX4SerialPortConfig.cc.

References kEthernetPortId.

Referenced by assignPort().

◆ makeFunction()

Function PX4SerialPortConfig::makeFunction ( const QString & paramName,
const QString & shortDescription,
const QVariantList & enumValues,
const QStringList & enumStrings,
int value )

value is the function parameter's value. currentPortId is defaultPortId when it is Disabled.

Definition at line 105 of file PX4SerialPortConfig.cc.

References PX4SerialPortConfig::Function::currentPortId, PX4SerialPortConfig::Function::defaultPortId, functionLabel(), kDisabledPortId, and PX4SerialPortConfig::Function::ports.

Referenced by PX4SerialPortsComponent::summaryItems().

◆ optionParamNames()

QStringList PX4SerialPortConfig::optionParamNames ( const QString & functionParamName,
int portId )

Extra settings shown for a function when it runs on portId.

Definition at line 225 of file PX4SerialPortConfig.cc.

References kDisabledPortId, and kEthernetPortId.

◆ ports()

QList< Port > PX4SerialPortConfig::ports ( const QList< Function > & functions)

Every port any function can run on, in port id order.

Definition at line 129 of file PX4SerialPortConfig.cc.

Referenced by PX4SerialPortsController::PX4SerialPortsController(), and PX4SerialPortsComponent::summaryItems().

◆ removeFromPort()

QList< ParamWrite > PX4SerialPortConfig::removeFromPort ( const QList< Function > & functions,
int portId,
const QString & functionParamName )

Writes which take functionParamName off portId. Empty if it isn't on the port, or the port is its default port.

Definition at line 210 of file PX4SerialPortConfig.cc.

References PX4SerialPortConfig::Function::currentPortId, PX4SerialPortConfig::Function::defaultPortId, and kDisabledPortId.

Referenced by PX4SerialPortsController::setPortFunctionEnabled().

Variable Documentation

◆ kDisabledPortId

int PX4SerialPortConfig::kDisabledPortId = 0
inlineconstexpr

◆ kEthernetPortId

int PX4SerialPortConfig::kEthernetPortId = 1000
inlineconstexpr

Definition at line 14 of file PX4SerialPortConfig.h.

Referenced by isFunctionParam(), isSharedPort(), and optionParamNames().