Skip to main content

Signal

Struct Signal 

Source
pub struct Signal {
    pub name: String,
    pub start_bit: u16,
    pub bit_length: u8,
    pub byte_order: ByteOrder,
    pub is_signed: bool,
    pub scale: f64,
    pub offset: f64,
    pub min: f64,
    pub max: f64,
    pub unit: String,
    pub receivers: Vec<String>,
    pub multiplexing_info: MultiplexingInfo,
}
Expand description

One signal of a Message — its layout, scaling, and metadata.

Fields§

§name: String

Signal name, e.g. Temperature.

§start_bit: u16

Start bit, in DBC bit numbering: the MSB for ByteOrder::Motorola, the LSB for ByteOrder::Intel (see crate::bits). Up to 511 — CAN FD layouts reach into byte 64.

§bit_length: u8

Signal width in bits (1–64).

§byte_order: ByteOrder

Bit layout order.

§is_signed: bool

Two’s-complement signed interpretation of the raw bits.

§scale: f64

Physical value = raw * scale + offset.

§offset: f64

Physical value = raw * scale + offset.

§min: f64

Declared physical minimum (from [min|max]).

§max: f64

Declared physical maximum (from [min|max]).

§unit: String

Unit string, e.g. "degK" (empty when the file carries "-" or "").

§receivers: Vec<String>

Receiving node names, in file order (Vector__XXX preserved as-is).

§multiplexing_info: MultiplexingInfo

Multiplexing role within the message.

Implementations§

Source§

impl Signal

Source

pub fn decode_raw(&self, data: &[u8]) -> f64

Decodes the signal’s physical value from a CAN frame payload: the raw bits are extracted per the layout, sign-extended when signed, then scaled (raw * scale + offset).

Total: bits beyond the buffer read as zero (partial payloads decode as if zero-filled — see crate::bits::extract_raw).

Source

pub fn encode_raw(&self, data: &mut [u8], value: f64) -> Result<(), DbcError>

Encodes a physical value into a CAN frame payload: scaled back to raw (round((value - offset) / scale), half away from zero), range- and width-checked, then written bit by bit.

The [min|max] range is enforced only when min < max — files that declare an empty range ([0|0], as in motohawk.dbc’s Enable) impose no constraint.

§Errors

DbcError::ValueOutOfRange for non-finite values or declared-range violations, DbcError::RawOutOfRange when the scaled raw does not fit the bit width, DbcError::BufferTooShort when the buffer cannot hold the layout.

Trait Implementations§

Source§

impl Clone for Signal

Source§

fn clone(&self) -> Self

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 Debug for Signal

Source§

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

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

impl PartialEq for Signal

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Signal

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 = !

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.