Browse Source

HAL_ChibiOS: report system ID in mavlink and logs

master
Andrew Tridgell 7 years ago
parent
commit
e5435e02ad
  1. 21
      libraries/AP_HAL_ChibiOS/Util.cpp
  2. 3
      libraries/AP_HAL_ChibiOS/Util.h

21
libraries/AP_HAL_ChibiOS/Util.cpp

@ -240,3 +240,24 @@ bool Util::flash_bootloader() @@ -240,3 +240,24 @@ bool Util::flash_bootloader()
return false;
}
/*
display system identifer - board type and serial number
*/
bool Util::get_system_id(char buf[40])
{
uint8_t serialid[12];
char board_name[14];
memcpy(serialid, (const void *)UDID_START, 12);
strncpy(board_name, CHIBIOS_SHORT_BOARD_NAME, 13);
board_name[13] = 0;
// this format is chosen to match the human_readable_serial()
// function in auth.c
snprintf(buf, 40, "%s %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X",
board_name,
(unsigned)serialid[0], (unsigned)serialid[1], (unsigned)serialid[2], (unsigned)serialid[3],
(unsigned)serialid[4], (unsigned)serialid[5], (unsigned)serialid[6], (unsigned)serialid[7],
(unsigned)serialid[8], (unsigned)serialid[9], (unsigned)serialid[10],(unsigned)serialid[11]);
return true;
}

3
libraries/AP_HAL_ChibiOS/Util.h

@ -44,6 +44,9 @@ public: @@ -44,6 +44,9 @@ public:
void set_imu_temp(float current);
void set_imu_target_temp(int8_t *target);
// get system ID as a string
bool get_system_id(char buf[40]) override;
#ifdef HAL_PWM_ALARM
bool toneAlarm_init();
void toneAlarm_set_tune(uint8_t tone);

Loading…
Cancel
Save