Skip to content

Commit 9693bcd

Browse files
jbangeloJADC362
andauthored
Rewrite signal module in Rust (#124)
The second chunk of changes from #122. This re-implements the GNSS signal related types of functionality in native Rust ## What's been changed - The `signal` module has been broken up into multiple files, though these extra files are not visible via the public API - The various string conversion functions have been moved to utilize the derive macros from the [`strum` crate](https://docs.rs/strum/0.27.2/strum/index.html), but the actual string values have remained the same - Conversions to/from `swiftnav-sys` integer types has been replaced with conversions to/from native Rust integer types - The conversion error types have changed to no longer contain the `swiftnav-sys` types and instead contain native Rust types - The error types use the [`thiserror` crate](https://docs.rs/thiserror/latest/thiserror/) to reduce boiler plate code ## What's been removed - `Code::sig_count()` - `Code::chip_count()` - `Code::chip_rate()` ## What's been added - The `signal::consts` module - `Constellation::sat_count()` - `Constellation::first_prn()` - `Code::get_carrier_frequency()` - `Code::get_glo_channel_frequency()` - `GnssSignal::carrier_frequency()` - `GnssSignal::get_glo_channel_frequency()` --------- Co-authored-by: Alejandro Duarte <[email protected]>
1 parent 24d5643 commit 9693bcd

File tree

8 files changed

+1658
-1265
lines changed

8 files changed

+1658
-1265
lines changed

swiftnav/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rustversion = "1.0"
1414
chrono = { version = "0.4", optional = true }
1515
swiftnav-sys = { version = "^0.10.0", path = "../swiftnav-sys/" }
1616
strum = { version = "0.27", features = ["derive"] }
17+
thiserror = "2.0"
1718

1819
[dev-dependencies]
1920
float_eq = "1.0.1"

swiftnav/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub mod edc;
6363
pub mod ephemeris;
6464
pub mod geoid;
6565
pub mod ionosphere;
66+
pub mod math;
6667
pub mod navmeas;
6768
pub mod reference_frame;
6869
pub mod signal;

swiftnav/src/math.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2025 Swift Navigation Inc.
2+
// Contact: Swift Navigation <[email protected]>
3+
//
4+
// This source is subject to the license found in the file 'LICENSE' which must
5+
// be be distributed together with this source. All other rights reserved.
6+
//
7+
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
8+
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
9+
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
10+
11+
/// We define a `const` max function since [`std::cmp::max`] isn't `const`
12+
pub(crate) const fn compile_time_max_u16(a: u16, b: u16) -> u16 {
13+
if b < a {
14+
a
15+
} else {
16+
b
17+
}
18+
}

0 commit comments

Comments
 (0)