source: flair-src/trunk/lib/FlairSensorActuator/src/Novatel.cpp@ 382

Last change on this file since 382 was 268, checked in by Sanahuja Guillaume, 6 years ago

add defines for architectures to speed up compile time

File size: 2.2 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2013/08/23
6// filename: Novatel.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: objet integrant le recepteur gps Novatel
14//
15//
16/*********************************************************************/
17#ifdef ARMV7A
18
19#include "Novatel.h"
20#include <SerialPort.h>
21#include <FrameworkManager.h>
22#include <string.h>
23
24using std::string;
25using namespace flair::core;
26
27namespace flair {
28namespace sensor {
29
30Novatel::Novatel(string name,
31 SerialPort *serialport, NmeaGps::NMEAFlags_t NMEAFlags,
32 uint8_t priority)
33 : NmeaGps(name, NMEAFlags), Thread(getFrameworkManager(), name, priority) {
34 this->serialport = serialport;
35
36 SetIsReady(true);
37}
38
39Novatel::~Novatel() {
40 SafeStop();
41 Join();
42}
43
44void Novatel::Run(void) {
45 ssize_t written;
46
47 WarnUponSwitches(true);
48
49 char to_send[] = "log gpggalong ontime 0.05\n";
50 written = serialport->Write(to_send, sizeof(to_send));
51 if (written < 0) {
52 Thread::Err("erreur write (%s)\n", strerror(-written));
53 }
54 char to_send2[] = "log gpvtg ontime 0.05\n";
55 written = serialport->Write(to_send2, sizeof(to_send2));
56 if (written < 0) {
57 Thread::Err("erreur write (%s)\n", strerror(-written));
58 }
59
60 Sync();
61
62 while (!ToBeStopped()) {
63 char response[1024] = {0};
64 int size = 0;
65 while (!ToBeStopped()) {
66 ssize_t read = serialport->Read(&response[size], 1);
67 if (read < 0) {
68 Thread::Err("erreur Read (%s)\n", strerror(-read));
69 }
70
71 if (response[size] == 0x0a ) break;
72 size++;
73 if (size==sizeof(response)) break;
74 }
75 if (size!=sizeof(response)) {
76 size++;
77 parseFrame(response, size);
78 } else {
79 Thread::Warn("frame too long for buffer\n");
80 }
81 }
82
83 WarnUponSwitches(false);
84}
85
86void Novatel::Sync(void) {
87 char data = 0;
88 ssize_t Read = 0;
89
90 // attente fin trame
91 while (data != 0x0a) {
92 Read = serialport->Read(&data, 1);
93 if (Read < 0) {
94 Thread::Err("erreur Read (%s)\n", strerror(-Read));
95 }
96 }
97}
98
99} // end namespace sensor
100} // end namespace flair
101
102#endif
Note: See TracBrowser for help on using the repository browser.