diff --git a/src/frames/mod.rs b/src/frames/mod.rs index 2270abf..1d40abc 100644 --- a/src/frames/mod.rs +++ b/src/frames/mod.rs @@ -134,7 +134,7 @@ pub fn parse_frame(data: &[u8]) -> Result { _ => Ok(FrameType::LongFrame{ function: Function::from(data[4])?, address: Address::from(data[5]), - data: &data[7..data.len() - 2], + data: &data[6..data.len() - 2], }), } }, diff --git a/src/lib.rs b/src/lib.rs index 019d9f9..961f8ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,5 +2,12 @@ mod frames; mod user_data; pub fn parse_frame(data: &[u8]) -> Result { - frames::parse_frame(data) + let frame = frames::parse_frame(data); + + if let Ok(frames::FrameType::LongFrame{function, address, data}) = &frame { + let user_data = user_data::parse_user_data(data); + println!("Function: {:?}, Address: {:?}, User Data: {:?}", function, address, user_data); + } + + frame } diff --git a/src/user_data/mod.rs b/src/user_data/mod.rs index 6b9f76f..3a8be29 100644 --- a/src/user_data/mod.rs +++ b/src/user_data/mod.rs @@ -131,7 +131,7 @@ impl std::fmt::Display for IdentificationNumberError { impl std::error::Error for IdentificationNumberError {} -#[derive(Debug, Clone, Copy)] +#[derive(Debug, PartialEq)] pub struct IdentificationNumber { number: u32, } @@ -155,6 +155,7 @@ impl IdentificationNumber { } +#[derive(Debug, PartialEq)] pub enum UserDataBlock { ResetAtApplicationLevel{subcode: ApplicationResetSubcode}, FixedDataStructure{ @@ -172,7 +173,7 @@ pub enum UserDataError { InvalidUserData, } -fn parse_user_data(data: &[u8]) -> Result { +pub fn parse_user_data(data: &[u8]) -> Result { let control_information = ControlInformation::from(data[0])?;