1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
// Copyright (C) 2015-2021 Swift Navigation Inc.
// Contact: https://support.swiftnav.com
//
// This source is subject to the license found in the file 'LICENSE' which must
// be be distributed together with this source. All other rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

//****************************************************************************
// Automatically generated from yaml/swiftnav/sbp/system.yaml
// with generate.py. Please do not hand edit!
//****************************************************************************/
//! Standardized system messages from Swift Navigation devices.
pub use msg_csac_telemetry::MsgCsacTelemetry;
pub use msg_csac_telemetry_labels::MsgCsacTelemetryLabels;
pub use msg_dgnss_status::MsgDgnssStatus;
pub use msg_gnss_time_offset::MsgGnssTimeOffset;
pub use msg_group_meta::MsgGroupMeta;
pub use msg_heartbeat::MsgHeartbeat;
pub use msg_ins_status::MsgInsStatus;
pub use msg_ins_updates::MsgInsUpdates;
pub use msg_pps_time::MsgPpsTime;
pub use msg_sensor_aid_event::MsgSensorAidEvent;
pub use msg_startup::MsgStartup;
pub use msg_status_journal::MsgStatusJournal;
pub use msg_status_report::MsgStatusReport;
pub use status_journal_item::StatusJournalItem;
pub use sub_system_report::SubSystemReport;

pub mod msg_csac_telemetry {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Experimental telemetry message
    ///
    /// The CSAC telemetry message has an implementation defined telemetry string
    /// from a device. It is not produced or available on general Swift Products.
    /// It is intended to be a low rate message for status purposes.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgCsacTelemetry {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Index representing the type of telemetry in use.  It is implementation
        /// defined.
        #[cfg_attr(feature = "serde", serde(rename = "id"))]
        pub id: u8,
        /// Comma separated list of values as defined by the index
        #[cfg_attr(feature = "serde", serde(rename = "telemetry"))]
        pub telemetry: SbpString<Vec<u8>, Unterminated>,
    }

    impl ConcreteMessage for MsgCsacTelemetry {
        const MESSAGE_TYPE: u16 = 65284;
        const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY";
    }

    impl SbpMessage for MsgCsacTelemetry {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgCsacTelemetry {
        fn friendly_name() -> &'static str {
            "CSAC TELEMETRY"
        }
    }

    impl TryFrom<Sbp> for MsgCsacTelemetry {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgCsacTelemetry(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgCsacTelemetry {
        const MIN_LEN: usize =
            <u8 as WireFormat>::MIN_LEN + <SbpString<Vec<u8>, Unterminated> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.id) + WireFormat::len(&self.telemetry)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.id, buf);
            WireFormat::write(&self.telemetry, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgCsacTelemetry {
                sender_id: None,
                id: WireFormat::parse_unchecked(buf),
                telemetry: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod msg_csac_telemetry_labels {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Experimental telemetry message labels
    ///
    /// The CSAC telemetry message provides labels for each member of the string
    /// produced by MSG_CSAC_TELEMETRY. It should be provided by a device at a
    /// lower rate than the MSG_CSAC_TELEMETRY.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgCsacTelemetryLabels {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Index representing the type of telemetry in use.  It is implementation
        /// defined.
        #[cfg_attr(feature = "serde", serde(rename = "id"))]
        pub id: u8,
        /// Comma separated list of telemetry field values
        #[cfg_attr(feature = "serde", serde(rename = "telemetry_labels"))]
        pub telemetry_labels: SbpString<Vec<u8>, Unterminated>,
    }

    impl ConcreteMessage for MsgCsacTelemetryLabels {
        const MESSAGE_TYPE: u16 = 65285;
        const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY_LABELS";
    }

    impl SbpMessage for MsgCsacTelemetryLabels {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgCsacTelemetryLabels {
        fn friendly_name() -> &'static str {
            "CSAC TELEMETRY LABELS"
        }
    }

    impl TryFrom<Sbp> for MsgCsacTelemetryLabels {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgCsacTelemetryLabels(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgCsacTelemetryLabels {
        const MIN_LEN: usize =
            <u8 as WireFormat>::MIN_LEN + <SbpString<Vec<u8>, Unterminated> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.id) + WireFormat::len(&self.telemetry_labels)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.id, buf);
            WireFormat::write(&self.telemetry_labels, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgCsacTelemetryLabels {
                sender_id: None,
                id: WireFormat::parse_unchecked(buf),
                telemetry_labels: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod msg_dgnss_status {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Status of received corrections
    ///
    /// This message provides information about the receipt of Differential
    /// corrections.  It is expected to be sent with each receipt of a complete
    /// corrections packet.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgDgnssStatus {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
        /// Latency of observation receipt
        #[cfg_attr(feature = "serde", serde(rename = "latency"))]
        pub latency: u16,
        /// Number of signals from base station
        #[cfg_attr(feature = "serde", serde(rename = "num_signals"))]
        pub num_signals: u8,
        /// Corrections source string
        #[cfg_attr(feature = "serde", serde(rename = "source"))]
        pub source: SbpString<Vec<u8>, Unterminated>,
    }

    impl MsgDgnssStatus {
        /// Gets the [DifferentialType][self::DifferentialType] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `DifferentialType` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `DifferentialType` were added.
        pub fn differential_type(&self) -> Result<DifferentialType, u8> {
            get_bit_range!(self.flags, u8, u8, 3, 0).try_into()
        }

        /// Set the bitrange corresponding to the [DifferentialType][DifferentialType] of the `flags` bitfield.
        pub fn set_differential_type(&mut self, differential_type: DifferentialType) {
            set_bit_range!(&mut self.flags, differential_type, u8, u8, 3, 0);
        }
    }

    impl ConcreteMessage for MsgDgnssStatus {
        const MESSAGE_TYPE: u16 = 65282;
        const MESSAGE_NAME: &'static str = "MSG_DGNSS_STATUS";
    }

    impl SbpMessage for MsgDgnssStatus {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgDgnssStatus {
        fn friendly_name() -> &'static str {
            "DGNSS STATUS"
        }
    }

    impl TryFrom<Sbp> for MsgDgnssStatus {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgDgnssStatus(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgDgnssStatus {
        const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <SbpString<Vec<u8>, Unterminated> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.flags)
                + WireFormat::len(&self.latency)
                + WireFormat::len(&self.num_signals)
                + WireFormat::len(&self.source)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.flags, buf);
            WireFormat::write(&self.latency, buf);
            WireFormat::write(&self.num_signals, buf);
            WireFormat::write(&self.source, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgDgnssStatus {
                sender_id: None,
                flags: WireFormat::parse_unchecked(buf),
                latency: WireFormat::parse_unchecked(buf),
                num_signals: WireFormat::parse_unchecked(buf),
                source: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Differential type
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum DifferentialType {
        /// Invalid
        Invalid = 0,

        /// Code Difference
        CodeDifference = 1,

        /// RTK
        Rtk = 2,
    }

    impl std::fmt::Display for DifferentialType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                DifferentialType::Invalid => f.write_str("Invalid"),
                DifferentialType::CodeDifference => f.write_str("Code Difference"),
                DifferentialType::Rtk => f.write_str("RTK"),
            }
        }
    }

    impl TryFrom<u8> for DifferentialType {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(DifferentialType::Invalid),
                1 => Ok(DifferentialType::CodeDifference),
                2 => Ok(DifferentialType::Rtk),
                i => Err(i),
            }
        }
    }
}

pub mod msg_gnss_time_offset {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Offset of the local time with respect to GNSS time
    ///
    /// The GNSS time offset message contains the information that is needed to
    /// translate messages tagged with a local timestamp (e.g. IMU or wheeltick
    /// messages) to GNSS time for the sender producing this message.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgGnssTimeOffset {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Weeks portion of the time offset
        #[cfg_attr(feature = "serde", serde(rename = "weeks"))]
        pub weeks: i16,
        /// Milliseconds portion of the time offset
        #[cfg_attr(feature = "serde", serde(rename = "milliseconds"))]
        pub milliseconds: i32,
        /// Microseconds portion of the time offset
        #[cfg_attr(feature = "serde", serde(rename = "microseconds"))]
        pub microseconds: i16,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
    }

    impl MsgGnssTimeOffset {
        /// Gets the `reserved_set_to_zero` stored in `flags`.
        pub fn reserved_set_to_zero(&self) -> u8 {
            get_bit_range!(self.flags, u8, u8, 7, 1)
        }

        /// Sets the `reserved_set_to_zero` bitrange of `flags`.
        pub fn set_reserved_set_to_zero(&mut self, reserved_set_to_zero: u8) {
            set_bit_range!(&mut self.flags, reserved_set_to_zero, u8, u8, 7, 1);
        }

        /// Gets the [WeeksBehavior][self::WeeksBehavior] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `WeeksBehavior` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `WeeksBehavior` were added.
        pub fn weeks_behavior(&self) -> Result<WeeksBehavior, u8> {
            get_bit_range!(self.flags, u8, u8, 0, 0).try_into()
        }

        /// Set the bitrange corresponding to the [WeeksBehavior][WeeksBehavior] of the `flags` bitfield.
        pub fn set_weeks_behavior(&mut self, weeks_behavior: WeeksBehavior) {
            set_bit_range!(&mut self.flags, weeks_behavior, u8, u8, 0, 0);
        }
    }

    impl ConcreteMessage for MsgGnssTimeOffset {
        const MESSAGE_TYPE: u16 = 65287;
        const MESSAGE_NAME: &'static str = "MSG_GNSS_TIME_OFFSET";
    }

    impl SbpMessage for MsgGnssTimeOffset {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgGnssTimeOffset {
        fn friendly_name() -> &'static str {
            "GNSS TIME OFFSET"
        }
    }

    impl TryFrom<Sbp> for MsgGnssTimeOffset {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgGnssTimeOffset(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgGnssTimeOffset {
        const MIN_LEN: usize = <i16 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i16 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.weeks)
                + WireFormat::len(&self.milliseconds)
                + WireFormat::len(&self.microseconds)
                + WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.weeks, buf);
            WireFormat::write(&self.milliseconds, buf);
            WireFormat::write(&self.microseconds, buf);
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgGnssTimeOffset {
                sender_id: None,
                weeks: WireFormat::parse_unchecked(buf),
                milliseconds: WireFormat::parse_unchecked(buf),
                microseconds: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Weeks behavior
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum WeeksBehavior {
        /// Not affected on local timestamp rollover
        NotAffectedOnLocalTimestampRollover = 0,

        /// Incremented on local timestamp rollover
        IncrementedOnLocalTimestampRollover = 1,
    }

    impl std::fmt::Display for WeeksBehavior {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                WeeksBehavior::NotAffectedOnLocalTimestampRollover => {
                    f.write_str("Not affected on local timestamp rollover")
                }
                WeeksBehavior::IncrementedOnLocalTimestampRollover => {
                    f.write_str("Incremented on local timestamp rollover")
                }
            }
        }
    }

    impl TryFrom<u8> for WeeksBehavior {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(WeeksBehavior::NotAffectedOnLocalTimestampRollover),
                1 => Ok(WeeksBehavior::IncrementedOnLocalTimestampRollover),
                i => Err(i),
            }
        }
    }
}

