Pymavlink arm status not correct

Hi, currently Im trying to read the arm status from the autopilot. this does work, however the status reported is not always correct.

TLDR;
I think it has todo with my herelink airunit acting like a companion computer with its own mavlink IDs.
I tried to set the target_system to my drone, but pymavlink seems to ignore it. How do I set the source system and filter messages accordingly?

connection='/dev/ttyACM0'
master = pymavlink.mavutil.mavlink_connection(connection,baud=115200,dialect='common')                                            

master.wait_heartbeat()

while True:
    master.wait_heartbeat()
    print(master.motors_armed())

this code prints:

128
128
128
0
0
128
128
128
0
0
128
128
128
0
0
128
128
128
0
0

while the vehicle is constantly armed… I think it should constantly be 128. what can be the cause of this issue?
also, I noticed the heartbeat messages look strange… it almost seems like there is another mavlink device sending something, but only the autopilot is connected. I even disconnected the gcs…

HEARTBEAT {type : 2, autopilot : 3, base_mode : 81, custom_mode : 0, system_status : 5, mavlink_version : 3}
STABILIZE
HEARTBEAT {type : 18, autopilot : 8, base_mode : 0, custom_mode : 0, system_status : 0, mavlink_version : 3}
Mode(0x00000000)
HEARTBEAT {type : 2, autopilot : 3, base_mode : 81, custom_mode : 0, system_status : 5, mavlink_version : 3}
STABILIZE
HEARTBEAT {type : 0, autopilot : 8, base_mode : 0, custom_mode : 33554829, system_status : 0, mavlink_version : 3}
Mode(0x00000000)
HEARTBEAT {type : 18, autopilot : 8, base_mode : 0, custom_mode : 0, system_status : 0, mavlink_version : 3}
Mode(0x00000000)
HEARTBEAT {type : 27, autopilot : 8, base_mode : 4, custom_mode : 0, system_status : 4, mavlink_version : 3}
Mode(0x00000004)
HEARTBEAT {type : 2, autopilot : 3, base_mode : 81, custom_mode : 0, system_status : 5, mavlink_version : 3}
STABILIZE
HEARTBEAT {type : 0, autopilot : 8, base_mode : 0, custom_mode : 33554829, system_status : 0, mavlink_version : 3}

could that be the uAvionx Ping? as I have the adsb carrier board… but I dont think so.
I just saw that type:27 indeed is ADSB, but 18 is companion computer, and although I do have one (the script runs on it) there is nothing else running on it that would emit a heartbeat… oooor could it be the Herelink?
thanks a lot,
Jonas

1 Like

Facing the same issue. Did you found the solution?

Use this -

from pymavlink import mavutil
connection_string = 'tcp:127.0.0.1:14550'
conn = mavutil.mavlink_connection(connection_string)

while True:
    msg = conn.recv_msg()
    if msg is not None:
        mtype = msg.get_type()
        if mtype == 'HEARTBEAT' and msg.type != mavutil.mavlink.MAV_TYPE_GCS:
                armed = conn.motors_armed()
                if armed:
                    print("Armed")
                else:
                    print("Disarmed")

Now it will work definitely.