void* UDPReceiver::receiverThreadFunction(void* arg) { UDPReceiver* thisPointer = (UDPReceiver*)arg; bool& stopReceiverThread = thisPointer->stopReceiverThread; while(!stopReceiverThread) { thisPointer->tryToReceivePacket(); thisPointer->actionWhenReceived(thisPointer->packetBuffer); } printf("%s\n","UDP receiver thread exited"); pthread_exit(NULL); }
THREAD_FUNC UDPReceiverEntry( void* ptr ) { // Get a new broadcaster object UDPReceiver* urObject = UDPReceiver::GetSingleton(); // Loop 'forever' urObject->ProcessLoop(); // Delete the broadcaster delete urObject; UDPReceiver::m_Singleton = 0; return 1; }
int main(int argc, char *argv[]) { UDPReceiver udpreceiver = UDPReceiver( CTL_CMD_PORT ); udpreceiver.init_connection(); while(1){ uint16_t packet_length = udpreceiver.listen(); if( packet_length != 0){ uint8_t *packet = new uint8_t[packet_length]; udpreceiver.get_packet( packet ); CommandPacket cp = CommandPacket( packet, packet_length); if (cp.valid()){ std::cout << cp << std::endl; } free(packet); } } exit(0); }
int main(int argc, char *argv[]) { UDPReceiver udpreceiver = UDPReceiver( CTL_CMD_PORT ); udpreceiver.init_connection(); while(1){ //printf("Started to listen\n"); uint16_t packet_length = udpreceiver.listen(); //printf("Finished listening. Packet length was %u\n", packet_length); if( packet_length != 0){ uint8_t *packet = new uint8_t[packet_length]; udpreceiver.get_packet( packet ); CommandPacket cp = CommandPacket( packet, packet_length); if (cp.valid()){ std::cout << cp << std::endl; } delete packet; } } exit(0); }
int main(int argc, char *argv[]) { UDPReceiver udpreceiver = UDPReceiver( SRV_TM_PORT ); udpreceiver.init_connection(); while(1){ //printf("Started to listen\n"); uint16_t packet_length = udpreceiver.listen(); //printf("Finished listening. Packet length was %u\n", packet_length); if( packet_length != 0){ uint8_t *packet = new uint8_t[packet_length]; udpreceiver.get_packet( packet ); TelemetryPacket cp = TelemetryPacket( packet, packet_length); //if (cp.valid() && (cp.getSourceID() == 0x30)){ if (cp.valid()){ std::cout << cp << std::endl; } delete packet; } } exit(0); }