How to achive Holybro 6X with Linnux PC Connection over Ethernet

I have been through PX4 Guide but it doesn’t help nor any of the forum discussion helped.

I am using Holybro 6X and have connected ETH to ethernet port (on my pc) directly.

I have done the setup which looks like this:
DEVICE=eth0
BOOTPROTO=static
NETMASK=255.255.255.0
IPADDR=192.168.0.4
ROUTER=192.168.0.1
DNS=192.168.0.1

The network file in pc looks like this:
network:
version: 2
renderer: NetworkManager
ethernets:
enp2s0:
addresses:
- 192.168.0.1/24
nameservers:
addresses: [192.168.0.1]
routes:
- to: 192.168.0.1
via: 192.168.0.1

I have changed the BOOTPROTO to fallback also and then tried but nothing happens. Neither I am able to ping nor I am able to connect to the port using MAVSDK code:
#!/usr/bin/env python3

import asyncio
from mavsdk import System

async def run():
drone=System()
print(1)
await drone.connect(system_address=‘udp://192/168/0/4:14540’)
print(2)
all_params=await drone.param.get_all_params()
for param in all_params.int_params:
print(f"{param.name}: {param.value}“)
for param in all_params.float_params:
print(f”{param.name}: {param.value}")

asyncio.run(run())

Parameter Setup looks like this:
MAV_2_BROADCAST = Always broadcast
MAV_2_Config = Ethernet
MAV_2_FLOW_CTRL = Auto-detected
MAV_2_FORWARD = Enabled
MAV_2_MODE = Onboard (Also tried the above config and code by setting this equal to Normal)
MAV_2_RADIO_CTL = Enabled (Tried with Disabled as well)
MAV_2_Rate = 100000 B/s
MAV_2_REMOTE_PRT = 14540
MAV_2_UDP_PRT = 14540
(Tried by setting the last two to 14550)

Inshort, most of the permutation/combination have been tried but still no clue on connection establishment

What could be the possible issue? How can I solve it?

To avoid some confusion with the UDP ports, let’s use different ports for the Pixhawk local port and the “remote” port on the computer that you’re connecting to.

E.g.

MAV_2_REMOTE_PRT = 14540
MAV_2_UDP_PRT = 14541

This means UDP packets would be sent from 14541 to everywhere (broadcast) on port 14540.

This then means you can listen anywhere on that port 14540 for packets arriving, so the argument in MAVSDK would be:

udp://:14540

Note that if you set the IP like this:

udp://192.168.0.4:14541

MAVSDK would be sending UDP packets to the Pixhawk to port 14541 instead. This would be used without broadcast.

If you use broadcast, you don’t have to know the IP because you basically try all in the subnet.

1 Like

I tried this solution, by setting the MAV_2_REMOTE_PRT = 14540 and MAV_2_UDP_PRT=14541

Then in the script, the code I use is:
await drone.connect(system_address=‘udp://:14540’)
After this I tried with:
await drone.connect(system_address=‘udp://:14541’)
As I didn’t get any result for this, I had setup the connection like:
await drone.connect(system_address=‘udp://:14541’)
and await drone.connect(system_address=‘udp://192.168.0.4:14541’)
but nothing happened but I would like to know what did you mean by “This would be used without broadcast.” Should I set the MAV_2_BROADCAST to NEVER BROADCAST or Ony Multicast?

I have connected to the Holybro by setting MAV_2_REMOTE_PRT = 14541 and MAV_2_UDP_PRT = 14541 but when I do either one of them as 14540 and 14541 or 14540 it doesn’t work, naybe I am missing some knowledge on how to do those settings or the 14540 port is preoccupied. Thank you for the help @JulianOes

Another error or bug encountered can’t comment what actually it is but after running a few test scripts and then I ran some other of my scripts, I am unable to get first heartbeat. It waits for the connection. Neither it is getting connected to my other codes. One of my code is:

from pymavlink import mavutil

connection=mavutil.mavlink_connection(‘udpin:192.168.0.2:14541’)

connection.wait_heartbeat()
print(“Heartbeat from Ststem (system %u component %u)” % (connection.target_system, connection.target_component))

message = connection.mav.command_long_encode(connection.target_system, connection.target_component, mavutil.mavlink.MAV_CMD_SET_MESSAGE_INTERVAL, 0, mavutil.mavlink.MAVLINK_MSG_ID_BATTERY_STATUS, 1000000, 0,0,0,0,0)

response = connection.recv_match(type=‘COMMAND_ACK’, blocking=True)
if response and response.command == mavutil.mavlink.MAV_CMD_SET_MESSAGE_INTERVAL and response.result == mavutil.mavlink.MAV_RESULT_ACCEPTED:
print(“Command Accepted”)

So the code is stuck to get the first heartbeat message.

You seem to be wildly testing things. I would suggest to go back to a sane configuration that you understand (and that I suggested) and then check using Wireshark what is going on.

@JulianOes thank you, I will again try out your suggestion.

Finally I accomplished it. @JulianOes thank you so much for the help! After firmware reset, below parameters were set.

MAV_2_BROADCAST = Always broadcast
MAV_2_Config = Ethernet
MAV_2_FLOW_CTRL = Auto-detected
MAV_2_FORWARD = Enabled
MAV_2_MODE = Normal
MAV_2_RADIO_CTL = Disabled
MAV_2_Rate = 100000 B/s
MAV_2_REMOTE_PRT = 14541
MAV_2_UDP_PRT = 14541

1 Like

Some stuff are here as well in case interested:

1 Like