Skip to content

marcelbuesing/tokio-socketcan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crates.io badge

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

About

Asynchronous Linux SocketCAN sockets with tokio

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%