diff --git a/src/lib.rs b/src/lib.rs index c118c19..d5f160e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -329,7 +329,8 @@ impl Vhal { pub fn get_gear_selection(&self) -> Result { self.get_property(VehicleProperty::GEAR_SELECTION, 0)?; - let resp = self.recv_retry()?; + let resp = self.recv_cmd()?; + resp.is_valid(VehicleHalProto::MsgType::GET_PROPERTY_RESP)?; Ok(c::VehicleGear::try_from(resp.expect_i32()?) .map_err(|_| VhalError::ReceiveMessageValueError)?) @@ -342,8 +343,8 @@ impl Vhal { pub fn get_vehicle_speed(&self) -> Result { self.get_property(VehicleProperty::PERF_VEHICLE_SPEED, 0)?; - let resp = self.recv_retry()?; - + let resp = self.recv_cmd()?; + resp.is_valid(VehicleHalProto::MsgType::GET_PROPERTY_RESP)?; resp.expect_f32() } @@ -354,8 +355,8 @@ impl Vhal { pub fn get_vehicle_display_speed(&self) -> Result { self.get_property(VehicleProperty::PERF_VEHICLE_SPEED_DISPLAY, 0)?; - let resp = self.recv_retry()?; - + let resp = self.recv_cmd()?; + resp.is_valid(VehicleHalProto::MsgType::GET_PROPERTY_RESP)?; resp.expect_f32() } @@ -426,17 +427,6 @@ impl Vhal { Ok(msg) } - - fn recv_retry(&self) -> Result { - let mut resp = self.recv_cmd()?; - if resp.is_valid(VehicleHalProto::MsgType::GET_PROPERTY_RESP).is_err() { - // Allow a single retry. - resp = self.recv_cmd()?; - resp.is_valid(VehicleHalProto::MsgType::GET_PROPERTY_RESP)?; - } - - Ok(resp) - } } #[cfg(test)]