Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Author: Mikayla Lee

AER Telemetry over CAN ISO-TP

Overview

This system receives motor-controller telemetry over CAN ISO-TP, decodes it into strongly typed data, and forwards it for downstream processing. It also includes vCAN-based test utilities for CI.


Function: read_can_hardware

Purpose: Continuously reads and decodes telemetry packets from can0

Workflow:

  • Opens an ISO-TP socket on can0 (source ID 0x666, destination ID 0x777)
  • Retries socket creation on failure with a 1-second backoff
  • Reads incoming packets asynchronously, validates packet length, and parses raw bytes into TelemetryData using Deku
  • Captures a timestamp with now_ms() and forwards via send_message(data, ts)

Error Handling:

  • Logs socket creation failures and malformed packets
  • Logs packets with trailing bytes after decode
  • Re-enters socket setup if packet reads stop or fail

Function: read_can

Dispatches to hardware ISO-TP reception (can0) or synthetic mode when the synthetic feature flag is enabled.


Function: read_can_synthetic

Publishes default TelemetryData at a ~1 ms interval for testing and CI. Logs throughput approximately once per second.


Struct: TelemetryData

Represents a fully decoded MCU telemetry packet received over CAN ISO-TP. Fields are decoded little-endian from a fixed-layout binary frame.

FieldTypeNotes
apps_travelf32Normalized accelerator pedal travel
bse_frontf32Front brake sensor
bse_rearf32Rear brake sensor
imd_resistancef32Isolation monitoring measured resistance
imd_statusu32Raw IMD status bits — interpret against MCU spec
pack_voltagef32HV pack voltage
pack_currentf32HV pack current
socf32Battery state of charge
discharge_limitf32Current discharge limit
charge_limitf32Current charge limit
low_cell_voltf32Minimum cell voltage
high_cell_voltf32Maximum cell voltage
avg_cell_voltf32Average cell voltage
motor_speedf32Motor rotational speed
motor_torquef32Instantaneous output torque
max_motor_torquef32Configured torque limit
motor_directionMotorRotateDirection
motor_stateMotorState
mcu_main_stateMCUMainState
mcu_work_modeMCUWorkMode
mcu_voltagef32MCU DC bus voltage
mcu_phase_currentf32MCU phase current
mcu_currentf32MCU current draw
motor_tempi32Motor temperature
mcu_tempi32MCU temperature
mcu_warning_levelMCUWarningLevelAggregated MCU warning severity
shocktravel14f32Shock travel channels 1–4
dc_main_wire_over_volt_faultbool
motor_phase_curr_faultbool
mcu_over_hot_faultbool
resolver_faultbool
phase_curr_sensor_faultbool
motor_over_spd_faultbool
drv_motor_over_hot_faultbool
dc_main_wire_over_curr_faultbool
drv_motor_over_cool_faultbool
dc_low_volt_warningbool
mcu_12v_low_volt_warningbool
motor_stall_faultbool
motor_open_phase_faultbool
over_currentbool (1 bit)System-level protection flag
under_voltagebool (1 bit)Supply below valid range
over_temperaturebool (1 bit)Temperature exceeded safe limit
appsbool (1 bit)APPS fault flag
bsebool (1 bit)BSE fault flag
bppsbool (1 bit)BPPS fault flag
apps_brake_plausbool (1 bit)Accelerator/brake plausibility violation
low_battery_voltagebool (1 bit)Battery low warning; followed by 24-bit pad