source: ntrip/trunk/BNC/bncgetthread.cpp@ 3944

Last change on this file since 3944 was 3734, checked in by stoecker, 13 years ago

fix crash with Galileo ephemeris available, some other valgrind fixes as well

File size: 22.1 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: bncGetThread
30 *
31 * Purpose: Thread that retrieves data from NTRIP caster
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Dec-2005
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <stdlib.h>
42#include <iomanip>
43#include <sstream>
44
45#include <QFile>
46#include <QTextStream>
47#include <QtNetwork>
48#include <QTime>
49
50#include "bncgetthread.h"
51#include "bnctabledlg.h"
52#include "bncapp.h"
53#include "bncutils.h"
54#include "bnczerodecoder.h"
55#include "bncnetqueryv0.h"
56#include "bncnetqueryv1.h"
57#include "bncnetqueryv2.h"
58#include "bncnetqueryrtp.h"
59#include "bncnetqueryudp.h"
60#include "bncnetqueryudp0.h"
61#include "bncnetquerys.h"
62#include "bncsettings.h"
63#include "latencychecker.h"
64#include "bncpppclient.h"
65#ifdef PPP_DLL_INTERFACE
66#include "dllinterface.h"
67#endif
68#include "upload/bncrtnetdecoder.h"
69#include "RTCM/RTCM2Decoder.h"
70#include "RTCM3/RTCM3Decoder.h"
71#include "GPSS/gpssDecoder.h"
72#include "GPSS/hassDecoder.h"
73#include "serial/qextserialport.h"
74
75using namespace std;
76
77// Constructor 1
78////////////////////////////////////////////////////////////////////////////
79bncGetThread::bncGetThread(bncRawFile* rawFile) {
80
81 _rawFile = rawFile;
82 _format = rawFile->format();
83 _staID = rawFile->staID();
84 _rawOutput = false;
85 _ntripVersion = "N";
86
87 initialize();
88}
89
90// Constructor 2
91////////////////////////////////////////////////////////////////////////////
92bncGetThread::bncGetThread(const QUrl& mountPoint,
93 const QByteArray& format,
94 const QByteArray& latitude,
95 const QByteArray& longitude,
96 const QByteArray& nmea,
97 const QByteArray& ntripVersion) {
98 _rawFile = 0;
99 _mountPoint = mountPoint;
100 _staID = mountPoint.path().mid(1).toAscii();
101 _format = format;
102 _latitude = latitude;
103 _longitude = longitude;
104 _nmea = nmea;
105 _ntripVersion = ntripVersion;
106
107 bncSettings settings;
108 if (!settings.value("rawOutFile").toString().isEmpty()) {
109 _rawOutput = true;
110 } else {
111 _rawOutput = false;
112 }
113
114 initialize();
115 initDecoder();
116}
117
118// Initialization (common part of the constructor)
119////////////////////////////////////////////////////////////////////////////
120void bncGetThread::initialize() {
121
122 bncSettings settings;
123
124 setTerminationEnabled(true);
125
126 bncApp* app = (bncApp*) qApp;
127
128 connect(this, SIGNAL(newMessage(QByteArray,bool)),
129 app, SLOT(slotMessage(const QByteArray,bool)));
130
131 _isToBeDeleted = false;
132 _query = 0;
133 _nextSleep = 0;
134 _PPPclient = 0;
135#ifdef PPP_DLL_INTERFACE
136 _dllInterface = 0;
137#endif
138 _miscMount = settings.value("miscMount").toString();
139 _decoder = 0;
140
141 // Serial Port
142 // -----------
143 _serialNMEA = NO_NMEA;
144 _serialOutFile = 0;
145 _serialPort = 0;
146
147 if (!_staID.isEmpty() &&
148 settings.value("serialMountPoint").toString() == _staID) {
149 _serialPort = new QextSerialPort(settings.value("serialPortName").toString() );
150 _serialPort->setTimeout(0,100);
151
152 // Baud Rate
153 // ---------
154 QString hlp = settings.value("serialBaudRate").toString();
155 if (hlp == "110") {
156 _serialPort->setBaudRate(BAUD110);
157 }
158 else if (hlp == "300") {
159 _serialPort->setBaudRate(BAUD300);
160 }
161 else if (hlp == "600") {
162 _serialPort->setBaudRate(BAUD600);
163 }
164 else if (hlp == "1200") {
165 _serialPort->setBaudRate(BAUD1200);
166 }
167 else if (hlp == "2400") {
168 _serialPort->setBaudRate(BAUD2400);
169 }
170 else if (hlp == "4800") {
171 _serialPort->setBaudRate(BAUD4800);
172 }
173 else if (hlp == "9600") {
174 _serialPort->setBaudRate(BAUD9600);
175 }
176 else if (hlp == "19200") {
177 _serialPort->setBaudRate(BAUD19200);
178 }
179 else if (hlp == "38400") {
180 _serialPort->setBaudRate(BAUD38400);
181 }
182 else if (hlp == "57600") {
183 _serialPort->setBaudRate(BAUD57600);
184 }
185 else if (hlp == "115200") {
186 _serialPort->setBaudRate(BAUD115200);
187 }
188
189 // Parity
190 // ------
191 hlp = settings.value("serialParity").toString();
192 if (hlp == "NONE") {
193 _serialPort->setParity(PAR_NONE);
194 }
195 else if (hlp == "ODD") {
196 _serialPort->setParity(PAR_ODD);
197 }
198 else if (hlp == "EVEN") {
199 _serialPort->setParity(PAR_EVEN);
200 }
201 else if (hlp == "SPACE") {
202 _serialPort->setParity(PAR_SPACE);
203 }
204
205 // Data Bits
206 // ---------
207 hlp = settings.value("serialDataBits").toString();
208 if (hlp == "5") {
209 _serialPort->setDataBits(DATA_5);
210 }
211 else if (hlp == "6") {
212 _serialPort->setDataBits(DATA_6);
213 }
214 else if (hlp == "7") {
215 _serialPort->setDataBits(DATA_7);
216 }
217 else if (hlp == "8") {
218 _serialPort->setDataBits(DATA_8);
219 }
220 hlp = settings.value("serialStopBits").toString();
221 if (hlp == "1") {
222 _serialPort->setStopBits(STOP_1);
223 }
224 else if (hlp == "2") {
225 _serialPort->setStopBits(STOP_2);
226 }
227
228 // Flow Control
229 // ------------
230 hlp = settings.value("serialFlowControl").toString();
231 if (hlp == "XONXOFF") {
232 _serialPort->setFlowControl(FLOW_XONXOFF);
233 }
234 else if (hlp == "HARDWARE") {
235 _serialPort->setFlowControl(FLOW_HARDWARE);
236 }
237 else {
238 _serialPort->setFlowControl(FLOW_OFF);
239 }
240
241 // Open Serial Port
242 // ----------------
243 _serialPort->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
244 if (!_serialPort->isOpen()) {
245 delete _serialPort;
246 _serialPort = 0;
247 emit(newMessage((_staID + ": Cannot open serial port\n"), true));
248 }
249 connect(_serialPort, SIGNAL(readyRead()),
250 this, SLOT(slotSerialReadyRead()));
251
252 // Automatic NMEA
253 // --------------
254 if (settings.value("serialAutoNMEA").toString() == "Auto") {
255 _serialNMEA = AUTO_NMEA;
256
257 QString fName = settings.value("serialFileNMEA").toString();
258 if (!fName.isEmpty()) {
259 _serialOutFile = new QFile(fName);
260 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
261 _serialOutFile->open(QIODevice::WriteOnly | QIODevice::Append);
262 }
263 else {
264 _serialOutFile->open(QIODevice::WriteOnly);
265 }
266 }
267 }
268
269 // Manual NMEA
270 // -----------
271 else {
272 _serialNMEA = MANUAL_NMEA;
273 }
274 }
275
276 if (!_staID.isEmpty()) {
277 _latencyChecker = new latencyChecker(_staID);
278 }
279 else {
280 _latencyChecker = 0;
281 }
282}
283
284// Instantiate the decoder
285//////////////////////////////////////////////////////////////////////////////
286t_irc bncGetThread::initDecoder() {
287
288 _decoder = 0;
289
290 if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1 ||
291 _format.indexOf("RTCM 2") != -1 ) {
292 emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
293 _decoder = new RTCM2Decoder(_staID.data());
294 }
295 else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1 ||
296 _format.indexOf("RTCM 3") != -1 ) {
297 emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
298 RTCM3Decoder* newDecoder = new RTCM3Decoder(_staID, _rawFile);
299 _decoder = newDecoder;
300 connect((RTCM3Decoder*) newDecoder, SIGNAL(newMessage(QByteArray,bool)),
301 this, SIGNAL(newMessage(QByteArray,bool)));
302 }
303 else if (_format.indexOf("GPSS") != -1 || _format.indexOf("BNC") != -1) {
304 emit(newMessage(_staID + ": Get Data in GPSS format", true));
305 _decoder = new gpssDecoder();
306 }
307 else if (_format.indexOf("ZERO") != -1) {
308 emit(newMessage(_staID + ": Get data in original format", true));
309 _decoder = new bncZeroDecoder(_staID);
310 }
311 else if (_format.indexOf("RTNET") != -1) {
312 emit(newMessage(_staID + ": Get data in RTNet format", true));
313 _decoder = new bncRtnetDecoder();
314 }
315 else if (_format.indexOf("HASS2ASCII") != -1) {
316 emit(newMessage(_staID + ": Get data in HASS2ASCII format", true));
317 _decoder = new hassDecoder(_staID);
318 }
319 else {
320 emit(newMessage(_staID + ": Unknown data format " + _format, true));
321 _isToBeDeleted = true;
322 return failure;
323 }
324
325 msleep(100); //sleep 0.1 sec
326
327 _decoder->initRinex(_staID, _mountPoint, _latitude, _longitude,
328 _nmea, _ntripVersion);
329
330 if (_rawFile) {
331 _decodersRaw[_staID] = _decoder;
332 }
333
334 // Initialize PPP Client?
335 // ----------------------
336#ifndef MLS_SOFTWARE
337 bncSettings settings;
338 if (settings.value("pppMount").toString() == _staID) {
339 _PPPclient = new bncPPPclient(_staID);
340 bncApp* app = (bncApp*) qApp;
341 app->_bncPPPclient = _PPPclient;
342 qRegisterMetaType<bncTime>("bncTime");
343 connect(_PPPclient, SIGNAL(newPosition(bncTime, double, double, double)),
344 this, SIGNAL(newPosition(bncTime, double, double, double)));
345 connect(_PPPclient, SIGNAL(newNMEAstr(QByteArray)),
346 this, SIGNAL(newNMEAstr(QByteArray)));
347#ifdef PPP_DLL_INTERFACE
348 _dllInterface = new t_dllInterface();
349#endif
350 }
351#endif
352
353 return success;
354}
355
356// Current decoder in use
357////////////////////////////////////////////////////////////////////////////
358GPSDecoder* bncGetThread::decoder() {
359 if (!_rawFile) {
360 return _decoder;
361 }
362 else {
363 if (_decodersRaw.contains(_staID) || initDecoder() == success) {
364 return _decodersRaw[_staID];
365 }
366 }
367 return 0;
368}
369
370// Destructor
371////////////////////////////////////////////////////////////////////////////
372bncGetThread::~bncGetThread() {
373 if (isRunning()) {
374 wait();
375 }
376 if (_query) {
377 _query->stop();
378 _query->deleteLater();
379 }
380 delete _PPPclient;
381#ifdef PPP_DLL_INTERFACE
382 delete _dllInterface;
383#endif
384 if (_rawFile) {
385 QMapIterator<QString, GPSDecoder*> it(_decodersRaw);
386 while (it.hasNext()) {
387 it.next();
388 delete it.value();
389 }
390 }
391 else {
392 delete _decoder;
393 }
394 delete _rawFile;
395 delete _serialOutFile;
396 delete _serialPort;
397 delete _latencyChecker;
398 emit getThreadFinished(_staID);
399}
400
401//
402////////////////////////////////////////////////////////////////////////////
403void bncGetThread::terminate() {
404 _isToBeDeleted = true;
405 if (!isRunning()) {
406 delete this;
407 }
408}
409
410// Run
411////////////////////////////////////////////////////////////////////////////
412void bncGetThread::run() {
413
414 while (true) {
415 try {
416 if (_isToBeDeleted) {
417 QThread::exit(0);
418 this->deleteLater();
419 return;
420 }
421
422 if (tryReconnect() != success) {
423 if (_latencyChecker) {
424 _latencyChecker->checkReconnect();
425 }
426 continue;
427 }
428
429 // Delete old observations
430 // -----------------------
431 if (_rawFile) {
432 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
433 while (itDec.hasNext()) {
434 itDec.next();
435 GPSDecoder* decoder = itDec.value();
436 decoder->_obsList.clear();
437 }
438 }
439 else {
440 _decoder->_obsList.clear();
441 }
442
443 // Read Data
444 // ---------
445 QByteArray data;
446 if (_query) {
447 _query->waitForReadyRead(data);
448 }
449 else if (_rawFile) {
450 data = _rawFile->readChunk();
451 _format = _rawFile->format();
452 _staID = _rawFile->staID();
453
454 if (data.isEmpty()) {
455 cout << "no more data" << endl;
456 ((bncApp*) qApp)->stopCombination();
457 QThread::exit(0);
458 delete this;
459 ::exit(0);
460 }
461 }
462 qint64 nBytes = data.size();
463
464 // Timeout, reconnect
465 // ------------------
466 if (nBytes == 0) {
467 if (_latencyChecker) {
468 _latencyChecker->checkReconnect();
469 }
470 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
471 msleep(10000); //sleep 10 sec, G. Weber
472 continue;
473 }
474 else {
475 emit newBytes(_staID, nBytes);
476 }
477
478 // Output Data
479 // -----------
480 if (_rawOutput) {
481 bncApp* app = (bncApp*) qApp;
482 app->writeRawData(data, _staID, _format);
483 }
484
485 if (_serialPort) {
486 slotSerialReadyRead();
487 _serialPort->write(data);
488 }
489
490 // Decode Data
491 // -----------
492 vector<string> errmsg;
493 if (!decoder()) {
494 _isToBeDeleted = true;
495 continue;
496 }
497 decoder()->_obsList.clear();
498 t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
499
500 // Perform various scans and checks
501 // --------------------------------
502 if (_latencyChecker) {
503 _latencyChecker->checkOutage(irc == success);
504 _latencyChecker->checkObsLatency(decoder()->_obsList);
505 _latencyChecker->checkCorrLatency(decoder()->corrGPSEpochTime());
506
507 emit newLatency(_staID, _latencyChecker->currentLatency());
508 }
509
510 scanRTCM();
511
512 // Loop over all observations (observations output)
513 // ------------------------------------------------
514 QListIterator<t_obs> it(decoder()->_obsList);
515 bool firstObs = true;
516 while (it.hasNext()) {
517 const t_obs& obs = it.next();
518
519 QString prn = QString("%1%2").arg(obs.satSys)
520 .arg(obs.satNum, 2, 10, QChar('0'));
521 long iSec = long(floor(obs.GPSWeeks+0.5));
522 long obsTime = obs.GPSWeek * 7*24*3600 + iSec;
523
524 // Check observation epoch
525 // -----------------------
526 if (!_rawFile && !dynamic_cast<gpssDecoder*>(decoder())) {
527 int week;
528 double sec;
529 currentGPSWeeks(week, sec);
530 long currTime = week * 7*24*3600 + long(sec);
531 const double maxDt = 600.0;
532 if (fabs(currTime - obsTime) > maxDt) {
533 emit( newMessage(_staID + ": Wrong observation epoch(s)", false) );
534 continue;
535 }
536 }
537
538 // Check observations coming twice (e.g. KOUR0 Problem)
539 // ----------------------------------------------------
540 if (!_rawFile) {
541 QMap<QString, long>::const_iterator it = _prnLastEpo.find(prn);
542 if (it != _prnLastEpo.end()) {
543 long oldTime = it.value();
544 if (obsTime < oldTime) {
545 emit( newMessage(_staID +
546 ": old observation " + prn.toAscii(), false));
547 continue;
548 }
549 else if (obsTime == oldTime) {
550 emit( newMessage(_staID +
551 ": observation coming more than once " + prn.toAscii(), false));
552 continue;
553 }
554 }
555 _prnLastEpo[prn] = obsTime;
556 }
557
558 decoder()->dumpRinexEpoch(obs, _format);
559
560 // PPP Client
561 // ----------
562#ifndef MLS_SOFTWARE
563 if (_PPPclient && _staID == _PPPclient->staID()) {
564 _PPPclient->putNewObs(obs);
565#ifdef PPP_DLL_INTERFACE
566 _dllInterface->putNewObs(obs);
567#endif
568 }
569#endif
570
571 // Emit new observation signal
572 // ---------------------------
573 if (!_isToBeDeleted) {
574 emit newObs(_staID, firstObs, obs);
575 }
576 firstObs = false;
577 }
578 decoder()->_obsList.clear();
579 }
580 catch (Exception& exc) {
581 emit(newMessage(_staID + " " + exc.what(), true));
582 _isToBeDeleted = true;
583 }
584 catch (...) {
585 emit(newMessage(_staID + " bncGetThread exception", true));
586 _isToBeDeleted = true;
587 }
588 }
589}
590
591// Try Re-Connect
592////////////////////////////////////////////////////////////////////////////
593t_irc bncGetThread::tryReconnect() {
594
595 // Easy Return
596 // -----------
597 if (_query && _query->status() == bncNetQuery::running) {
598 _nextSleep = 0;
599 if (_rawFile) {
600 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
601 while (itDec.hasNext()) {
602 itDec.next();
603 GPSDecoder* decoder = itDec.value();
604 decoder->setRinexReconnectFlag(false);
605 }
606 }
607 else {
608 _decoder->setRinexReconnectFlag(false);
609 }
610 return success;
611 }
612
613 // Start a new query
614 // -----------------
615 if (!_rawFile) {
616
617 sleep(_nextSleep);
618 if (_nextSleep == 0) {
619 _nextSleep = 1;
620 }
621 else {
622 _nextSleep = 2 * _nextSleep;
623 if (_nextSleep > 256) {
624 _nextSleep = 256;
625 }
626#ifdef MLS_SOFTWARE
627 if (_nextSleep > 4) {
628 _nextSleep = 4;
629 }
630#endif
631 }
632
633 delete _query;
634 if (_ntripVersion == "U") {
635 _query = new bncNetQueryUdp();
636 }
637 else if (_ntripVersion == "R") {
638 _query = new bncNetQueryRtp();
639 }
640 else if (_ntripVersion == "S") {
641 _query = new bncNetQueryS();
642 }
643 else if (_ntripVersion == "N") {
644 _query = new bncNetQueryV0();
645 }
646 else if (_ntripVersion == "UN") {
647 _query = new bncNetQueryUdp0();
648 }
649 else if (_ntripVersion == "2") {
650 _query = new bncNetQueryV2(false);
651 }
652 else if (_ntripVersion == "2s") {
653 _query = new bncNetQueryV2(true);
654 }
655 else {
656 _query = new bncNetQueryV1();
657 }
658 if (_nmea == "yes" && _serialNMEA != AUTO_NMEA) {
659 QByteArray gga = ggaString(_latitude, _longitude, "100.0");
660 _query->startRequest(_mountPoint, gga);
661 }
662 else {
663 _query->startRequest(_mountPoint, "");
664 }
665 if (_query->status() != bncNetQuery::running) {
666 return failure;
667 }
668 }
669
670 if (_rawFile) {
671 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
672 while (itDec.hasNext()) {
673 itDec.next();
674 GPSDecoder* decoder = itDec.value();
675 decoder->setRinexReconnectFlag(false);
676 }
677 }
678 else {
679 _decoder->setRinexReconnectFlag(false);
680 }
681
682 return success;
683}
684
685// RTCM scan output
686//////////////////////////////////////////////////////////////////////////////
687void bncGetThread::scanRTCM() {
688
689 if (!decoder()) {
690 return;
691 }
692
693 bncSettings settings;
694 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked ) {
695
696 if ( _miscMount == _staID || _miscMount == "ALL" ) {
697
698 // RTCM message types
699 // ------------------
700 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
701 QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
702 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
703 }
704
705 // RTCMv3 antenna descriptor
706 // -------------------------
707 for (int ii=0;ii<decoder()->_antType.size();ii++) {
708 QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
709 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
710 }
711
712 // RTCM Antenna Coordinates
713 // ------------------------
714 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
715 QByteArray antT;
716 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
717 antT = "ARP";
718 }
719 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
720 antT = "APC";
721 }
722 QByteArray ant1, ant2, ant3;
723 ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx,0,'f',4).toAscii();
724 ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy,0,'f',4).toAscii();
725 ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz,0,'f',4).toAscii();
726 emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
727 emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
728 emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
729 double hh = 0.0;
730 if (decoder()->_antList[ii].height_f) {
731 hh = decoder()->_antList[ii].height;
732 QByteArray ant4 = QString("%1 ").arg(hh,0,'f',4).toAscii();
733 emit(newMessage(_staID + ": Antenna height above marker " + ant4 + "m", true));
734 }
735 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
736 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
737 hh, antT));
738 }
739 }
740 }
741
742#ifdef MLS_SOFTWARE
743 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
744 QByteArray antT;
745 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
746 antT = "ARP";
747 }
748 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
749 antT = "APC";
750 }
751 double hh = 0.0;
752 if (decoder()->_antList[ii].height_f) {
753 hh = decoder()->_antList[ii].height;
754 }
755 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
756 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
757 hh, antT));
758 }
759
760 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
761 emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
762 }
763#endif
764
765 decoder()->_typeList.clear();
766 decoder()->_antType.clear();
767 decoder()->_antList.clear();
768}
769
770// Handle Data from Serial Port
771////////////////////////////////////////////////////////////////////////////
772void bncGetThread::slotSerialReadyRead() {
773 if (_serialPort) {
774 int nb = _serialPort->bytesAvailable();
775 if (nb > 0) {
776 QByteArray data = _serialPort->read(nb);
777
778 if (_serialNMEA == AUTO_NMEA) {
779 int i1 = data.indexOf("$GPGGA");
780 if (i1 != -1) {
781 int i2 = data.indexOf("*", i1);
782 if (i2 != -1 && data.size() > i2 + 1) {
783 QByteArray gga = data.mid(i1,i2-i1+3);
784 _query->sendNMEA(gga);
785 }
786 }
787 }
788
789 if (_serialOutFile) {
790 _serialOutFile->write(data);
791 _serialOutFile->flush();
792 }
793 }
794 }
795}
Note: See TracBrowser for help on using the repository browser.