pub mod msg_group_meta {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Solution Group Metadata
    ///
    /// This leading message lists the time metadata of the Solution Group. It
    /// also lists the atomic contents (i.e. types of messages included) of the
    /// Solution Group.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgGroupMeta {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Id of the Msgs Group, 0 is Unknown, 1 is Bestpos, 2 is Gnss
        #[cfg_attr(feature = "serde", serde(rename = "group_id"))]
        pub group_id: u8,
        /// Status flags (reserved)
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
        /// Size of list group_msgs
        #[cfg_attr(feature = "serde", serde(rename = "n_group_msgs"))]
        pub n_group_msgs: u8,
        /// An in-order list of message types included in the Solution Group,
        /// including GROUP_META itself
        #[cfg_attr(feature = "serde", serde(rename = "group_msgs"))]
        pub group_msgs: Vec<u16>,
    }

    impl MsgGroupMeta {
        /// Gets the [SolutionGroupType][self::SolutionGroupType] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `SolutionGroupType` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `SolutionGroupType` were added.
        pub fn solution_group_type(&self) -> Result<SolutionGroupType, u8> {
            get_bit_range!(self.flags, u8, u8, 1, 0).try_into()
        }

        /// Set the bitrange corresponding to the [SolutionGroupType][SolutionGroupType] of the `flags` bitfield.
        pub fn set_solution_group_type(&mut self, solution_group_type: SolutionGroupType) {
            set_bit_range!(&mut self.flags, solution_group_type, u8, u8, 1, 0);
        }
    }

    impl ConcreteMessage for MsgGroupMeta {
        const MESSAGE_TYPE: u16 = 65290;
        const MESSAGE_NAME: &'static str = "MSG_GROUP_META";
    }

    impl SbpMessage for MsgGroupMeta {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgGroupMeta {
        fn friendly_name() -> &'static str {
            "GROUP META"
        }
    }

    impl TryFrom<Sbp> for MsgGroupMeta {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgGroupMeta(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgGroupMeta {
        const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <Vec<u16> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.group_id)
                + WireFormat::len(&self.flags)
                + WireFormat::len(&self.n_group_msgs)
                + WireFormat::len(&self.group_msgs)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.group_id, buf);
            WireFormat::write(&self.flags, buf);
            WireFormat::write(&self.n_group_msgs, buf);
            WireFormat::write(&self.group_msgs, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgGroupMeta {
                sender_id: None,
                group_id: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
                n_group_msgs: WireFormat::parse_unchecked(buf),
                group_msgs: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Solution Group type
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum SolutionGroupType {
        /// None (invalid)
        None = 0,

        /// GNSS only
        GnssOnly = 1,

        /// GNSS+INS (Fuzed)
        Gnssins = 2,
    }

    impl std::fmt::Display for SolutionGroupType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                SolutionGroupType::None => f.write_str("None (invalid)"),
                SolutionGroupType::GnssOnly => f.write_str("GNSS only"),
                SolutionGroupType::Gnssins => f.write_str("GNSS+INS (Fuzed)"),
            }
        }
    }

    impl TryFrom<u8> for SolutionGroupType {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(SolutionGroupType::None),
                1 => Ok(SolutionGroupType::GnssOnly),
                2 => Ok(SolutionGroupType::Gnssins),
                i => Err(i),
            }
        }
    }
}

