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 Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DataStructures = "0.18, 0.19"
Dictionaries = "0.4"
DocStringExtensions = "0.6, 0.7, 0.8, 0.9"
Downloads = "1"
GNSSSignals = "3.2"
GNSSSignals = "3.3"
Random = "1"
Test = "1"
Tracking = "2"
Expand Down
16 changes: 16 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ reset_decoder_state
is_sat_healthy
```

## Signal Metadata

`GNSSSignals.get_data_frequency` is extended for [`GNSSDecoderState`](@ref): it
returns the navigation-message symbol rate of the signal the decoder demodulates
(e.g. `50 Hz` for GPS L1 C/A, `100 Hz` for GPS L5-I, `50 Hz` for GPS L2C-M). It
forwards to the corresponding signal's rate in GNSSSignals, so the value stays
single-sourced. Dispatch is on the constants type, which keeps decoders that
share a data container distinct — GPS L5-I and L2C-M both decode into
`GPSCNAVData` but report their own rates.

```julia
using GNSSDecoder, GNSSSignals
get_data_frequency(GPSL5IDecoderState(1)) # 100 Hz
get_data_frequency(GPSL2CMDecoderState(1)) # 50 Hz
```

## Shared Utilities

Signal-independent building blocks used across the decoders (CRC-24Q, the
Expand Down
7 changes: 7 additions & 0 deletions src/galileo/e1b.jl
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,13 @@ function GNSSDecoderState(system::GalileoE1B_BOC11, prn)
GalileoE1BDecoderState(prn)
end

# Both the full CBOC E1B and its BOC(1,1) approximation decode into
# `GalileoE1BConstants` and carry the identical 250 Hz I/NAV symbol stream, so a
# single method keyed on the constants type serves both. Forwarded from
# GNSSSignals (see `src/gps/l1ca.jl`).
GNSSSignals.get_data_frequency(::GNSSDecoderState{<:Any,GalileoE1BConstants}) =
get_data_frequency(GalileoE1B)

"""
$(TYPEDSIGNATURES)

Expand Down
5 changes: 5 additions & 0 deletions src/galileo/e5a.jl
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ function GNSSDecoderState(system::GalileoE5aI, prn)
GalileoE5aDecoderState(prn)
end

# F/NAV symbol rate, forwarded from GNSSSignals (see `src/gps/l1ca.jl`). The
# decoder runs on the E5a-I data component, so the rate is E5a-I's.
GNSSSignals.get_data_frequency(::GNSSDecoderState{<:Any,GalileoE5aConstants}) =
get_data_frequency(GalileoE5aI)

"""
$(TYPEDSIGNATURES)

Expand Down
4 changes: 4 additions & 0 deletions src/gps/l1c_d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,10 @@ function GNSSDecoderState(system::GPSL1C_D, prn)
GPSL1C_DDecoderState(prn)
end

# Nav-message symbol rate, forwarded from GNSSSignals (see `src/gps/l1ca.jl`).
GNSSSignals.get_data_frequency(::GNSSDecoderState{<:Any,GPSL1C_DConstants}) =
get_data_frequency(GPSL1C_D)

"""
$(TYPEDSIGNATURES)

Expand Down
7 changes: 7 additions & 0 deletions src/gps/l1ca.jl
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,13 @@ function GNSSDecoderState(system::GPSL1CA, prn)
GPSL1CADecoderState(prn)
end

# Navigation-message symbol rate of the signal this decoder demodulates,
# forwarded from GNSSSignals so the rate stays single-sourced. Dispatched on the
# constants type, which is 1:1 with the signal (and is what tells apart decoders
# that share a data type — see the GPS CNAV note in `src/gps/l5.jl`).
GNSSSignals.get_data_frequency(::GNSSDecoderState{<:Any,GPSL1CAConstants}) =
get_data_frequency(GPSL1CA)

"""
$(TYPEDSIGNATURES)

Expand Down
5 changes: 5 additions & 0 deletions src/gps/l2c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ function GNSSDecoderState(system::GPSL2CM, prn)
GPSL2CMDecoderState(prn)
end

# L2C-M's CNAV symbol rate; keyed on the constants type so it stays distinct from
# L5-I despite sharing `GPSCNAVData` (see `src/gps/l5.jl`).
GNSSSignals.get_data_frequency(::GNSSDecoderState{<:Any,GPSL2CMConstants}) =
get_data_frequency(GPSL2CM)

"""
$(TYPEDSIGNATURES)

Expand Down
7 changes: 7 additions & 0 deletions src/gps/l5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ function GNSSDecoderState(system::GPSL5I, prn)
GPSL5IDecoderState(prn)
end

# GPS CNAV rides on both L5-I (100 sps) and L2C-M (50 sps) but decodes into a
# single `GPSCNAVData`, so the symbol rate is keyed on the constants type
# (`GPSL5IConstants` vs `GPSL2CMConstants`) — the only thing that tells the two
# decoders apart. Forwarded from GNSSSignals (see `src/gps/l1ca.jl`).
GNSSSignals.get_data_frequency(::GNSSDecoderState{<:Any,GPSL5IConstants}) =
get_data_frequency(GPSL5I)

"""
$(TYPEDSIGNATURES)

Expand Down
26 changes: 26 additions & 0 deletions test/data_frequency.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@testset "Navigation-message data frequency" begin
# `get_data_frequency` on a decoder state forwards to the GNSSSignals data
# rate of the signal it demodulates, so a decoder state can report its own
# nav-message symbol rate without the caller re-deriving which signal it is.
signal_of_state = [
(GPSL1CADecoderState(1), GPSL1CA),
(GPSL1C_DDecoderState(1), GPSL1C_D),
(GPSL5IDecoderState(1), GPSL5I),
(GPSL2CMDecoderState(1), GPSL2CM),
(GalileoE1BDecoderState(1), GalileoE1B),
(GalileoE5aDecoderState(1), GalileoE5aI),
]
for (state, signal) in signal_of_state
@test get_data_frequency(state) == get_data_frequency(signal)
end

# GPS L5-I and L2C-M share `GPSCNAVData` but run at different symbol rates;
# dispatch on the constants type must keep them distinct.
@test get_data_frequency(GPSL5IDecoderState(1)) !=
get_data_frequency(GPSL2CMDecoderState(1))

# The E1B BOC(1,1) approximation decodes the identical I/NAV stream, so its
# decoder reports the same rate as full E1B.
@test get_data_frequency(GNSSDecoder.GNSSDecoderState(GalileoE1B_BOC11(), 1)) ==
get_data_frequency(GalileoE1B)
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ end
end

include("gnss_supertype.jl")
include("data_frequency.jl")
include("bit_fiddling.jl")
include("gpsl1.jl")
include("gps_l1c_d.jl")
Expand Down
Loading