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: StringSignal name, e.g. Temperature.
start_bit: u16Start 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: u8Signal width in bits (1–64).
byte_order: ByteOrderBit layout order.
is_signed: boolTwo’s-complement signed interpretation of the raw bits.
scale: f64Physical value = raw * scale + offset.
offset: f64Physical value = raw * scale + offset.
min: f64Declared physical minimum (from [min|max]).
max: f64Declared physical maximum (from [min|max]).
unit: StringUnit 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: MultiplexingInfoMultiplexing role within the message.
Implementations§
Source§impl Signal
impl Signal
Sourcepub fn decode_raw(&self, data: &[u8]) -> f64
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).
Sourcepub fn encode_raw(&self, data: &mut [u8], value: f64) -> Result<(), DbcError>
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.