Ignore:
Timestamp:
03/06/18 12:12:58 (6 years ago)
Author:
Sanahuja Guillaume
Message:

maj for armv5te

File:
1 edited

Legend:

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

    r214 r224  
    5050}
    5151
    52 SimuBldc::SimuBldc(const Object *parent, string name, uint8_t motors_count,
    53                    uint32_t modelId,uint32_t deviceId)
    54     : Bldc(parent, name, motors_count) {
    55   shmem =
    56       new SharedMem(this, ShMemName(modelId, deviceId), motors_count * sizeof(float)+sizeof(Time));
    57      
    58   buf=(char*)malloc(motors_count * sizeof(float)+sizeof(Time));
    59   if(buf==NULL) {
    60     Err("error creating buffer\n");
    61     return;
    62   }
    63  
    64   // reset values
    65   float *values=(float*)buf;
    66   for (int i = 0; i < motors_count; i++) values[i] = 0;
    67   Time time=GetTime();
    68   memcpy(buf+motors_count * sizeof(float),&time,sizeof(Time));
    69 
    70   shmem->Write(buf, motors_count * sizeof(float)+sizeof(Time));
    71  
    72   SetIsReady(true);
    73 }
    74 
    7552SimuBldc::~SimuBldc() {
    7653  if(buf!=NULL) free(buf);
     
    9976}
    10077
    101 void SimuBldc::GetSpeeds(float *value,Time* time) const {
    102   float *values=(float*)buf;
    103   shmem->Read(buf, MotorsCount() * sizeof(float)+sizeof(Time));
    104   memcpy(time,buf+MotorsCount() * sizeof(float),sizeof(Time));
    105 
    106   for (int i = 0; i < MotorsCount(); i++) {
    107     value[i] = values[i];
    108   }
    109 }
    110 
    11178} // end namespace sensor
    11279} // end namespace flair
Note: See TracChangeset for help on using the changeset viewer.