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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ members = ["ublox", "ublox_derive"]
resolver = "2"

[workspace.package]
rust-version = "1.78.0"
rust-version = "1.81.0"
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ members = ["*"]
resolver = "2"

[workspace.package]
rust-version = "1.78.0"
rust-version = "1.81.0"
41 changes: 41 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euxo pipefail

need() {
if ! command -v "$1" > /dev/null 2>&1; then
echo "need $1 (command not found)"
exit 1
fi
}

cargo clippy -- -D warnings
cargo fmt --all -- --check

FEATURE_SETS=(
"--features=alloc,std,ubx_proto23"
"--no-default-features --features=alloc,ubx_proto23"
"--no-default-features --features=ubx_proto23"
"--no-default-features --features=ubx_proto27"
)

for features in "${FEATURE_SETS[@]}"; do
cargo build ${features}
cargo test ${features}
done

# Examples - using a subshell to isolate directory changes
(
cd examples || exit 1
cargo build --release
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo hack check --rust-version --workspace
)


need cargo-hack
cargo hack check --rust-version --workspace
(
cd examples || exit 1
cargo hack check --rust-version --workspace
)
5 changes: 4 additions & 1 deletion ublox/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use alloc::vec::Vec;

use crate::{
error::ParserError,
ubx_packets::{match_packet, PacketRef, MAX_PAYLOAD_LEN, SYNC_CHAR_1, SYNC_CHAR_2},
ubx_packets::{
packetref::{match_packet, PacketRef, MAX_PAYLOAD_LEN},
SYNC_CHAR_1, SYNC_CHAR_2,
},
};

/// This trait represents an underlying buffer used for the Parser. We provide
Expand Down
208 changes: 7 additions & 201 deletions ublox/src/ubx_packets/packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ use num_traits::cast::{FromPrimitive, ToPrimitive};
use num_traits::float::FloatCore;

use ublox_derive::{
define_recv_packets, ubx_extend, ubx_extend_bitflags, ubx_packet_recv, ubx_packet_recv_send,
ubx_packet_send,
ubx_extend, ubx_extend_bitflags, ubx_packet_recv, ubx_packet_recv_send, ubx_packet_send,
};

use crate::error::{MemWriterError, ParserError};
#[cfg(feature = "serde")]
use crate::serde::ser::SerializeMap;
use crate::ubx_packets::packets::mon_ver::is_cstr_valid;
#[allow(unused_imports, reason = "It's only unused in some feature sets")]
use crate::FieldIter;

use super::{
ubx_checksum, MemWriter, Position, UbxChecksumCalc, UbxPacketCreator, UbxPacketMeta,
UbxUnknownPacketRef, SYNC_CHAR_1, SYNC_CHAR_2,
SYNC_CHAR_1, SYNC_CHAR_2,
};

pub use packetref::PacketRef;
pub mod packetref;

/// Used to help serialize the packet's fields flattened within a struct containing the msg_id and class fields, but
/// without using the serde FlatMapSerializer which requires alloc.
#[cfg(feature = "serde")]
Expand Down Expand Up @@ -5172,204 +5176,6 @@ struct SecUniqId {
unique_id: [u8; 5],
}

// TODO: how to split this in module while using the proc_macros
// in my first noob attempt I failed as the proc_macros fail due to visibility issues
#[cfg(feature = "ubx_proto23")]
define_recv_packets!(
enum PacketRef {
_ = UbxUnknownPacketRef,
AlpSrv,
AckAck,
AckNak,
CfgAnt,
CfgEsfAlg,
CfgEsfWt,
CfgItfm,
CfgGnss,
CfgNav5,
CfgOdo,
CfgPrtI2c,
CfgPrtSpi,
CfgPrtUart,
CfgSmgr,
CfgTmode2,
CfgTmode3,
CfgTp5,
EsfAlg,
EsfIns,
EsfMeas,
EsfStatus,
EsfRaw,
InfError,
InfWarning,
InfNotice,
InfTest,
InfDebug,
HnrAtt,
HnrIns,
HnrPvt,
MonVer,
MonGnss,
MonHw,
MgaAck,
MgaGpsIono,
MgaGpsEph,
MgaGloEph,
NavAtt,
NavClock,
NavDop,
NavEoe,
NavHpPosLlh,
NavHpPosEcef,
NavOdo,
NavPvt,
NavPosLlh,
NavRelPosNed,
NavSat,
NavSolution,
NavStatus,
NavVelNed,
NavTimeUTC,
NavTimeLs,
NavVelECEF,
RxmRawx,
RxmRtcm,
RxmSfrbx,
SecUniqId,
TimSvin,
TimTp,
TimTm2,
TimTos,
}
);

#[cfg(feature = "ubx_proto27")]
define_recv_packets!(
enum PacketRef {
_ = UbxUnknownPacketRef,
AlpSrv,
AckAck,
AckNak,
CfgItfm,
CfgPrtI2c,
CfgPrtSpi,
CfgPrtUart,
CfgNav5,
CfgAnt,
CfgOdo,
CfgTmode2,
CfgTmode3,
CfgTp5,
CfgEsfAlg,
CfgEsfWt,
EsfAlg,
EsfIns,
EsfMeas,
EsfStatus,
EsfRaw,
InfError,
InfWarning,
InfNotice,
InfTest,
InfDebug,
MonVer,
MonGnss,
MonHw,
MgaAck,
MgaGpsIono,
MgaGpsEph,
MgaGloEph,
NavAtt,
NavClock,
NavDop,
NavEoe,
NavHpPosLlh,
NavHpPosEcef,
NavOdo,
NavPvt,
NavPosLlh,
NavRelPosNed,
NavSig,
NavSat,
NavSolution,
NavStatus,
NavVelNed,
NavTimeUTC,
NavTimeLs,
NavVelECEF,
RxmRawx,
RxmRtcm,
RxmSfrbx,
SecUniqId,
TimSvin,
TimTp,
TimTm2,
}
);

#[cfg(feature = "ubx_proto31")]
define_recv_packets!(
enum PacketRef {
_ = UbxUnknownPacketRef,
AlpSrv,
AckAck,
AckNak,
CfgItfm,
CfgPrtI2c,
CfgPrtSpi,
CfgPrtUart,
CfgNav5,
CfgAnt,
CfgOdo,
CfgTmode2,
CfgTmode3,
CfgTp5,
CfgEsfAlg,
CfgEsfWt,
EsfAlg,
EsfIns,
EsfMeas,
EsfStatus,
EsfRaw,
InfError,
InfWarning,
InfNotice,
InfTest,
InfDebug,
MonVer,
MonGnss,
MonHw,
MgaAck,
MgaGpsIono,
MgaGpsEph,
MgaGloEph,
NavAtt,
NavClock,
NavDop,
NavEoe,
NavHpPosLlh,
NavHpPosEcef,
NavOdo,
NavPvt,
NavPosLlh,
NavRelPosNed,
NavSat,
NavSig,
NavSolution,
NavStatus,
NavVelNed,
NavTimeUTC,
NavTimeLs,
NavVelECEF,
RxmRawx,
RxmRtcm,
RxmSfrbx,
SecUniqId,
TimSvin,
TimTp,
TimTm2,
}
);
#[cfg(test)]
mod test {
use super::*;
Expand Down
Loading