pub mod msg_heartbeat {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// System heartbeat message
    ///
    /// The heartbeat message is sent periodically to inform the host or other
    /// attached devices that the system is running. It is used to monitor system
    /// malfunctions. It also contains status flags that indicate to the host the
    /// status of the system and whether it is operating correctly. Currently, the
    /// expected heartbeat interval is 1 sec.
    ///
    /// The system error flag is used to indicate that an error has occurred in
    /// the system. To determine the source of the error, the remaining error
    /// flags should be inspected.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgHeartbeat {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u32,
    }

    impl MsgHeartbeat {
        /// Gets the [ExternalAntennaPresent][self::ExternalAntennaPresent] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `ExternalAntennaPresent` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `ExternalAntennaPresent` were added.
        pub fn external_antenna_present(&self) -> Result<ExternalAntennaPresent, u8> {
            get_bit_range!(self.flags, u32, u8, 31, 31).try_into()
        }

        /// Set the bitrange corresponding to the [ExternalAntennaPresent][ExternalAntennaPresent] of the `flags` bitfield.
        pub fn set_external_antenna_present(
            &mut self,
            external_antenna_present: ExternalAntennaPresent,
        ) {
            set_bit_range!(&mut self.flags, external_antenna_present, u32, u8, 31, 31);
        }

        /// Gets the [ExternalAntennaShort][self::ExternalAntennaShort] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `ExternalAntennaShort` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `ExternalAntennaShort` were added.
        pub fn external_antenna_short(&self) -> Result<ExternalAntennaShort, u8> {
            get_bit_range!(self.flags, u32, u8, 30, 30).try_into()
        }

        /// Set the bitrange corresponding to the [ExternalAntennaShort][ExternalAntennaShort] of the `flags` bitfield.
        pub fn set_external_antenna_short(&mut self, external_antenna_short: ExternalAntennaShort) {
            set_bit_range!(&mut self.flags, external_antenna_short, u32, u8, 30, 30);
        }

        /// Gets the `sbp_major_protocol_version_number` stored in `flags`.
        pub fn sbp_major_protocol_version_number(&self) -> u8 {
            get_bit_range!(self.flags, u32, u8, 23, 16)
        }

        /// Sets the `sbp_major_protocol_version_number` bitrange of `flags`.
        pub fn set_sbp_major_protocol_version_number(
            &mut self,
            sbp_major_protocol_version_number: u8,
        ) {
            set_bit_range!(
                &mut self.flags,
                sbp_major_protocol_version_number,
                u32,
                u8,
                23,
                16
            );
        }

        /// Gets the `sbp_minor_protocol_version_number` stored in `flags`.
        pub fn sbp_minor_protocol_version_number(&self) -> u8 {
            get_bit_range!(self.flags, u32, u8, 15, 8)
        }

        /// Sets the `sbp_minor_protocol_version_number` bitrange of `flags`.
        pub fn set_sbp_minor_protocol_version_number(
            &mut self,
            sbp_minor_protocol_version_number: u8,
        ) {
            set_bit_range!(
                &mut self.flags,
                sbp_minor_protocol_version_number,
                u32,
                u8,
                15,
                8
            );
        }

        /// Gets the [SwiftNapError][self::SwiftNapError] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `SwiftNapError` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `SwiftNapError` were added.
        pub fn swift_nap_error(&self) -> Result<SwiftNapError, u8> {
            get_bit_range!(self.flags, u32, u8, 2, 2).try_into()
        }

        /// Set the bitrange corresponding to the [SwiftNapError][SwiftNapError] of the `flags` bitfield.
        pub fn set_swift_nap_error(&mut self, swift_nap_error: SwiftNapError) {
            set_bit_range!(&mut self.flags, swift_nap_error, u32, u8, 2, 2);
        }

        /// Gets the [IoError][self::IoError] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `IoError` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `IoError` were added.
        pub fn io_error(&self) -> Result<IoError, u8> {
            get_bit_range!(self.flags, u32, u8, 1, 1).try_into()
        }

        /// Set the bitrange corresponding to the [IoError][IoError] of the `flags` bitfield.
        pub fn set_io_error(&mut self, io_error: IoError) {
            set_bit_range!(&mut self.flags, io_error, u32, u8, 1, 1);
        }

        /// Gets the [SystemErrorFlag][self::SystemErrorFlag] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `SystemErrorFlag` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `SystemErrorFlag` were added.
        pub fn system_error_flag(&self) -> Result<SystemErrorFlag, u8> {
            get_bit_range!(self.flags, u32, u8, 0, 0).try_into()
        }

        /// Set the bitrange corresponding to the [SystemErrorFlag][SystemErrorFlag] of the `flags` bitfield.
        pub fn set_system_error_flag(&mut self, system_error_flag: SystemErrorFlag) {
            set_bit_range!(&mut self.flags, system_error_flag, u32, u8, 0, 0);
        }
    }

    impl ConcreteMessage for MsgHeartbeat {
        const MESSAGE_TYPE: u16 = 65535;
        const MESSAGE_NAME: &'static str = "MSG_HEARTBEAT";
    }

    impl SbpMessage for MsgHeartbeat {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgHeartbeat {
        fn friendly_name() -> &'static str {
            "HEARTBEAT"
        }
    }

    impl TryFrom<Sbp> for MsgHeartbeat {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgHeartbeat(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgHeartbeat {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgHeartbeat {
                sender_id: None,
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// External antenna present
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum ExternalAntennaPresent {
        /// No external antenna detected
        NoExternalAntennaDetected = 0,

        /// External antenna is present
        ExternalAntennaIsPresent = 1,
    }

    impl std::fmt::Display for ExternalAntennaPresent {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                ExternalAntennaPresent::NoExternalAntennaDetected => {
                    f.write_str("No external antenna detected")
                }
                ExternalAntennaPresent::ExternalAntennaIsPresent => {
                    f.write_str("External antenna is present")
                }
            }
        }
    }

    impl TryFrom<u8> for ExternalAntennaPresent {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(ExternalAntennaPresent::NoExternalAntennaDetected),
                1 => Ok(ExternalAntennaPresent::ExternalAntennaIsPresent),
                i => Err(i),
            }
        }
    }

    /// External antenna short
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum ExternalAntennaShort {
        /// No short detected
        NoShortDetected = 0,

        /// Short detected
        ShortDetected = 1,
    }

    impl std::fmt::Display for ExternalAntennaShort {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                ExternalAntennaShort::NoShortDetected => f.write_str("No short detected"),
                ExternalAntennaShort::ShortDetected => f.write_str("Short detected"),
            }
        }
    }

    impl TryFrom<u8> for ExternalAntennaShort {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(ExternalAntennaShort::NoShortDetected),
                1 => Ok(ExternalAntennaShort::ShortDetected),
                i => Err(i),
            }
        }
    }

    /// SwiftNAP Error
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum SwiftNapError {
        /// System Healthy
        SystemHealthy = 0,

        /// An error has occurred in the SwiftNAP
        AnErrorHasOccurredInTheSwiftNap = 1,
    }

    impl std::fmt::Display for SwiftNapError {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                SwiftNapError::SystemHealthy => f.write_str("System Healthy"),
                SwiftNapError::AnErrorHasOccurredInTheSwiftNap => {
                    f.write_str("An error has occurred in the SwiftNAP")
                }
            }
        }
    }

    impl TryFrom<u8> for SwiftNapError {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(SwiftNapError::SystemHealthy),
                1 => Ok(SwiftNapError::AnErrorHasOccurredInTheSwiftNap),
                i => Err(i),
            }
        }
    }

    /// IO Error
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum IoError {
        /// System Healthy
        SystemHealthy = 0,

        /// An IO error has occurred
        AnIoErrorHasOccurred = 1,
    }

    impl std::fmt::Display for IoError {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                IoError::SystemHealthy => f.write_str("System Healthy"),
                IoError::AnIoErrorHasOccurred => f.write_str("An IO error has occurred"),
            }
        }
    }

    impl TryFrom<u8> for IoError {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(IoError::SystemHealthy),
                1 => Ok(IoError::AnIoErrorHasOccurred),
                i => Err(i),
            }
        }
    }

    /// System Error Flag
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum SystemErrorFlag {
        /// System Healthy
        SystemHealthy = 0,

        /// An error has occurred
        AnErrorHasOccurred = 1,
    }

    impl std::fmt::Display for SystemErrorFlag {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                SystemErrorFlag::SystemHealthy => f.write_str("System Healthy"),
                SystemErrorFlag::AnErrorHasOccurred => f.write_str("An error has occurred"),
            }
        }
    }

    impl TryFrom<u8> for SystemErrorFlag {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(SystemErrorFlag::SystemHealthy),
                1 => Ok(SystemErrorFlag::AnErrorHasOccurred),
                i => Err(i),
            }
        }
    }
}

