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 c/include/libsbp/system_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@

#define SBP_STATUS_REPORT_SYSTEM_STARLING (0)
#define SBP_STATUS_REPORT_SYSTEM_PRECISION_GNSS_MODULE (1)
#define SBP_STATUS_REPORT_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_MASK (0x1ff)
#define SBP_STATUS_REPORT_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_MASK (0xff)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small error in the spec and just ran the c generator because I think it's the only other language using this feature

#define SBP_STATUS_REPORT_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_SHIFT (8u)
#define SBP_STATUS_REPORT_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_GET(flags) \
((u16)( \
Expand Down
2 changes: 1 addition & 1 deletion c/include/libsbp/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define SBP_PATCH_VERSION 3

/** Full SBP version string. */
#define SBP_VERSION "4.1.3"
#define SBP_VERSION "4.1.4-alpha"

/** \} */

Expand Down
8 changes: 2 additions & 6 deletions generator/sbpg/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ def main():
elif args.test_java:
import sbpg.targets.test_java as test_java
test_java.render_source(output_dir, parsed)
elif args.rust:
import sbpg.targets.rust as rs
rs.render_source(output_dir, parsed)
elif args.test_rust:
import sbpg.targets.test_rust as test_rs
test_rs.render_source(output_dir, parsed)
Expand All @@ -200,10 +197,9 @@ def main():
parsed = [yaml.parse_spec(spec) for _, spec in file_index_items]
java.render_table(output_dir, parsed)
elif args.rust:
import sbpg.targets.rust as rs
parsed = [yaml.parse_spec(spec) for spec in file_index.values()]
rs.render_mod(output_dir, parsed)
rs.render_sbp_cargo_toml(output_dir, release)
rs.render_sbp2json_cargo_toml(output_dir, release)
rs.render_all(output_dir, parsed, release)
elif args.test_c:
test_c.render_check_suites(output_dir, all_specs)
test_c.render_check_main(output_dir, all_specs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,53 @@ pub mod (((m)));
((*- endfor *))
pub mod unknown;

((*- for p in packages *))
((*- for m in p.definitions *))
((*- for m in msgs *))
((*- if m.is_real_message *))
use self::(((p.identifier|mod_name)))::(((m.identifier|camel_case)));
use self::(((m.parent_mod_name)))::(((m.mod_name)))::(((m.msg_name)));
((*- endif *))
((*- endfor *))
((*- endfor *))
use self::unknown::Unknown;

mod lib {
//! Common imports so we can just `use super::lib::*` in all the message files

pub use std::convert::{TryFrom, TryInto};

pub use crate::wire_format::{WireFormat, PayloadParseError};
pub use crate::sbp_string::{SbpString, Unterminated, NullTerminated, Multipart, DoubleNullTerminated};
pub use crate::sbp_string::{
DoubleNullTerminated, Multipart, NullTerminated, SbpString, Unterminated,
};
#[cfg(feature = "swiftnav")]
pub use crate::time;
pub use crate::wire_format::{PayloadParseError, WireFormat};

pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError};

pub use bytes::{Buf, BufMut};

macro_rules! get_bit_range {
($bitrange:expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => {{
let source_bit_len = std::mem::size_of::<$source_ty>() * 8;
let target_bit_len = std::mem::size_of::<$target_ty>() * 8;
let result =
(($bitrange << (source_bit_len - $msb - 1)) >> (source_bit_len - $msb - 1 + $lsb)) as $target_ty;
result << (target_bit_len - ($msb - $lsb + 1)) >> (target_bit_len - ($msb - $lsb + 1))
}};
}

macro_rules! set_bit_range {
($bitrange:expr, $value: expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => {
let source_bit_len = std::mem::size_of::<$source_ty>() * 8;
let mask: $source_ty = !(0 as $source_ty)
<< (source_bit_len - $msb - 1)
>> (source_bit_len - $msb - 1 + $lsb)
<< ($lsb);
*$bitrange &= !mask;
*$bitrange |= ($value as $source_ty << $lsb) & mask;
};
}

pub(crate) use get_bit_range;
pub(crate) use set_bit_range;
}

use lib::*;
Expand Down Expand Up @@ -87,7 +112,7 @@ impl std::error::Error for TryFromSbpError {}
pub enum Sbp {
((*- for m in msgs *))
/// (((m.short_desc | commentify(indent=2) )))
(((m.identifier|camel_case)))( (((m.identifier|camel_case))) ),
(((m.msg_name)))( (((m.msg_name))) ),
((*- endfor *))
/// Unknown message type
Unknown( Unknown ),
Expand Down Expand Up @@ -122,10 +147,10 @@ impl Sbp {
pub fn from_frame<B: Buf>(mut frame: crate::Frame<B>) -> Result<Sbp, PayloadParseError> {
match frame.msg_type {
((*- for m in msgs *))
(((m.identifier|camel_case)))::MESSAGE_TYPE => {
let mut msg = (((m.identifier|camel_case)))::parse(&mut frame.payload)?;
(((m.msg_name)))::MESSAGE_TYPE => {
let mut msg = (((m.msg_name)))::parse(&mut frame.payload)?;
msg.set_sender_id(frame.sender_id);
Ok(Sbp::(((m.identifier|camel_case)))(msg))
Ok(Sbp::(((m.msg_name)))(msg))
},
((*- endfor *))
_ => {
Expand All @@ -141,7 +166,7 @@ impl SbpMessage for Sbp {
fn message_name(&self) -> &'static str {
match self {
((*- for m in msgs *))
Sbp::(((m.identifier|camel_case)))(msg) => {
Sbp::(((m.msg_name)))(msg) => {
msg.message_name()
},
((*- endfor *))
Expand All @@ -154,7 +179,7 @@ impl SbpMessage for Sbp {
fn message_type(&self) -> u16 {
match self {
((*- for m in msgs *))
Sbp::(((m.identifier|camel_case)))(msg) => {
Sbp::(((m.msg_name)))(msg) => {
msg.message_type()
},
((*- endfor *))
Expand All @@ -167,7 +192,7 @@ impl SbpMessage for Sbp {
fn sender_id(&self) -> Option<u16> {
match self {
((*- for m in msgs *))
Sbp::(((m.identifier|camel_case)))(msg) => {
Sbp::(((m.msg_name)))(msg) => {
msg.sender_id()
},
((*- endfor *))
Expand All @@ -180,7 +205,7 @@ impl SbpMessage for Sbp {
fn set_sender_id(&mut self, new_id: u16) {
match self {
((*- for m in msgs *))
Sbp::(((m.identifier|camel_case)))(msg) => {
Sbp::(((m.msg_name)))(msg) => {
msg.set_sender_id(new_id)
},
((*- endfor *))
Expand All @@ -193,7 +218,7 @@ impl SbpMessage for Sbp {
fn encoded_len(&self) -> usize {
match self {
((*- for m in msgs *))
Sbp::(((m.identifier|camel_case)))(msg) => {
Sbp::(((m.msg_name)))(msg) => {
msg.encoded_len()
},
((*- endfor *))
Expand All @@ -207,7 +232,7 @@ impl SbpMessage for Sbp {
fn gps_time(&self) -> Option<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {
match self {
((*- for m in msgs *))
Sbp::(((m.identifier|camel_case)))(msg) => {
Sbp::(((m.msg_name)))(msg) => {
msg.gps_time()
},
((*- endfor *))
Expand All @@ -228,7 +253,7 @@ impl WireFormat for Sbp {
fn write<B: BufMut>(&self, buf: &mut B) {
match self {
((*- for m in msgs *))
Sbp::(((m.identifier|camel_case)))(msg) => {
Sbp::(((m.msg_name)))(msg) => {
WireFormat::write(msg, buf)
},
((*- endfor *))
Expand All @@ -241,7 +266,7 @@ impl WireFormat for Sbp {
fn len(&self) -> usize {
match self {
((*- for m in msgs *))
Sbp::(((m.identifier|camel_case)))(msg) => {
Sbp::(((m.msg_name)))(msg) => {
WireFormat::len(msg)
},
((*- endfor *))
Expand All @@ -253,9 +278,9 @@ impl WireFormat for Sbp {
}

((* for m in msgs *))
impl From<(((m.identifier|camel_case)))> for Sbp {
fn from(msg: (((m.identifier|camel_case)))) -> Self {
Sbp::(((m.identifier|camel_case)))(msg)
impl From<(((m.msg_name)))> for Sbp {
fn from(msg: (((m.msg_name)))) -> Self {
Sbp::(((m.msg_name)))(msg)
}

}
Expand Down
Loading