diff --git a/Cargo.toml b/Cargo.toml index 4d26abf..81aa652 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ecu_diagnostics" -version = "0.95.1" +version = "0.95.2" authors = ["Ashcon Mohseninia "] edition = "2021" description = "A rust crate for ECU diagnostic servers and communication APIs" diff --git a/src/hardware/socketcan.rs b/src/hardware/socketcan.rs index 0a4fb53..9d3281a 100644 --- a/src/hardware/socketcan.rs +++ b/src/hardware/socketcan.rs @@ -122,7 +122,7 @@ impl PacketChannel for SocketCanCanChannel { } let channel = socketcan::CANSocket::open(&self.device.info.name)?; channel.filter_accept_all()?; - channel.set_nonblocking(true)?; + channel.set_nonblocking(false)?; self.channel = Some(channel); self.device.canbus_active.store(true, Ordering::Relaxed); Ok(()) @@ -153,6 +153,7 @@ impl PacketChannel for SocketCanCanChannel { let timeout = std::cmp::max(1, timeout_ms) as u128; let mut result: Vec = Vec::with_capacity(max); self.safe_with_iface(|iface| { + iface.set_read_timeout(std::time::Duration::from_millis(timeout_ms as u64))?; let start = Instant::now(); let mut read: socketcan::CANFrame; while start.elapsed().as_millis() <= timeout {