pub mod msg_ins_status {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Inertial Navigation System status message
    ///
    /// The INS status message describes the state of the operation and
    /// initialization of the inertial navigation system.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgInsStatus {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u32,
    }

    impl MsgInsStatus {
        /// Gets the [InsType][self::InsType] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `InsType` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `InsType` were added.
        pub fn ins_type(&self) -> Result<InsType, u8> {
            get_bit_range!(self.flags, u32, u8, 31, 29).try_into()
        }

        /// Set the bitrange corresponding to the [InsType][InsType] of the `flags` bitfield.
        pub fn set_ins_type(&mut self, ins_type: InsType) {
            set_bit_range!(&mut self.flags, ins_type, u32, u8, 31, 29);
        }

        /// Gets the [MotionState][self::MotionState] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `MotionState` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `MotionState` were added.
        pub fn motion_state(&self) -> Result<MotionState, u8> {
            get_bit_range!(self.flags, u32, u8, 13, 11).try_into()
        }

        /// Set the bitrange corresponding to the [MotionState][MotionState] of the `flags` bitfield.
        pub fn set_motion_state(&mut self, motion_state: MotionState) {
            set_bit_range!(&mut self.flags, motion_state, u32, u8, 13, 11);
        }

        /// Gets the [OdometrySynch][self::OdometrySynch] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `OdometrySynch` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `OdometrySynch` were added.
        pub fn odometry_synch(&self) -> Result<OdometrySynch, u8> {
            get_bit_range!(self.flags, u32, u8, 10, 10).try_into()
        }

        /// Set the bitrange corresponding to the [OdometrySynch][OdometrySynch] of the `flags` bitfield.
        pub fn set_odometry_synch(&mut self, odometry_synch: OdometrySynch) {
            set_bit_range!(&mut self.flags, odometry_synch, u32, u8, 10, 10);
        }

        /// Gets the [OdometryStatus][self::OdometryStatus] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `OdometryStatus` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `OdometryStatus` were added.
        pub fn odometry_status(&self) -> Result<OdometryStatus, u8> {
            get_bit_range!(self.flags, u32, u8, 9, 8).try_into()
        }

        /// Set the bitrange corresponding to the [OdometryStatus][OdometryStatus] of the `flags` bitfield.
        pub fn set_odometry_status(&mut self, odometry_status: OdometryStatus) {
            set_bit_range!(&mut self.flags, odometry_status, u32, u8, 9, 8);
        }

        /// Gets the [InsError][self::InsError] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `InsError` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `InsError` were added.
        pub fn ins_error(&self) -> Result<InsError, u8> {
            get_bit_range!(self.flags, u32, u8, 7, 4).try_into()
        }

        /// Set the bitrange corresponding to the [InsError][InsError] of the `flags` bitfield.
        pub fn set_ins_error(&mut self, ins_error: InsError) {
            set_bit_range!(&mut self.flags, ins_error, u32, u8, 7, 4);
        }

        /// Gets the [GnssFix][self::GnssFix] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `GnssFix` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `GnssFix` were added.
        pub fn gnss_fix(&self) -> Result<GnssFix, u8> {
            get_bit_range!(self.flags, u32, u8, 3, 3).try_into()
        }

        /// Set the bitrange corresponding to the [GnssFix][GnssFix] of the `flags` bitfield.
        pub fn set_gnss_fix(&mut self, gnss_fix: GnssFix) {
            set_bit_range!(&mut self.flags, gnss_fix, u32, u8, 3, 3);
        }

        /// Gets the [Mode][self::Mode] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `Mode` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `Mode` were added.
        pub fn mode(&self) -> Result<Mode, u8> {
            get_bit_range!(self.flags, u32, u8, 2, 0).try_into()
        }

        /// Set the bitrange corresponding to the [Mode][Mode] of the `flags` bitfield.
        pub fn set_mode(&mut self, mode: Mode) {
            set_bit_range!(&mut self.flags, mode, u32, u8, 2, 0);
        }
    }

    impl ConcreteMessage for MsgInsStatus {
        const MESSAGE_TYPE: u16 = 65283;
        const MESSAGE_NAME: &'static str = "MSG_INS_STATUS";
    }

    impl SbpMessage for MsgInsStatus {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgInsStatus {
        fn friendly_name() -> &'static str {
            "INS STATUS"
        }
    }

    impl TryFrom<Sbp> for MsgInsStatus {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgInsStatus(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgInsStatus {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgInsStatus {
                sender_id: None,
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// INS Type
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum InsType {
        /// Smoothpose Loosely Coupled
        SmoothposeLooselyCoupled = 0,

        /// Starling
        Starling = 1,
    }

    impl std::fmt::Display for InsType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                InsType::SmoothposeLooselyCoupled => f.write_str("Smoothpose Loosely Coupled"),
                InsType::Starling => f.write_str("Starling"),
            }
        }
    }

    impl TryFrom<u8> for InsType {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(InsType::SmoothposeLooselyCoupled),
                1 => Ok(InsType::Starling),
                i => Err(i),
            }
        }
    }

    /// Motion State
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum MotionState {
        /// Unknown or Init
        UnknownOrInit = 0,

        /// Arbitrary Motion
        ArbitraryMotion = 1,

        /// Straight Motion
        StraightMotion = 2,

        /// Stationary
        Stationary = 3,
    }

    impl std::fmt::Display for MotionState {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                MotionState::UnknownOrInit => f.write_str("Unknown or Init"),
                MotionState::ArbitraryMotion => f.write_str("Arbitrary Motion"),
                MotionState::StraightMotion => f.write_str("Straight Motion"),
                MotionState::Stationary => f.write_str("Stationary"),
            }
        }
    }

    impl TryFrom<u8> for MotionState {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(MotionState::UnknownOrInit),
                1 => Ok(MotionState::ArbitraryMotion),
                2 => Ok(MotionState::StraightMotion),
                3 => Ok(MotionState::Stationary),
                i => Err(i),
            }
        }
    }

    /// Odometry Synch
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum OdometrySynch {
        /// Odometry timestamp nominal
        OdometryTimestampNominal = 0,

        /// Odometry timestamp out of bounds
        OdometryTimestampOutOfBounds = 1,
    }

    impl std::fmt::Display for OdometrySynch {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                OdometrySynch::OdometryTimestampNominal => {
                    f.write_str("Odometry timestamp nominal")
                }
                OdometrySynch::OdometryTimestampOutOfBounds => {
                    f.write_str("Odometry timestamp out of bounds")
                }
            }
        }
    }

    impl TryFrom<u8> for OdometrySynch {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(OdometrySynch::OdometryTimestampNominal),
                1 => Ok(OdometrySynch::OdometryTimestampOutOfBounds),
                i => Err(i),
            }
        }
    }

    /// Odometry status
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum OdometryStatus {
        /// No Odometry
        NoOdometry = 0,

        /// Odometry received within last second
        OdometryReceivedWithinLastSecond = 1,

        /// Odometry not received within last second
        OdometryNotReceivedWithinLastSecond = 2,
    }

    impl std::fmt::Display for OdometryStatus {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                OdometryStatus::NoOdometry => f.write_str("No Odometry"),
                OdometryStatus::OdometryReceivedWithinLastSecond => {
                    f.write_str("Odometry received within last second")
                }
                OdometryStatus::OdometryNotReceivedWithinLastSecond => {
                    f.write_str("Odometry not received within last second")
                }
            }
        }
    }

    impl TryFrom<u8> for OdometryStatus {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(OdometryStatus::NoOdometry),
                1 => Ok(OdometryStatus::OdometryReceivedWithinLastSecond),
                2 => Ok(OdometryStatus::OdometryNotReceivedWithinLastSecond),
                i => Err(i),
            }
        }
    }

    /// INS Error
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum InsError {
        /// IMU Data Error
        ImuDataError = 1,

        /// INS License Error
        InsLicenseError = 2,

        /// IMU Calibration Data Error
        ImuCalibrationDataError = 3,
    }

    impl std::fmt::Display for InsError {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                InsError::ImuDataError => f.write_str("IMU Data Error"),
                InsError::InsLicenseError => f.write_str("INS License Error"),
                InsError::ImuCalibrationDataError => f.write_str("IMU Calibration Data Error"),
            }
        }
    }

    impl TryFrom<u8> for InsError {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                1 => Ok(InsError::ImuDataError),
                2 => Ok(InsError::InsLicenseError),
                3 => Ok(InsError::ImuCalibrationDataError),
                i => Err(i),
            }
        }
    }

    /// GNSS Fix
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum GnssFix {
        /// No GNSS fix available
        NoGnssFixAvailable = 0,

        /// GNSS fix
        GnssFix = 1,
    }

    impl std::fmt::Display for GnssFix {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                GnssFix::NoGnssFixAvailable => f.write_str("No GNSS fix available"),
                GnssFix::GnssFix => f.write_str("GNSS fix"),
            }
        }
    }

    impl TryFrom<u8> for GnssFix {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(GnssFix::NoGnssFixAvailable),
                1 => Ok(GnssFix::GnssFix),
                i => Err(i),
            }
        }
    }

    /// Mode
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum Mode {
        /// Awaiting initialization
        AwaitingInitialization = 0,

        /// Dynamically aligning
        DynamicallyAligning = 1,

        /// Ready
        Ready = 2,

        /// GNSS Outage exceeds max duration
        GnssOutageExceedsMaxDuration = 3,

        /// FastStart seeding
        FastStartSeeding = 4,

        /// FastStart validating
        FastStartValidating = 5,

        /// Validating unsafe fast start seed
        ValidatingUnsafeFastStartSeed = 6,
    }

    impl std::fmt::Display for Mode {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                Mode::AwaitingInitialization => f.write_str("Awaiting initialization"),
                Mode::DynamicallyAligning => f.write_str("Dynamically aligning"),
                Mode::Ready => f.write_str("Ready"),
                Mode::GnssOutageExceedsMaxDuration => {
                    f.write_str("GNSS Outage exceeds max duration")
                }
                Mode::FastStartSeeding => f.write_str("FastStart seeding"),
                Mode::FastStartValidating => f.write_str("FastStart validating"),
                Mode::ValidatingUnsafeFastStartSeed => {
                    f.write_str("Validating unsafe fast start seed")
                }
            }
        }
    }

    impl TryFrom<u8> for Mode {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(Mode::AwaitingInitialization),
                1 => Ok(Mode::DynamicallyAligning),
                2 => Ok(Mode::Ready),
                3 => Ok(Mode::GnssOutageExceedsMaxDuration),
                4 => Ok(Mode::FastStartSeeding),
                5 => Ok(Mode::FastStartValidating),
                6 => Ok(Mode::ValidatingUnsafeFastStartSeed),
                i => Err(i),
            }
        }
    }
}

