Not retrieving correct SYSID at GCS

Hi,
I am having similar issues. I have a GCS and a drone with a CC. I can’t seem to get my pymavlink code to retrieve the correct SYSID. I have them connected through mavproxy. In particular on the drone I run:
mavproxy.exe --mastter=COM3 --out=udp:127.0.0.1:14551 --console --map
and on the GCS I run:
mavproxy.exe --out=udp:127.0.0.1:14551 --console --map
My simple pymavlink code shown below returns:
Connected to MAVLink system with ID: 1
System ID does not match SYSID_THISMAV

on the drone param show SYSID_THISMAV returns 2
on the GCS param show SYSID_THISMAV returns 1

It seem as if its not getting the SYSID from the drone?
Any help would be useful as I need to use this to get my 2-drone system programmed.

thank you.

***** the code ******
from pymavlink import mavutil

Set the connection parameters

connection_string = ‘udp:localhost:14551’

Create a MAVLink connection

master = mavutil.mavlink_connection(connection_string)

Wait for the heartbeat message to ensure the connection is established

msg = master.wait_heartbeat()

Print information about the connected drone

if msg is not None:
system_id = msg.get_srcSystem()
print(f"Connected to MAVLink system with ID: {system_id}")

# Check if system ID matches SYSID_THISMAV
sysid_thismav = 2  # Set to the correct value of SYSID_THISMAV
if system_id == sysid_thismav:
    print("System ID matches SYSID_THISMAV")
else:
    print("System ID does not match SYSID_THISMAV")

else:
print(“Did not receive heartbeat message. Check your connection.”)

There’s no need to duplicate posts across multiple topics.

I’m pretty sure what you’re seeing is that your vehicle is ID 1, and your GCS is ID 2.

Thank you, my bad about duplicate posts. I thought I was editing the post, but actually I edited the other post that I thought I deleted.
when I run the mavproxy command on my drone (param show SYSID_THISMAV) it returns 2. When I run it on my GCS it shows 1. Is SYSID_THISMAV is different from what you referred to as “vehicle id”??? if so, can I change my vehicle id on the drone to 2?
Thank you.

This line:

print(f"Connected to MAVLink system with ID: {system_id}")

should be printing whatever is set on your vehicle’s SYSID_THISMAV parameter.

The GCS also has an ID that exists in the same “space” to differentiate it on the network.

I think what you’re doing is retrieving the vehicle ID in one case and the GCS ID in the other.

You should set the SYSID_THISMAV parameter to a unique identifier for each vehicle, and you should ensure that no GCS duplicates that ID on the same network. There should be documentation for pymavlink describing how to set its GCS ID.

Thank you this helped. Now I have two drones, drone1 with sysid 10 and drone2 with sysid 2. The both have companion computers connected serially to the orange cube. They are both on the same local area network. They both run mavproxy. I am trying to network these so that I can run a pymavlink code on drone1 and connect to both drone1 sysid 10 and drone 2 sysid 2. What mavproxy codes should I run on each? I can’t seem to get them to see each other. Thank you again for your help.

I am currently using on drone1
mavproxy.exe --master=COM3 --out udpbcast:192.168.1.255:14550 --out=udp:127.0.0.1:14552
and on drone 2
mavproxy.exe --master=COM3 --out udpbcast:192.168.1.255:14551 --out udpout:127.0.0.1:14553
I can see both drones on Mission Planner run on the CC of drone1 each with their unique sysid. However, mavproxy only sees one drone and my pymavlink code can’t connect to both drones (to get both heartbeats). Thank you for your help.