From 462cf131d599136d1e24474b2b522ed1975b7be4 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 27 Jul 2018 10:29:47 +0200 Subject: [PATCH] mavlink: add sysid to UUID To avoid that multiple SITL instances have the same UUID we add the mavlink system ID to the UUID which is sent via mavlink. This should resolve the case where multiple vehicles show up with the same UUID in simulation. Note that the UUID show in `ver` will still be the same for all instances. --- src/modules/mavlink/mavlink_main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 0806c646df..35d4bcb9d3 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1310,6 +1310,14 @@ void Mavlink::send_autopilot_capabilites() board_get_uuid32(uid); msg.uid = (((uint64_t)uid[PX4_CPU_UUID_WORD32_UNIQUE_M]) << 32) | uid[PX4_CPU_UUID_WORD32_UNIQUE_H]; +#ifdef CONFIG_ARCH_BOARD_SITL + // To avoid that multiple SITL instances have the same UUID, we add the mavlink + // system ID. We subtract 1, so that the first UUID remains unchanged given the + // default system ID is 1. + // + // Note that the UUID show in `ver` will still be the same for all instances. + msg.uid += mavlink_system.sysid - 1; +#endif mavlink_msg_autopilot_version_send_struct(get_channel(), &msg); } }