pub mod msg_ins_updates {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Inertial Navigation System update status message
    ///
    /// The INS update status message contains information about executed and
    /// rejected INS updates. This message is expected to be extended in the
    /// future as new types of measurements are being added.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgInsUpdates {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// GPS Time of Week
        #[cfg_attr(feature = "serde", serde(rename = "tow"))]
        pub tow: u32,
        /// GNSS position update status flags
        #[cfg_attr(feature = "serde", serde(rename = "gnsspos"))]
        pub gnsspos: u8,
        /// GNSS velocity update status flags
        #[cfg_attr(feature = "serde", serde(rename = "gnssvel"))]
        pub gnssvel: u8,
        /// Wheelticks update status flags
        #[cfg_attr(feature = "serde", serde(rename = "wheelticks"))]
        pub wheelticks: u8,
        /// Wheelticks update status flags
        #[cfg_attr(feature = "serde", serde(rename = "speed"))]
        pub speed: u8,
        /// NHC update status flags
        #[cfg_attr(feature = "serde", serde(rename = "nhc"))]
        pub nhc: u8,
        /// Zero velocity update status flags
        #[cfg_attr(feature = "serde", serde(rename = "zerovel"))]
        pub zerovel: u8,
    }

    impl MsgInsUpdates {
        /// Gets the `number_of_attempted_gnss_position_updates_since_last_message` stored in `gnsspos`.
        pub fn number_of_attempted_gnss_position_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.gnsspos, u8, u8, 7, 4)
        }

        /// Sets the `number_of_attempted_gnss_position_updates_since_last_message` bitrange of `gnsspos`.
        pub fn set_number_of_attempted_gnss_position_updates_since_last_message(
            &mut self,
            number_of_attempted_gnss_position_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.gnsspos,
                number_of_attempted_gnss_position_updates_since_last_message,
                u8,
                u8,
                7,
                4
            );
        }

        /// Gets the `number_of_rejected_gnss_position_updates_since_last_message` stored in `gnsspos`.
        pub fn number_of_rejected_gnss_position_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.gnsspos, u8, u8, 3, 0)
        }

        /// Sets the `number_of_rejected_gnss_position_updates_since_last_message` bitrange of `gnsspos`.
        pub fn set_number_of_rejected_gnss_position_updates_since_last_message(
            &mut self,
            number_of_rejected_gnss_position_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.gnsspos,
                number_of_rejected_gnss_position_updates_since_last_message,
                u8,
                u8,
                3,
                0
            );
        }

        /// Gets the `number_of_attempted_gnss_velocity_updates_since_last_message` stored in `gnssvel`.
        pub fn number_of_attempted_gnss_velocity_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.gnssvel, u8, u8, 7, 4)
        }

        /// Sets the `number_of_attempted_gnss_velocity_updates_since_last_message` bitrange of `gnssvel`.
        pub fn set_number_of_attempted_gnss_velocity_updates_since_last_message(
            &mut self,
            number_of_attempted_gnss_velocity_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.gnssvel,
                number_of_attempted_gnss_velocity_updates_since_last_message,
                u8,
                u8,
                7,
                4
            );
        }

        /// Gets the `number_of_rejected_gnss_velocity_updates_since_last_message` stored in `gnssvel`.
        pub fn number_of_rejected_gnss_velocity_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.gnssvel, u8, u8, 3, 0)
        }

        /// Sets the `number_of_rejected_gnss_velocity_updates_since_last_message` bitrange of `gnssvel`.
        pub fn set_number_of_rejected_gnss_velocity_updates_since_last_message(
            &mut self,
            number_of_rejected_gnss_velocity_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.gnssvel,
                number_of_rejected_gnss_velocity_updates_since_last_message,
                u8,
                u8,
                3,
                0
            );
        }

        /// Gets the `number_of_attempted_wheeltick_updates_since_last_message` stored in `wheelticks`.
        pub fn number_of_attempted_wheeltick_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.wheelticks, u8, u8, 7, 4)
        }

        /// Sets the `number_of_attempted_wheeltick_updates_since_last_message` bitrange of `wheelticks`.
        pub fn set_number_of_attempted_wheeltick_updates_since_last_message(
            &mut self,
            number_of_attempted_wheeltick_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.wheelticks,
                number_of_attempted_wheeltick_updates_since_last_message,
                u8,
                u8,
                7,
                4
            );
        }

        /// Gets the `number_of_rejected_wheeltick_updates_since_last_message` stored in `wheelticks`.
        pub fn number_of_rejected_wheeltick_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.wheelticks, u8, u8, 3, 0)
        }

        /// Sets the `number_of_rejected_wheeltick_updates_since_last_message` bitrange of `wheelticks`.
        pub fn set_number_of_rejected_wheeltick_updates_since_last_message(
            &mut self,
            number_of_rejected_wheeltick_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.wheelticks,
                number_of_rejected_wheeltick_updates_since_last_message,
                u8,
                u8,
                3,
                0
            );
        }

        /// Gets the `number_of_attempted_speed_updates_since_last_message` stored in `speed`.
        pub fn number_of_attempted_speed_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.speed, u8, u8, 7, 4)
        }

        /// Sets the `number_of_attempted_speed_updates_since_last_message` bitrange of `speed`.
        pub fn set_number_of_attempted_speed_updates_since_last_message(
            &mut self,
            number_of_attempted_speed_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.speed,
                number_of_attempted_speed_updates_since_last_message,
                u8,
                u8,
                7,
                4
            );
        }

        /// Gets the `number_of_rejected_speed_updates_since_last_message` stored in `speed`.
        pub fn number_of_rejected_speed_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.speed, u8, u8, 3, 0)
        }

        /// Sets the `number_of_rejected_speed_updates_since_last_message` bitrange of `speed`.
        pub fn set_number_of_rejected_speed_updates_since_last_message(
            &mut self,
            number_of_rejected_speed_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.speed,
                number_of_rejected_speed_updates_since_last_message,
                u8,
                u8,
                3,
                0
            );
        }

        /// Gets the `number_of_attempted_nhc_updates_since_last_message` stored in `nhc`.
        pub fn number_of_attempted_nhc_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.nhc, u8, u8, 7, 4)
        }

        /// Sets the `number_of_attempted_nhc_updates_since_last_message` bitrange of `nhc`.
        pub fn set_number_of_attempted_nhc_updates_since_last_message(
            &mut self,
            number_of_attempted_nhc_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.nhc,
                number_of_attempted_nhc_updates_since_last_message,
                u8,
                u8,
                7,
                4
            );
        }

        /// Gets the `number_of_rejected_nhc_updates_since_last_message` stored in `nhc`.
        pub fn number_of_rejected_nhc_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.nhc, u8, u8, 3, 0)
        }

        /// Sets the `number_of_rejected_nhc_updates_since_last_message` bitrange of `nhc`.
        pub fn set_number_of_rejected_nhc_updates_since_last_message(
            &mut self,
            number_of_rejected_nhc_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.nhc,
                number_of_rejected_nhc_updates_since_last_message,
                u8,
                u8,
                3,
                0
            );
        }

        /// Gets the `number_of_attempted_zero_velocity_updates_since_last_message` stored in `zerovel`.
        pub fn number_of_attempted_zero_velocity_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.zerovel, u8, u8, 7, 4)
        }

        /// Sets the `number_of_attempted_zero_velocity_updates_since_last_message` bitrange of `zerovel`.
        pub fn set_number_of_attempted_zero_velocity_updates_since_last_message(
            &mut self,
            number_of_attempted_zero_velocity_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.zerovel,
                number_of_attempted_zero_velocity_updates_since_last_message,
                u8,
                u8,
                7,
                4
            );
        }

        /// Gets the `number_of_rejected_zero_velocity_updates_since_last_message` stored in `zerovel`.
        pub fn number_of_rejected_zero_velocity_updates_since_last_message(&self) -> u8 {
            get_bit_range!(self.zerovel, u8, u8, 3, 0)
        }

        /// Sets the `number_of_rejected_zero_velocity_updates_since_last_message` bitrange of `zerovel`.
        pub fn set_number_of_rejected_zero_velocity_updates_since_last_message(
            &mut self,
            number_of_rejected_zero_velocity_updates_since_last_message: u8,
        ) {
            set_bit_range!(
                &mut self.zerovel,
                number_of_rejected_zero_velocity_updates_since_last_message,
                u8,
                u8,
                3,
                0
            );
        }
    }

    impl ConcreteMessage for MsgInsUpdates {
        const MESSAGE_TYPE: u16 = 65286;
        const MESSAGE_NAME: &'static str = "MSG_INS_UPDATES";
    }

    impl SbpMessage for MsgInsUpdates {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }

        #[cfg(feature = "swiftnav")]
        fn gps_time(&self) -> Option<std::result::Result<time::MessageTime, time::GpsTimeError>> {
            let tow_s = (self.tow as f64) / 1000.0;
            let gps_time = match time::GpsTime::new(0, tow_s) {
                Ok(gps_time) => gps_time.tow(),
                Err(e) => return Some(Err(e.into())),
            };
            Some(Ok(time::MessageTime::Rover(gps_time.into())))
        }
    }

    impl FriendlyName for MsgInsUpdates {
        fn friendly_name() -> &'static str {
            "INS UPDATES"
        }
    }

    impl TryFrom<Sbp> for MsgInsUpdates {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgInsUpdates(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgInsUpdates {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.tow)
                + WireFormat::len(&self.gnsspos)
                + WireFormat::len(&self.gnssvel)
                + WireFormat::len(&self.wheelticks)
                + WireFormat::len(&self.speed)
                + WireFormat::len(&self.nhc)
                + WireFormat::len(&self.zerovel)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.tow, buf);
            WireFormat::write(&self.gnsspos, buf);
            WireFormat::write(&self.gnssvel, buf);
            WireFormat::write(&self.wheelticks, buf);
            WireFormat::write(&self.speed, buf);
            WireFormat::write(&self.nhc, buf);
            WireFormat::write(&self.zerovel, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgInsUpdates {
                sender_id: None,
                tow: WireFormat::parse_unchecked(buf),
                gnsspos: WireFormat::parse_unchecked(buf),
                gnssvel: WireFormat::parse_unchecked(buf),
                wheelticks: WireFormat::parse_unchecked(buf),
                speed: WireFormat::parse_unchecked(buf),
                nhc: WireFormat::parse_unchecked(buf),
                zerovel: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod msg_pps_time {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Local time at detection of PPS pulse
    ///
    /// The PPS time message contains the value of the sender's local time in
    /// microseconds at the moment a pulse is detected on the PPS input. This is
    /// to be used for synchronisation of sensor data sampled with a local
    /// timestamp (e.g. IMU or wheeltick messages) where GNSS time is unknown to
    /// the sender.
    ///
    /// The local time used to timestamp the PPS pulse must be generated by the
    /// same clock which is used to timestamp the IMU/wheel sensor data and should
    /// follow the same roll-over rules (i.e. it should roll over to zero after
    /// 604800 seconds). A separate MSG_PPS_TIME message should be sent for each
    /// source of sensor data which uses local timestamping.  The sender ID for
    /// each of these MSG_PPS_TIME messages should match the sender ID of the
    /// respective sensor data.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgPpsTime {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Local time in microseconds
        #[cfg_attr(feature = "serde", serde(rename = "time"))]
        pub time: u64,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
    }

    impl MsgPpsTime {
        /// Gets the `reserved_set_to_zero` stored in `flags`.
        pub fn reserved_set_to_zero(&self) -> u8 {
            get_bit_range!(self.flags, u8, u8, 7, 2)
        }

        /// Sets the `reserved_set_to_zero` bitrange of `flags`.
        pub fn set_reserved_set_to_zero(&mut self, reserved_set_to_zero: u8) {
            set_bit_range!(&mut self.flags, reserved_set_to_zero, u8, u8, 7, 2);
        }

        /// Gets the [TimeUncertainty][self::TimeUncertainty] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `TimeUncertainty` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `TimeUncertainty` were added.
        pub fn time_uncertainty(&self) -> Result<TimeUncertainty, u8> {
            get_bit_range!(self.flags, u8, u8, 1, 0).try_into()
        }

        /// Set the bitrange corresponding to the [TimeUncertainty][TimeUncertainty] of the `flags` bitfield.
        pub fn set_time_uncertainty(&mut self, time_uncertainty: TimeUncertainty) {
            set_bit_range!(&mut self.flags, time_uncertainty, u8, u8, 1, 0);
        }
    }

    impl ConcreteMessage for MsgPpsTime {
        const MESSAGE_TYPE: u16 = 65288;
        const MESSAGE_NAME: &'static str = "MSG_PPS_TIME";
    }

    impl SbpMessage for MsgPpsTime {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgPpsTime {
        fn friendly_name() -> &'static str {
            "PPS TIME"
        }
    }

    impl TryFrom<Sbp> for MsgPpsTime {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgPpsTime(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgPpsTime {
        const MIN_LEN: usize = <u64 as WireFormat>::MIN_LEN + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.time) + WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.time, buf);
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgPpsTime {
                sender_id: None,
                time: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Time uncertainty
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum TimeUncertainty {
        /// Unknown
        Unknown = 0,

        /// +/- 10 milliseconds
        _10Milliseconds = 1,

        /// +/- 10 microseconds
        _10Microseconds = 2,

        /// < 1 microseconds
        _1Microseconds = 3,
    }

    impl std::fmt::Display for TimeUncertainty {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                TimeUncertainty::Unknown => f.write_str("Unknown"),
                TimeUncertainty::_10Milliseconds => f.write_str("+/- 10 milliseconds"),
                TimeUncertainty::_10Microseconds => f.write_str("+/- 10 microseconds"),
                TimeUncertainty::_1Microseconds => f.write_str("< 1 microseconds"),
            }
        }
    }

    impl TryFrom<u8> for TimeUncertainty {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(TimeUncertainty::Unknown),
                1 => Ok(TimeUncertainty::_10Milliseconds),
                2 => Ok(TimeUncertainty::_10Microseconds),
                3 => Ok(TimeUncertainty::_1Microseconds),
                i => Err(i),
            }
        }
    }
}

