- Notifications
You must be signed in to change notification settings - Fork81
Closed
Description
This is code:
use socketcan::{CanFdSocket,Socket};use std::error::Error;fnmain() ->Result<(),Box<dynError>>{// Open the CAN devicelet socket =CanFdSocket::open("can0")?;// Set non-blocking mode socket.set_nonblocking(true).map_err(|e|{eprintln!("Failed to set non-blocking mode: {}", e); e})?;loop{// Read CAN framematch socket.read_frame(){Ok(frame) =>{// Print the received CAN frameprintln!("Received frame: {:?}", frame);}Err(e)if e.kind() == std::io::ErrorKind::WouldBlock =>{// If there are no readable frames, continue the loopcontinue;}Err(e) =>{// Handle other errorsdbg!("Error reading frame: {}", e);}}}}
When running, the following is the situation
smirk@veh:~/project/canfuzz$ cargo run Finished`dev` profile [unoptimized + debuginfo] target(s)in 0.10swarning: the following packages contain code that will be rejected by a future version of Rust: bitfwarning: the following packages contain code that will be rejected by a future version of Rust: bitflags v0.4.0note: to see what the problems were, use the option`--future-incompat-report`, or run`cargo reportnote: to see what the problems were, use the option`--future-incompat-report`, or run`cargo report future-incompatibilities --id 1` Running`target/debug/canfuzz`Received frame: Fd(CanFdFrame { 45##5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00Received frame: Fd(CanFdFrame { 45##5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00thread'main' panicked at core/src/panicking.rs:221:5:unsafe precondition(s) violated: ptr::copy_nonoverlapping requires that both pointer arguments are aunsafe precondition(s) violated: ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null and the specified memory rangesdo not overlapnote: run with`RUST_BACKTRACE=1` environment variable to display a backtracethread caused non-unwinding panic. aborting.Aborted (core dumped)
The panic triggering time is not fixed.
I want to achieve the same functionality as candump, but use candump without interruption, and write my own code to trigger panic
Metadata
Metadata
Assignees
Labels
No labels