1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Network layer implementations for automotive protocols.
//!
//! This module provides implementations for network layer protocols, primarily:
//! - J1939 (SAE J1939) - A higher-layer protocol for commercial vehicles
//!
//! The network layer is responsible for:
//! - Message routing and addressing
//! - Network management
//! - Message prioritization
//! - Protocol-specific addressing schemes
//!
//! The J1939 protocol is widely used in commercial vehicles and provides:
//! - Parameter Group Numbers (PGN) based addressing
//! - Multi-packet message transport
//! - Network management functions
//! - Standardized diagnostic messages
//!
//! # Examples
//!
//! ```text
//! # Example usage of the network layer (conceptual, not actual code)
//! # J1939 configuration:
//! let j1939_config = j1939::CustomConfig {
//! name: 0x0000AABBCCDDEEFF, // ECU NAME (64-bit identifier)
//! address: 0x42, // Preferred source address
//! priority: 6 // Default priority for messages
//! };
//!
//! # Create a J1939 instance and open the connection
//! let mut j1939 = j1939::CustomInterface::new(j1939_config);
//! j1939.open();
//!
//! # Claim a network address
//! j1939.claim_address(0x42);
//!
//! # Send a J1939 message
//! let pgn = 0x00EF00; // Example PGN (Electronic Engine Controller)
//! let dest_addr = 0xFF; // Broadcast address
//! let data = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];
//!
//! j1939.send_message(pgn, dest_addr, &data);
//!
//! # Receive J1939 messages
//! let msg = j1939.receive_message();
//! ```
use crateResult;
use crate;
/// Network layer trait that must be implemented by J1939