pub mod msg_sensor_aid_event {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Sensor state and update status data
    ///
    /// This diagnostic message contains state and update status information for
    /// all sensors that are being used by the fusion engine. This message will be
    /// generated asynchronously to the solution messages and will be emitted
    /// anytime a sensor update is being processed.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgSensorAidEvent {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Update timestamp in milliseconds.
        #[cfg_attr(feature = "serde", serde(rename = "time"))]
        pub time: u32,
        /// Sensor type
        #[cfg_attr(feature = "serde", serde(rename = "sensor_type"))]
        pub sensor_type: u8,
        /// Sensor identifier
        #[cfg_attr(feature = "serde", serde(rename = "sensor_id"))]
        pub sensor_id: u16,
        /// Reserved for future use
        #[cfg_attr(feature = "serde", serde(rename = "sensor_state"))]
        pub sensor_state: u8,
        /// Number of available measurements in this epoch
        #[cfg_attr(feature = "serde", serde(rename = "n_available_meas"))]
        pub n_available_meas: u8,
        /// Number of attempted measurements in this epoch
        #[cfg_attr(feature = "serde", serde(rename = "n_attempted_meas"))]
        pub n_attempted_meas: u8,
        /// Number of accepted measurements in this epoch
        #[cfg_attr(feature = "serde", serde(rename = "n_accepted_meas"))]
        pub n_accepted_meas: u8,
        /// Reserved for future use
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u32,
    }

    impl MsgSensorAidEvent {
        /// Gets the [TypeIdentifier][self::TypeIdentifier] stored in the `sensor_type` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `TypeIdentifier` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `TypeIdentifier` were added.
        pub fn type_identifier(&self) -> Result<TypeIdentifier, u8> {
            get_bit_range!(self.sensor_type, u8, u8, 7, 0).try_into()
        }

        /// Set the bitrange corresponding to the [TypeIdentifier][TypeIdentifier] of the `sensor_type` bitfield.
        pub fn set_type_identifier(&mut self, type_identifier: TypeIdentifier) {
            set_bit_range!(&mut self.sensor_type, type_identifier, u8, u8, 7, 0);
        }
    }

    impl ConcreteMessage for MsgSensorAidEvent {
        const MESSAGE_TYPE: u16 = 65289;
        const MESSAGE_NAME: &'static str = "MSG_SENSOR_AID_EVENT";
    }

    impl SbpMessage for MsgSensorAidEvent {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgSensorAidEvent {
        fn friendly_name() -> &'static str {
            "SENSOR AID EVENT"
        }
    }

    impl TryFrom<Sbp> for MsgSensorAidEvent {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgSensorAidEvent(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgSensorAidEvent {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.time)
                + WireFormat::len(&self.sensor_type)
                + WireFormat::len(&self.sensor_id)
                + WireFormat::len(&self.sensor_state)
                + WireFormat::len(&self.n_available_meas)
                + WireFormat::len(&self.n_attempted_meas)
                + WireFormat::len(&self.n_accepted_meas)
                + WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.time, buf);
            WireFormat::write(&self.sensor_type, buf);
            WireFormat::write(&self.sensor_id, buf);
            WireFormat::write(&self.sensor_state, buf);
            WireFormat::write(&self.n_available_meas, buf);
            WireFormat::write(&self.n_attempted_meas, buf);
            WireFormat::write(&self.n_accepted_meas, buf);
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgSensorAidEvent {
                sender_id: None,
                time: WireFormat::parse_unchecked(buf),
                sensor_type: WireFormat::parse_unchecked(buf),
                sensor_id: WireFormat::parse_unchecked(buf),
                sensor_state: WireFormat::parse_unchecked(buf),
                n_available_meas: WireFormat::parse_unchecked(buf),
                n_attempted_meas: WireFormat::parse_unchecked(buf),
                n_accepted_meas: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Type identifier
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum TypeIdentifier {
        /// GNSS position
        GnssPosition = 0,

        /// GNSS average velocity
        GnssAverageVelocity = 1,

        /// GNSS instantaneous velocity
        GnssInstantaneousVelocity = 2,

        /// Wheel ticks
        WheelTicks = 3,

        /// Wheel speed
        WheelSpeed = 4,

        /// IMU
        Imu = 5,

        /// Time differences of carrier phase
        TimeDifferencesOfCarrierPhase = 6,
    }

    impl std::fmt::Display for TypeIdentifier {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                TypeIdentifier::GnssPosition => f.write_str("GNSS position"),
                TypeIdentifier::GnssAverageVelocity => f.write_str("GNSS average velocity"),
                TypeIdentifier::GnssInstantaneousVelocity => {
                    f.write_str("GNSS instantaneous velocity")
                }
                TypeIdentifier::WheelTicks => f.write_str("Wheel ticks"),
                TypeIdentifier::WheelSpeed => f.write_str("Wheel speed"),
                TypeIdentifier::Imu => f.write_str("IMU"),
                TypeIdentifier::TimeDifferencesOfCarrierPhase => {
                    f.write_str("Time differences of carrier phase")
                }
            }
        }
    }

    impl TryFrom<u8> for TypeIdentifier {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(TypeIdentifier::GnssPosition),
                1 => Ok(TypeIdentifier::GnssAverageVelocity),
                2 => Ok(TypeIdentifier::GnssInstantaneousVelocity),
                3 => Ok(TypeIdentifier::WheelTicks),
                4 => Ok(TypeIdentifier::WheelSpeed),
                5 => Ok(TypeIdentifier::Imu),
                6 => Ok(TypeIdentifier::TimeDifferencesOfCarrierPhase),
                i => Err(i),
            }
        }
    }
}

