Skip to content

Commit d0012df

Browse files
committed
add ubx_protocol to see output of derive via cargo expand
1 parent 6ab7a40 commit d0012df

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["ublox", "ublox_derive"]
2+
members = ["ublox", "ublox_derive", "ubx_protocol"]
33

44
[patch.'crates-io']
55
ublox_derive = { path = "ublox_derive" }

ubx_protocol/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "ubx_protocol"
3+
version = "0.0.1"
4+
authors = ["Evgeniy A. Dushistov <dushistov@mail.ru>", "Lane Kolbly <lane@rscheme.org>"]
5+
edition = "2018"
6+
license = "MIT"
7+
description = "A crate to parse/generate messages of UBX protocol (proprietary u-blox GPS devices protocol)"
8+
9+
[dependencies]
10+
ublox_derive = "0.0.0"

ubx_protocol/src/lib.rs

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
use ublox_derive::{UbxPacketRecv, UbxPacketSend, UbxDefineSubTypes};
2+
3+
pub trait UbxPacket {
4+
const class: u8;
5+
const id: u8;
6+
const fixed_length: Option<u16>;
7+
}
8+
9+
10+
#[derive(UbxPacketRecv, UbxDefineSubTypes)]
11+
#[ubx(class = 1, id = 2, fixed_len = 28)]
12+
#[repr(packed)]
13+
/// Geodetic Position Solution
14+
struct NavPosLLHRaw {
15+
itow: u32,
16+
#[ubx(map_type = f64, scale = 1e-7, alias = lon_degrees)]
17+
lon: i32,
18+
lat: i32,
19+
#[ubx(map_type = f64, scale = 1e-3, alias = height_ellipsoid_meters)]
20+
height_ellipsoid: i32,
21+
height_msl: i32,
22+
/// Horizontal Accuracy Estimate
23+
horizontal_accuracy: u32,
24+
vertical_accuracy: u32,
25+
}
26+
27+
#[derive(UbxPacketRecv, UbxDefineSubTypes)]
28+
#[repr(packed)]
29+
#[ubx(class = 1, id = 3, fixed_len = 16)]
30+
struct NavStatusRaw {
31+
itow: u32,
32+
#[ubx(enum {
33+
NoFix = 0,
34+
DeadReckoningOnly = 1,
35+
Fix2D = 2,
36+
Fix3D = 3,
37+
GpsDeadReckoningCombine = 4,
38+
TimeOnlyFix = 5,
39+
})]
40+
gps_fix: u8,
41+
#[ubx(bitflags {
42+
GpsFixOk = bit0,
43+
DiffSoln = bit1,
44+
WknSet = bit2,
45+
TowSet = bit3,
46+
})]
47+
flags: u8,
48+
fix_status: u8,
49+
flags2: u8,
50+
time_to_first_fix: u32,
51+
uptime_ms: u32,
52+
}
53+
54+
#[derive(UbxPacketSend, UbxDefineSubTypes)]
55+
#[repr(packed)]
56+
#[ubx(class = 5, id = 1, fixed_len = 0)]
57+
struct AckAckRaw {}
58+
59+
#[derive(UbxPacketSend, UbxDefineSubTypes)]
60+
#[repr(packed)]
61+
#[ubx(class = 6, id = 4)]
62+
struct CfgRstRaw {
63+
#[ubx(bitflags {
64+
Eph = bit0,
65+
Alm = bit1,
66+
Health = bit2,
67+
/// Klobuchard
68+
Klob = bit3,
69+
Pos = bit4,
70+
Clkd = bit5,
71+
Osc = bit6,
72+
Utc = bit7,
73+
Rtc = bit8,
74+
HotStart = mask0,
75+
})]
76+
nav_bbr_mask: u16,
77+
#[ubx(enum {
78+
/// Hardware reset (Watchdog) immediately
79+
HardwareReset = 0,
80+
ControlledSoftwareReset = 1,
81+
})]
82+
reset_mode: u8,
83+
reserved1: u8,
84+
}

0 commit comments

Comments
 (0)