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 Aspect | Unidirectional (Throttle) | Unidirectional (Commands) | Bidirectional (Throttle & Commands) |
|---|---|---|---|
| Telemetry Bit | false (Set to 0) | true (Set to 1) | true (Set to 1) |
| XOR Checksum Mode | Standard | Bitwise Inverted | Bitwise Inverted |
| ESC Action | Executes throttle Remains silent | Executes command Returns a ghost reply | Executes command Returns a telemetry frame |
| FC Pin Mode | Permanent Output | Permanent Output | Flips from Output to Input right after TX |
| Repetition Gate | Streams continuously | Must repeat ~10 times to execute | Commands must repeat ~10 times to execute |
| FC Software Action | Fire-and-forget stream | Fire-and-forget stream | Transmits, then pauses ~30µs to capture GcrFrame |
Implementations§
Source§impl DshotCommandFrame
impl DshotCommandFrame
pub const NO_TELEMETRY: bool = false
pub const WITH_TELEMETRY: bool = true
pub const UNI_DIRECTIONAL: bool = false
pub const BI_DIRECTIONAL: bool = true
pub const MAX_RAW_VALUE: u16 = 2047
pub const THROTTLE_OFFSET: u16 = 48
pub const THROTTLE_MIN: u16 = 48
pub const THROTTLE_MAX: u16 = 2047
pub const fn new(value: u16) -> Self
pub const fn from_raw(value: u16) -> Self
pub const fn from_command(command: DshotCommand) -> Self
pub const fn raw(self) -> u16
Sourcepub const fn value(self) -> u16
pub const fn value(self) -> u16
Extracts the original 11-bit command/throttle value from the processed 16-bit frame.
pub const fn is_telemetry_enabled(self) -> bool
pub const fn checksum(self) -> u16
Sourcepub const fn calculate_checksum(frame_raw: u16) -> u16
pub const fn calculate_checksum(frame_raw: u16) -> u16
Calculates the standard 4-bit XOR outbound checksum.
Sourcepub const fn encode_raw(value: u16, with_telemetry: bool) -> Self
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.
Sourcepub fn from_throttle_unidirectional(throttle: f32) -> Self
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.
Sourcepub fn from_throttle_bidirectional(throttle: f32) -> Self
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.
pub fn from_throttle(throttle: f32, bidirectional: bool) -> Self
Source§impl DshotCommandFrame
impl DshotCommandFrame
pub fn to_gcr20(self) -> u32
Sourcepub fn gcr20_to_nrzi21(input: u32) -> u32
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:
- If the current input bit in GCR data is a 1 then the output bit is the inverse of the previous output bit
- If the current input bit in GCR data is a 0 then the output bit is the same as the previous output
pub fn gcr_encode(self) -> u32
Trait Implementations§
Source§impl Clone for DshotCommandFrame
impl Clone for DshotCommandFrame
Source§fn clone(&self) -> DshotCommandFrame
fn clone(&self) -> DshotCommandFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more