pub mod msg_startup {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// System start-up message
    ///
    /// The system start-up message is sent once on system start-up. It notifies
    /// the host or other attached devices that the system has started and is now
    /// ready to respond to commands or configuration requests.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgStartup {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Cause of startup
        #[cfg_attr(feature = "serde", serde(rename = "cause"))]
        pub cause: u8,
        /// Startup type
        #[cfg_attr(feature = "serde", serde(rename = "startup_type"))]
        pub startup_type: u8,
        /// Reserved
        #[cfg_attr(feature = "serde", serde(rename = "reserved"))]
        pub reserved: u16,
    }

    impl MsgStartup {
        /// Gets the [CauseOfStartup][self::CauseOfStartup] stored in the `cause` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `CauseOfStartup` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `CauseOfStartup` were added.
        pub fn cause_of_startup(&self) -> Result<CauseOfStartup, u8> {
            get_bit_range!(self.cause, u8, u8, 7, 0).try_into()
        }

        /// Set the bitrange corresponding to the [CauseOfStartup][CauseOfStartup] of the `cause` bitfield.
        pub fn set_cause_of_startup(&mut self, cause_of_startup: CauseOfStartup) {
            set_bit_range!(&mut self.cause, cause_of_startup, u8, u8, 7, 0);
        }

        /// Gets the [StartupType][self::StartupType] stored in the `startup_type` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `StartupType` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `StartupType` were added.
        pub fn startup_type(&self) -> Result<StartupType, u8> {
            get_bit_range!(self.startup_type, u8, u8, 7, 0).try_into()
        }

        /// Set the bitrange corresponding to the [StartupType][StartupType] of the `startup_type` bitfield.
        pub fn set_startup_type(&mut self, startup_type: StartupType) {
            set_bit_range!(&mut self.startup_type, startup_type, u8, u8, 7, 0);
        }
    }

    impl ConcreteMessage for MsgStartup {
        const MESSAGE_TYPE: u16 = 65280;
        const MESSAGE_NAME: &'static str = "MSG_STARTUP";
    }

    impl SbpMessage for MsgStartup {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgStartup {
        fn friendly_name() -> &'static str {
            "STARTUP"
        }
    }

    impl TryFrom<Sbp> for MsgStartup {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgStartup(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgStartup {
        const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.cause)
                + WireFormat::len(&self.startup_type)
                + WireFormat::len(&self.reserved)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.cause, buf);
            WireFormat::write(&self.startup_type, buf);
            WireFormat::write(&self.reserved, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgStartup {
                sender_id: None,
                cause: WireFormat::parse_unchecked(buf),
                startup_type: WireFormat::parse_unchecked(buf),
                reserved: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Cause of startup
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum CauseOfStartup {
        /// Power on
        PowerOn = 0,

        /// Software reset
        SoftwareReset = 1,

        /// Watchdog reset
        WatchdogReset = 2,
    }

    impl std::fmt::Display for CauseOfStartup {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                CauseOfStartup::PowerOn => f.write_str("Power on"),
                CauseOfStartup::SoftwareReset => f.write_str("Software reset"),
                CauseOfStartup::WatchdogReset => f.write_str("Watchdog reset"),
            }
        }
    }

    impl TryFrom<u8> for CauseOfStartup {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(CauseOfStartup::PowerOn),
                1 => Ok(CauseOfStartup::SoftwareReset),
                2 => Ok(CauseOfStartup::WatchdogReset),
                i => Err(i),
            }
        }
    }

    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum StartupType {
        /// Cold start
        ColdStart = 0,

        /// Warm start
        WarmStart = 1,

        /// Hot start
        HotStart = 2,
    }

    impl std::fmt::Display for StartupType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                StartupType::ColdStart => f.write_str("Cold start"),
                StartupType::WarmStart => f.write_str("Warm start"),
                StartupType::HotStart => f.write_str("Hot start"),
            }
        }
    }

    impl TryFrom<u8> for StartupType {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(StartupType::ColdStart),
                1 => Ok(StartupType::WarmStart),
                2 => Ok(StartupType::HotStart),
                i => Err(i),
            }
        }
    }
}

pub mod msg_status_journal {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Status report journal
    ///
    /// The status journal message contains past status reports (see
    /// MSG_STATUS_REPORT) and functions as a error/event storage for telemetry
    /// purposes.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgStatusJournal {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Identity of reporting system
        #[cfg_attr(feature = "serde", serde(rename = "reporting_system"))]
        pub reporting_system: u16,
        /// SBP protocol version
        #[cfg_attr(feature = "serde", serde(rename = "sbp_version"))]
        pub sbp_version: u16,
        /// Total number of status reports sent since system startup
        #[cfg_attr(feature = "serde", serde(rename = "total_status_reports"))]
        pub total_status_reports: u32,
        /// Index and number of messages in this sequence. First nibble is the size
        /// of the sequence (n), second nibble is the zero-indexed counter (ith
        /// packet of n)
        #[cfg_attr(feature = "serde", serde(rename = "sequence_descriptor"))]
        pub sequence_descriptor: u8,
        /// Status journal
        #[cfg_attr(feature = "serde", serde(rename = "journal"))]
        pub journal: Vec<StatusJournalItem>,
    }

    impl MsgStatusJournal {
        /// Gets the [System][self::System] stored in the `reporting_system` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `System` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u16)`. This may be because of a malformed message,
        /// or because new variants of `System` were added.
        pub fn system(&self) -> Result<System, u16> {
            get_bit_range!(self.reporting_system, u16, u16, 15, 0).try_into()
        }

        /// Set the bitrange corresponding to the [System][System] of the `reporting_system` bitfield.
        pub fn set_system(&mut self, system: System) {
            set_bit_range!(&mut self.reporting_system, system, u16, u16, 15, 0);
        }

        /// Gets the `sbp_major_protocol_version_number` stored in `sbp_version`.
        pub fn sbp_major_protocol_version_number(&self) -> u8 {
            get_bit_range!(self.sbp_version, u16, u8, 15, 8)
        }

        /// Sets the `sbp_major_protocol_version_number` bitrange of `sbp_version`.
        pub fn set_sbp_major_protocol_version_number(
            &mut self,
            sbp_major_protocol_version_number: u8,
        ) {
            set_bit_range!(
                &mut self.sbp_version,
                sbp_major_protocol_version_number,
                u16,
                u8,
                15,
                8
            );
        }

        /// Gets the `sbp_minor_protocol_version_number` stored in `sbp_version`.
        pub fn sbp_minor_protocol_version_number(&self) -> u8 {
            get_bit_range!(self.sbp_version, u16, u8, 7, 0)
        }

        /// Sets the `sbp_minor_protocol_version_number` bitrange of `sbp_version`.
        pub fn set_sbp_minor_protocol_version_number(
            &mut self,
            sbp_minor_protocol_version_number: u8,
        ) {
            set_bit_range!(
                &mut self.sbp_version,
                sbp_minor_protocol_version_number,
                u16,
                u8,
                7,
                0
            );
        }
    }

    impl ConcreteMessage for MsgStatusJournal {
        const MESSAGE_TYPE: u16 = 65533;
        const MESSAGE_NAME: &'static str = "MSG_STATUS_JOURNAL";
    }

    impl SbpMessage for MsgStatusJournal {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgStatusJournal {
        fn friendly_name() -> &'static str {
            "STATUS JOURNAL"
        }
    }

    impl TryFrom<Sbp> for MsgStatusJournal {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgStatusJournal(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgStatusJournal {
        const MIN_LEN: usize = <u16 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <Vec<StatusJournalItem> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.reporting_system)
                + WireFormat::len(&self.sbp_version)
                + WireFormat::len(&self.total_status_reports)
                + WireFormat::len(&self.sequence_descriptor)
                + WireFormat::len(&self.journal)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.reporting_system, buf);
            WireFormat::write(&self.sbp_version, buf);
            WireFormat::write(&self.total_status_reports, buf);
            WireFormat::write(&self.sequence_descriptor, buf);
            WireFormat::write(&self.journal, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgStatusJournal {
                sender_id: None,
                reporting_system: WireFormat::parse_unchecked(buf),
                sbp_version: WireFormat::parse_unchecked(buf),
                total_status_reports: WireFormat::parse_unchecked(buf),
                sequence_descriptor: WireFormat::parse_unchecked(buf),
                journal: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// System
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum System {
        /// Starling
        Starling = 0,

        /// Precision GNSS Module (PGM)
        PrecisionGnssModule = 1,
    }

    impl std::fmt::Display for System {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                System::Starling => f.write_str("Starling"),
                System::PrecisionGnssModule => f.write_str("Precision GNSS Module (PGM)"),
            }
        }
    }

    impl TryFrom<u16> for System {
        type Error = u16;
        fn try_from(i: u16) -> Result<Self, u16> {
            match i {
                0 => Ok(System::Starling),
                1 => Ok(System::PrecisionGnssModule),
                i => Err(i),
            }
        }
    }
}

