Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (5 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/Novatel.cpp

    r3 r15  
    2424using namespace flair::core;
    2525
    26 namespace flair
    27 {
    28 namespace sensor
    29 {
     26namespace flair {
     27namespace sensor {
    3028
    31 Novatel::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;
     29Novatel::Novatel(const FrameworkManager *parent, string name,
     30                 SerialPort *serialport, Gps::NMEAFlags_t NMEAFlags,
     31                 uint8_t priority)
     32    : Gps(parent, name, NMEAFlags), Thread(parent, name, priority) {
     33  this->serialport = serialport;
    3434}
    3535
    36 Novatel::~Novatel()
    37 {
    38     SafeStop();
    39     Join();
     36Novatel::~Novatel() {
     37  SafeStop();
     38  Join();
    4039}
    4140
    42 void Novatel::Run(void)
    43 {
    44     char response[200] = {0};
    45     int size;
    46     ssize_t written;
     41void Novatel::Run(void) {
     42  char response[200] = {0};
     43  int size;
     44  ssize_t written;
    4745
    48     WarnUponSwitches(true);
     46  WarnUponSwitches(true);
    4947
    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));
     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++;
    5572    }
    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     }
     73    size++;
     74    parseFrame(response, size);
     75  }
    6276
    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);
     77  WarnUponSwitches(false);
    8478}
    8579
    86 void Novatel::Sync(void)
    87 {
    88     char data=0;
    89     ssize_t Read = 0;
     80void Novatel::Sync(void) {
     81  char data = 0;
     82  ssize_t Read = 0;
    9083
    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         }
     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));
    9989    }
     90  }
    10091}
    10192
Note: See TracChangeset for help on using the changeset viewer.