feat(diagnostics): split error and shutdown messages

This commit is contained in:
Onur Özkan committed 2026-08-09 22:20:59 +03:00
1 parent 9646451645
commit afafd126d7
25 files changed
+608 -225

No files matched your search

+16 -16
View File
@@ -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);
}