source: ntrip/trunk/BNC/RTIGS/rtigs.cpp@ 67

Last change on this file since 67 was 67, checked in by mervart, 18 years ago

* empty log message *

File size: 2.0 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * Bernese NTRIP Client
4 * -------------------------------------------------------------------------
5 *
6 * Class: rtigs
7 *
8 * Purpose: RTIGS Decoder
9 *
10 * Author: L. Mervart
11 *
12 * Created: 24-Aug-2006
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include "rtigs.h"
19
20using namespace std;
21
22// Constructor
23////////////////////////////////////////////////////////////////////////////
24rtigs::rtigs() : GPSDecoder() {
25}
26
27// Destructor
28////////////////////////////////////////////////////////////////////////////
29rtigs::~rtigs() {
30}
31
32//
33////////////////////////////////////////////////////////////////////////////
34void rtigs::Decode(char* buffer, int bufLen) {
35
36 // Append the incomming data to the internal buffer
37 // ------------------------------------------------
38 _buffer.append( QByteArray(buffer, bufLen) );
39
40 // Find the beginning of the message
41 // ---------------------------------
42 bool found = false;
43 for (int ii = 0; ii < _buffer.size(); ii++) {
44 unsigned short xx;
45 memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
46 SwitchBytes( (char*) &xx, sizeof(xx) );
47 if (xx == 200) {
48 _buffer = _buffer.mid(ii);
49 found = true;
50 break;
51 }
52 }
53 if (! found) {
54 cout << "Message not found\n";
55 _buffer.clear();
56 return;
57 }
58
59 unsigned char* p_buf = (unsigned char*) _buffer.data();
60
61 unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
62 unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
63
64 // Not enough new data, return
65 // ---------------------------
66 if (_buffer.size() < numbytes) {
67 return;
68 }
69
70 // Decode the epoch
71 // ----------------
72 if (messType == 200) {
73 RTIGSO_T rtigs_obs;
74 short retval = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
75 if (retval >= 1) {
76 _GPSTrans.print_CMEAS();
77 }
78 }
79
80 // Unprocessed bytes remain in buffer
81 // ----------------------------------
82 _buffer = _buffer.mid(numbytes);
83}
Note: See TracBrowser for help on using the repository browser.