Rust crate providing a variety of automotive related libraries, such as communicating with CAN interfaces and diagnostic APIs

Overview

The Automotive Crate

crates.io docs.rs

Welcome to the automotive crate documentation. The purpose of this crate is to help you with all things automotive related. Most importantly, it provides a fully async CAN interface supporting multiple adapters.

Async CAN Example

The following adapter opens the first available adapter on the system, and then receives all frames.

let adapter = automotive::adapter::get_adapter().unwrap();
let mut stream = adapter.recv();

while let Some(frame) = stream.next().await {
    let id: u32 = frame.id.into();
    println!("[{}]\t0x{:x}\t{}", frame.bus, id, hex::encode(frame.data));
}

UDS Example

The automotive crate also supplies interfaces for various diagnostic protocols such as UDS. The adapter is first wrapped to support the ISO Transport Layer, then a UDS Client is created. All methods are fully async, making it easy to communicate with multiple ECUs in parallel. See #21 for progress on the supported SIDs.

let adapter = automotive::adapter::get_adapter().unwrap();
let isotp = automotive::isotp::IsoTPAdapter::from_id(&adapter, 0x7a1);
let uds = automotive::uds::UDSClient::new(&isotp);

uds.tester_present().await.unwrap();
let response = uds.read_data_by_identifier(DataIdentifier::ApplicationSoftwareIdentification as u16).await.unwrap();

println!("Application Software Identification: {}", hex::encode(response));

Suported adapters

The following adapters are supported. Hardware implementations can be blocking, as the AsyncCanAdapter takes care of presenting an async interface to the user.

  • SocketCAN (Linux only, supported using socketcan-rs)
  • comma.ai panda (all platforms)

Roadmap

Features I'd like to add in the future. Also check the issues page.

  • CCP/XCP Client
  • Update file extraction (e.g. .frf and .odx)
  • VIN Decoding
  • J2534 Support on Windows
  • More raw device support, such as ValueCAN and P-CAN by reverse engineering the USB protocol
  • WebUSB support
You might also like...
📊 Collect cloud usage data, so that it can be combined with impact data of Boavizta API.
📊 Collect cloud usage data, so that it can be combined with impact data of Boavizta API.

cloud-scanner Collect aws cloud usage data, so that it can be combined with impact data of Boavizta API. ⚠ Very early Work in progress ! At the moment

A tool to export TiDB database data to files in cases where the TiDB server can't be restored.
A tool to export TiDB database data to files in cases where the TiDB server can't be restored.

tidb-exporter TiDB uses RocksDB as default storage engine(in fact, TiKV uses it). tidb-exporter can export data from pure RocksDB data files even when

Safe Rust crate for creating socket servers and clients with ease.

bitsock Safe Rust crate for creating socket servers and clients with ease. Description This crate can be used for Client -- Server applications of e

Rust utility crate for parsing, encoding and generating x25519 keys used by WireGuard

WireGuard Keys This is a utility crate for parsing, encoding and generating x25519 keys that are used by WireGuard. It exports custom types that can b

Library + CLI-Tool to measure the TTFB (time to first byte) of HTTP requests. Additionally, this crate measures the times of DNS lookup, TCP connect and TLS handshake.

TTFB: CLI + Lib to Measure the TTFB of HTTP/1.1 Requests Similar to the network tab in Google Chrome or Mozilla Firefox, this crate helps you find the

Rust crate for configurable parallel web crawling, designed to crawl for content

url-crawler A configurable parallel web crawler, designed to crawl a website for content. Changelog Docs.rs Example extern crate url_crawler; use std:

Rust crate for scraping URLs from HTML pages

