Skip to content

Commit

Permalink
Revert "Allow a single retry with wrong msg_type"
Browse files Browse the repository at this point in the history
This reverts commit c1d2245.
  • Loading branch information
aesteve-rh committed Feb 2, 2024
1 parent c1d2245 commit 5184eed
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ impl Vhal {

pub fn get_gear_selection(&self) -> Result<c::VehicleGear> {
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)?)
Expand All @@ -342,8 +343,8 @@ impl Vhal {

pub fn get_vehicle_speed(&self) -> Result<f32> {
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()
}

Expand All @@ -354,8 +355,8 @@ impl Vhal {

pub fn get_vehicle_display_speed(&self) -> Result<f32> {
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()
}

Expand Down Expand Up @@ -426,17 +427,6 @@ impl Vhal {

Ok(msg)
}

fn recv_retry(&self) -> Result<EmulatorMessage> {
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)]
Expand Down

0 comments on commit 5184eed

Please sign in to comment.