Skip to content

Commit

Permalink
add CfgEsfWt message
Browse files Browse the repository at this point in the history
- this message is available on Series 8 devices
- for series 9 it is considered legacy and there is no gurantee
  according to the manual that it will work. Series 9 devices introduced
  a new set of messages specific for ADR produts. See reference manual
  from uBlox.
- this messages has been tested for Vehicle Speed configuration on F9R
  devices and it worked

Signed-off-by: Andrei Gherghescu <[email protected]>
  • Loading branch information
andrei-ng committed Jan 31, 2025
1 parent 194c79e commit 2601a30
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

## [0.1.0] - 2025-xx-xx
### Added
- [[#28](https://github.com/andrei-ng/u-blox.rs/pull/28)] Add UBX-CFG-ESFWT message
- [[#27](https://github.com/andrei-ng/u-blox.rs/pull/27)] Merge [ublox-rs/ublox/pull/24](https://github.com/ublox-rs/ublox/pull/24) PR that adds `UBX-NAV-RELPOSNED` into this repository.
- remove duplicate package definition `MgaGpsEph`
- add features flags to differentiate between uBlox Series 8 and uBlox Series 9 devices; As `UBX-NAV-RELPOSNED` has different lengths depending on the protocol /series.
49 changes: 39 additions & 10 deletions examples/adr-message-parsing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ fn main() {
)
.expect("Could not configure ports for UBX-CFG-ESFALG");

device
.write_all(
&CfgMsgAllPortsBuilder::set_rate_for::<EsfAlg>([0, 1, 0, 1, 0, 0]).into_packet_bytes(),
)
.expect("Could not configure ports for UBX-ESF-INS");

device
.write_all(
&CfgMsgAllPortsBuilder::set_rate_for::<NavPvt>([0, 0, 0, 0, 0, 0]).into_packet_bytes(),
Expand Down Expand Up @@ -173,12 +167,40 @@ fn main() {
)
.expect("Could not write UBX-CFG-ESFALG msg due to: {e}");

// Send packet request to read the new CfgEsfAlg
device
.write_all(&UbxPacketRequest::request_for::<CfgEsfAlg>().into_packet_bytes())
.expect("Unable to write request/poll for UBX-CFG-ESFALG message");

// Start reading data
device
.write_all(
&CfgMsgAllPortsBuilder::set_rate_for::<CfgEsfAlg>([0, 1, 0, 1, 0, 0])
.into_packet_bytes(),
)
.expect("Could not configure ports for UBX-ESF-INS");

// Configure Wheel Speed for ESF
device
.write_all(
&ublox::CfgEsfWtBuilder {
flags1: CfgEsfWtFlags1::USE_WHEEL_TICK_SPEED,
wt_frequency: 13,
..Default::default()
}
.into_packet_bytes(),
)
.expect("Could not write UBX-CFG-ESFALG msg due to: {e}");

device
.write_all(&UbxPacketRequest::request_for::<CfgEsfWt>().into_packet_bytes())
.expect("Unable to write request/poll for UBX-CFG-ESFALG message");

device
.write_all(
&CfgMsgAllPortsBuilder::set_rate_for::<CfgEsfWt>([0, 1, 0, 1, 0, 0])
.into_packet_bytes(),
)
.expect("Could not configure ports for UBX-ESF-INS");

println!("Opened uBlox device, waiting for messages...");
loop {
device
Expand All @@ -191,6 +213,14 @@ fn main() {
packet.extension().collect::<Vec<&str>>()
);
},
PacketRef::CfgEsfWt(msg) => {
println!("Received: {:?}", msg);
},
PacketRef::CfgEsfAlg(msg) => {
println!("Received: {:?}", msg);
},


PacketRef::EsfStatus(status) => {
println!(
"EsfStatus: tow: {}, version: {}, {:?},{:?}, fusion_mode: {:?}, num_sens: {}",
Expand All @@ -215,9 +245,8 @@ fn main() {
}
println!("calib_tag: {:?}", msg.calib_tag());
},

_ => {
println!("{:?}", packet);
{} //println!("{:?}", packet);
},
})
.unwrap();
Expand Down
84 changes: 84 additions & 0 deletions ublox/src/ubx_packets/packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2869,6 +2869,89 @@ impl fmt::Debug for CfgEsfAlgFlags {
}
}

/// Get/set wheel-tick configuration
/// Only available for ADR products
#[ubx_packet_recv_send]
#[ubx(
class = 0x06,
id = 0x82,
fixed_payload_len = 32,
flags = "default_for_builder"
)]
struct CfgEsfWt {
version: u8,

#[ubx(map_type = CfgEsfWtFlags1)]
flags1: u8,

#[ubx(map_type = CfgEsfWtFlags2)]
flags2: u8,
reserved1: u8,

/// Wheel tick scaling factor
#[ubx(map_type = f64, scale = 1e-6)]
wt_factor: u32,

/// Wheel tick quantization
#[ubx(map_type = f64, scale = 1e-6)]
wt_quant_error: u32,

/// Wheel tick counter maximum value
wt_count_max: u32,

/// Wheel tick latency due to e.g. CAN bus
wt_latency: u16,

/// Nominal wheel tick data frequency
wt_frequency: u8,

#[ubx(map_type = CfgEsfWtFlags3)]
flags3: u8,

/// Speed sensor dead band
speed_dead_band: u16,

reserved2: [u8; 10],
}

#[ubx_extend_bitflags]
#[ubx(from, into_raw, rest_reserved)]
bitflags! {
#[derive(Default, Debug)]
pub struct CfgEsfWtFlags1 : u8 {
/// Use combined rear wheel-ticks
const COMBINED_TICKS = 0x01;
/// Low-speed COG filter enabled flag
const USE_WHEEL_TICK_SPEED = 0x10;
/// Direction pin polarity
const DIR_PIN_POLARITY = 0x20;
/// Use wheel tick pin for speed measurement
const USE_WT_PIN = 0x40;
}
}

#[ubx_extend_bitflags]
#[ubx(from, into_raw, rest_reserved)]
bitflags! {
#[derive(Default, Debug)]
pub struct CfgEsfWtFlags2 : u8 {
const AUTO_WT_COUNT_MAX_OFF = 0x01;
const AUTO_DIR_PIN_POL_OFF = 0x02;
const AUTO_SOFTWARE_WT_OFF = 0x04;
const AUTO_USE_WT_SPEED_OFF = 0x08;
}
}

#[ubx_extend_bitflags]
#[ubx(from, into_raw, rest_reserved)]
bitflags! {
#[derive(Default, Debug)]
pub struct CfgEsfWtFlags3 : u8 {
/// Count both rising and falling edges of wheel-tick
const CNT_BOTH_EDGES = 0x01;
}
}

#[ubx_extend]
#[ubx(from, rest_reserved)]
#[repr(u8)]
Expand Down Expand Up @@ -4526,6 +4609,7 @@ define_recv_packets!(
CfgTmode3,
CfgTp5,
CfgEsfAlg,
CfgEsfWt,
EsfAlg,
EsfIns,
EsfMeas,
Expand Down

0 comments on commit 2601a30

Please sign in to comment.