dbc_rs/signal/
mod.rs

1mod core;
2mod decode;
3mod parse;
4#[cfg(feature = "std")]
5mod serialize;
6
7#[cfg(feature = "std")]
8mod builder;
9
10use crate::{ByteOrder, MAX_NAME_SIZE, Receivers, compat::String};
11
12/// Represents a CAN signal within a message.
13///
14/// A `Signal` contains:
15/// - A name
16/// - Start bit position and length
17/// - Byte order (big-endian or little-endian)
18/// - Signed/unsigned flag
19/// - Factor and offset for physical value conversion
20/// - Min/max range
21/// - Optional unit string
22/// - Receivers (nodes that receive this signal)
23///
24/// # Examples
25///
26/// ```rust,no_run
27/// use dbc_rs::Dbc;
28///
29/// let dbc = Dbc::parse(r#"VERSION "1.0"
30///
31/// BU_: ECM
32///
33/// BO_ 256 Engine : 8 ECM
34///  SG_ RPM : 0|16@1+ (0.25,0) [0|8000] "rpm" *
35/// "#)?;
36///
37/// let message = dbc.messages().at(0).unwrap();
38/// let signal = message.signals().at(0).unwrap();
39/// println!("Signal: {} (bits: {}-{})", signal.name(), signal.start_bit(), signal.start_bit() + signal.length() - 1);
40/// # Ok::<(), dbc_rs::Error>(())
41/// ```
42#[derive(Debug, Clone)]
43pub struct Signal {
44    name: String<{ MAX_NAME_SIZE }>,
45    start_bit: u16,
46    length: u16,
47    byte_order: ByteOrder,
48    unsigned: bool,
49    factor: f64,
50    offset: f64,
51    min: f64,
52    max: f64,
53    unit: Option<String<{ MAX_NAME_SIZE }>>,
54    receivers: Receivers,
55    /// True if this is a multiplexer switch signal (marked with 'M')
56    is_multiplexer_switch: bool,
57    /// If this is a multiplexed signal (marked with 'm0', 'm1', etc.), this contains the switch value
58    /// None means this is a normal signal (not multiplexed)
59    multiplexer_switch_value: Option<u64>,
60}
61
62#[cfg(feature = "std")]
63pub use builder::SignalBuilder;