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

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

sensoractuator

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