Changeset 41 in flair-src for trunk/lib/FlairSensorActuator/src/Mb800.cpp


Ignore:
Timestamp:
Jun 28, 2016, 3:20:04 PM (5 years ago)
Author:
Sanahuja Guillaume
Message:

m

File:
1 edited

Legend:

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

    r15 r41  
    4343  /** Debut init **/
    4444  char response[200] = {0};
    45   int size;
     45  int size,written;
    4646
    4747  /** Fin init **/
     
    4949  /** Debut config **/
    5050  char to_send[] = "$PASHS,NME,ALL,A,OFF\r\n";
    51   serialport->Write(to_send, sizeof(to_send));
    52 
     51  written=serialport->Write(to_send, sizeof(to_send));
     52  if (written< 0) {
     53      Thread::Err("erreur Write (%s)\n", strerror(-written));
     54  }
     55/*
    5356  {
    5457    char to_send[] = "$PASHS,CPD,AFP,95.0\r\n";
    55     serialport->Write(to_send, sizeof(to_send));
     58    written=serialport->Write(to_send, sizeof(to_send));
     59    if (written< 0) {
     60      Thread::Err("erreur Write (%s)\n", strerror(-written));
     61    }
    5662  }
    5763  {
    5864    char to_send[] = "$PASHS,DIF,PRT,C,RT3\r\n";
    59     serialport->Write(to_send, sizeof(to_send));
     65    written=serialport->Write(to_send, sizeof(to_send));
     66    if (written< 0) {
     67      Thread::Err("erreur Write (%s)\n", strerror(-written));
     68    }
    6069  }
    61 
     70*/
    6271  if ((NMEAFlags & GGA) != 0) {
    6372    char to_send[] = "$PASHS,NME,GGA,A,ON,0.05\r\n";
    64     size = serialport->Write(to_send, sizeof(to_send));
    65     // Printf("ecrit %i\n",size);
     73    written = serialport->Write(to_send, sizeof(to_send));
     74    if (written< 0) {
     75      Thread::Err("erreur Write (%s)\n", strerror(-written));
     76    }
    6677  }
    6778  if ((NMEAFlags & VTG) != 0) {
    6879    char to_send[] = "$PASHS,NME,VTG,A,ON,0.05\r\n";
    69     size = serialport->Write(to_send, sizeof(to_send));
    70     // Printf("%i\n",size);
     80    written = serialport->Write(to_send, sizeof(to_send));
     81    if (written< 0) {
     82      Thread::Err("erreur Write (%s)\n", strerror(-written));
     83    }
    7184  }
    7285  if ((NMEAFlags & GST) != 0) {
    7386    char to_send[] = "$PASHS,NME,GST,A,ON,0.05\r\n";
    74     size = serialport->Write(to_send, sizeof(to_send));
    75     // Printf("%i\n",size);
     87    written = serialport->Write(to_send, sizeof(to_send));
     88    if (written< 0) {
     89      Thread::Err("erreur Write (%s)\n", strerror(-written));
     90    }
    7691  }
    7792
     
    8499
    85100  while (!ToBeStopped()) {
     101    //Printf("loop\n");
    86102    SleepMS(10);
    87     size = 0;
     103    size = 0;/*
    88104    while (!ToBeStopped()) {
    89105      ssize_t read = serialport->Read(&response[size], 1);
     
    95111        break;
    96112      size++;
    97     }
     113    }*/
    98114    size++;
    99     parseFrame(response, size);
     115    //parseFrame(response, size);
    100116  }
    101117  /** fin running loop **/
     
    106122  char data = 0;
    107123  ssize_t read = 0;
    108 
     124Printf("sync\n");
    109125  // attente fin trame
    110   while (data != 0x0a) {
     126  while (data != 0x0a && !ToBeStopped()) {
    111127    read = serialport->Read(&data, 1);
     128    SleepMS(10);
     129    Printf("%i %x\n",read,data);
    112130    if (read < 0) {
    113131      Thread::Err("erreur Read (%s)\n", strerror(-read));
Note: See TracChangeset for help on using the changeset viewer.