Beispiel #1
0
int CommandQueue::add_packet(CommandPacket &cp)
{
    if(!cp.valid()) throw cpInvalidException;

    Command cm(0x10ff, 0xffff);
    int count = 0;

    while(cp.remainingBytes() > 0) {
        cp.readNextCommandTo(cm);
        *this << cm;
        count++;
    }

    return count;
}
Beispiel #2
0
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);
}
Beispiel #3
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);
}