iso15765_2/can/
address.rs

1use serde::{Deserialize, Serialize};
2
3/// ISO-TP address format.
4#[derive(Debug, Copy, Clone, Default, Eq, PartialEq)]
5pub enum AddressFormat {
6    #[default]
7    Normal = 0x01, // 11bit CAN-ID
8    NormalFixed = 0x02, // 29bit CAN-ID
9    Extend = 0x03,      // 11bit Remote CAN-ID
10    ExtendMixed = 0x04, // 11bit and 11bit Remote CAN-ID mixed
11    Enhanced = 0x05,    // 11bit(Remote) and 29bot CAN-ID
12}
13
14/// ISO-TP address type.
15#[derive(Debug, Copy, Clone, Default, Eq, PartialEq)]
16pub enum AddressType {
17    #[default]
18    Physical,
19    Functional,
20}
21
22/// ISO-TP address
23///
24/// * `tx_id`: transmit identifier.
25/// * `rx_id`: receive identifier.
26/// * `fid`: functional address identifier.
27#[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize, Serialize)]
28pub struct Address {
29    pub tx_id: u32,
30    pub rx_id: u32,
31    pub fid: u32,
32}
33
34impl Default for Address {
35    fn default() -> Self {
36        Self {
37            tx_id: 0x7E0,
38            rx_id: 0x7E8,
39            fid: 0x7DF,
40        }
41    }
42}