source: ntrip/trunk/BNC/RTIGS/RTIGSDecoder.cpp@ 457

Last change on this file since 457 was 457, checked in by mervart, 17 years ago

* empty log message *

File size: 4.0 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters,
3// written by Leos Mervart.
4//
5// Copyright (C) 2006
6// German Federal Agency for Cartography and Geodesy (BKG)
7// http://www.bkg.bund.de
8// Czech Technical University Prague, Department of Advanced Geodesy
9// http://www.fsv.cvut.cz
10//
11// Email: euref-ip@bkg.bund.de
12//
13// This program is free software; you can redistribute it and/or
14// modify it under the terms of the GNU General Public License
15// as published by the Free Software Foundation, version 2.
16//
17// This program is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU General Public License for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program; if not, write to the Free Software
24// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26/* -------------------------------------------------------------------------
27 * BKG NTRIP Client
28 * -------------------------------------------------------------------------
29 *
30 * Class: RTIGSDecoder
31 *
32 * Purpose: RTIGS Decoder
33 *
34 * Author: L. Mervart
35 *
36 * Created: 24-Aug-2006
37 *
38 * Changes:
39 *
40 * -----------------------------------------------------------------------*/
41
42#include "RTIGSDecoder.h"
43#include "bncconst.h"
44
45using namespace std;
46
47#undef L1
48#undef L2
49
50// Constructor
51////////////////////////////////////////////////////////////////////////////
52RTIGSDecoder::RTIGSDecoder() {
53}
54
55// Destructor
56////////////////////////////////////////////////////////////////////////////
57RTIGSDecoder::~RTIGSDecoder() {
58}
59
60//
61////////////////////////////////////////////////////////////////////////////
62void RTIGSDecoder::Decode(char* buffer, int bufLen) {
63
64 // Append the incomming data to the internal buffer
65 // ------------------------------------------------
66 _buffer.append(buffer, bufLen);
67
68 // Find the beginning of the message
69 // ---------------------------------
70 bool found = false;
71 for (unsigned ii = 0; ii < _buffer.size(); ii++) {
72 unsigned short xx;
73 memcpy( (void*) &xx, &_buffer[ii], sizeof(xx) );
74 if (_GPSTrans.f_IsLittleEndian) {
75 SwitchBytes( (char*) &xx, sizeof(xx) );
76 }
77 if (xx == 200) {
78 _buffer = _buffer.substr(ii);
79 found = true;
80 break;
81 }
82 }
83
84 if (! found) {
85 _buffer.clear();
86 return;
87 }
88
89 unsigned char* p_buf = (unsigned char*) _buffer.data();
90
91 unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
92 unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
93
94 // Not enough new data, return
95 // ---------------------------
96 if (_buffer.size() < numbytes) {
97 return;
98 }
99
100 // Decode the epoch
101 // ----------------
102 if (messType == 200) {
103 RTIGSO_T rtigs_obs;
104 short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
105
106 for (short ii = 0; ii < numObs; ii++) {
107 Observation* obs = new Observation();
108 obs->satSys = 'G';
109 obs->satNum = _GPSTrans.DecObs.Obs[ii].sat_prn;
110 obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
111 obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
112 obs->C1 = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
113 obs->P1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
114 obs->P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
115 obs->L1 = _GPSTrans.DecObs.Obs[ii].p1_phase;
116 obs->L2 = _GPSTrans.DecObs.Obs[ii].p2_phase;
117 obs->S1 = _GPSTrans.DecObs.Obs[ii].l1_sn;
118 obs->S2 = _GPSTrans.DecObs.Obs[ii].l2_sn;
119 obs->SNR1 = int(ceil(_GPSTrans.DecObs.Obs[ii].l1_sn / 60.0 * 9.0));
120 obs->SNR2 = int(ceil(_GPSTrans.DecObs.Obs[ii].l2_sn / 60.0 * 9.0));
121
122 _obsList.push_back(obs);
123 }
124 }
125
126 // Unprocessed bytes remain in buffer
127 // ----------------------------------
128 _buffer = _buffer.substr(numbytes);
129}
Note: See TracBrowser for help on using the repository browser.