diff --git a/candid_server/src/client_handler.rs b/candid_server/src/client_handler.rs index f9fe21d..5812531 100644 --- a/candid_server/src/client_handler.rs +++ b/candid_server/src/client_handler.rs @@ -42,13 +42,12 @@ pub fn new_client_handler( loop { // Get an incoming frame from the client - let id: u32; - match connection.read_u32::() { - Ok(inner) => id = inner, - Err(_) => { - println!("Connection to client {:?} dropped.", ip); - break; - } + let id; + if let Ok(inner) = connection.read_u32::() { + id = inner; + } else { + println!("Connection to client {:?} dropped.", ip); + break; } let mut data = [0 as u8; 8]; @@ -57,12 +56,9 @@ pub fn new_client_handler( break; } - let frame = CANFrame::new(id, &data, false, false).unwrap(); - println!("New frame {:X}", frame); - // Write the frame to the CAN Socket + let frame = CANFrame::new(id, &data, false, false).unwrap(); can_socket.write_frame_insist(&frame).unwrap(); - println!("Written"); } });