Skip to content

Commit

Permalink
Add RCDisplayField record. Fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
lvauvillier committed Jun 18, 2024
1 parent b1fe258 commit 2a961e2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
2 changes: 2 additions & 0 deletions dji-log-parser/src/keychain/feature_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ impl FeaturePoint {
58 => FeaturePoint::BaseFeature,
// FCIMUInfoDataType
59 => FeaturePoint::BaseFeature,
// RemoteControllerDisplayField
62 => FeaturePoint::RCFeature,
// FlightControllerCommonOSDField
63 => FeaturePoint::BaseFeature,
// Default
Expand Down
20 changes: 16 additions & 4 deletions dji-log-parser/src/record/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod mc_param;
mod ofdm;
mod osd;
mod rc;
mod rc_display_field;
mod rc_gps;
mod recover_info;
mod smart_battery;
Expand All @@ -47,6 +48,7 @@ pub use mc_param::MCParams;
pub use ofdm::OFDM;
pub use osd::OSD;
pub use rc::RC;
pub use rc_display_field::RCDisplayField;
pub use rc_gps::RCGPS;
pub use recover_info::RecoverInfo;
pub use smart_battery::SmartBattery;
Expand Down Expand Up @@ -273,6 +275,12 @@ pub enum Record {
OFDM,
#[br(temp, assert(self_2 == END_BYTE))] u8,
),
#[br(magic = 50u8)]
Recover(
#[br(temp, args(version <= 12), parse_with = utils::read_u16)] u16,
#[br(count = self_0)] Vec<u8>,
#[br(temp, assert(self_2 == 0xff))] u8,
),
#[br(magic = 56u8)]
KeyStorage(
#[br(temp, args(version <= 12), parse_with = utils::read_u16)] u16,
Expand All @@ -283,11 +291,15 @@ pub enum Record {
KeyStorage,
#[br(temp, assert(self_2 == END_BYTE))] u8,
),
#[br(magic = 50u8)]
Recover(
#[br(magic = 62u8)]
RCDisplayField(
#[br(temp, args(version <= 12), parse_with = utils::read_u16)] u16,
#[br(count = self_0)] Vec<u8>,
#[br(temp, assert(self_2 == 0xff))] u8,
#[br(
pad_size_to = self_0,
map_stream = |reader| record_decoder(reader, 62, version, keychain, self_0),
)]
RCDisplayField,
#[br(temp, assert(self_2 == END_BYTE))] u8,
),
JPEG(#[br(parse_with = utils::read_jpeg)] Vec<u8>),
// Valid record of unknown data
Expand Down
20 changes: 20 additions & 0 deletions dji-log-parser/src/record/rc_display_field.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use binrw::binread;
use serde::Serialize;

#[binread]
#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
#[br(little)]
pub struct RCDisplayField {
#[br(temp)]
_unknown: [u8; 7],
/// right stick - horizontal
pub aileron: u16,
/// right stick - vertical
pub elevator: u16,
/// left stick - vertical
pub throttle: u16,
/// left stick - horizontal
pub rudder: u16,
pub gimbal: u16,
}

0 comments on commit 2a961e2

Please sign in to comment.