Updated adsb stuff
This commit is contained in:
@@ -141,7 +141,7 @@ impl TryFrom<u8> for Capability {
|
||||
return Err(Error::new(
|
||||
ErrorKind::InvalidData,
|
||||
format!("invalid CA value: {}", value),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
Ok(capability)
|
||||
@@ -164,9 +164,8 @@ impl TryFrom<u8> for Capability {
|
||||
pub enum ADSBMessage {
|
||||
AircraftIdentification(AircraftIdentification),
|
||||
SurfacePosition(SurfacePosition),
|
||||
AirbornePositionBaro(AirbornePositionBaro),
|
||||
AirbornePosition(AirbornePosition),
|
||||
AirborneVelocities(AirborneVelocities),
|
||||
AirbornePositionGNSS(AirbornePositionGNSS),
|
||||
Reserved(u8),
|
||||
AircraftStatus(AircraftStatus),
|
||||
TargetState(TargetState),
|
||||
@@ -188,9 +187,9 @@ impl ADSBMessage {
|
||||
ADSBMessage::AircraftIdentification(AircraftIdentification::decode(type_code, data)?)
|
||||
}
|
||||
5..=8 => ADSBMessage::SurfacePosition(SurfacePosition::decode(data)?),
|
||||
9..=18 => ADSBMessage::AirbornePositionBaro(AirbornePositionBaro::decode(data)?),
|
||||
9..=18 => ADSBMessage::AirbornePosition(AirbornePosition::decode(type_code, data)?),
|
||||
19 => ADSBMessage::AirborneVelocities(AirborneVelocities::decode(data)?),
|
||||
20..=22 => ADSBMessage::AirbornePositionGNSS(AirbornePositionGNSS::decode(data)?),
|
||||
20..=22 => ADSBMessage::AirbornePosition(AirbornePosition::decode(type_code, data)?),
|
||||
23..=27 => ADSBMessage::Reserved(type_code),
|
||||
28 => ADSBMessage::AircraftStatus(AircraftStatus::decode(data)?),
|
||||
29 => ADSBMessage::TargetState(TargetState::decode(data)?),
|
||||
@@ -199,7 +198,7 @@ impl ADSBMessage {
|
||||
return Err(Error::new(
|
||||
ErrorKind::InvalidData,
|
||||
format!("unsupported ADS-B type_code {}", type_code),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -310,10 +309,10 @@ impl SurfacePosition {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct AirbornePositionBaro {}
|
||||
pub struct AirbornePosition {}
|
||||
|
||||
impl AirbornePositionBaro {
|
||||
pub fn decode(_data: &[u8]) -> Result<Self> {
|
||||
impl AirbornePosition {
|
||||
pub fn decode(_type_code: u8, _data: &[u8]) -> Result<Self> {
|
||||
Ok(Self {})
|
||||
}
|
||||
}
|
||||
@@ -327,15 +326,6 @@ impl AirborneVelocities {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct AirbornePositionGNSS {}
|
||||
|
||||
impl AirbornePositionGNSS {
|
||||
pub fn decode(_data: &[u8]) -> Result<Self> {
|
||||
Ok(Self {})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct AircraftStatus {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::io::{Error, ErrorKind, Result};
|
||||
|
||||
pub mod adsb;
|
||||
pub mod adsb_frame;
|
||||
pub mod device;
|
||||
|
||||
pub fn hex_to_bytes(s: &str) -> Result<Vec<u8>> {
|
||||
@@ -20,7 +20,7 @@ pub fn hex_to_bytes(s: &str) -> Result<Vec<u8>> {
|
||||
return Err(Error::new(
|
||||
ErrorKind::InvalidInput,
|
||||
format!("invalid hex char '{}'", chunk[0] as char),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
let lo = match hex_val(chunk[1]) {
|
||||
@@ -29,7 +29,7 @@ pub fn hex_to_bytes(s: &str) -> Result<Vec<u8>> {
|
||||
return Err(Error::new(
|
||||
ErrorKind::InvalidInput,
|
||||
format!("invalid hex char '{}'", chunk[1] as char),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
out.push((hi << 4) | lo);
|
||||
|
||||
Reference in New Issue
Block a user