pub struct EegPacket {
pub timestamp: f64,
pub event_id: u8,
pub counter: u8,
pub ref_value: f32,
pub drl: f32,
pub channels: Vec<f32>,
pub feature_status: u8,
pub checksum_valid: bool,
}Expand description
A parsed EEG data packet from the MW75 device.
Each packet carries one sample across all 12 EEG channels plus reference and DRL (Driven Right Leg) values. The MW75 streams at 500 Hz, so one packet arrives approximately every 2 ms.
§Wire format
byte[0] : 0xAA sync byte
byte[1] : event ID (239 = EEG)
byte[2] : data length
byte[3] : counter (0–255, wrapping)
bytes[4..8] : REF value (f32 LE)
bytes[8..12] : DRL value (f32 LE)
bytes[12..60] : 12 × f32 LE channel values
byte[60] : feature status
bytes[61..63] : checksum (u16 LE, sum of bytes 0..61 & 0xFFFF)§Channel scaling
Raw ADC float values are multiplied by the EEG scaling factor
(crate::protocol::EEG_SCALING_FACTOR = 0.023842) to convert
to microvolts. A raw value of 1000.0 becomes ≈ 23.84 µV.
§Example
let packet = EegPacket {
timestamp: 1710000000.0,
event_id: 239,
counter: 42,
ref_value: 5.0,
drl: -3.0,
channels: vec![10.0; 12],
feature_status: 0,
checksum_valid: true,
};
assert_eq!(packet.channels.len(), 12);Fields§
§timestamp: f64Wall-clock timestamp in seconds since Unix epoch, captured when the packet was received from the transport.
event_id: u8Event ID byte from the packet header. Always 239 for EEG data.
counter: u8Monotonically increasing packet counter (wraps at 255).
Used for dropped-packet detection: if counter jumps by more than 1,
(counter - last_counter - 1) packets were lost.
ref_value: f32Reference electrode value (f32, already in correct units).
drl: f32DRL (Driven Right Leg) electrode value (f32, already in correct units).
channels: Vec<f32>12 EEG channel values in µV.
Raw ADC float values are multiplied by the scaling factor
(0.023842) to convert to microvolts.
feature_status: u8Feature status byte from the packet.
checksum_valid: boolWhether the packet checksum validated correctly.
Always true for packets returned by crate::parse::parse_eeg_packet
(invalid packets are rejected before constructing this struct).