Skip to main content

EegPacket

Struct EegPacket 

Source
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: f64

Wall-clock timestamp in seconds since Unix epoch, captured when the packet was received from the transport.

§event_id: u8

Event ID byte from the packet header. Always 239 for EEG data.

§counter: u8

Monotonically 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: f32

Reference electrode value (f32, already in correct units).

§drl: f32

DRL (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: u8

Feature status byte from the packet.

§checksum_valid: bool

Whether the packet checksum validated correctly. Always true for packets returned by crate::parse::parse_eeg_packet (invalid packets are rejected before constructing this struct).

Trait Implementations§

Source§

impl Clone for EegPacket

Source§

fn clone(&self) -> EegPacket

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EegPacket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V