Changeset 38 in flair-src for trunk/lib/FlairSensorActuator


Ignore:
Timestamp:
Jun 23, 2016, 10:15:30 AM (9 years ago)
Author:
Bayard Gildas
Message:

Modif. pour ajour manette émulée (EmulatedController)

Location:
trunk/lib/FlairSensorActuator/src
Files:
2 added
2 edited

Legend:

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

    r15 r38  
    3434namespace sensor {
    3535
    36 TargetController::TargetController(const FrameworkManager *parent, string name,
    37                                    uint8_t priority)
    38     : Thread(parent, name, priority), IODevice(parent, name) {
    39   main_tab = new Tab(getFrameworkManager()->GetTabWidget(), name);
    40   TabWidget *tab = new TabWidget(main_tab->NewRow(), name);
    41   setup_tab = new Tab(tab, "Reglages");
     36TargetController::TargetController(const FrameworkManager* parent,string name,uint8_t priority) :
     37    Thread(parent,name,priority),IODevice(parent,name) {
     38    main_tab=new Tab(getFrameworkManager()->GetTabWidget(),name);
     39    TabWidget* tab=new TabWidget(main_tab->NewRow(),name);
     40    setup_tab=new Tab(tab,"Reglages");
     41    SetPeriodMS(20);; //50Hz
    4242}
    4343
     
    150150          }
    151151        }
    152       } else {
    153         // Thread::Info("Debug: relax...\n");
    154         usleep(20000); // 20ms
    155152      }
     153      WaitPeriod();
    156154    }
    157155  }
  • trunk/lib/FlairSensorActuator/src/TargetEthController.cpp

    r15 r38  
    8080  bool fullDatagramReceived = false;
    8181
    82   do {
    83     received =
    84         dataSocket->RecvMessage(receiveFrameBuffer + receiveCurrentPosition,
    85                                 bytesToReceive, TIME_NONBLOCK);
    86     if (received > 0) {
    87       bytesToReceive -= received;
    88       if (bytesToReceive == 0) {
    89         // a full datagram has been read in receiveFrameBuffer
    90         fullDatagramReceived = true;
    91         receiveCurrentPosition = 0;
    92         // we swap the data and reception buffers to avoid copy
    93         char *swapFrameBuffer = dataFrameBuffer;
    94         dataFrameBuffer = receiveFrameBuffer;
    95         receiveFrameBuffer = swapFrameBuffer;
    96       }
    97     }
    98   } while (!received < 0);
     82    do {
     83        received=dataSocket->RecvMessage(receiveFrameBuffer+receiveCurrentPosition,bytesToReceive,TIME_NONBLOCK);
     84        if (received>0) {
     85            receiveCurrentPosition+=received;
     86            bytesToReceive-=received;
     87            if (bytesToReceive==0) {
     88                //a full datagram has been read in receiveFrameBuffer
     89                fullDatagramReceived=true;
     90                //we swap the data and reception buffers to avoid copy
     91                char *swapFrameBuffer=dataFrameBuffer;
     92                dataFrameBuffer=receiveFrameBuffer;
     93                receiveFrameBuffer=swapFrameBuffer;
     94                receiveCurrentPosition=0;
     95                bytesToReceive=dataFrameSize;
     96            }
     97        }
     98    } while (!(received<0));
    9999
    100100  return fullDatagramReceived;
Note: See TracChangeset for help on using the changeset viewer.