Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generator/sbpg/targets/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def render_source(output_dir, package_spec):
if 'types' in includes:
del includes[includes.index('types')]
with open(destination_filename, 'w') as f:
f.write(py_template.render(msgs=sorted(package_spec.definitions, key=lambda msg: msg.sbp_id),
f.write(py_template.render(msgs=sorted(package_spec.definitions, key=lambda msg: msg.identifier),
pkg_name=name,
filepath="/".join(package_spec.filepath) + ".yaml",
description=package_spec.description,
Expand Down
96 changes: 48 additions & 48 deletions rust/sbp/src/messages/acquisition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,39 +162,42 @@ impl AcqSvProfileDep {
}
}

/// Deprecated
/// Satellite acquisition result
///
/// Deprecated.
/// This message describes the results from an attempted GPS signal
/// acquisition search for a satellite PRN over a code phase/carrier
/// frequency range. It contains the parameters of the point in the
/// acquisition search space with the best carrier-to-noise (CN/0)
/// ratio.
///
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug)]
#[allow(non_snake_case)]
pub struct MsgAcqResultDepB {
pub struct MsgAcqResult {
pub sender_id: Option<u16>,
/// SNR of best point. Currently in arbitrary SNR points, but will be in
/// units of dB Hz in a later revision of this message.
pub snr: f32,
/// CN/0 of best point
pub cn0: f32,
/// Code phase of best point
pub cp: f32,
/// Carrier frequency of best point
pub cf: f32,
/// GNSS signal for which acquisition was attempted
pub sid: GnssSignalDep,
pub sid: GnssSignal,
}

impl MsgAcqResultDepB {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgAcqResultDepB, crate::Error> {
Ok(MsgAcqResultDepB {
impl MsgAcqResult {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgAcqResult, crate::Error> {
Ok(MsgAcqResult {
sender_id: None,
snr: _buf.read_f32::<LittleEndian>()?,
cn0: _buf.read_f32::<LittleEndian>()?,
cp: _buf.read_f32::<LittleEndian>()?,
cf: _buf.read_f32::<LittleEndian>()?,
sid: GnssSignalDep::parse(_buf)?,
sid: GnssSignal::parse(_buf)?,
})
}
}
impl super::SBPMessage for MsgAcqResultDepB {
const MSG_ID: u16 = 20;
impl super::SBPMessage for MsgAcqResult {
const MSG_ID: u16 = 47;

fn get_sender_id(&self) -> Option<u16> {
self.sender_id
Expand Down Expand Up @@ -249,29 +252,39 @@ impl super::SBPMessage for MsgAcqResultDepA {
}
}

/// Deprecated.
/// Deprecated
///
/// Deprecated.
///
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug)]
#[allow(non_snake_case)]
pub struct MsgAcqSvProfileDep {
pub struct MsgAcqResultDepB {
pub sender_id: Option<u16>,
/// SV profiles during acquisition time
pub acq_sv_profile: Vec<AcqSvProfileDep>,
/// SNR of best point. Currently in arbitrary SNR points, but will be in
/// units of dB Hz in a later revision of this message.
pub snr: f32,
/// Code phase of best point
pub cp: f32,
/// Carrier frequency of best point
pub cf: f32,
/// GNSS signal for which acquisition was attempted
pub sid: GnssSignalDep,
}

impl MsgAcqSvProfileDep {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgAcqSvProfileDep, crate::Error> {
Ok(MsgAcqSvProfileDep {
impl MsgAcqResultDepB {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgAcqResultDepB, crate::Error> {
Ok(MsgAcqResultDepB {
sender_id: None,
acq_sv_profile: AcqSvProfileDep::parse_array(_buf)?,
snr: _buf.read_f32::<LittleEndian>()?,
cp: _buf.read_f32::<LittleEndian>()?,
cf: _buf.read_f32::<LittleEndian>()?,
sid: GnssSignalDep::parse(_buf)?,
})
}
}
impl super::SBPMessage for MsgAcqSvProfileDep {
const MSG_ID: u16 = 30;
impl super::SBPMessage for MsgAcqResultDepB {
const MSG_ID: u16 = 20;

fn get_sender_id(&self) -> Option<u16> {
self.sender_id
Expand Down Expand Up @@ -358,42 +371,29 @@ impl super::SBPMessage for MsgAcqSvProfile {
}
}

/// Satellite acquisition result
/// Deprecated.
///
/// This message describes the results from an attempted GPS signal
/// acquisition search for a satellite PRN over a code phase/carrier
/// frequency range. It contains the parameters of the point in the
/// acquisition search space with the best carrier-to-noise (CN/0)
/// ratio.
/// Deprecated.
///
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug)]
#[allow(non_snake_case)]
pub struct MsgAcqResult {
pub struct MsgAcqSvProfileDep {
pub sender_id: Option<u16>,
/// CN/0 of best point
pub cn0: f32,
/// Code phase of best point
pub cp: f32,
/// Carrier frequency of best point
pub cf: f32,
/// GNSS signal for which acquisition was attempted
pub sid: GnssSignal,
/// SV profiles during acquisition time
pub acq_sv_profile: Vec<AcqSvProfileDep>,
}

impl MsgAcqResult {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgAcqResult, crate::Error> {
Ok(MsgAcqResult {
impl MsgAcqSvProfileDep {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgAcqSvProfileDep, crate::Error> {
Ok(MsgAcqSvProfileDep {
sender_id: None,
cn0: _buf.read_f32::<LittleEndian>()?,
cp: _buf.read_f32::<LittleEndian>()?,
cf: _buf.read_f32::<LittleEndian>()?,
sid: GnssSignal::parse(_buf)?,
acq_sv_profile: AcqSvProfileDep::parse_array(_buf)?,
})
}
}
impl super::SBPMessage for MsgAcqResult {
const MSG_ID: u16 = 47;
impl super::SBPMessage for MsgAcqSvProfileDep {
const MSG_ID: u16 = 30;

fn get_sender_id(&self) -> Option<u16> {
self.sender_id
Expand Down
98 changes: 49 additions & 49 deletions rust/sbp/src/messages/bootload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,6 @@ impl super::SBPMessage for MsgBootloaderHandshakeDepA {
}
}

/// Bootloader jump to application (host => device)
///
/// The host initiates the bootloader to jump to the application.
///
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug)]
#[allow(non_snake_case)]
pub struct MsgBootloaderJumpToApp {
pub sender_id: Option<u16>,
/// Ignored by the device
pub jump: u8,
}

impl MsgBootloaderJumpToApp {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgBootloaderJumpToApp, crate::Error> {
Ok(MsgBootloaderJumpToApp {
sender_id: None,
jump: _buf.read_u8()?,
})
}
}
impl super::SBPMessage for MsgBootloaderJumpToApp {
const MSG_ID: u16 = 177;

fn get_sender_id(&self) -> Option<u16> {
self.sender_id
}

fn set_sender_id(&mut self, new_id: u16) {
self.sender_id = Some(new_id);
}
}

/// Bootloading handshake request (host => device)
///
/// The handshake message request from the host establishes a
Expand Down Expand Up @@ -161,34 +128,29 @@ impl super::SBPMessage for MsgBootloaderHandshakeResp {
}
}

/// Read FPGA device ID over UART response (host <= device)
/// Bootloader jump to application (host => device)
///
/// The device message from the host reads a unique device
/// identifier from the SwiftNAP, an FPGA. The host requests the ID
/// by sending a MSG_NAP_DEVICE_DNA_REQ message. The device
/// responds with a MSG_NAP_DEVICE_DNA_RESP messagage with the
/// device ID in the payload. Note that this ID is tied to the FPGA,
/// and not related to the Piksi's serial number.
/// The host initiates the bootloader to jump to the application.
///
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug)]
#[allow(non_snake_case)]
pub struct MsgNapDeviceDnaResp {
pub struct MsgBootloaderJumpToApp {
pub sender_id: Option<u16>,
/// 57-bit SwiftNAP FPGA Device ID. Remaining bits are padded on the right.
pub dna: Vec<u8>,
/// Ignored by the device
pub jump: u8,
}

impl MsgNapDeviceDnaResp {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgNapDeviceDnaResp, crate::Error> {
Ok(MsgNapDeviceDnaResp {
impl MsgBootloaderJumpToApp {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgBootloaderJumpToApp, crate::Error> {
Ok(MsgBootloaderJumpToApp {
sender_id: None,
dna: crate::parser::read_u8_array_limit(_buf, 8)?,
jump: _buf.read_u8()?,
})
}
}
impl super::SBPMessage for MsgNapDeviceDnaResp {
const MSG_ID: u16 = 221;
impl super::SBPMessage for MsgBootloaderJumpToApp {
const MSG_ID: u16 = 177;

fn get_sender_id(&self) -> Option<u16> {
self.sender_id
Expand Down Expand Up @@ -231,3 +193,41 @@ impl super::SBPMessage for MsgNapDeviceDnaReq {
self.sender_id = Some(new_id);
}
}

/// Read FPGA device ID over UART response (host <= device)
///
/// The device message from the host reads a unique device
/// identifier from the SwiftNAP, an FPGA. The host requests the ID
/// by sending a MSG_NAP_DEVICE_DNA_REQ message. The device
/// responds with a MSG_NAP_DEVICE_DNA_RESP messagage with the
/// device ID in the payload. Note that this ID is tied to the FPGA,
/// and not related to the Piksi's serial number.
///
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug)]
#[allow(non_snake_case)]
pub struct MsgNapDeviceDnaResp {
pub sender_id: Option<u16>,
/// 57-bit SwiftNAP FPGA Device ID. Remaining bits are padded on the right.
pub dna: Vec<u8>,
}

impl MsgNapDeviceDnaResp {
pub fn parse(_buf: &mut &[u8]) -> Result<MsgNapDeviceDnaResp, crate::Error> {
Ok(MsgNapDeviceDnaResp {
sender_id: None,
dna: crate::parser::read_u8_array_limit(_buf, 8)?,
})
}
}
impl super::SBPMessage for MsgNapDeviceDnaResp {
const MSG_ID: u16 = 221;

fn get_sender_id(&self) -> Option<u16> {
self.sender_id
}

fn set_sender_id(&mut self, new_id: u16) {
self.sender_id = Some(new_id);
}
}
Loading