Skip to main content

DriverMode

Enum DriverMode 

Source
#[repr(u8)]
pub enum DriverMode { Normal = 0, Replay = 1, }
Expand description

Driver 工作模式

§模式说明

  • Normal: 正常模式,TX 线程按周期发送控制指令(MIT/Position)
  • Replay: 回放模式,TX 线程暂停周期性发送,仅发送显式指令

§设计目的

Replay 模式用于安全地回放预先录制的 CAN 帧,避免双控制流冲突:

  • 正常模式:TX 线程每 1ms 发送一次控制指令
  • 回放模式:暂停 TX 线程,由回放逻辑控制帧发送时机

§线程安全

使用原子操作确保模式切换的线程安全性。

Variants§

§

Normal = 0

正常模式(默认)

TX 线程按周期发送控制指令(MIT/Position 模式)。

§

Replay = 1

回放模式

TX 线程暂停周期性发送,仅发送显式指令。 用于安全回放预先录制的 CAN 帧。

Implementations§

Source§

impl DriverMode

Source

pub fn from_u8(value: u8) -> Self

从 u8 转换

如果值无效,返回 Normal 模式。

Source

pub fn as_u8(self) -> u8

转换为 u8

Source

pub fn is_replay(self) -> bool

是否为回放模式

Source

pub fn is_normal(self) -> bool

是否为正常模式

Trait Implementations§

Source§

impl Clone for DriverMode

Source§

fn clone(&self) -> DriverMode

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 DriverMode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for DriverMode

Source§

fn default() -> DriverMode

Returns the “default value” for a type. Read more
Source§

impl PartialEq for DriverMode

Source§

fn eq(&self, other: &DriverMode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for DriverMode

Source§

impl Eq for DriverMode

Source§

impl StructuralPartialEq for DriverMode

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more