Changeset 41 in flair-src for trunk


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

m

Location:
trunk/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairMeta/src/UavFactory.cpp

    r15 r41  
    2929using namespace flair::meta;
    3030
     31namespace { // anonymous
     32     vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> vectoroffunctions;
     33}
     34
    3135Uav *CreateUav(FrameworkManager *parent, string uav_name, string uav_type,
    3236               UavMultiplex *multiplex) {
    33   /*if(uav_type=="ardrone2") {
    34         return new ArDrone2(parent,uav_name,multiplex);
    35     } else */ if (uav_type == "hds_x4") {
     37
     38  Uav *uav;
     39  for(int i=0;i<vectoroffunctions.size();i++) {
     40    uav=vectoroffunctions.at(i)(parent, uav_name, uav_type,multiplex);
     41    if(uav!=NULL) return uav;
     42  }
     43
     44  if (uav_type == "hds_x4") {
    3645    parent->Err("UAV type %s not yet implemented\n", uav_type.c_str());
    3746    return NULL;
     
    6069  }
    6170}
     71
     72void RegisterUavCreator(flair::meta::Uav*(*func)(FrameworkManager *parent, string uav_name, string uav_type,
     73               UavMultiplex *multiplex)) {
     74                 vectoroffunctions.push_back(func);
     75
     76}
  • trunk/lib/FlairMeta/src/UavFactory.h

    r15 r41  
    2525                            flair::filter::UavMultiplex *multiplex = NULL);
    2626
     27void RegisterUavCreator(flair::meta::Uav*(*func)(flair::core::FrameworkManager *parent,
     28                                   std::string uav_name, std::string uav_type,
     29                                   flair::filter::UavMultiplex *multiplex));
    2730#endif // UAVFACTORY
  • 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.