51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
//! UART/ BLE I/O Protocol
|
|
|
|
pub mod msg {
|
|
#![allow(clippy::all, clippy::pedantic, clippy::nursery, dead_code)]
|
|
include!(concat!(env!("OUT_DIR"), "/c_its_io.rs"));
|
|
}
|
|
|
|
impl From<msg::RawMsgRx> for msg::SerialOutputMsg {
|
|
fn from(value: msg::RawMsgRx) -> Self {
|
|
use msg::serial_output_msg::Payload;
|
|
|
|
Self {
|
|
payload: Some(Payload::RxMsg(value)),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<msg::DenmEvent> for msg::SerialOutputMsg {
|
|
fn from(value: msg::DenmEvent) -> Self {
|
|
use msg::serial_output_msg::Payload;
|
|
|
|
Self {
|
|
payload: Some(Payload::Denm(value)),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<msg::PositionState> for crate::applogic::PositionState {
|
|
fn from(value: msg::PositionState) -> Self {
|
|
let position = geo_types::Point::new(
|
|
value.position.longitude_deg.into(),
|
|
value.position.latitude_deg.into(),
|
|
);
|
|
let heading_deg = value.heading.map(|v| {
|
|
#[allow(clippy::cast_precision_loss)]
|
|
let val = (v as f32) / 10.;
|
|
val
|
|
});
|
|
let speed_mps = value.speed.map(|v| {
|
|
#[allow(clippy::cast_precision_loss)]
|
|
let val = (v as f32) / 100.;
|
|
val
|
|
});
|
|
|
|
Self {
|
|
position,
|
|
heading_deg,
|
|
speed_mps,
|
|
}
|
|
}
|
|
}
|