diff --git a/docs/en/advanced_config/ethernet_setup.md b/docs/en/advanced_config/ethernet_setup.md index 6b307382abb..b8353138e17 100644 --- a/docs/en/advanced_config/ethernet_setup.md +++ b/docs/en/advanced_config/ethernet_setup.md @@ -164,15 +164,16 @@ You must separately configure the PX4 IP address and other _network settings_ ([ PX4 configures the serial port to connect to a GCS via MAVLink, using the parameters shown below: -| Parameter | Value | Description | -| ------------------------------------------------------------------------------ | ------ | ------------------------------------------------------------ | -| [MAV_2_CONFIG](../advanced_config/parameter_reference.md#MAV_2_CONFIG) | 1000 | Configure Ethernet port | -| [MAV_2_BROADCAST](../advanced_config/parameter_reference.md#MAV_2_BROADCAST) | 1 | Broadcast `HEARTBEAT` messages | -| [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) | 0 | Send the "normal" set of MAVLink messages (i.e. the GCS set) | -| [MAV_2_RADIO_CTL](../advanced_config/parameter_reference.md#MAV_2_RADIO_CTL) | 0 | Disable software throttling of MAVLink traffic | -| [MAV_2_RATE](../advanced_config/parameter_reference.md#MAV_2_RATE) | 100000 | Maximum sending rate | -| [MAV_2_REMOTE_PRT](../advanced_config/parameter_reference.md#MAV_2_REMOTE_PRT) | 14550 | MAVLink Remote Port of 14550 (GCS) | -| [MAV_2_UDP_PRT](../advanced_config/parameter_reference.md#MAV_2_UDP_PRT) | 14550 | MAVLink Network Port of 14550 (GCS) | +| Parameter | Value | Description | +| --------------------------------------------------------------------------------------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------- | +| [MAV_2_CONFIG](../advanced_config/parameter_reference.md#MAV_2_CONFIG) | 1000 | Configure Ethernet port | +| [MAV_2_BROADCAST](../advanced_config/parameter_reference.md#MAV_2_BROADCAST) | 1 | Broadcast `HEARTBEAT` messages | +| [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) | 0 | Send the "normal" set of MAVLink messages (i.e. the GCS set) | +| [MAV_2_RADIO_CTL](../advanced_config/parameter_reference.md#MAV_2_RADIO_CTL) | 0 | Disable software throttling of MAVLink traffic | +| [MAV_2_RATE](../advanced_config/parameter_reference.md#MAV_2_RATE) | 100000 | Maximum sending rate | +| [MAV_2_REMOTE_IP](../advanced_config/parameter_reference.md#MAV_2_REMOTE_IP)
| 0 | Auto-discover the partner address from incoming packets (see [MAVLink Partner Address](#partner_address)) | +| [MAV_2_REMOTE_PRT](../advanced_config/parameter_reference.md#MAV_2_REMOTE_PRT) | 14550 | MAVLink Remote Port of 14550 (GCS) | +| [MAV_2_UDP_PRT](../advanced_config/parameter_reference.md#MAV_2_UDP_PRT) | 14550 | MAVLink Network Port of 14550 (GCS) | Normally a companion computer would use port `14540` (rather than `14550`) and stream the set of MAVLink messages specified in the `Onboard` profile. You can configure this setup by changing [MAV_2_REMOTE_PRT](../advanced_config/parameter_reference.md#MAV_2_REMOTE_PRT) and [MAV_2_UDP_PRT](../advanced_config/parameter_reference.md#MAV_2_UDP_PRT) to `14540` and [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) to `2` (Onboard). @@ -180,6 +181,24 @@ Note however that this will still work using the GCS profile. For more information on MAVLink serial port configuration see [MAVLink Peripherals (GCS/OSD/Companion)](../peripherals/mavlink_peripherals.md) +### MAVLink Partner Address {#partner_address} + +By default, PX4 learns its MAVLink partner's address and port from the first UDP packet it receives on [MAV_2_UDP_PRT](../advanced_config/parameter_reference.md#MAV_2_UDP_PRT), and sends replies there. +Until then, it broadcasts its MAVLink stream on the local network if [MAV_2_BROADCAST](../advanced_config/parameter_reference.md#MAV_2_BROADCAST) is `1` and [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) isn't `2` (Onboard). +This is why the GCS initiates the connection in the [QGroundControl example](#qgroundcontrol-setup-example). + +If PX4 needs to initiate the connection to a partner with a known, fixed address, such as a companion computer that never sends the first packet, set [MAV_2_REMOTE_IP](../advanced_config/parameter_reference.md#MAV_2_REMOTE_IP) to the partner's address. +The value is a 32-bit integer with the first octet in the most significant byte: for example, `192.168.1.2` is `-1062731518`. +PX4 then sends to that address at port [MAV_2_REMOTE_PRT](../advanced_config/parameter_reference.md#MAV_2_REMOTE_PRT), and auto-discovery is disabled. +Set it back to `0` (the default) to restore auto-discovery. +Changes take effect after a reboot. + +::: tip +The [startup script](../concept/system_startup.md) passes a non-zero value of this parameter to the `mavlink start` command's `-t` option (`-t p:MAV_2_REMOTE_IP`). +If you start a MAVLink instance manually from the [console](../debug/consoles.md), `-t` accepts either a literal address (`-t 192.168.1.2`) or a reference to the parameter (`-t p:MAV_2_REMOTE_IP`). +See the [mavlink module reference](../modules/modules_communication.md#mavlink_usage) for the full command usage. +::: + ## QGroundControl Setup Example Assuming you have already [Set up the Ethernet Network](#setting-up-the-ethernet-network) so your ground station computer and PX4 run on the same network, and diff --git a/docs/en/peripherals/mavlink_peripherals.md b/docs/en/peripherals/mavlink_peripherals.md index cfc4ba46ceb..4ad2b8d1f22 100644 --- a/docs/en/peripherals/mavlink_peripherals.md +++ b/docs/en/peripherals/mavlink_peripherals.md @@ -81,6 +81,7 @@ On this hardware, there is a [default serial port mapping](../peripherals/serial - [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) = `0` (normal/GCS) - [MAV_2_RADIO_CTL](../advanced_config/parameter_reference.md#MAV_2_RADIO_CTL) = `0` - [MAV_2_RATE](../advanced_config/parameter_reference.md#MAV_2_RATE) = `100000` +- [MAV_2_REMOTE_IP](../advanced_config/parameter_reference.md#MAV_2_REMOTE_IP) = `0` (auto-discover partner, see [MAVLink Partner Address](../advanced_config/ethernet_setup.md#partner_address)) - [MAV_2_REMOTE_PRT](../advanced_config/parameter_reference.md#MAV_2_REMOTE_PRT)= `14550` (GCS) - [MAV_2_UDP_PRT](../advanced_config/parameter_reference.md#MAV_2_UDP_PRT) = `14550` (GCS)