3 * Copyright 2007 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <usrp_inband_usb_packet.h>
28 #include <mb_class_registry.h>
30 #include <usrp_usb_interface.h>
33 typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy
35 int main(int argc, char *argv[]) {
38 std::cout << "Usage: ./read_packets <data_file>\n";
43 std::ofstream outfile;
45 unsigned int pkt_size = transport_pkt::max_pkt_size();
46 unsigned int pkt_num=0;
49 char pkt_data[pkt_size]; // allocate the number of bytes for a single packet
51 pkt = (transport_pkt *)pkt_data; // makes operations cleaner to read
53 // Open the file and read the packets, dumping information
54 infile.open(argv[1], std::ios::binary|std::ios::in);
58 //outfile.open("dump.dat",std::ios::out|std::ios::binary);
60 // read 1 packet in to the memory
61 infile.read(pkt_data, pkt_size);
63 while(!infile.eof()) {
65 printf("Packet %u\n", pkt_num);
67 if(pkt->start_of_burst())
68 printf("\tstart of burst\n");
70 if(pkt->end_of_burst())
71 printf("\tend of burst\n");
73 // if(pkt->carrier_sense())
74 // printf("\tcarrier sense\n");
76 printf("\tchannel: \t0x%x\n", pkt->chan());
77 printf("\ttimestamp: \t0x%x\n", pkt->timestamp());
78 //printf("\ttimestamp: \t%u\n", pkt->timestamp());
79 printf("\tlength: \t%u\n", pkt->payload_len());
80 printf("\trssi: \t%u\n", pkt->rssi());
82 printf("\tpayload: \n");
83 for(int i=0; i < pkt->payload_len(); i++)
84 //for(int i=0; i < pkt->max_payload(); i++)
86 printf("\t%d\t0x%x\n", i, *(pkt->payload()+i));
87 //outfile.write((const char*)(pkt->payload()+i),1);
88 //printf("\t\t0x%x\n", pkt->payload()+i);
95 // read 1 packet in to the memory
96 infile.read(pkt_data, pkt_size);