mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-26 02:28:29 -04:00
AP_UAVCAN: use const unique id length variable
This commit is contained in:
parent
e017783f69
commit
c37a9966c1
@ -180,28 +180,26 @@ void AP_UAVCAN::init(uint8_t driver_index)
|
||||
hw_version.major = AP_UAVCAN_HW_VERS_MAJOR;
|
||||
hw_version.minor = AP_UAVCAN_HW_VERS_MINOR;
|
||||
|
||||
uint8_t len = hw_version.unique_id.capacity();
|
||||
uint8_t *unique_id = new uint8_t[len];
|
||||
const uint8_t uid_buf_len = hw_version.unique_id.capacity();
|
||||
uint8_t uid_len = uid_buf_len;
|
||||
uint8_t unique_id[uid_buf_len];
|
||||
|
||||
if (unique_id) {
|
||||
hal.util->get_system_id_unformatted(unique_id, len);
|
||||
uavcan::copy(unique_id, unique_id + len, hw_version.unique_id.begin());
|
||||
} else {
|
||||
AP_HAL::panic("UAVCAN: Failed to allocate Unique ID");
|
||||
}
|
||||
if (hal.util->get_system_id_unformatted(unique_id, uid_len)) {
|
||||
uavcan::copy(unique_id, unique_id + uid_len, hw_version.unique_id.begin());
|
||||
|
||||
_node->setHardwareVersion(hw_version);
|
||||
_node->setHardwareVersion(hw_version);
|
||||
|
||||
int start_res = _node->start();
|
||||
if (start_res < 0) {
|
||||
debug_uavcan(1, "UAVCAN: node start problem, error %d\n\r", start_res);
|
||||
return;
|
||||
}
|
||||
int start_res = _node->start();
|
||||
if (start_res < 0) {
|
||||
debug_uavcan(1, "UAVCAN: node start problem, error %d\n\r", start_res);
|
||||
return;
|
||||
}
|
||||
|
||||
//Start Servers
|
||||
//Start Servers
|
||||
#ifdef HAS_UAVCAN_SERVERS
|
||||
_servers.init(*_node);
|
||||
_servers.init(*_node);
|
||||
#endif
|
||||
}
|
||||
// Roundup all subscribers from supported drivers
|
||||
AP_GPS_UAVCAN::subscribe_msgs(this);
|
||||
AP_Compass_UAVCAN::subscribe_msgs(this);
|
||||
|
@ -83,13 +83,7 @@ class AP_UAVCAN_FileEventTracer : public uavcan::dynamic_node_id_server::IEventT
|
||||
protected:
|
||||
virtual void onEvent(uavcan::dynamic_node_id_server::TraceCode code, uavcan::int64_t argument)
|
||||
{
|
||||
struct log_UAVCAN_EVT pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_UAVCAN_EVT_MSG),
|
||||
time_us : AP_HAL::micros64(),
|
||||
code : code,
|
||||
argument : argument
|
||||
};
|
||||
DataFlash_Class::instance()->WriteBlock(&pkt, sizeof(pkt));
|
||||
DataFlash_Class::instance()->Log_Write("UCEV", "TimeUS,code,arg", "s--", "F--", "Qhq", AP_HAL::micros64(), code, argument);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user