AP_BLHeli: use the HAL accessor for the MSP_UID reply

The MSP_UID handler read the MCU serial number by dereferencing
UDID_START, which only exists on ChibiOS, and the motor-mask debug line
used a %08lx specifier on a uint32_t. uint32_t is unsigned long on
arm-none-eabi, so the format was correct there and wrong everywhere
else. Neither is portable to SITL, so AP_BLHeli could only build for
ChibiOS targets.

Use hal.util->get_system_id_unformatted() so the reply works on any
HAL - on ChibiOS it does the same memcpy from UDID_START that this
replaces - and cast the mask to match the format. The reply stays a
fixed 12 bytes, zero padded, matching AP_MSP_Telem_Backend.

Co-authored-by: Peter Barker <pb-gh@barker.dropbear.id.au>
This commit is contained in:
Andy Piper
2026-08-31 12:21:17 +10:00
committed by Peter Barker
co-authored by Peter Barker
parent 8f94cedce7
commit f65dcaac38
+7 -7
View File
@@ -25,10 +25,6 @@
#if HAVE_AP_BLHELI_SUPPORT
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
#include <hal.h>
#endif
#include <AP_Math/crc.h>
#include <AP_Vehicle/AP_Vehicle_Type.h>
#if APM_BUILD_TYPE(APM_BUILD_Rover)
@@ -415,11 +411,15 @@ void AP_BLHeli::msp_process_command(void)
blheli.connected[blheli.chan] = false;
break;
case MSP_UID:
case MSP_UID: {
// MCU identifier
debug("MSP_UID");
msp_send_reply(msp.cmdMSP, (const uint8_t *)UDID_START, 12);
uint8_t uid[12] {};
uint8_t len = sizeof(uid);
hal.util->get_system_id_unformatted(uid, len);
msp_send_reply(msp.cmdMSP, uid, sizeof(uid));
break;
}
// a literal "4" is used for the PWMType here to allow Rover
// to use the same number for the same protocol. At time of
@@ -1504,7 +1504,7 @@ void AP_BLHeli::init(uint32_t mask, AP_HAL::RCOutput::output_mode otype)
}
}
motor_mask = mask;
debug("ESC: %u motors mask=0x%08lx", num_motors, digital_mask);
debug("%u motors mask=0x%08lx", num_motors, (unsigned long)digital_mask);
// check if we have a combination of reversible and normal
mixed_type = (mask != (mask & channel_reversible_mask.get())) && (channel_reversible_mask.get() != 0);