diff --git a/src/CommunicationManager.cpp b/src/CommunicationManager.cpp index 772fd02..a1e125d 100644 --- a/src/CommunicationManager.cpp +++ b/src/CommunicationManager.cpp @@ -170,11 +170,13 @@ void CommunicationManager::Run_In_Swarm_Mode() ros::Rate loop_rate(LOOP_RATE); counter=0; - test_1=1; + while (ros::ok()) { Check_In_Messages_and_Transfer_To_Topics(); Send_multi_msg(); + //if(counter==10) {test_1=5;} + //else counter++; ros::spinOnce(); loop_rate.sleep(); } @@ -373,7 +375,7 @@ inline void CommunicationManager::Check_In_Messages_and_Transfer_To_Topics() { std::size_t size_in_messages = in_messages_->Get_Size(); uint16_t* header; - if(!multi_msgs_receive.empty()) steps++; + //if(!multi_msgs_receive.empty()) steps++; if(steps>200){ steps=0; multi_msgs_receive.clear(); @@ -407,8 +409,8 @@ inline void CommunicationManager::Check_In_Messages_and_Transfer_To_Topics() char temporary_buffer[20]; std::string frame; - if(current_int64 <= 3){ - Generate_Transmit_Request_Frame(in_message->c_str(), &frame,sizeof(uint64_t) * 4); + /*if(current_int64 <= 3){ + Generate_Transmit_Request_Frame(in_message->c_str(), &frame,sizeof(uint64_t) * ); serial_device_.Send_Frame(frame); } if(current_int64 == (uint64_t)device_id ){ @@ -419,7 +421,7 @@ inline void CommunicationManager::Check_In_Messages_and_Transfer_To_Topics() std::cout<<"Time taken for send and receive : "<1 && header[2]==1){ /*copy msg size*/ @@ -454,8 +456,9 @@ inline void CommunicationManager::Check_In_Messages_and_Transfer_To_Topics() //char temporary_buffer[20]; //std::string frame; std::cout << "Multi msg Received header " <0){ + test_1--; + char temporary_buffer[sizeof(uint64_t) * 5]; std::string frame; uint64_t constant_msg[3]; constant_msg[1]=245253253253532; constant_msg[2]=245253253253532; constant_msg[3]=245253253253532; constant_msg[0]=(uint64_t) device_id; + constant_msg[4]=(uint64_t) test_t; gettimeofday(&t1, NULL); /*Copy the data to char buff*/ - memcpy((void*)temporary_buffer,(void*)constant_msg,sizeof(uint64_t) * 4); - Generate_Transmit_Request_Frame(temporary_buffer, &frame,sizeof(uint64_t) * 4); + /*memcpy((void*)temporary_buffer,(void*)constant_msg,sizeof(uint64_t) * 5); + Generate_Transmit_Request_Frame(temporary_buffer, &frame,sizeof(uint64_t) * 5); multi_msgs_send_dict.push_back(frame); - } + }*/ if( !( multi_msgs_send_dict.empty() ) ){ /*If the sent message chunk not the last message then send else clear the dict*/ if( (uint16_t)(multi_msgs_send_dict.size() ) - 1 == sending_chunk_no && (uint16_t)ack_received_dict.size() == (uint16_t)(no_of_dev)-1){