Skip to content

Commit

Permalink
Merge pull request #132 from quartiq/rs/issue-130/blocked-status
Browse files Browse the repository at this point in the history
Adding blocked reason to state reporting
  • Loading branch information
ryan-summers authored Jan 20, 2021
2 parents 4bdc3f1 + 8fef435 commit db9135d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/rf_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct SupplyMeasurements {
pub enum ChannelFault {
OverTemperature,
UnderTemperature,
OverCurrent,
SupplyAlert,
}

/// Represents the three power interlocks present on the device.
Expand Down Expand Up @@ -97,8 +97,14 @@ pub enum ChannelState {
impl serde::Serialize for ChannelState {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
match *self {
ChannelState::Blocked(_) => {
serializer.serialize_unit_variant("ChannelState", 0, "Blocked")
ChannelState::Blocked(ChannelFault::SupplyAlert) => {
serializer.serialize_unit_variant("ChannelState", 0, "Blocked(SupplyAlert)")
}
ChannelState::Blocked(ChannelFault::UnderTemperature) => {
serializer.serialize_unit_variant("ChannelState", 0, "Blocked(UnderTempeterature)")
}
ChannelState::Blocked(ChannelFault::OverTemperature) => {
serializer.serialize_unit_variant("ChannelState", 0, "Blocked(OverTemperature)")
}
ChannelState::Disabled => {
serializer.serialize_unit_variant("ChannelState", 1, "Disabled")
Expand Down Expand Up @@ -579,7 +585,7 @@ impl RfChannel {
} else if temperature < 5.0 {
Some(ChannelFault::UnderTemperature)
} else if self.pins.alert.is_low().unwrap() {
Some(ChannelFault::OverCurrent)
Some(ChannelFault::SupplyAlert)
} else {
None
}
Expand Down

0 comments on commit db9135d

Please sign in to comment.