6 releases
0.4.1 | Feb 8, 2025 |
---|---|
0.4.0 | Feb 8, 2025 |
0.3.1 | Dec 29, 2024 |
0.2.2 | Dec 24, 2024 |
#603 in Network programming
246 downloads per month
52KB
1.5K
SLoC
CAN Adapter API
J2534 is a work in progress, but RP1210 works.
Brokers packets from a queue to and from the attached RP1210 adapter. Includes:
- RP1210 calls
- RP1210 .INI file parsing
- Bus that supports multiple listeners
- packet that encapsulates the byte[]
- simulator for development on machines that don't support RP1210
Usage for command line J1939 logger
Usage: Usage: logger [OPTIONS] --adapter <ADAPTER> --device <DEVICE>
RP1210 Devices:
PEAKRP32 PEAK-System PCAN Adapter
--adapter PCAN-USB --device 1: PEAK-System CAN Adapter (USB, 1 Channel)
Options:
-D, --adapter <ADAPTER>
RP1210 Adapter Identifier
-d, --device <DEVICE>
RP1210 Device ID
-C, --connection-string <CONNECTION_STRING>
RP1210 Connection String [default: J1939:Baud=Auto]
-a, --sa <SOURCE_ADDRESS>
RP1210 Adapter Address (used for packets send and transport protocol) [default: F9]
-v, --verbose
--app-packetize
-h, --help
Print help
API
Example:
// request VIN from ECM
// start collecting packets
let mut packets = rp1210.iter_for(Duration::from_secs(5));
// send request for VIN
rp1210.push(J1939Packet::new(1, 0x18EA00F9, &[0xEC, 0xFE, 0x00]));
// filter for ECM result
packets
.find(|p| p.pgn() == 0xFEEC && p.source() == 0)
// log the VINs
.map(|p| {
print!(
"ECM {:02X} VIN: {}\n{}",
p.source(),
String::from_utf8(p.data.clone()).unwrap(),
p
)
});
Applications
When combined with DBC or J1939DA parsing, this becomes a light weight CAN logger. See https://github.com/SolidDesignNet/j1939logger.
Note for Linux setup:
slcan setup:
slcand /dev/ttyACM0
ip link set can0 name slcan
ip link set slcan type can bitrate 500000
ip link set slcan up
PEAK
ip link set can0 name peak
ip link set peak type can bitrate 500000
ip link set peak up
Dependencies
~5–13MB
~158K SLoC