DataBus::Packet DataBus::PacketParser::takePacket() { // Check if packet is available if (isPacketAvailable() == false) { // Error, packet is not available return Packet(); } // Start reading next packet m_state = State_WaitForStartOfFrame; // Return packet return m_packetList.takeFirst(); }
/* * First thread "pck_collec" implementation for Packet collection */ void *pck_collec(void *tr){ while(endOfPackets()==0){ if(isPacketAvailable()){ pthread_mutex_lock( &mutexip ); packets[pck_counter] = getPacket(); pck_counter++; recv_pck++; pthread_mutex_unlock( &mutexip ); } pthread_mutex_lock( &mutexip ); if(pck_counter>=max_pck) pck_counter=0; pthread_mutex_unlock( &mutexip ); } pthread_exit(NULL); }