[293] | 1 | /* Defines for the RTIGS <--> Raw Converter
|
---|
| 2 | * - Source functions
|
---|
| 3 | *
|
---|
| 4 | * Copyright (c) 2006
|
---|
| 5 | * Geoscience Australia
|
---|
| 6 | *
|
---|
| 7 | * Written by James Stewart
|
---|
| 8 | * E-mail: James.Stewart@ga.gov.au
|
---|
| 9 | *
|
---|
| 10 | * Enquiries contact
|
---|
| 11 | * Michael Moore
|
---|
| 12 | * E-mail: Michael.Moore@ga.gov.au
|
---|
| 13 | *
|
---|
| 14 | * Based on the GNU General Public License published Icecast 1.3.12
|
---|
| 15 | *
|
---|
| 16 | * This program is free software; you can redistribute it and/or
|
---|
| 17 | * modify it under the terms of the GNU General Public License
|
---|
| 18 | * as published by the Free Software Foundation; either version 2
|
---|
| 19 | * of the License, or (at your option) any later version.
|
---|
| 20 | *
|
---|
| 21 | * This program is distributed in the hope that it will be useful,
|
---|
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 24 | * GNU General Public License for more details.
|
---|
| 25 | *
|
---|
| 26 | * You should have received a copy of the GNU General Public License
|
---|
| 27 | * along with this program; if not, write to the Free Software
|
---|
| 28 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 29 | */
|
---|
| 30 | #ifndef __RTIGS_H_INCLUDED__
|
---|
| 31 | #define __RTIGS_H_INCLUDED__ 1
|
---|
[52] | 32 |
|
---|
[293] | 33 | typedef unsigned int u_int32_t;
|
---|
| 34 | typedef unsigned short u_int16_t;
|
---|
| 35 | typedef unsigned char u_int8_t;
|
---|
| 36 | typedef unsigned char u_char;
|
---|
[52] | 37 |
|
---|
[293] | 38 | #define C ((double)299792458.00) /* speed of light in vaccuum */
|
---|
| 39 | #define F1 ((double)1575.42E+06) /* GPS L1 frequency */
|
---|
| 40 | #define F2 ((double)1227.60E+06) /* GPS L2 frequency */
|
---|
| 41 | #define F1_SQUARE (F1 * F1) /* GPS L1 frequency squared */
|
---|
| 42 | #define F2_SQUARE (F2 * F2) /* GPS L2 frequency squared */
|
---|
| 43 | #define W1 ((double)(C / F1)) /* GPS L1 wavelength */
|
---|
| 44 | #define W2 ((double)(C / F2)) /* GPS L2 wavelength */
|
---|
| 45 | #define F1ION (F2_SQUARE / (F1_SQUARE - F2_SQUARE)) /* L1 iono scale factor */
|
---|
| 46 | #define F2ION (F1_SQUARE / (F1_SQUARE - F2_SQUARE)) /* L2 iono scale factor */
|
---|
| 47 | #define SF1 (F1ION + F2ION)
|
---|
| 48 | #define SF2 (F1ION * 2)
|
---|
| 49 | #define SF3 (F2ION * 2)
|
---|
| 50 | #define MAXCYCLEOSL1 374 // changed to fit 83.88 metres 441 Feb. 24/2004 ~100m in cycles was 526
|
---|
| 51 | #define MAXCYCLEOSL2 291 // changed to fit 83.88 metres 343 Feb. 24/2004 was ~100m in cycles 410
|
---|
[67] | 52 |
|
---|
[293] | 53 | /* RTIGSH_T Structure -> RTIGS Header structure, Used For Working Out What Sort Of Packet We Got */
|
---|
| 54 | struct RTIGSH_T
|
---|
| 55 | {
|
---|
| 56 | u_int16_t rec_id;
|
---|
| 57 | u_int16_t sta_id;
|
---|
| 58 | u_int32_t GPSTime;
|
---|
| 59 | u_int16_t num_bytes;
|
---|
| 60 | u_int8_t IODS;
|
---|
| 61 | u_int8_t misc;
|
---|
| 62 | };
|
---|
[52] | 63 |
|
---|
| 64 |
|
---|
[293] | 65 | /* RTIGSS_T Structure -> RTIGS Station structure, normally rec_id = 100 */
|
---|
| 66 | struct RTIGSS_T
|
---|
| 67 | {
|
---|
| 68 | u_int16_t rec_id;
|
---|
| 69 | u_int16_t sta_id;
|
---|
| 70 | u_int32_t GPSTime;
|
---|
| 71 | u_int16_t num_bytes;
|
---|
| 72 | u_int8_t IODS;
|
---|
| 73 | u_int8_t sta_rec_type;
|
---|
| 74 | u_char IGS_UniqueID[8];
|
---|
| 75 | };
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | /* RTIGSO_T Structure -> RTIGS Observation structure, normally rec_id = 200 */
|
---|
| 79 | struct RTIGSO_T
|
---|
| 80 | {
|
---|
| 81 | u_int16_t rec_id;
|
---|
| 82 | u_int16_t sta_id;
|
---|
| 83 | u_int32_t GPSTime;
|
---|
| 84 | u_int16_t num_bytes;
|
---|
| 85 | u_int8_t IODS;
|
---|
| 86 | u_int8_t num_obs;
|
---|
| 87 | u_char data[12][21];
|
---|
| 88 | };
|
---|
| 89 |
|
---|
| 90 | /* RTIGSE_T Structure -> RTIGS Ephemeris structure, normally rec_id = 300 */
|
---|
| 91 | struct RTIGSE_T
|
---|
| 92 | {
|
---|
| 93 | u_int16_t rec_id;
|
---|
| 94 | u_int16_t sta_id;
|
---|
| 95 | u_int32_t GPSTime;
|
---|
| 96 | u_int16_t num_bytes;
|
---|
| 97 | u_int8_t IODS;
|
---|
| 98 | u_int8_t prn;
|
---|
| 99 | u_char data[72];
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 | /* RTIGSM_T Structure -> RTIGS Met structure, normally rec_id = 400 */
|
---|
| 104 | struct RTIGSM_T
|
---|
| 105 | {
|
---|
| 106 | u_int16_t rec_id;
|
---|
| 107 | u_int16_t sta_id;
|
---|
| 108 | u_int32_t GPSTime;
|
---|
| 109 | u_int16_t num_bytes;
|
---|
| 110 | u_int8_t IODS;
|
---|
| 111 | u_int8_t num_obs;
|
---|
| 112 | long temp;
|
---|
| 113 | long press;
|
---|
| 114 | long humid;
|
---|
| 115 | };
|
---|
| 116 |
|
---|
| 117 | /* The 21 Byte SOC Compressed Observation Structure per SV */
|
---|
| 118 | struct JPL_COMP_OBS_T
|
---|
| 119 | {
|
---|
| 120 | unsigned char prn; // satellite ID
|
---|
| 121 | unsigned short epoch_sequence; // like Ashtech seq number of phase epochs
|
---|
| 122 | // was like this, now modulo 10 hours,
|
---|
| 123 | // each digit is now 1 sec, not .05 secs like before
|
---|
| 124 | unsigned char ca_range[5]; // ca range in millimeters
|
---|
| 125 | // first 4 bits are status bits, as follows
|
---|
| 126 | // if bit 7 on, sucessful packing of ca_range
|
---|
| 127 | // if bit 6 on, Z track mode or AS is on
|
---|
| 128 | // if bit 5 on, overflow of L2_block phase
|
---|
| 129 | // if bit 4 on, overflow of L1_block phase
|
---|
| 130 | // next 36 bits are the observable
|
---|
| 131 | // 68719.476735 is the max allowable obsev.
|
---|
| 132 | // if not packed, L2_block and L1_block is
|
---|
| 133 | // just then packed with 0s
|
---|
| 134 |
|
---|
| 135 | unsigned char CA_snr; // receiver snr for ca in dbHz KML the SNR is (DBHz * 4.25) rounded to an int (max is 60.0)
|
---|
| 136 | unsigned char L2_range_phase[5];
|
---|
| 137 | // first 2 bytes and 2 bits is for the range, next 6 bits and 2 bytes are for phase.
|
---|
| 138 | //
|
---|
| 139 | // range units are in millimeters, from -131071 to 131071 (2^17 - 1)
|
---|
| 140 | // 0000 0000 0000 0000 01 would be +1 mm
|
---|
| 141 | // 100000000000000001 would be -1 mm
|
---|
| 142 | // 0100 0000 0000 0000 00 would be 65536 mm
|
---|
| 143 | // 1100 0000 0000 0000 00 would be -65536 mm
|
---|
| 144 | // 0111 1111 1111 1111 11 would be 131071 mm
|
---|
| 145 | // 111111111111111111 woule be -131071 mm
|
---|
| 146 | // dynamic range must be <= 131.071 meters
|
---|
| 147 | //
|
---|
| 148 | // phase units are in 2/100 millimeters from -4194304 to 4194304
|
---|
| 149 | // 00 0000 0000 0000 0000 0001 would be +.02 mm
|
---|
| 150 | // 10 0000 0000 0000 0000 0001 would be -.02 mm
|
---|
| 151 | // 01 1111 1111 1111 1111 1111 ( 2097151) would be 41943.02 mm
|
---|
| 152 | // 11 1111 1111 1111 1111 1111 (-2097151) would be -41943.02 mm
|
---|
| 153 | // (2^21 - 1)*2 mm
|
---|
| 154 | // dynamic range must be <= 41.94302 meters
|
---|
| 155 | //
|
---|
| 156 | // note if the limits are exceded, a -0 (minus zero) is returned
|
---|
| 157 | // indicating not a number
|
---|
| 158 | //
|
---|
| 159 | // Note however, we extended this dynamic range to 83.88606 meters as
|
---|
| 160 | // below with the spare bits in the ca_range field. If this limit
|
---|
| 161 | // is exceeded we return a -0 ( minus zero )
|
---|
| 162 | unsigned char L2_snr; // snr for this data type in dbHz, the SNR is (DBHz * 4.25) rounded to an int (max is 60.0 )
|
---|
| 163 | unsigned char L1_range_phase[5]; // same as format for L2_range_phase
|
---|
| 164 | unsigned char L1_snr; // snr for this data type in dbHz, the SNR is (DBHz * 4.25) rounded to an int (max is 60.0 )
|
---|
| 165 | };
|
---|
| 166 |
|
---|
| 167 |
|
---|
| 168 | /* GPSSatellite Structure -> 44 Byte raw SV Structure */
|
---|
| 169 | struct GPSSatellite
|
---|
| 170 | {
|
---|
| 171 | unsigned char prn;
|
---|
| 172 | unsigned char CASnr;
|
---|
| 173 | unsigned char L1Snr;
|
---|
| 174 | unsigned char L2Snr;
|
---|
| 175 | double CARange;
|
---|
| 176 | double P1Range;
|
---|
| 177 | double L1Phase;
|
---|
| 178 | double P2Range;
|
---|
| 179 | double L2Phase;
|
---|
| 180 | unsigned short locktime;
|
---|
| 181 | };
|
---|
| 182 |
|
---|
| 183 | /* GPSEpoch Structure -> raw epoch Structure */
|
---|
| 184 | struct GPSEpoch_T
|
---|
| 185 | {
|
---|
| 186 | unsigned int GPSTime;
|
---|
| 187 | unsigned short sta_id;
|
---|
| 188 | unsigned char num_sv;
|
---|
| 189 | unsigned char padding;
|
---|
| 190 | struct GPSSatellite sv[12];
|
---|
| 191 | };
|
---|
| 192 |
|
---|
| 193 | struct GPSMet_T
|
---|
| 194 | {
|
---|
| 195 | unsigned int GPSTime;
|
---|
| 196 | unsigned short sta_id;
|
---|
| 197 | long temperature;
|
---|
| 198 | long humidity;
|
---|
| 199 | long pressure;
|
---|
| 200 | };
|
---|
| 201 |
|
---|
| 202 | typedef struct RTIGSO_T RTIGSO;
|
---|
| 203 | typedef struct RTIGSE_T RTIGSE;
|
---|
| 204 | typedef struct RTIGSS_T RTIGSS;
|
---|
| 205 | typedef struct RTIGSM_T RTIGSM;
|
---|
| 206 | typedef struct RTIGSH_T RTIGSH;
|
---|
| 207 | typedef struct GPSEpoch_T GPSEpoch;
|
---|
| 208 | typedef struct GPSMet_T GPSMet;
|
---|
| 209 |
|
---|
| 210 |
|
---|
| 211 | /* Function Declarations */
|
---|
| 212 | extern void bytes_to_rtigsh(RTIGSH *rtigsh, unsigned char *packet);
|
---|
| 213 | extern int rtigso_to_raw(RTIGSO *rtigso, GPSEpoch *gpse);
|
---|
| 214 | extern int rtigsm_to_raw(RTIGSM *rtigsm, GPSMet *met);
|
---|
| 215 |
|
---|
| 216 |
|
---|
| 217 | void revbytes(unsigned char *buf, unsigned char size);
|
---|
| 218 |
|
---|
[52] | 219 | #endif
|
---|
[293] | 220 |
|
---|
| 221 |
|
---|