Changeset 442 in flair-src for trunk


Ignore:
Timestamp:
Sep 6, 2021, 3:55:48 PM (3 months ago)
Author:
Sanahuja Guillaume
Message:

update buffering

Location:
trunk/lib/FlairCore/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/SendData.cpp

    r437 r442  
    121121  pimpl_->send_size = value;
    122122
    123   if (getUiCom() != NULL)
    124     getUiCom()->UpdateDataToSendSize();
     123  if (getUiCom() != NULL) {
     124      getUiCom()->UpdateDataToSendSize();
     125        getUiCom()->UpdateDataToSendBufferSize(this);
     126  }
    125127}
    126128
  • trunk/lib/FlairCore/src/ui_com.cpp

    r441 r442  
    5353
    5454#ifdef __XENO__
     55 Err("multi buffering is not well implemented in RT\n");
     56#endif
     57
     58#ifdef __XENO__
    5559  int status;
    5660  string tmp_name;
     
    370374  }
    371375 
     376  if(ptr->actual_size==0) {
     377      if (IsBigEndian()) {
     378        ptr->buf[0] = MULTIPLE_DATA_BIG_ENDIAN;
     379      } else {
     380        ptr->buf[0]  = MULTIPLE_DATA_LITTLE_ENDIAN;
     381      }
     382      ptr->actual_size+=sizeof(char);
     383      memcpy(ptr->buf+ptr->actual_size,&(ptr->period),sizeof(uint16_t));
     384      ptr->actual_size+=sizeof(uint16_t);
     385      memcpy(ptr->buf+ptr->actual_size,&(ptr->nb_buffering),sizeof(uint16_t));
     386      ptr->actual_size+=sizeof(uint16_t);
     387  }
     388 
    372389  dataToSend->CopyDatas(ptr->buf+ptr->actual_size);
    373390  ptr->actual_size+=dataToSend->SendSize();
    374   Printf("nb buffered %i\n",ptr->actual_size);
     391  Printf("nb buffered %i/%i\n",ptr->actual_size,ptr->final_size);
    375392  Printf("pushed size %i period %i nb buffering %i\n",dataToSend->SendSize(),dataToSend->SendPeriod(),dataToSend->NbBuffering());
    376   if(ptr->actual_size==ptr->final_size) {
     393  if(ptr->actual_size>=ptr->final_size) {//par securité on test aussi le cas ou supérieur
    377394      Printf("ready to send\n");
    378395      //clean
     
    556573
    557574//TODO: check if it is RT compatible
     575//must be called with mutex locked
    558576void ui_com::UpdateSendData(const SendData *obj) {
    559577  // le mutex est deja pris par l'appellant
     
    594612        }
    595613        bufSize*=(*pushedDatasIterator).nb_buffering;
     614        if(bufSize!=0) bufSize+=sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t);//header+period+nb_buffering
    596615        if(bufSize!=(*pushedDatasIterator).final_size && bufSize!=0) {
    597616            Printf("change buf size %i->%i\n",(*pushedDatasIterator).final_size,bufSize);
     
    628647        tmp.final_size=0;
    629648        for (size_t i = 0; i < datasToSend.size(); i++) {
     649            Printf("data %i/%i %i %i\n",i,datasToSend.size(),datasToSend.at(i)->SendPeriod() ,datasToSend.at(i)->NbBuffering());
    630650            if (datasToSend.at(i)->IsEnabled() && datasToSend.at(i)->SendPeriod() == obj->SendPeriod() && datasToSend.at(i)->NbBuffering()==obj->NbBuffering()) {
    631651              tmp.final_size+=datasToSend.at(i)->SendSize();
     652              Printf("add %i\n",datasToSend.at(i)->SendSize());
    632653            }
    633654        }
    634655        tmp.final_size*=obj->NbBuffering();
     656        tmp.final_size+=sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t);//header+period+nb_buffering
    635657        printf("final size %i\n",tmp.final_size);
    636658        tmp.buf=(char*)malloc(tmp.final_size);
     
    664686}
    665687
     688void ui_com::UpdateDataToSendBufferSize(const SendData *obj) {
     689    send_mutex->GetMutex();
     690   
     691    PushedData_t* ptr=NULL;
     692    //get buffer for this couple period/nb_buffering
     693    for (size_t i = 0; i < pushedDatas.size(); i++) {
     694      if (pushedDatas.at(i).period==obj->SendPeriod() && pushedDatas.at(i).nb_buffering==obj->NbBuffering()) {
     695          ptr=&pushedDatas.at(i);
     696        }
     697    }
     698    if(ptr==NULL) {
     699        Err("no corresponding match for couple %i %i\n",obj->SendPeriod(),obj->NbBuffering());
     700        return;
     701    }
     702   
     703    ptr->final_size=sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t);//header+period+nb_buffering
     704    ptr->final_size+=obj->SendSize()*obj->NbBuffering();
     705    Printf("final %i\n",ptr->final_size);
     706    free(ptr->buf);
     707    ptr->buf=(char*)malloc(ptr->final_size);
     708   
     709    send_mutex->ReleaseMutex();
     710}
     711
    666712void ui_com::RemoveSendData(const SendData *obj) {
    667713  // printf("remove_data_to_send %i\n",data_to_send.size());
  • trunk/lib/FlairCore/src/unexported/communication.h

    r253 r442  
    1313#define DATA_BIG_ENDIAN 0x03
    1414#define CLOSING_CONNECTION 0x04
     15#define MULTIPLE_DATA_LITTLE_ENDIAN 0x05
     16#define MULTIPLE_DATA_BIG_ENDIAN 0x06
    1517
    1618//messages file socket
  • trunk/lib/FlairCore/src/unexported/ui_com.h

    r441 r442  
    4545  void UpdateSendData(const flair::gui::SendData *obj);//must be called with mutex locked
    4646  void RemoveSendData(const flair::gui::SendData *obj);
     47  void UpdateDataToSendBufferSize(const flair::gui::SendData *obj);
    4748  void UpdateDataToSendSize(void);
    4849  void Block(void);
Note: See TracChangeset for help on using the changeset viewer.