#tokio #socketcan #linux #sockets

tokio-socketcan

Asynchronous Linux SocketCAN sockets with tokio

4 releases

✓ Uses Rust 2018 edition

0.1.3 Feb 23, 2019
0.1.2 Feb 8, 2019
0.1.1 Jan 10, 2019
0.1.0 Jan 10, 2019
Download history 16/week @ 2019-01-08 10/week @ 2019-01-15 6/week @ 2019-01-22 8/week @ 2019-01-29 11/week @ 2019-02-05 6/week @ 2019-02-12 18/week @ 2019-02-19 17/week @ 2019-02-26 12/week @ 2019-03-05 31/week @ 2019-03-12 62/week @ 2019-03-19 49/week @ 2019-03-26

82 downloads per month

MIT license

13KB
212 lines

crates.io badge documentation

tokio-socketcan

SocketCAN support for tokio based on the socketcan crate.

Example echo server

use futures::stream::Stream;
use futures::future::{self, Future};

let socket_rx = tokio_socketcan::CANSocket::open("vcan0").unwrap();
let socket_tx = tokio_socketcan::CANSocket::open("vcan0").unwrap();

tokio::run(socket_rx.for_each(move |frame| {
    socket_tx.write_frame(frame)
}).map_err(|_err| {}));

Testing

Integrating the test into a CI system is non-trivial as it relies on a vcan0 virtual can device existing. Adding one to most linux systems is pretty easy with root access but attaching a vcan device to a container for CI seems difficult to find support for.

To run the tests locally, though, setup should be simple:

sudo modprobe vcan
sudo ip link add vcan0 type vcan
sudo ip link set vcan0 up
cargo test

Changelog

0.1.2

  • Added futures::sink::Sink implementation for the CANSocket

Dependencies

~3MB
~52K SLoC