@@ -534,12 +534,9 @@ pub(crate) fn closest_nav_standards(
534
534
// start by trying to locate desired revision.
535
535
// On each mismatch, we decrement and move on to next major/minor combination.
536
536
let ( mut major, mut minor) : ( u8 , u8 ) = revision. into ( ) ;
537
+
537
538
loop {
538
- // filter on both:
539
- // + Exact Constellation
540
- // + Exact NavMessageType
541
- // + Exact revision we're currently trying to locate
542
- // algorithm: decreasing, starting from desired revision
539
+ // Match constellation, message type & revision exactly
543
540
let items: Vec < _ > = database
544
541
. iter ( )
545
542
. filter ( |item| {
@@ -556,7 +553,7 @@ pub(crate) fn closest_nav_standards(
556
553
// we start @ minor = 10, which is
557
554
// larger than most revisions we know
558
555
if major == 0 {
559
- // we're done: browsed all possibilities
556
+ // we're done
560
557
break ;
561
558
} else {
562
559
major -= 1 ;
@@ -569,6 +566,7 @@ pub(crate) fn closest_nav_standards(
569
566
return Some ( items[ 0 ] ) ;
570
567
}
571
568
} // loop
569
+
572
570
None
573
571
}
574
572
@@ -669,6 +667,7 @@ mod test {
669
667
Version :: new ( 3 , 0 ) ,
670
668
NavMessageType :: LNAV ,
671
669
) ,
670
+ // NAV V4 (exact)
672
671
(
673
672
Constellation :: BeiDou ,
674
673
Version :: new ( 4 , 0 ) ,
@@ -710,12 +709,14 @@ mod test {
710
709
) ;
711
710
712
711
let standards = found. unwrap ( ) ;
712
+
713
713
assert ! (
714
714
standards. constellation == constellation,
715
715
"bad constellation identified \" {}\" , expecting \" {}\" " ,
716
716
constellation,
717
717
standards. constellation
718
718
) ;
719
+
719
720
assert ! (
720
721
standards. version == rev,
721
722
"should have matched {} V{} exactly, because it exists in DB" ,
@@ -744,8 +745,45 @@ mod test {
744
745
Version :: new ( 3 , 0 ) ,
745
746
NavMessageType :: LNAV ,
746
747
) ,
748
+ (
749
+ Constellation :: BeiDou ,
750
+ Version :: new ( 4 , 2 ) ,
751
+ Version :: new ( 4 , 0 ) ,
752
+ NavMessageType :: CNV1 ,
753
+ ) ,
754
+ (
755
+ Constellation :: BeiDou ,
756
+ Version :: new ( 4 , 2 ) ,
757
+ Version :: new ( 4 , 0 ) ,
758
+ NavMessageType :: CNV2 ,
759
+ ) ,
760
+ (
761
+ Constellation :: BeiDou ,
762
+ Version :: new ( 4 , 2 ) ,
763
+ Version :: new ( 4 , 0 ) ,
764
+ NavMessageType :: CNV3 ,
765
+ ) ,
766
+ (
767
+ Constellation :: Galileo ,
768
+ Version :: new ( 4 , 2 ) ,
769
+ Version :: new ( 4 , 0 ) ,
770
+ NavMessageType :: INAV ,
771
+ ) ,
772
+ (
773
+ Constellation :: QZSS ,
774
+ Version :: new ( 4 , 2 ) ,
775
+ Version :: new ( 4 , 0 ) ,
776
+ NavMessageType :: LNAV ,
777
+ ) ,
778
+ (
779
+ Constellation :: QZSS ,
780
+ Version :: new ( 4 , 2 ) ,
781
+ Version :: new ( 4 , 0 ) ,
782
+ NavMessageType :: CNAV ,
783
+ ) ,
747
784
] {
748
785
let found = closest_nav_standards ( constellation, desired, msg) ;
786
+
749
787
assert ! (
750
788
found. is_some( ) ,
751
789
"should have converged for \" {}\" V\" {}\" (\" {}\" ) to nearest frame revision" ,
0 commit comments