Skip to main content

DshotCommandFrame

Struct DshotCommandFrame 

Source
pub struct DshotCommandFrame(/* private fields */);
Expand description

DshotCommandFrame: transmitted from the Flight Controller(FC) to the ESC.

Whenever the FC wants the motor to spin, beep, or change direction, it transmits a 16-bit DshotCommandFrame.
Bits 0–10 (11 bits): Throttle value or Command, values 48 to 2047 for motor speed (throttle), values 1 to 47 for commands.
Bit 11 (1 bit): Telemetry Request Flag.
Bits 12–15 (4 bits): Checksum (technically a 4-bit Longitudinal Redundancy Check (LRC)).

Operational AspectUnidirectional (Throttle)Unidirectional (Commands)Bidirectional (Throttle & Commands)
Telemetry Bitfalse (Set to 0)true (Set to 1)true (Set to 1)
XOR Checksum ModeStandardBitwise InvertedBitwise Inverted
ESC ActionExecutes throttle
Remains silent
Executes command
Returns a ghost reply
Executes command
Returns a telemetry frame
FC Pin ModePermanent OutputPermanent OutputFlips from Output to Input right after TX
Repetition GateStreams continuouslyMust repeat ~10 times to executeCommands must repeat ~10 times to execute
FC Software ActionFire-and-forget streamFire-and-forget streamTransmits, then pauses ~30µs to capture GcrFrame

Implementations§

Source§

impl DshotCommandFrame

Source

pub const NO_TELEMETRY: bool = false

Source

pub const WITH_TELEMETRY: bool = true

Source

pub const UNI_DIRECTIONAL: bool = false

Source

pub const BI_DIRECTIONAL: bool = true

Source

pub const MAX_RAW_VALUE: u16 = 2047

Source

pub const THROTTLE_OFFSET: u16 = 48

Source

pub const THROTTLE_MIN: u16 = 48

Source

pub const THROTTLE_MAX: u16 = 2047

Source

pub const fn new(value: u16) -> Self

Source

pub const fn from_raw(value: u16) -> Self

Source

pub const fn from_command(command: DshotCommand) -> Self

Source

pub const fn raw(self) -> u16

Source

pub const fn value(self) -> u16

Extracts the original 11-bit command/throttle value from the processed 16-bit frame.

Source

pub const fn is_telemetry_enabled(self) -> bool

Source

pub const fn checksum(self) -> u16

Source

pub const fn calculate_checksum(frame_raw: u16) -> u16

Calculates the standard 4-bit XOR outbound checksum.

Source

pub const fn encode_raw(value: u16, with_telemetry: bool) -> Self

Assembles an 11-bit command and a telemetry flag into a complete 16-bit Dshot transmission word.

Source

pub fn from_throttle_unidirectional(throttle: f32) -> Self

Converts a throttle scale [0.0, 1.0] directly to the Dshot frame range [48, 2047]. In unidirectional mode the telemetry bit is not set and the checksum is not inverted.

Source

pub fn from_throttle_bidirectional(throttle: f32) -> Self

Converts a throttle scale [0.0, 1.0] directly to the Dshot frame range [48, 2047]. In bidirectional mode the telemetry bit is not set and the checksum is not inverted.

Source

pub fn from_throttle(throttle: f32, bidirectional: bool) -> Self

Source§

impl DshotCommandFrame

Source

pub fn to_gcr20(self) -> u32

Source

pub fn gcr20_to_nrzi21(input: u32) -> u32

Map the GCR to a 21-bit NRZI value, this new value starts with a 0 and the rest of the bits are set by the following two rules:

  1. If the current input bit in GCR data is a 1 then the output bit is the inverse of the previous output bit
  2. If the current input bit in GCR data is a 0 then the output bit is the same as the previous output
Source

pub fn gcr_encode(self) -> u32

Methods from Deref<Target = u16>§

1.43.0 · Source

pub const MIN: u16 = 0

1.43.0 · Source

pub const MAX: u16

1.53.0 · Source

pub const BITS: u32

Trait Implementations§

Source§

impl Clone for DshotCommandFrame

Source§

fn clone(&self) -> DshotCommandFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for DshotCommandFrame

Source§

impl Debug for DshotCommandFrame

Source§

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

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

impl Default for DshotCommandFrame

Source§

fn default() -> DshotCommandFrame

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

impl Deref for DshotCommandFrame

Source§

type Target = u16

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Eq for DshotCommandFrame

Source§

impl From<DshotCommandFrame> for u16

Source§

fn from(frame: DshotCommandFrame) -> Self

Converts to this type from the input type.
Source§

impl Ord for DshotCommandFrame

Source§

fn cmp(&self, other: &DshotCommandFrame) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for DshotCommandFrame

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for DshotCommandFrame

Source§

fn partial_cmp(&self, other: &DshotCommandFrame) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for DshotCommandFrame

Source§

impl TryFrom<u16> for DshotCommandFrame

Source§

type Error = u16

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

fn try_from(value: u16) -> Result<Self, u16>

Performs the conversion.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.