Fix off-by-one PRN guard in GPS/SBAS code generation

This commit is contained in:
Carles Fernandez
2026-08-08 13:14:17 +02:00
parent ba89374a87
commit ce9ec8ced7
2 changed files with 3 additions and 3 deletions
@@ -45,7 +45,7 @@ void gps_l1_ca_code_gen_int(own::span<int32_t> dest, int32_t prn, uint32_t chip_
// compute delay array index for given PRN number
if (120 <= prn && prn <= 138)
{
prn_idx = prn - 88; // SBAS PRNs are at array indices 31 to 50 (offset: -120+33-1 =-88)
prn_idx = prn - 88; // SBAS PRNs are at array indices 32 to 50 (offset: -120+33-1 =-88)
}
else
{
@@ -53,7 +53,7 @@ void gps_l1_ca_code_gen_int(own::span<int32_t> dest, int32_t prn, uint32_t chip_
}
// A simple error check
if ((prn_idx < 0) || (prn_idx > 51))
if ((prn_idx < 0) || (prn_idx > 50))
{
return;
}
+1 -1
View File
@@ -6,7 +6,7 @@
*
* SBAS PRN codes (120–138) are generated by the GPS L1 C/A code generator
* using SBAS-specific G2 initial state delays (index offset -88 into the
* delays table, covering indices 31..50 for PRN 120..138).
* delays table, covering indices 32..50 for PRN 120..138).
*
* -----------------------------------------------------------------------------
*