feat(diagnostics): split error and shutdown messages
This commit is contained in:
1 parent
9646451645
commit
afafd126d7
25 files changed
+608
-225
No files matched your search
@@ -18,8 +18,8 @@ use kaptan_drivers::{
|
||||
mtf01::Mtf01Service,
|
||||
};
|
||||
use kaptan_log::{
|
||||
DeliveryClass, ErrorReport, EventHub, KaptanError, LogFilter, LogFlags, StaticErrorMailbox,
|
||||
StaticErrorMessage, TransportAdmission,
|
||||
DeliveryClass, ErrorReport, EventHub, KaptanError, LogFilter, LogFlags, StaticError,
|
||||
StaticErrorMailbox, TransportAdmission,
|
||||
};
|
||||
use kaptan_log_mavlink::{DiagnosticPayload, encode_diagnostic};
|
||||
use kaptan_spi::SpiCompletion;
|
||||
@@ -54,11 +54,11 @@ const KAPTAN_LOG_FRAME_MAXIMUM_BYTES: usize =
|
||||
kaptan_mavlink::message::kaptan::KAPTAN_LOG_DATA::ENCODED_LEN
|
||||
+ MAVLINK_V2_UNSIGNED_OVERHEAD_BYTES;
|
||||
// The static F722 telemetry profile is bounded at 62 scheduled frames/s.
|
||||
// It permits ten `KAPTAN_ERROR` and five `KAPTAN_LOG` frames/s. Their maxima
|
||||
// are respectively 162 and 163 payload bytes plus 12 unsigned MAVLink V2
|
||||
// framing bytes, so 62×48 + 10×174 + 5×175 = 5,591 bytes/s. MAVLink signing
|
||||
// is not enabled in this telemetry-only image; any future signing profile
|
||||
// must re-budget its signature overhead before it can enable the endpoint.
|
||||
// It permits ten `KAPTAN_ERROR` and five `KAPTAN_LOG` frames/s. Both maxima
|
||||
// are 163 payload bytes plus 12 unsigned MAVLink V2 framing bytes, so
|
||||
// 62×48 + 15×175 = 5,601 bytes/s. MAVLink signing is not enabled in this
|
||||
// telemetry-only image; any future signing profile must re-budget its
|
||||
// signature overhead before it can enable the endpoint.
|
||||
pub(crate) const WORST_CASE_OBSERVABILITY_BYTES_PER_SECOND: usize = SCHEDULED_FRAMES_PER_SECOND
|
||||
* SCHEDULED_FRAME_MAXIMUM_BYTES
|
||||
+ ERROR_RECORDS_PER_SECOND as usize * KAPTAN_ERROR_FRAME_MAXIMUM_BYTES
|
||||
@@ -427,7 +427,7 @@ pub(crate) fn on_uart4_interrupt(mtf01: &mut Option<F722Mtf01>) {
|
||||
}
|
||||
ReceiveInterrupt::Fault => {
|
||||
mtf01.reset();
|
||||
record_mtf01_fault(F722TelemetryError::Mtf01Uart.error_message());
|
||||
record_mtf01_fault(F722TelemetryError::Mtf01Uart.static_error());
|
||||
}
|
||||
ReceiveInterrupt::NotPending => {}
|
||||
}
|
||||
@@ -455,7 +455,7 @@ impl F722LidarState {
|
||||
if self.startup_ticks == LIDAR_STARTUP_TICKS
|
||||
&& let Err(error) = range.finish_startup()
|
||||
{
|
||||
record_lidar_fault(error.error_message());
|
||||
record_lidar_fault(error.static_error());
|
||||
}
|
||||
} else {
|
||||
publish_lidar_event(range.on_periodic_tick());
|
||||
@@ -542,13 +542,13 @@ impl F722MavlinkState {
|
||||
while let Some(fault) = self.data_channel.take_transport_fault() {
|
||||
let message = match fault {
|
||||
kaptan_mavlink::transmitter::TransmitFaultKind::Memory => {
|
||||
F722TelemetryError::TransmitMemory.error_message()
|
||||
F722TelemetryError::TransmitMemory.static_error()
|
||||
}
|
||||
kaptan_mavlink::transmitter::TransmitFaultKind::Engine => {
|
||||
F722TelemetryError::TransmitEngine.error_message()
|
||||
F722TelemetryError::TransmitEngine.static_error()
|
||||
}
|
||||
kaptan_mavlink::transmitter::TransmitFaultKind::Terminal => {
|
||||
F722TelemetryError::TransmitTerminal.error_message()
|
||||
F722TelemetryError::TransmitTerminal.static_error()
|
||||
}
|
||||
};
|
||||
let _ = self.logs.publish_error_static(LogFlags::NONE, message);
|
||||
@@ -634,19 +634,19 @@ pub fn record_mavlink_completion(completion: kaptan_dma::TxCompletion) {
|
||||
fn publish_lidar_event<E: ErrorReport>(event: LidarLiteV3ServiceEvent<E>) {
|
||||
match event {
|
||||
LidarLiteV3ServiceEvent::Measurement(snapshot) => RANGES.publish(snapshot),
|
||||
LidarLiteV3ServiceEvent::Fault(error) => record_lidar_fault(error.error_message()),
|
||||
LidarLiteV3ServiceEvent::Fault(error) => record_lidar_fault(error.static_error()),
|
||||
LidarLiteV3ServiceEvent::Idle => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn record_imu_fault(message: &'static StaticErrorMessage) {
|
||||
fn record_imu_fault(message: &'static StaticError) {
|
||||
IMU_FAULTS.record(message);
|
||||
}
|
||||
|
||||
fn record_lidar_fault(message: &'static StaticErrorMessage) {
|
||||
fn record_lidar_fault(message: &'static StaticError) {
|
||||
LIDAR_FAULTS.record(message);
|
||||
}
|
||||
|
||||
fn record_mtf01_fault(message: &'static StaticErrorMessage) {
|
||||
fn record_mtf01_fault(message: &'static StaticError) {
|
||||
MTF01_FAULTS.record(message);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ use kaptan_drivers::{
|
||||
Mpu6000Service, Mpu6000ServiceEvent,
|
||||
},
|
||||
};
|
||||
use kaptan_log::{ErrorReport, StaticErrorMessage};
|
||||
use kaptan_log::{ErrorReport, StaticError};
|
||||
use kaptan_sensor::imu::ImuSnapshot;
|
||||
use kaptan_spi::SpiCompletion;
|
||||
use stm32f7::stm32f722;
|
||||
@@ -31,7 +31,7 @@ pub(crate) enum ImuEvent {
|
||||
Idle,
|
||||
Initialized,
|
||||
Sample(ImuSnapshot),
|
||||
Fault(&'static StaticErrorMessage),
|
||||
Fault(&'static StaticError),
|
||||
}
|
||||
|
||||
/// Opaque owner of the selected F722 IMU service.
|
||||
@@ -96,11 +96,11 @@ impl F722Imu {
|
||||
match &mut self.inner {
|
||||
F722ImuKind::Mpu6000(imu) => match imu.begin() {
|
||||
Ok(()) => ImuEvent::Idle,
|
||||
Err(error) => ImuEvent::Fault(error.error_message()),
|
||||
Err(error) => ImuEvent::Fault(error.static_error()),
|
||||
},
|
||||
F722ImuKind::Icm42688(imu) => match imu.begin() {
|
||||
Ok(()) => ImuEvent::Idle,
|
||||
Err(error) => ImuEvent::Fault(error.error_message()),
|
||||
Err(error) => ImuEvent::Fault(error.static_error()),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ fn mpu_event<E: ErrorReport>(event: Mpu6000ServiceEvent<E>) -> ImuEvent {
|
||||
Mpu6000ServiceEvent::Idle => ImuEvent::Idle,
|
||||
Mpu6000ServiceEvent::Initialized => ImuEvent::Initialized,
|
||||
Mpu6000ServiceEvent::Sample(sample) => ImuEvent::Sample(sample),
|
||||
Mpu6000ServiceEvent::Fault(error) => ImuEvent::Fault(error.error_message()),
|
||||
Mpu6000ServiceEvent::Fault(error) => ImuEvent::Fault(error.static_error()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ fn icm_event<E: ErrorReport>(event: Icm42688ServiceEvent<E>, mount: ImuMount) ->
|
||||
Icm42688ServiceEvent::Idle => ImuEvent::Idle,
|
||||
Icm42688ServiceEvent::Initialized => ImuEvent::Initialized,
|
||||
Icm42688ServiceEvent::Sample(sample) => ImuEvent::Sample(align_mount(sample, mount)),
|
||||
Icm42688ServiceEvent::Fault(error) => ImuEvent::Fault(error.error_message()),
|
||||
Icm42688ServiceEvent::Fault(error) => ImuEvent::Fault(error.static_error()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use kaptan_board::{
|
||||
BoardConfig, BoardProfile, DataChannelRates, ImuDevice, ImuMount, MavlinkEndpoint, MavlinkPort,
|
||||
TelemetryProfile, VerticalSensingKind,
|
||||
};
|
||||
use kaptan_log::{LogFlags, LogRecord, LogText, Severity};
|
||||
use kaptan_log::{ErrorAdditionalInformation, ErrorPath, LogFlags, LogRecord, LogText, Severity};
|
||||
use kaptan_log_mavlink::{DiagnosticPayload, encode_diagnostic};
|
||||
use kaptan_mavlink::encoder::MavlinkEncoder;
|
||||
use platform_stm32f7::{
|
||||
@@ -214,7 +214,11 @@ fn telemetry_has_no_inbound_command_authority() {
|
||||
fn f722_link_budget_uses_both_maximum_generated_diagnostic_frames() {
|
||||
let text = LogText::from_message(&"x".repeat(160));
|
||||
let log_record = LogRecord::new(Severity::Info, LogFlags::NONE, text);
|
||||
let error_record = LogRecord::new(Severity::Error, LogFlags::NONE, text);
|
||||
let error_record = LogRecord::error(
|
||||
LogFlags::NONE,
|
||||
ErrorPath::from_message(&"p".repeat(96)),
|
||||
ErrorAdditionalInformation::from_message(&"i".repeat(64)),
|
||||
);
|
||||
let mut encoder = MavlinkEncoder::new(1, 1);
|
||||
let DiagnosticPayload::Log(log_payload) = encode_diagnostic(&log_record) else {
|
||||
panic!("info record must use KAPTAN_LOG");
|
||||
@@ -230,17 +234,20 @@ fn f722_link_budget_uses_both_maximum_generated_diagnostic_frames() {
|
||||
kaptan_mavlink::message::kaptan::KAPTAN_LOG_DATA::ENCODED_LEN,
|
||||
163
|
||||
);
|
||||
assert_eq!(error_frame.raw_bytes().len(), 174);
|
||||
assert_eq!(error_frame.raw_bytes().len(), 175);
|
||||
assert_eq!(
|
||||
kaptan_mavlink::message::kaptan::KAPTAN_ERROR_DATA::ENCODED_LEN,
|
||||
162
|
||||
163
|
||||
);
|
||||
assert_eq!(error_payload.path_length, 96);
|
||||
assert_eq!(error_payload.additional_information_length, 64);
|
||||
assert_eq!(error_payload.flags.bits(), LogFlags::NONE.bits());
|
||||
assert_eq!(
|
||||
62 * 48 + 10 * error_frame.raw_bytes().len() + 5 * log_frame.raw_bytes().len(),
|
||||
5_591
|
||||
5_601
|
||||
);
|
||||
let board = platform_source("src/f722/board.rs");
|
||||
assert!(board.contains("KAPTAN_ERROR_FRAME_MAXIMUM_BYTES"));
|
||||
assert!(board.contains("KAPTAN_LOG_FRAME_MAXIMUM_BYTES"));
|
||||
assert!(board.contains("5,591 bytes/s"));
|
||||
assert!(board.contains("5,601 bytes/s"));
|
||||
}
|
||||
Reference in new issue
Block a user