url-scraper Rust crate for scraping URLs from HTML pages. Example extern crate url_scraper; use url_scraper::UrlScraper; fn main() { let director

Dav-server-rs - Rust WebDAV server library. A fork of the webdav-handler crate.

dav-server-rs A fork of the webdav-handler-rs project. Generic async HTTP/Webdav handler Webdav (RFC4918) is defined as HTTP (GET/HEAD/PUT/DELETE) plu

The netns-rs crate provides an ultra-simple interface for handling network namespaces in Rust.

netns-rs The netns-rs crate provides an ultra-simple interface for handling network namespaces in Rust. Changing namespaces requires elevated privileg

Comments
  • [uds] support response pending

    [uds] support response pending

    Add method on ISO-TP to return a stream. This can be used to wait for the next response from the ECU without risking to drop a packet when resubscribing again.

    opened by pd0wm 0
  • [AsyncCAN] Ensure send future resolves when packet is ACKed

    [AsyncCAN] Ensure send future resolves when packet is ACKed

    Currently the send future resolves as soon as it's sent to the background thread. This makes it not possible to properly implement frame separation between ISO-TP frames when there is other traffic on the bus.

    TODO:

    • [x] Delay resolving send future: https://github.com/I-CAN-hack/automotive/commit/d3e40dd298959a6b782a033c2dbe90530a3ff671
    • [ ] Call callback when frame is actually received https://github.com/I-CAN-hack/automotive/pull/30
    • [ ] Test that all adapters return frames in the same order as they were queued to send
    enhancement 
    opened by pd0wm 2
  • UDS Client

    UDS Client

    Implement all UDS SIDs from ISO Standard

    • [ ] Diagnostic and Communication Management
      • [x] DiagnosticSessionControl = 0x10
      • [x] EcuReset = 0x11
      • [x] SecurityAccess = 0x27
      • [ ] CommunicationControl = 0x28
      • [x] TesterPresent = 0x3e
      • [ ] AccessTimingParameter = 0x83
      • [ ] SecuredDataTransmission = 0x84
      • [ ] ControlDTCSetting = 0x85
      • [ ] ResponseOnEvent = 0x86
      • [ ] LinkControl = 0x87
    • [ ] Data Transmission
      • [x] ReadDataByIdentifier = 0x22
      • [x] ReadMemoryByAddress = 0x23
      • [ ] ReadScalingDataByIdentifier = 0x24
      • [ ] ReadDataByPeriodicIdentifier = 0x2a
      • [ ] DynamicallyDefineDataIdentifier = 0x2c
      • [x] WriteDataByIdentifier = 0x2e
      • [x] WriteMemoryByAddress = 0x3d
    • [ ] Stored Data Transmission
      • [ ] ClearDiagnosticInformation = 0x14
      • [ ] ReadDTCInformation = 0x19
    • [ ] Input/Output Control
      • [ ] InputOutputControlByIdentifier = 0x2f
    • [x] Routine
      • [x] RoutineControl = 0x31
    • [ ] Upload/Download
      • [x] RequestDownload = 0x34
      • [x] RequestUpload = 0x35
      • [x] TransferData = 0x36
      • [x] RequestTransferExit = 0x37
      • [ ] RequestFileTransfer = 0x38
    enhancement 
    opened by pd0wm 0
Releases(v0.1.4)
  • v0.1.4(Feb 24, 2024)

    What's Changed

    • Added many UDS sids. Now supporting all needed SIDs to reflash an ECU.
      • 0x10 - Diagnostic Session Control
      • 0x27 - Security Access
      • 0x2E - Write Data by Identifier
      • 0x34 - Request Download
      • 0x35 - Request Upload
      • 0x36 - Transfer Data
      • 0x11 - ECU Reset
      • 0x23 - Read Memory by Address
      • 0x3D - Write Memory by Address
      • 0x31 - Routine Control

    Full Changelog: https://github.com/I-CAN-hack/automotive/compare/v0.1.3...v0.1.4

    Source code(tar.gz)
    Source code(zip)
  • v0.1.3(Feb 22, 2024)

Owner
I CAN Hack
Automotive, Embedded and IoT security
I CAN Hack
SOCKS5 implement library, with some useful utilities such as dns-query, socks5-server, dns2socks, udp-client, etc.

socks5-impl Fundamental abstractions and async read / write functions for SOCKS5 protocol and Relatively low-level asynchronized SOCKS5 server impleme

null 5 Aug 3, 2023
Afterglow-Server provides back-end APIs for the Afterglow workflow engine.

Afterglow-Server ?? Note: This project is still heavily in development and is at an early stage. Afterglow-Server provides back-end APIs for the After

梦歆 0 Jun 2, 2022
A simple API gateway written in Rust, using the Hyper and Reqwest libraries.

API Gateway A simple API gateway written in Rust, using the Hyper and Reqwest libraries. This gateway can be used to forward requests to different bac

Adão Raul 3 Apr 24, 2023
A collection of lower-level libraries for composable network services.

Actix Net A collection of lower-level libraries for composable network services. Example See actix-server/examples and actix-tls/examples for some bas

Actix 582 Dec 28, 2022
Reverse proxy for HTTP microservices and STDIO. Openfass watchdog which can run webassembly with wasmer-gpu written in rust.

The of-watchdog implements an HTTP server listening on port 8080, and acts as a reverse proxy for running functions and microservices. It can be used independently, or as the entrypoint for a container with OpenFaaS.

yanghaku 7 Sep 15, 2022
Tiny CLI application in rust to scan ports from a given IP and find how many are open. You can also pass the amount of threads for that scan

Port Scanner A simple multi-threaded port scanner written in Rust. Usage Run the port scanner by providing the target IP address and optional flags. $

nicolas lopes 4 Aug 29, 2023
「🧱」Test a list of payloads and see if you can bypass it

「 ?? 」About TTWAF TTWAF, or Test This WAF, is a Web Application Firewall (WAF) bypass testing tool. You can test a list of payloads like XSS, LFI, RCE

Amolo Hunters 20 Dec 2, 2022
Implementation of the Docker Registry HTTP API V2 in Rust, that can act as a proxy to other registries

Docker registry server and proxy (I'm bad at creating catchy names, but this one is good enough.) This project aims to implement a Docker Registry HTT

l4p1n (Mathias B.) 2 Dec 30, 2022
Transforms UDP stream into (fake) TCP streams that can go through Layer 3 & Layer 4 (NAPT) firewalls/NATs.

Phantun A lightweight and fast UDP to TCP obfuscator. Table of Contents Phantun Latest release Overview Usage 1. Enable Kernel IP forwarding 2. Add re

Datong Sun 782 Dec 30, 2022
The goal of this challenge is to create an isometric, decorated scene in which the character can move around the objects in the room.

The goal of this challenge is to create an isometric, decorated scene in which the character can move around the objects in the room.

Ivan Reshetnikov 0 Feb 4, 2022