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

Last change on this file since 133 was 51, checked in by Sanahuja Guillaume, 8 years ago

gps

File size: 2.1 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
18#include "Novatel.h"
19#include <SerialPort.h>
20#include <FrameworkManager.h>
21#include <string.h>
22
23using std::string;
24using namespace flair::core;
25
26namespace flair {
27namespace sensor {
28
29Novatel::Novatel(const FrameworkManager *parent, string name,
30 SerialPort *serialport, NmeaGps::NMEAFlags_t NMEAFlags,
31 uint8_t priority)
32 : NmeaGps(parent, name, NMEAFlags), Thread(parent, name, priority) {
33 this->serialport = serialport;
34}
35
36Novatel::~Novatel() {
37 SafeStop();
38 Join();
39}
40
41void Novatel::Run(void) {
42 char response[200] = {0};
43 int size;
44 ssize_t written;
45
46 WarnUponSwitches(true);
47
48 char to_send[] = "log gpggalong ontime 0.05\n";
49 written = serialport->Write(to_send, sizeof(to_send));
50 if (written < 0) {
51 Thread::Err("erreur write (%s)\n", strerror(-written));
52 }
53 char to_send2[] = "log gpvtg ontime 0.05\n";
54 written = serialport->Write(to_send2, sizeof(to_send2));
55 if (written < 0) {
56 Thread::Err("erreur write (%s)\n", strerror(-written));
57 }
58
59 Sync();
60
61 while (!ToBeStopped()) {
62 size = 0;
63 while (1) {
64 // ssize_t read = rt_dev_read(uart_fd, &response[size],1);
65 ssize_t Read = serialport->Read(&response[size], 1);
66 if (Read < 0) {
67 Thread::Err("erreur Read (%s)\n", strerror(-Read));
68 }
69 if (response[size] == 0x0a)
70 break;
71 size++;
72 }
73 size++;
74 parseFrame(response, size);
75 }
76
77 WarnUponSwitches(false);
78}
79
80void Novatel::Sync(void) {
81 char data = 0;
82 ssize_t Read = 0;
83
84 // attente fin trame
85 while (data != 0x0a) {
86 Read = serialport->Read(&data, 1);
87 if (Read < 0) {
88 Thread::Err("erreur Read (%s)\n", strerror(-Read));
89 }
90 }
91}
92
93} // end namespace sensor
94} // end namespace framewor
Note: See TracBrowser for help on using the repository browser.