Index: /trunk/lib/FlairSensorActuator/src/NeoM8N.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/NeoM8N.cpp	(revision 195)
+++ /trunk/lib/FlairSensorActuator/src/NeoM8N.cpp	(revision 195)
@@ -0,0 +1,142 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+//  created:    2017/08/30
+//  filename:   NeoM8N.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    objet integrant le recepteur gps ublox NeoM8N
+//
+//
+/*********************************************************************/
+
+#include "NeoM8N.h"
+#include <SerialPort.h>
+#include <FrameworkManager.h>
+#include <string.h>
+
+using std::string;
+using namespace flair::core;
+
+namespace flair {
+namespace sensor {
+
+NeoM8N::NeoM8N(string name,
+             SerialPort *serialport,NmeaGps::NMEAFlags_t NMEAFlags,uint8_t priority)
+    : NmeaGps(name, NMEAFlags), Thread(getFrameworkManager(), name, priority) {
+  this->serialport = serialport;
+  serialport->SetRxTimeout(100000000);
+  
+  SetIsReady(true);
+}
+
+NeoM8N::~NeoM8N() {
+  SafeStop();
+  Join();
+}
+
+void NeoM8N::Run(void) {
+  char response[200] = {0};
+  int size,written;
+
+  //turn off all mesages
+  {
+    char tx[]={0x06, 0x01, 0x03, 0, 0xf0, 0,0};
+    for(int i=0;i<0x100;i++) {
+      tx[5]=i;//msg id
+      SendUbx(tx,sizeof(tx));
+    }
+  }
+  //10Hz output
+  {
+    char tx[]={0x06, 0x08, 0x06, 0, 0x64, 0, 0x01, 0, 0, 0};
+    SendUbx(tx,sizeof(tx));
+  }
+  
+  if ((NMEAFlags & GGA) != 0) {
+    char tx[]={0x06, 0x01, 0x03, 0, 0xf0, 0,0x01};
+    SendUbx(tx,sizeof(tx));
+  }
+  if ((NMEAFlags & VTG) != 0) {
+    char tx[]={0x06, 0x01, 0x03, 0, 0xf0, 0x05,0x01};
+    SendUbx(tx,sizeof(tx));
+  }
+  if ((NMEAFlags & GST) != 0) {
+    char tx[]={0x06, 0x01, 0x03, 0, 0xf0, 0x07,0x01};
+    SendUbx(tx,sizeof(tx));
+  }
+  if ((NMEAFlags & GSA) != 0) {
+    char tx[]={0x06, 0x01, 0x03, 0, 0xf0, 0x02,0x01};
+    SendUbx(tx,sizeof(tx));
+  }
+  
+  /** Debut running loop **/
+  WarnUponSwitches(true);
+
+  Sync();
+  
+  while (!ToBeStopped()) {
+    //SleepMS(10);??
+    size = 0;
+    while (!ToBeStopped()) {
+      ssize_t read = serialport->Read(&response[size], 1);
+      if (read < 0) {
+        Thread::Err("erreur Read (%s)\n", strerror(-read));
+      }
+
+      if (response[size] == 0x0a)
+        break;
+      size++;
+    }
+    size++;
+    parseFrame(response, size);
+  }
+  /** fin running loop **/
+  WarnUponSwitches(false);
+}
+
+void NeoM8N::SendUbx(char* buf,size_t length) {
+  char header[2]={0xb5,0x62};
+  int written=serialport->Write(header, sizeof(header));
+  if (written< 0) {
+      Thread::Err("erreur Write (%s)\n", strerror(-written));
+  }
+  
+  written=serialport->Write(buf, length);
+  if (written< 0) {
+      Thread::Err("erreur Write (%s)\n", strerror(-written));
+  }
+  
+  unsigned char checksum[2]={0,0};
+  for(int i=0;i<length;i++) {
+     checksum[0] = checksum[0] + buf[i];
+     checksum[1] = checksum[1] + checksum[0];
+  }
+  written=serialport->Write(checksum, sizeof(checksum));
+  if (written< 0) {
+      Thread::Err("erreur Write (%s)\n", strerror(-written));
+  }
+}
+
+void NeoM8N::Sync(void) {
+  char data = 0;
+  ssize_t read = 0;
+
+  // attente fin trame
+  while (data != 0x0a && !ToBeStopped()) {
+    read = serialport->Read(&data, 1);
+    SleepMS(10);
+
+    if (read < 0) {
+      Thread::Err("erreur Read (%s)\n", strerror(-read));
+    }
+  }
+}
+
+} // end namespace sensor
+} // end namespace flair
Index: /trunk/lib/FlairSensorActuator/src/NeoM8N.h
===================================================================
--- /trunk/lib/FlairSensorActuator/src/NeoM8N.h	(revision 195)
+++ /trunk/lib/FlairSensorActuator/src/NeoM8N.h	(revision 195)
@@ -0,0 +1,77 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+/*!
+ * \file NeoM8N.h
+ * \brief Class for NeoM8N gps receiver
+ * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
+ * \date 2017/08/30
+ * \version 4.0
+ */
+
+#ifndef NEOM8N_H
+#define NEOM8N_H
+
+#include <Thread.h>
+#include <NmeaGps.h>
+
+namespace flair {
+namespace core {
+class SerialPort;
+}
+}
+
+namespace flair {
+namespace sensor {
+/*! \class NeoM8N
+*
+* \brief Class for mb800 gps receiver
+*/
+class NeoM8N : public core::Thread, public NmeaGps {
+public:
+  /*!
+  * \brief Constructor
+  *
+  * Construct a NeoM8N.
+  * It will be child of the FrameworkManager.
+	* 
+  * \param name name
+  * \param serialport serialport
+  * \param NMEAFlags NMEA sentances to enable
+  * \param priority priority of the Thread
+  */
+  NeoM8N(std::string name,
+        core::SerialPort *serialport,NmeaGps::NMEAFlags_t NMEAFlags,uint8_t priority);
+
+  /*!
+  * \brief Destructor
+  *
+  */
+  ~NeoM8N();
+
+private:
+  /*!
+  * \brief Update using provided datas
+  *
+  * Reimplemented from IODevice.
+  *
+  * \param data data from the parent to process
+  */
+  void UpdateFrom(const core::io_data *data){};
+
+  /*!
+  * \brief Run function
+  *
+  * Reimplemented from Thread.
+  *
+  */
+  void Run(void);
+
+  void Sync(void);
+  void SendUbx(char* buf,size_t length);//message without header/footer
+  core::SerialPort *serialport;
+};
+} // end namespace sensor
+} // end namespace flair
+#endif // NEOM8N_H