pub mod msg_status_report {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Status report message
    ///
    /// The status report is sent periodically to inform the host or other
    /// attached devices that the system is running. It is used to monitor system
    /// malfunctions. It contains status reports that indicate to the host the
    /// status of each subsystem and whether it is operating correctly.
    ///
    /// Interpretation of the subsystem specific status code is product dependent,
    /// but if the generic status code is initializing, it should be ignored.
    /// Refer to product documentation for details.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgStatusReport {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Identity of reporting system
        #[cfg_attr(feature = "serde", serde(rename = "reporting_system"))]
        pub reporting_system: u16,
        /// SBP protocol version
        #[cfg_attr(feature = "serde", serde(rename = "sbp_version"))]
        pub sbp_version: u16,
        /// Increments on each status report sent
        #[cfg_attr(feature = "serde", serde(rename = "sequence"))]
        pub sequence: u32,
        /// Number of seconds since system start-up
        #[cfg_attr(feature = "serde", serde(rename = "uptime"))]
        pub uptime: u32,
        /// Reported status of individual subsystems
        #[cfg_attr(feature = "serde", serde(rename = "status"))]
        pub status: Vec<SubSystemReport>,
    }

    impl MsgStatusReport {
        /// Gets the [System][self::System] stored in the `reporting_system` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `System` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u16)`. This may be because of a malformed message,
        /// or because new variants of `System` were added.
        pub fn system(&self) -> Result<System, u16> {
            get_bit_range!(self.reporting_system, u16, u16, 15, 0).try_into()
        }

        /// Set the bitrange corresponding to the [System][System] of the `reporting_system` bitfield.
        pub fn set_system(&mut self, system: System) {
            set_bit_range!(&mut self.reporting_system, system, u16, u16, 15, 0);
        }

        /// Gets the `sbp_major_protocol_version_number` stored in `sbp_version`.
        pub fn sbp_major_protocol_version_number(&self) -> u8 {
            get_bit_range!(self.sbp_version, u16, u8, 15, 8)
        }

        /// Sets the `sbp_major_protocol_version_number` bitrange of `sbp_version`.
        pub fn set_sbp_major_protocol_version_number(
            &mut self,
            sbp_major_protocol_version_number: u8,
        ) {
            set_bit_range!(
                &mut self.sbp_version,
                sbp_major_protocol_version_number,
                u16,
                u8,
                15,
                8
            );
        }

        /// Gets the `sbp_minor_protocol_version_number` stored in `sbp_version`.
        pub fn sbp_minor_protocol_version_number(&self) -> u8 {
            get_bit_range!(self.sbp_version, u16, u8, 7, 0)
        }

        /// Sets the `sbp_minor_protocol_version_number` bitrange of `sbp_version`.
        pub fn set_sbp_minor_protocol_version_number(
            &mut self,
            sbp_minor_protocol_version_number: u8,
        ) {
            set_bit_range!(
                &mut self.sbp_version,
                sbp_minor_protocol_version_number,
                u16,
                u8,
                7,
                0
            );
        }
    }

    impl ConcreteMessage for MsgStatusReport {
        const MESSAGE_TYPE: u16 = 65534;
        const MESSAGE_NAME: &'static str = "MSG_STATUS_REPORT";
    }

    impl SbpMessage for MsgStatusReport {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgStatusReport {
        fn friendly_name() -> &'static str {
            "STATUS REPORT"
        }
    }

    impl TryFrom<Sbp> for MsgStatusReport {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgStatusReport(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgStatusReport {
        const MIN_LEN: usize = <u16 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <Vec<SubSystemReport> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.reporting_system)
                + WireFormat::len(&self.sbp_version)
                + WireFormat::len(&self.sequence)
                + WireFormat::len(&self.uptime)
                + WireFormat::len(&self.status)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.reporting_system, buf);
            WireFormat::write(&self.sbp_version, buf);
            WireFormat::write(&self.sequence, buf);
            WireFormat::write(&self.uptime, buf);
            WireFormat::write(&self.status, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgStatusReport {
                sender_id: None,
                reporting_system: WireFormat::parse_unchecked(buf),
                sbp_version: WireFormat::parse_unchecked(buf),
                sequence: WireFormat::parse_unchecked(buf),
                uptime: WireFormat::parse_unchecked(buf),
                status: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// System
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum System {
        /// Starling
        Starling = 0,

        /// Precision GNSS Module (PGM)
        PrecisionGnssModule = 1,
    }

    impl std::fmt::Display for System {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                System::Starling => f.write_str("Starling"),
                System::PrecisionGnssModule => f.write_str("Precision GNSS Module (PGM)"),
            }
        }
    }

    impl TryFrom<u16> for System {
        type Error = u16;
        fn try_from(i: u16) -> Result<Self, u16> {
            match i {
                0 => Ok(System::Starling),
                1 => Ok(System::PrecisionGnssModule),
                i => Err(i),
            }
        }
    }
}

pub mod status_journal_item {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Subsystem Status report
    ///
    /// Reports the uptime and the state of a subsystem via generic and specific
    /// status codes.  If the generic state is reported as initializing, the
    /// specific state should be ignored.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct StatusJournalItem {
        /// Milliseconds since system startup
        #[cfg_attr(feature = "serde", serde(rename = "uptime"))]
        pub uptime: u32,
        #[cfg_attr(feature = "serde", serde(rename = "report"))]
        pub report: SubSystemReport,
    }

    impl WireFormat for StatusJournalItem {
        const MIN_LEN: usize =
            <u32 as WireFormat>::MIN_LEN + <SubSystemReport as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.uptime) + WireFormat::len(&self.report)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.uptime, buf);
            WireFormat::write(&self.report, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            StatusJournalItem {
                uptime: WireFormat::parse_unchecked(buf),
                report: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod sub_system_report {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Subsystem Status report
    ///
    /// Report the general and specific state of a subsystem.  If the generic
    /// state is reported as initializing, the specific state should be ignored.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct SubSystemReport {
        /// Identity of reporting subsystem
        #[cfg_attr(feature = "serde", serde(rename = "component"))]
        pub component: u16,
        /// Generic form status report
        #[cfg_attr(feature = "serde", serde(rename = "generic"))]
        pub generic: u8,
        /// Subsystem specific status code
        #[cfg_attr(feature = "serde", serde(rename = "specific"))]
        pub specific: u8,
    }

    impl SubSystemReport {
        /// Gets the [Subsystem][self::Subsystem] stored in the `component` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `Subsystem` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u16)`. This may be because of a malformed message,
        /// or because new variants of `Subsystem` were added.
        pub fn subsystem(&self) -> Result<Subsystem, u16> {
            get_bit_range!(self.component, u16, u16, 15, 0).try_into()
        }

        /// Set the bitrange corresponding to the [Subsystem][Subsystem] of the `component` bitfield.
        pub fn set_subsystem(&mut self, subsystem: Subsystem) {
            set_bit_range!(&mut self.component, subsystem, u16, u16, 15, 0);
        }

        /// Gets the [Generic][self::Generic] stored in the `generic` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `Generic` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `Generic` were added.
        pub fn generic(&self) -> Result<Generic, u8> {
            get_bit_range!(self.generic, u8, u8, 7, 0).try_into()
        }

        /// Set the bitrange corresponding to the [Generic][Generic] of the `generic` bitfield.
        pub fn set_generic(&mut self, generic: Generic) {
            set_bit_range!(&mut self.generic, generic, u8, u8, 7, 0);
        }
    }

    impl WireFormat for SubSystemReport {
        const MIN_LEN: usize = <u16 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.component)
                + WireFormat::len(&self.generic)
                + WireFormat::len(&self.specific)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.component, buf);
            WireFormat::write(&self.generic, buf);
            WireFormat::write(&self.specific, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            SubSystemReport {
                component: WireFormat::parse_unchecked(buf),
                generic: WireFormat::parse_unchecked(buf),
                specific: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Subsystem
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum Subsystem {
        /// Primary GNSS Antenna
        PrimaryGnssAntenna = 0,

        /// Measurement Engine
        MeasurementEngine = 1,

        /// Corrections Client
        CorrectionsClient = 2,

        /// Differential GNSS Engine
        DifferentialGnssEngine = 3,

        /// CAN
        Can = 4,

        /// Wheel Odometry
        WheelOdometry = 5,

        /// Sensor Fusion Engine
        SensorFusionEngine = 6,
    }

    impl std::fmt::Display for Subsystem {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                Subsystem::PrimaryGnssAntenna => f.write_str("Primary GNSS Antenna"),
                Subsystem::MeasurementEngine => f.write_str("Measurement Engine"),
                Subsystem::CorrectionsClient => f.write_str("Corrections Client"),
                Subsystem::DifferentialGnssEngine => f.write_str("Differential GNSS Engine"),
                Subsystem::Can => f.write_str("CAN"),
                Subsystem::WheelOdometry => f.write_str("Wheel Odometry"),
                Subsystem::SensorFusionEngine => f.write_str("Sensor Fusion Engine"),
            }
        }
    }

    impl TryFrom<u16> for Subsystem {
        type Error = u16;
        fn try_from(i: u16) -> Result<Self, u16> {
            match i {
                0 => Ok(Subsystem::PrimaryGnssAntenna),
                1 => Ok(Subsystem::MeasurementEngine),
                2 => Ok(Subsystem::CorrectionsClient),
                3 => Ok(Subsystem::DifferentialGnssEngine),
                4 => Ok(Subsystem::Can),
                5 => Ok(Subsystem::WheelOdometry),
                6 => Ok(Subsystem::SensorFusionEngine),
                i => Err(i),
            }
        }
    }

    /// Generic
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum Generic {
        /// OK/Nominal
        OKNominal = 0,

        /// Initializing
        Initializing = 1,

        /// Unknown
        Unknown = 2,

        /// Degraded
        Degraded = 3,

        /// Unusable
        Unusable = 4,
    }

    impl std::fmt::Display for Generic {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                Generic::OKNominal => f.write_str("OK/Nominal"),
                Generic::Initializing => f.write_str("Initializing"),
                Generic::Unknown => f.write_str("Unknown"),
                Generic::Degraded => f.write_str("Degraded"),
                Generic::Unusable => f.write_str("Unusable"),
            }
        }
    }

    impl TryFrom<u8> for Generic {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(Generic::OKNominal),
                1 => Ok(Generic::Initializing),
                2 => Ok(Generic::Unknown),
                3 => Ok(Generic::Degraded),
                4 => Ok(Generic::Unusable),
                i => Err(i),
            }
        }
    }
}