Skip to main content

listener.rs — Incoming Packet Handler

run_listener() is the main receive loop. It runs for the lifetime of the app as a spawned async task. On every received UDP datagram it:

  1. Decodes the raw bytes as a PbEnvelope using prost
  2. Extracts the inner payload variant
  3. Checks a per-payload throttle — events are forwarded to the frontend at most once every 100ms per payload type, regardless of how fast the rover sends
  4. Emits a Tauri event to the frontend with the decoded message as the payload

Throttling

Each payload type has its own independent Throttle instance. This prevents high-frequency streams (e.g. IMU at 50Hz) from flooding the frontend with more updates than it can usefully render.

Tauri events emitted

These are the event names the frontend can listen to with listen():

Event name

Payload type

Typical source

imu-update

SensorBoardImuInfo

IMU sensor

gps-update

SensorBoardGpsInfo

GPS sensor

ph-update

SensorBoardPhInfo

pH sensor

arm-ctrl-update

ArmBoardControlSignals

Arm controller

arm-diag-update

ArmBoardDiagnostics

Arm board

arm-feedback-update

ArmBoardMovementFeedback

Arm movement

arm-pos-update

ArmBoardActualPositions

Arm position

arm-target-update

ArmBoardTargetMovement

Arm target

arm-obstructions-update

ArmBoardObstructions

Arm safety

drive-diag-update

DrivingBoardDiagnostics

Drive board

drive-motor-update

DrivingBoardMotorMessage

Drive motors

drive-progress-update

DrivingBoardMotorPeriodicProgress

Drive progress

sensor-diag-update

SensorBoardDiagnostics

Sensor board

control-mode-update

ControlMode

Rover control mode

mission-command-update

MissionCommand

Mission system

detected-objects-update

DetectedObjects

Vision system

object-selection-update

ObjectSelection

Vision system

load-cell-update

LoadCellInfo

Load cell (rock weight)

pressure-update

PressureInfo

Pressure sensor

rock-measure-request-update

RockMeasureRequest

Science task

rock-measure-result-update

RockMeasureResult

Science task

rover-localization-update

RoverLocalization

Navigation

camera-feed-status

{ port, stale }

GStreamer health watcher

Note for future developers: If you add new protobufers you must add them here or the app won't compile