Changeset 442 in flair-src
- Timestamp:
- Sep 6, 2021, 3:55:48 PM (3 years ago)
- Location:
- trunk/lib/FlairCore/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/SendData.cpp
r437 r442 121 121 pimpl_->send_size = value; 122 122 123 if (getUiCom() != NULL) 124 getUiCom()->UpdateDataToSendSize(); 123 if (getUiCom() != NULL) { 124 getUiCom()->UpdateDataToSendSize(); 125 getUiCom()->UpdateDataToSendBufferSize(this); 126 } 125 127 } 126 128 -
trunk/lib/FlairCore/src/ui_com.cpp
r441 r442 53 53 54 54 #ifdef __XENO__ 55 Err("multi buffering is not well implemented in RT\n"); 56 #endif 57 58 #ifdef __XENO__ 55 59 int status; 56 60 string tmp_name; … … 370 374 } 371 375 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 372 389 dataToSend->CopyDatas(ptr->buf+ptr->actual_size); 373 390 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); 375 392 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 377 394 Printf("ready to send\n"); 378 395 //clean … … 556 573 557 574 //TODO: check if it is RT compatible 575 //must be called with mutex locked 558 576 void ui_com::UpdateSendData(const SendData *obj) { 559 577 // le mutex est deja pris par l'appellant … … 594 612 } 595 613 bufSize*=(*pushedDatasIterator).nb_buffering; 614 if(bufSize!=0) bufSize+=sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t);//header+period+nb_buffering 596 615 if(bufSize!=(*pushedDatasIterator).final_size && bufSize!=0) { 597 616 Printf("change buf size %i->%i\n",(*pushedDatasIterator).final_size,bufSize); … … 628 647 tmp.final_size=0; 629 648 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()); 630 650 if (datasToSend.at(i)->IsEnabled() && datasToSend.at(i)->SendPeriod() == obj->SendPeriod() && datasToSend.at(i)->NbBuffering()==obj->NbBuffering()) { 631 651 tmp.final_size+=datasToSend.at(i)->SendSize(); 652 Printf("add %i\n",datasToSend.at(i)->SendSize()); 632 653 } 633 654 } 634 655 tmp.final_size*=obj->NbBuffering(); 656 tmp.final_size+=sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t);//header+period+nb_buffering 635 657 printf("final size %i\n",tmp.final_size); 636 658 tmp.buf=(char*)malloc(tmp.final_size); … … 664 686 } 665 687 688 void 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 666 712 void ui_com::RemoveSendData(const SendData *obj) { 667 713 // printf("remove_data_to_send %i\n",data_to_send.size()); -
trunk/lib/FlairCore/src/unexported/communication.h
r253 r442 13 13 #define DATA_BIG_ENDIAN 0x03 14 14 #define CLOSING_CONNECTION 0x04 15 #define MULTIPLE_DATA_LITTLE_ENDIAN 0x05 16 #define MULTIPLE_DATA_BIG_ENDIAN 0x06 15 17 16 18 //messages file socket -
trunk/lib/FlairCore/src/unexported/ui_com.h
r441 r442 45 45 void UpdateSendData(const flair::gui::SendData *obj);//must be called with mutex locked 46 46 void RemoveSendData(const flair::gui::SendData *obj); 47 void UpdateDataToSendBufferSize(const flair::gui::SendData *obj); 47 48 void UpdateDataToSendSize(void); 48 49 void Block(void);
Note:
See TracChangeset
for help on using the changeset viewer.