// socketcan/examples/async_std_bridge.rs // // Example application for using async-std with socketcan-rs. // // This file is part of the Rust 'socketcan-rs' library. // // Licensed under the MIT license: // // This file may not be copied, modified, or distributed except according // to those terms. //! A SocketCAN example using async-std. //! //! This sends CAN data frames received on one interface to another. //! use socketcan::{async_std::CanSocket, CanFrame, Result}; #[async_std::main] async fn main() -> Result<()> { let sock_rx = CanSocket::open("vcan0")?; let sock_tx = CanSocket::open("can0")?; loop { let frame = sock_rx.read_frame().await?; if matches!(frame, CanFrame::Data(_)) { sock_tx.write_frame(&frame).await?; } } }