12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include <signal.h>
- #include "ublox6.h"
-
- using namespace std;
-
- bool shouldRun = true;
-
- void sig_handler(int signo)
- {
- if (signo == SIGINT)
- shouldRun = false;
- }
-
- const size_t bufferLength = 256;
-
- int main (int argc, char **argv)
- {
- signal(SIGINT, sig_handler);
-
-
-
- upm::Ublox6* nmea = new upm::Ublox6(0);
-
-
- if (!nmea->setupTty(B9600))
- {
- cerr << "Failed to setup tty port parameters" << endl;
- return 1;
- }
-
-
-
-
-
-
-
-
-
-
-
-
- char nmeaBuffer[bufferLength];
- while (shouldRun)
- {
-
-
- if (nmea->dataAvailable())
- {
- int rv = nmea->readData(nmeaBuffer, bufferLength);
-
- if (rv > 0)
- write(1, nmeaBuffer, rv);
-
- if (rv < 0)
- {
- cerr << "Port read error." << endl;
- break;
- }
-
- continue;
- }
-
- usleep(100000);
- }
-
-
- cout << "Exiting..." << endl;
-
- delete nmea;
- return 0;
- }
|