ROSaic
sbf_structs.hpp
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // © Copyright 2020, Septentrio NV/SA.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // 3. Neither the name of the copyright holder nor the names of its
14 // contributors may be used to endorse or promote products derived
15 // from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 // *****************************************************************************
30 
31 #ifndef SBFStructs_HPP
32 #define SBFStructs_HPP
33 
35 #ifndef NR_OF_LOGICALCHANNELS
36 #define NR_OF_LOGICALCHANNELS 80
37 #endif
38 #ifndef MAX_NB_INMARSATCHANNELS
40 #define MAX_NB_INMARSATCHANNELS 1
41 #endif
42 #ifndef MAX_NR_OF_SIGNALS_PER_SATELLITE
44 #define MAX_NR_OF_SIGNALS_PER_SATELLITE 7
45 #endif
46 #ifndef NR_OF_ANTENNAS
48 #define NR_OF_ANTENNAS 3
49 #endif
50 #ifndef MAXSB_NBRANTENNA
52 #define MAXSB_NBRANTENNA 4
53 #endif
54 #ifndef MAXSB_CHANNELSATINFO
56 #define MAXSB_CHANNELSATINFO (NR_OF_LOGICALCHANNELS + MAX_NB_INMARSATCHANNELS)
57 #endif
58 #ifndef MAXSB_CHANNELSTATEINFO
60 #define MAXSB_CHANNELSTATEINFO (MAXSB_CHANNELSATINFO * MAXSB_NBRANTENNA)
61 #endif
62 #ifndef MAXSB_MEASEPOCH_T1
64 #define MAXSB_MEASEPOCH_T1 (NR_OF_LOGICALCHANNELS + MAX_NB_INMARSATCHANNELS)
65 #endif
66 #ifndef MAXSB_MEASEPOCH_T2
68 #define MAXSB_MEASEPOCH_T2 ((MAXSB_MEASEPOCH_T1) * ( ((MAX_NR_OF_SIGNALS_PER_SATELLITE) * (NR_OF_ANTENNAS)) -1))
69 #endif
70 
71 // ROSaic includes
72 #include "ssn_types.hpp"
73 
74 #if defined(__GNUC__) || defined(__ARMCC__)
75 /* Before the advent of the CPMF platform, double data types were always
76  * 32-bit aligned, meaning that the struct were aligned to an address
77  * that was divisible by 4. On the CPMF, double data types are 64-bit
78  * aligned. The "packed, aligned(4)" attribute combination is necessary
79  * to enforce 32-bit alignment for double data types and to port the SBF
80  * encoding/decoding functionality to the CPMF.
81  */
82 // The aligned variable attribute specifies a minimum alignment for the variable or structure field, measured in bytes.
83 // The aligned attribute only increases the alignment for a struct or struct member. For a variable that is not in a
84 // structure, the minimum alignment is the natural alignment of the variable type. To set the alignment in a structure
85 // to any value greater than 0, use the packed variable attribute. Without packed, the minimum alignment is the natural
86 // alignment of the variable type.
87 
88 # define SBFDOUBLE double __attribute__((packed, aligned(4)))
89 #else
90 # define SBFDOUBLE double
91 #endif
92 
93 
94 /* Force packing the structs on 4-byte alignment (needed for GCC 64 bit compilations) */
95 #pragma pack(push,4)
96 // Clearly, there will be padding bytes for some structs, but those will be ignored by our decoding software, as also
97 // suggested in the firmware.
98 // Example usages of pragma directives:
99 // #pragma warn +xxx (To show the warning)
100 // #pragma startup func1 and
101 // #pragma exit func2 would not work with GCC compilers (just ignored)
102 // printf("Size of A is: %ld", sizeof(A)); [%d works fine with signed, unsigned and negative integer values, l stands
103 // for long], recall we want structs to avoid wasting = padding
104 // To force compiler to use 1 byte packaging: #pragma pack(1)
105 // Same result for struct s {int i...} __attribute__((packed)); could be shown via printf("%zu ", offsetof(s, i));
106 // #pragma pack() // n defaults to 8; equivalent to /Zp8, Valid values are 1, 2, 4, 8, and 16, forces the maximum
107 // alignment of each field to be the value specified by n
108 // push: Pushes the current alignment setting on an internal stack and then optionally sets the new alignment,
109 // identifier is also allowed
110 
120 typedef struct
121 {
122  uint8_t sync_1;
123  uint8_t sync_2;
124  uint16_t crc;
125  uint16_t id;
126  uint16_t length;
127 } BlockHeader_t;
128 
129 
135 {
137 
138  /* Time Header */
139  uint32_t tow;
140  uint16_t wnc;
141 
142  uint8_t mode;
143  uint8_t error;
147  float undulation;
148  float vx;
149  float vy;
150  float vz;
151  float cog;
153  float rx_clk_drift;
154  uint8_t time_system;
155  uint8_t datum;
156  uint8_t nr_sv;
157  uint8_t wa_corr_info;
158  uint16_t reference_id;
159  uint16_t mean_corr_age;
160  uint32_t signal_info;
161  uint8_t alert_flag;
162  uint8_t nr_bases;
163  uint16_t ppp_info;
164  uint16_t latency;
165  uint16_t h_accuracy;
166  uint16_t v_accuracy;
167  uint8_t misc;
168 };
169 
175 {
177 
178  /* Time Header */
179  uint32_t tow;
180  uint16_t wnc;
181 
182  uint8_t mode;
183  uint8_t error;
187  float undulation;
188  float vn;
189  float ve;
190  float vu;
191  float cog;
193  float rx_clk_drift;
194  uint8_t time_system;
195  uint8_t datum;
196  uint8_t nr_sv;
197  uint8_t wa_corr_info;
198  uint16_t reference_id;
199  uint16_t mean_corr_age;
200  uint32_t signal_info;
201  uint8_t alert_flag;
202  uint8_t nr_bases;
203  uint16_t ppp_info;
204  uint16_t latency;
205  uint16_t h_accuracy;
206  uint16_t v_accuracy;
207  uint8_t misc;
208 };
209 
214 struct AttEuler
215 {
217 
218  /* Time Header */
219  uint32_t tow;
220  uint16_t wnc;
221 
222  uint8_t nr_sv;
223  uint8_t error;
224  uint16_t mode;
225  uint16_t reserved;
226  float heading;
227  float pitch;
228  float roll;
229  float pitch_dot;
230  float roll_dot;
231  float heading_dot;
232 };
233 
234 
240 {
242 
243  /* Time Header */
244  uint32_t tow;
245  uint16_t wnc;
246 
247  uint8_t reserved;
248  uint8_t error;
255 };
256 
261 typedef struct
262 {
263  uint8_t antenna;
264  uint8_t reserved;
265  uint16_t tracking_status;
266  uint16_t pvt_status;
267  uint16_t pvt_info;
269 
274 typedef struct
275 {
276  uint8_t sv_id;
277  uint8_t freq_nr;
278  uint8_t reserved1[2];
279  uint16_t az_rise_set;
280  uint16_t health_status;
281  int8_t elev;
282  uint8_t n2;
283  uint8_t channel;
284  uint8_t reserved2;
286 
288 #ifndef SBF_CHANNELSTATUS_DATA_LENGTH
289 #define SBF_CHANNELSTATUS_DATA_LENGTH MAXSB_CHANNELSATINFO * sizeof(ChannelSatInfo) + MAXSB_CHANNELSTATEINFO * sizeof(ChannelStateInfo)
290 #endif
291 
297 {
299 
300  /* Time Header */
301  uint32_t tow;
302  uint16_t wnc;
303 
304  uint8_t n;
305  uint8_t sb1_size;
306  uint8_t sb2_size;
307  uint8_t reserved[3];
309 };
310 
315 typedef struct
316 {
317  uint8_t type;
318  uint8_t lock_time;
319  uint8_t cn0;
320  uint8_t offsets_msb;
321  int8_t carrier_msb;
322  uint8_t obs_info;
323  uint16_t code_offset_lsb;
324  uint16_t carrier_lsb;
327 
332 typedef struct
333 {
334  uint8_t rx_channel;
335  uint8_t type;
336  uint8_t sv_id;
337  uint8_t misc;
338  uint32_t code_lsb;
339  int32_t doppler;
340  uint16_t carrier_lsb;
341  int8_t carrier_msb;
342  uint8_t cn0;
343  uint16_t lock_time;
344  uint8_t obs_info;
345  uint8_t n_type2;
347 
349 #ifndef MEASEPOCH_DATA_LENGTH
350 #define MEASEPOCH_DATA_LENGTH (MAXSB_MEASEPOCH_T1 * sizeof(MeasEpochChannelType1) + MAXSB_MEASEPOCH_T2 * sizeof(MeasEpochChannelType2))
351 #endif
352 
357 struct MeasEpoch
358 {
360 
361  /* Time Header */
362  uint32_t tow;
363  uint16_t wnc;
364 
365  /* MeasEpoch Header */
366  uint8_t n;
367  uint8_t sb1_size;
368  uint8_t sb2_size;
369 
370  uint8_t common_flags;
371  uint8_t cum_clk_jumps;
372  uint8_t reserved;
373  uint8_t data[MEASEPOCH_DATA_LENGTH];
374 };
375 
380 struct DOP
381 {
383 
384  /* Time Header */
385  uint32_t tow;
386  uint16_t wnc;
387 
388  uint8_t nr_sv;
389  uint8_t reserved;
390  uint16_t pdop;
391  uint16_t tdop;
392  uint16_t hdop;
393  uint16_t vdop;
394  float hpl;
395  float vpl;
396 };
397 
403 {
405 
406  /* Time Header */
407  uint32_t tow;
408  uint16_t wnc;
409 
410  uint8_t reserved[2];
411  char marker_name[60];
412  char marker_number[20];
413  char observer[20];
414  char agency[40];
415  char rx_serial_number[20];
416  char rx_name[20];
417  char rx_version[20];
418  char ant_serial_nbr[20];
419  char ant_type[20];
420  float delta_h; /* [m] */
421  float delta_e; /* [m] */
422  float delta_n; /* [m] */
423  char marker_type[20];
424  char gnss_fw_version[40];
425 };
426 
432 {
434 
435  /* Time Header */
436  uint32_t tow;
437  uint16_t wnc;
438 
439  uint8_t n;
440  uint8_t reserved;
441  uint16_t indicators[40];
442 };
443 
447 typedef struct
448 {
449  uint8_t frontend_id;
450  int8_t gain;
451  uint8_t sample_var;
452  uint8_t blanking_stat;
453 } AGCState_t;
454 
460 {
462 
463  /* Time Header */
464  uint32_t tow;
465  uint16_t wnc;
466 
467  uint8_t cpu_load;
468  uint8_t ext_error;
469  uint32_t up_time;
470  uint32_t rx_status;
471  uint32_t rx_error;
472  uint8_t n;
473  uint8_t sb_lngth;
474  uint8_t cmd_count;
475  uint8_t temperature;
476  AGCState_t agc_state[18];
477 };
478 
484 {
486 
487  /* Time Header */
488  uint32_t tow;
489  uint16_t wnc;
490 
491  uint8_t mode;
492  uint8_t error;
493  float cov_xx;
494  float cov_yy;
495  float cov_zz;
496  float cov_bb;
497  float cov_xy;
498  float cov_xz;
499  float cov_xb;
500  float cov_yz;
501  float cov_yb;
502  float cov_zb;
503 };
504 
510 {
512 
513  /* Time Header */
514  uint32_t tow;
515  uint16_t wnc;
516 
517  uint8_t mode;
518  uint8_t error;
519  float cov_latlat;
520  float cov_lonlon;
521  float cov_hgthgt;
522  float cov_bb;
523  float cov_latlon;
524  float cov_lathgt;
525  float cov_latb;
526  float cov_lonhgt;
527  float cov_lonb;
528  float cov_hb;
529 };
530 
536 {
538 
539  /* Time Header */
540  uint32_t tow;
541  uint16_t wnc;
542 
543  uint8_t mode;
544  uint8_t error;
545  float cov_vxvx;
546  float cov_vyvy;
547  float cov_vzvz;
548  float cov_dtdt;
549  float cov_vxvy;
550  float cov_vxvz;
551  float cov_vxdt;
552  float cov_vyvz;
553  float cov_vydt;
554  float cov_vzdt;
555 };
556 
562 {
564 
565  /* Time Header */
566  uint32_t tow;
567  uint16_t wnc;
568 
569  uint8_t mode;
570  uint8_t error;
571  float cov_vnvn;
572  float cov_veve;
573  float cov_vuvu;
574  float cov_dtdt;
575  float cov_vnve;
576  float cov_vnvu;
577  float cov_vndt;
578  float cov_vevu;
579  float cov_vedt;
580  float cov_vudt;
581 };
582 
583 #pragma pack ( pop )
584 // The above form of the pack pragma affects only class, struct, and union type declarations between
585 // push and pop directives. (A pop directive with no prior push results in a warning diagnostic from the compiler.)
586 
592 static const uint16_t CRC_LOOK_UP[256] = {
593  0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
594  0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
595  0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
596  0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
597  0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
598  0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
599  0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
600  0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
601  0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
602  0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
603  0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
604  0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
605  0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
606  0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
607  0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
608  0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
609  0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
610  0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
611  0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
612  0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
613  0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
614  0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
615  0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
616  0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
617  0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
618  0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
619  0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
620  0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
621  0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
622  0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
623  0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
624  0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
625 };
626 
627 #endif // SBFStructs_HPP
uint16_t pdop
uint8_t sb2_size
Struct for the SBF block "AttCovEuler".
#define MEASEPOCH_DATA_LENGTH
Max number of bytes that the data part of the MeasEpoch struct can consist of.
float cov_headroll
#define SBF_CHANNELSTATUS_DATA_LENGTH
Max number of bytes that the Data part of the ChannelStatus struct can consist of.
uint16_t mode
uint16_t tdop
uint8_t time_system
float cov_rollroll
uint16_t reference_id
uint8_t wa_corr_info
uint8_t time_system
double rx_clk_bias
BlockHeader_t block_header
BlockHeader_t block_header
uint16_t length
Length of the entire message including the header. A multiple of 4 between 8 and 4096.
uint16_t vdop
BlockHeader_t block_header
BlockHeader_t block_header
float cov_headpitch
Struct for the SBF block "VelCovCartesian".
uint16_t v_accuracy
float hpl
uint16_t wnc
uint8_t common_flags
Struct for the SBF block's header message.
uint16_t v_accuracy
#define SBFDOUBLE
Definition: sbf_structs.hpp:90
uint8_t sb1_size
BlockHeader_t block_header
Struct for the SBF block "VelCovGeodetic".
Struct for the SBF sub-block "MeasEpochChannelType1".
Struct for the SBF block "ReceiverSetup".
uint16_t health_status
BlockHeader_t block_header
uint16_t wnc
uint16_t crc
The check sum.
Struct for the SBF block "PosCovGeodetic".
float rx_clk_drift
float heading_dot
uint16_t latency
uint32_t tow
uint8_t n
uint16_t ppp_info
uint32_t signal_info
uint8_t misc
uint32_t tow
uint8_t sb2_size
uint8_t nr_bases
float roll_dot
uint16_t tracking_status
uint16_t ppp_info
double latitude
BlockHeader_t block_header
uint16_t wnc
uint8_t reserved
uint32_t up_time
uint8_t nr_sv
uint32_t signal_info
Struct for the SBF block "PVTGeodetic".
uint8_t sync_1
first sync byte is $ or 0x24
Struct for the SBF block "AttEuler".
uint16_t h_accuracy
BlockHeader_t block_header
BlockHeader_t block_header
float rx_clk_drift
uint8_t sb1_size
uint16_t reference_id
Struct for the SBF sub-block "MeasEpochChannelType2".
float pitch_dot
uint32_t tow
float vpl
Struct for the SBF block "QualityInd".
BlockHeader_t block_header
double longitude
uint32_t tow
uint16_t mean_corr_age
uint8_t alert_flag
Struct for the SBF sub-block "ChannelStateInfo".
uint8_t nr_sv
uint8_t sample_var
Struct for the SBF block "PVTCartesian".
float cov_pitchroll
uint16_t wnc
static const uint16_t CRC_LOOK_UP[256]
CRC look-up table for fast computation of the 16-bit CRC for SBF blocks.
Struct for the SBF block "PosCovCartesian".
uint8_t error
uint8_t reserved
uint8_t alert_flag
uint8_t error
float heading
float pitch
uint32_t tow
uint16_t az_rise_set
BlockHeader_t block_header
uint8_t reserved
uint32_t tow
Struct for the SBF sub-block "ChannelSatInfo".
Struct for the SBF block "ChannelStatus".
uint16_t reserved
Struct for the SBF block "MeasEpoch".
uint8_t cum_clk_jumps
double rx_clk_bias
float undulation
BlockHeader_t block_header
Struct for the SBF block "DOP".
uint32_t tow
float cov_headhead
uint16_t id
This is the block ID.
Struct for the SBF sub-block "AGCState".
uint16_t hdop
uint16_t h_accuracy
uint32_t rx_error
uint8_t datum
uint8_t blanking_stat
uint16_t wnc
Aims at making the C++ code as portable as possible, by dealing with all compilers except for MS comp...
uint32_t rx_status
BlockHeader_t block_header
uint8_t sync_2
2nd sync byte is @ or 0x40
uint8_t nr_sv
uint8_t reserved
uint16_t latency
float roll
float cov_pitchpitch
uint16_t mean_corr_age
uint8_t temperature
uint8_t nr_bases
BlockHeader_t block_header
uint8_t frontend_id
uint8_t mode
uint8_t wa_corr_info
uint16_t wnc
uint8_t error
uint16_t wnc
Struct for the SBF block "ReceiverStatus".