|
| 1 | +# `ace-gateway` |
| 2 | + |
| 3 | +DoIP gateway, ISO-TP bridge node, and DoIP tester. |
| 4 | + |
| 5 | +**`DoipGateway<A, MAX_TESTERS, BUF>`** — gateway state machine. Translates DoIP frames from TCP into UDS bytes on CAN, and CAN responses back into DoIP frames. Has two faces — `handle_tcp` and `handle_can` — because it spans two buses. Routing table maps DoIP logical addresses to CAN IDs. |
| 6 | + |
| 7 | +**`IsoTpNode<N>`** — bridges raw UDS bytes to ISO-TP CAN frames. Two independent segmenters (request and response directions) to handle concurrent multi-frame exchanges. Key methods: `handle_from_gateway(uds_data)`, `handle_uds_response(uds_data)`, `handle_from_ecu(can_frame)`. |
| 8 | + |
| 9 | +**`DoipTester<MAX_CONNECTIONS, MAX_TARGETS>`** — models a physical DoIP tester device. Owns multiple `DoipConnection`s (one per TCP connection). Each connection addresses multiple ECUs simultaneously via `target_address`. P2/P2* timeouts are learned dynamically from `DiagnosticSessionControlResponse`. Events are tagged `(ConnectionId, TargetId, DoipTesterEvent)`. |
| 10 | + |
| 11 | +```rust |
| 12 | +let mut tester = DoipTester::<4, 8>::new(0x0E00, NodeAddress(0x0E00)); |
| 13 | + |
| 14 | +// Open a connection to a gateway |
| 15 | +let conn = tester.open_connection(DoipConnectionConfig::new(0x0E80))?; |
| 16 | + |
| 17 | +// After TCP connects (TcpSimBus::connect or real TcpStream): |
| 18 | +// tester.on_tcp_event(&TcpEvent::ConnectionEstablished { .. }, now); |
| 19 | +// → automatically sends RoutingActivationRequest |
| 20 | + |
| 21 | +// Send UDS to ECU 0x0001 on that connection |
| 22 | +tester.request(conn, 0x0001, &[0x10, 0x03], now)?; |
| 23 | + |
| 24 | +// Drain events |
| 25 | +for (conn_id, target_id, event) in tester.drain_events() { |
| 26 | + // ... |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +Node profiles accumulate from UDP announcements: |
| 31 | + |
| 32 | +```rust |
| 33 | +if let Some(profile) = tester.profile(0x0E80) { |
| 34 | + println!("VIN: {:?}", profile.vin); |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +**`GatewayConfig`** builder: |
| 39 | + |
| 40 | +```rust |
| 41 | +let config = GatewayConfig::new(0x0E80) |
| 42 | + .with_tester(0x0E00) |
| 43 | + .with_node(CanNodeEntry { |
| 44 | + logical_address: 0x0001, |
| 45 | + request_can_id: 0x7E0, |
| 46 | + response_can_id: 0x7E8, |
| 47 | + functional_can_id: 0x7DF, |
| 48 | + }); |
| 49 | +``` |
0 commit comments