Advertisement
ciusss89

gn3s.cpp

Sep 27th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 21.63 KB | None | 0 0
  1. /*
  2.  * Code from: USRP - Universal Software Radio Peripheral (GNU Radio)
  3.  *
  4.  * Initial modifications by:
  5.  *
  6.  * Stephan Esterhuizen, Aerospace Engineering Sciences
  7.  * University of Colorado at Boulder
  8.  * Boulder CO, USA
  9.  *
  10.  * Further modifications for use with the SiGe USB module to accompany
  11.  * the textbook: "A Software-Defined GPS and Galileo Receiver: A
  12.  * Single-Frequency Approach" by Kai Borre, Dennis Akos, et.al. by:
  13.  *
  14.  * Marcus Junered, GNSS Research Group
  15.  * Lulea University of Technology
  16.  * Lulea, Sweden
  17.  *
  18.  * Further review and modifications of user interface has been made by:
  19.  *
  20.  * Jonas Lindstrom
  21.  * Lulea University of Technology
  22.  * Lulea, Sweden
  23.  *
  24.  * http://ccar.colorado.edu/gnss
  25.  *
  26.  *  Furthur modifications integrating 4120 devices have been made by:
  27.  *
  28.  *  Marcus Wilkerson
  29.  *  University of Colorado, Boulder
  30.  *  Boulder, CO, USA
  31.  *
  32.  *  Some minor changes were made by
  33.  *
  34.  *  Oscar Isoz
  35.  *  University of Colorado, Boulder
  36.  *  Boulder, CO, USA
  37.  *
  38.  * Change Documentation (2/2008 - 5/2008)
  39.  * --------------------------------------
  40.  * - MW - Added PID array variable for SiGe 4120 GPS Front End
  41.  * - MW - Fixed a bug if LIBUSB found more devices on the bus and gave
  42.  *        each device a different index number. It was hardcoded to "1" before.
  43.  * - MW - Added check for 4120 module in usb_fx2_find fcn
  44.  * - MW - If 4120, use I/Q values of -1 and +1 instead of -1,-3,+1,+3 as with
  45.  *        4110 modules. This is in main().
  46.  * - OI - Changed the user interface
  47.  *
  48.  * ---------------------------------------------------------------------
  49.  *
  50.  * GN3S - GNSS IF Streamer for Windows
  51.  * Copyright (C) 2006 Marcus Junered
  52.  *
  53.  * This program is free software; you can redistribute it and/or modify
  54.  * it under the terms of the GNU General Public License as published by
  55.  * the Free Software Foundation; either version 2 of the License, or
  56.  * (at your option) any later version.
  57.  *
  58.  * This program is distributed in the hope that it will be useful,
  59.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  60.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  61.  * GNU General Public License for more details.
  62.  *
  63.  * You should have received a copy of the GNU General Public License
  64.  * along with this program; if not, write to the Free Software
  65.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  66.  */
  67.  
  68.  #include "main.h"
  69.  
  70.  using namespace std;
  71.  
  72.  // Entry of main function
  73.  int main(int argc, char *argv[])
  74.  {
  75.     bool b_overrun = false;         //  buffer overrun flag
  76.     bool b_RFI = false;
  77.     char cp_filename[64];           //  data file name
  78.     char cp_agc_filename[64];       //  agc data file name (when agc_on = 1)
  79.     char version;                   //  version of modules
  80.     unsigned char uc_flags[5];
  81.  
  82.     /*  Control Variable */
  83.     int i_col_mode = 32;            //  Data collection mode, default value is 32
  84.     int i_AGC = 1;                  //
  85.     int i_col_time = 0;
  86.     int i_tmp = 0;
  87.     int i_ch = -1;                  //  Command parameter buffer;
  88.     int i_decimate = 1;
  89.     int i_RFI_det = 0;
  90.     /*  State variable */
  91.     unsigned int ui_agc_count = 0;  //  AGC data collected size
  92.     unsigned int ui_pack = 1;       //  Pack mode
  93.     unsigned int ui_time_to_collect = 2;//  Data collection time
  94.     unsigned int agc_on = 0;        //  AGC logging on/off flag
  95.  
  96.     unsigned int ul_buf_size = 1048576*32;
  97.     unsigned int ul_agc_buf_size = 320;
  98.     unsigned int ul_num_bytes_written = 0;
  99.  
  100.     bool b_run = true;              //  Main loop control variable
  101.     unsigned int k = 0;             //  Main loop numbers
  102.     unsigned int ui_agc_tot = 0;    //
  103.     unsigned int ui_agc_buf_pos = 0;//
  104.  
  105.     float ul_kmax;                  //  Size of data buffered
  106.     timeval tv_max, tv_now, tv_start;
  107.  
  108.  
  109.     /*  Clear date file name */
  110.     strcpy(cp_agc_filename," ");
  111.     strcpy(cp_filename," ");
  112.  
  113.     /*  Timer   */
  114.     timeval st_cpu_time;
  115.     string  str;
  116.     /*  Device */
  117.     Fx2_dev fx2_d = Fx2_dev(0);
  118.  
  119.     /************************* Look for a device*****************************/
  120.     fx2_d = Fx2_dev(0);     //  Looking for device with PID 0x0b38
  121.     if (fx2_d.usb_fx2_find() != 0)
  122.     {
  123.         version = 0;
  124.     }
  125.     else
  126.     {
  127.         fx2_d = Fx2_dev(2); //  Looking for device with PID 0x0b3a
  128.         if (fx2_d.usb_fx2_find() != 0)
  129.         {
  130.             version = 1;
  131.         }
  132.         else
  133.         {
  134.             fx2_d = Fx2_dev(3);     // Looking for device with PID 0x0b3f
  135.             if(fx2_d.usb_fx2_find()!=0)
  136.             {
  137.                 version = 2;
  138.             }
  139.             else
  140.             {
  141.                 printf("\t no GNSS frontend found\n");
  142.                 return(0);
  143.                 fx2_d.close();
  144.             }
  145.         }
  146.     }
  147.     /************************ Display the help information according to PID of module **************/
  148.     if (version == 0)
  149.     {
  150.         while ( (i_ch = getopt (argc,argv,"ho:s:")) != EOF )
  151.         {
  152.             switch(i_ch)
  153.             {
  154.                 case 'h':   // help
  155.                     help_lv();
  156.                     return 0;
  157.                 case 's':   // size(sec)
  158.                     sscanf(optarg, "%u", &ui_time_to_collect);
  159.                     break;
  160.                 case 'o':   // filename
  161.                     strcpy(cp_filename, optarg);
  162.                     i_tmp = strlen(optarg);
  163.                     if (i_tmp>4)
  164.                     {
  165.                         memcpy(cp_agc_filename,(const char*)optarg,(i_tmp-2));
  166.  
  167.                         memcpy((cp_agc_filename+i_tmp-4),"_agc.bin\0",sizeof("_agc.bin\0"));
  168.                     }
  169.                     else
  170.                     {
  171.                         strcpy(cp_agc_filename,"test_agc.bin");
  172.                     }
  173.                     break;
  174.                  default:
  175.                     break;
  176.             }
  177.         }
  178.     }
  179.     else if (version == 1 )
  180.     {
  181.         while ( (i_ch = getopt ( argc, argv, "ho:s:c:" )) != EOF )
  182.         {
  183.             switch(i_ch)
  184.             {
  185.                 case 'h':   // help
  186.                     help_hv(1);
  187.                     return 0;
  188.                     break;
  189.                 case 's':   // size(sec)
  190.                     sscanf(optarg,"%u", &ui_time_to_collect);
  191.                     break;
  192.                 case 'o':   // file name
  193.                     strcpy(cp_filename, optarg);
  194.                     i_tmp = strlen(optarg);
  195.                     if (i_tmp>4)
  196.                     {
  197.                         memcpy(cp_agc_filename,(const char*)optarg,(i_tmp-2));
  198.  
  199.                         memcpy((cp_agc_filename+i_tmp-4),"_agc.bin\0",sizeof("_agc.bin\0"));
  200.                     }
  201.                     else
  202.                     {
  203.                         strcpy(cp_agc_filename,"test_agc.bin");
  204.                     }
  205.                     break;
  206.                  case 'c':
  207.                     sscanf(optarg, "%u", &i_tmp);
  208.                     switch(i_tmp)
  209.                     {
  210.                         case 1: i_col_mode = 32; break;
  211.                         case 2: i_col_mode = 36; break;
  212.                         case 3: i_col_mode = 38; break;
  213.                         case 4: i_col_mode = 42; break;
  214.                         case 5: i_col_mode = 132; break;
  215.                         case 6: i_col_mode = 136; break;
  216.                         case 7: i_col_mode = 138; break;
  217.                         case 8: i_col_mode = 142; break;
  218.                         default: break;
  219.                     }
  220.                     break;
  221.                  default:
  222.                     break;
  223.             }
  224.         }
  225.     }
  226.     else if (version == 2)
  227.     {
  228.         while ( (i_ch = getopt ( argc, argv, "ho:s:b:c:p:d:a:" )) != EOF )
  229.         {
  230.             switch(i_ch)
  231.             {
  232.                 case 'h':   // help
  233.                     help_hv(version);
  234.                     return 0;
  235.                     break;
  236.                 case 's':   // data size (sec)
  237.                     sscanf(optarg, "%u", &ui_time_to_collect);
  238.                     break;
  239.                 case 'o':   // data filename
  240.                     strcpy(cp_filename, optarg);
  241.                     i_tmp = strlen(optarg);
  242.                     if (i_tmp>4)
  243.                     {
  244.                         memcpy(cp_agc_filename,(const char*)optarg,(i_tmp-2));
  245.  
  246.                         memcpy((cp_agc_filename+i_tmp-4),"_agc.bin\0",sizeof("_agc.bin\0"));
  247.                     }
  248.                     else
  249.                     {
  250.                         strcpy(cp_agc_filename,"test_agc.bin");
  251.                     }
  252.                     break;
  253.                 case 'c':   // data collection mode
  254.                     sscanf(optarg, "%u", &i_tmp);
  255.                     switch(i_tmp)
  256.                     {
  257.                         case 1: i_col_mode = 32; break;
  258.                         case 2: i_col_mode = 36; break;
  259.                         case 3: i_col_mode = 38; break;
  260.                         case 4: i_col_mode = 42; break;
  261.                         case 5: i_col_mode = 132; break;
  262.                         case 6: i_col_mode = 136; break;
  263.                         case 7: i_col_mode = 138; break;
  264.                         case 8: i_col_mode = 142; break;
  265.                         default: break;
  266.                     }
  267.                     break;
  268.                  case 'p':  // Pack data, not supported by this firmware
  269.                     sscanf(optarg,"%u",&ui_pack);
  270.                     if (!(ui_pack==4 ||(ui_pack==2)||(ui_pack==1)))
  271.                     {
  272.                         printf("Wrong value, value has to be 1,2 or 4\n");
  273.                         return(-1);
  274.                     }
  275.                     break;
  276.                  case 'd':  // Decimate data
  277.                     sscanf(optarg, "%u", &i_decimate);
  278.                     break;
  279.                  case 'a':  // AGC logging on/off
  280.                     sscanf(optarg, "%u", &agc_on);
  281.                     break;
  282.                  default:
  283.                     break;
  284.             }
  285.         }
  286.     }
  287.     else
  288.     {
  289.         return 0;
  290.     }
  291.     /***********************  Create init file *******************************************/
  292.     if (strlen(cp_filename)<2)
  293.     {
  294.         strcpy(cp_filename, "test.bin");
  295.         strcpy(cp_agc_filename,"test_agc.bin");
  296.     }
  297.     FileSaver fs = FileSaver(cp_filename);
  298.     fs.open_file(cp_filename);
  299.     fs.set_fid(1);
  300.     fs.set_decimate(i_decimate);
  301.     fs.set_pack(ui_pack);
  302.  
  303.     FileSaver fs_agc =FileSaver(cp_agc_filename);
  304.     fs_agc.open_file(cp_agc_filename);
  305.     fs_agc.set_fid(100);
  306.     fs_agc.set_pack(1);
  307.     fs_agc.set_decimate(1);
  308.  
  309.  
  310.     if(agc_on == 0)
  311.     {
  312.         fs_agc.close_file();
  313.         DeleteFile(cp_agc_filename);
  314.     }
  315.     /*****************************INIT USB **********************************/
  316.     fx2_d.usb_fx2_init();
  317.     if((version == 2)&&(agc_on == 1))
  318.     {
  319.         fx2_d.usrp_xfer (VRQ_AGC,i_AGC);
  320.     }
  321.     else
  322.     {
  323.         fx2_d.usrp_xfer (VRQ_AGC,0);
  324.     }
  325.     fx2_d.usrp_xfer (VRQ_CMODE,132 );
  326.     fx2_d.usrp_xfer (VRQ_XFER, 0 );
  327.  
  328.     fx2_d.usrp_xfer (VRQ_XFER, 1);
  329.     fx2_d.usrp_xfer2(VRQ_FLAGS, 0, uc_flags, 5);
  330.     fx2_d.usrp_xfer (VRQ_XFER, 0 );
  331.     /******************************INIT Buffers ************************/
  332.     short *shp_agc_data;
  333.     short *shp_agc_data_store;
  334.     char  *ch_if_data;
  335.     timeval tv;
  336.  
  337.     fs.set_decimate(i_decimate);
  338.     // Allocate buffer
  339.     ch_if_data = new char[BUFSIZE];
  340.     shp_agc_data = new short[100];
  341.     // Initiate buffer
  342.     for(int t = 0; t< 100; t++)
  343.     {
  344.         shp_agc_data[t] = 0;
  345.     }
  346.     for(int t = 0; t<BUFSIZE; t++)
  347.     {
  348.         ch_if_data[t] = 0;
  349.     }
  350.     // Set up the Timer
  351.     tv_max.tv_sec = i_col_time;
  352.     gettimeofday(&tv_start,NULL);
  353.  
  354.     fx2_d.usrp_xfer(VRQ_CMODE, i_col_mode);
  355.     fx2_d.usrp_xfer(VRQ_XFER, 1);
  356.     gettimeofday(&tv_max,NULL);
  357.  
  358.     if((version == 2)&&(agc_on == 1))
  359.     {
  360.         fx2_d.usrp_xfer(VRQ_AGC,2);
  361.     }
  362.     gettimeofday(&tv_now,NULL);
  363.  
  364.     int j = 0;      // Buffer data collected in each loop
  365.     int currK = 0;
  366.     float percentage = 0.0;
  367.     //  Cursor
  368.     HANDLE hStdout;
  369.     hStdout   =   GetStdHandle(STD_OUTPUT_HANDLE);
  370.     COORD   coord;
  371.     CONSOLE_SCREEN_BUFFER_INFO bInfo;
  372.  
  373.     while(b_run)
  374.     {
  375.         // Time control
  376.         if ((tv_now.tv_sec+tv_now.tv_usec/1e6) - (tv_start.tv_sec+tv_start.tv_usec/1e6) >= ui_time_to_collect)
  377.         {
  378.             // Set the current cursor to the right position
  379.             SetConsoleCursorPosition(hStdout,  bInfo.dwCursorPosition);
  380.             printf("%3.0f%% data collected",100.0);
  381.             b_run = false;
  382.         }
  383.         // Print capture information at the start
  384.         if(k==0)
  385.         {
  386.             printf("\n");
  387.             switch(i_col_mode)
  388.             {
  389.                 case 32:
  390.                     ul_kmax = 16.368 * ui_time_to_collect/i_decimate;
  391.                     printf("Attemping to collect %dsecs/%.1fMB of data\n",ui_time_to_collect,ul_kmax);
  392.                     break;
  393.                 case 36:
  394.                     ul_kmax = 8.184 * ui_time_to_collect/i_decimate;
  395.                     printf("Attemping to collect %dsecs/%.1fMB of data\n",ui_time_to_collect,ul_kmax);
  396.                     break;
  397.                 case 38:
  398.                     ul_kmax = 5.456 * ui_time_to_collect/i_decimate;
  399.                     printf("Attemping to collect %dsecs/%.1fMB of data\n",ui_time_to_collect,ul_kmax);
  400.                     break;
  401.                 case 42:
  402.                     ul_kmax = 4.092 * ui_time_to_collect/i_decimate;
  403.                     printf("Attemping to collect %dsecs/%.1fMB of data\n",ui_time_to_collect,ul_kmax);
  404.                     break;
  405.                 case 132:
  406.                     ul_kmax = 16.368 * ui_time_to_collect/i_decimate;
  407.                     printf("Attemping to collect %dsecs/%.1fMB of data\n",ui_time_to_collect,ul_kmax);
  408.                     break;
  409.                 case 136:
  410.                     ul_kmax = 8.184 * ui_time_to_collect/i_decimate;
  411.                     printf("Attemping to collect %dsecs/%.1fMB of data\n",ui_time_to_collect,ul_kmax);
  412.                     break;
  413.                 case 138:
  414.                     ul_kmax = 5.456 * ui_time_to_collect/i_decimate;
  415.                     printf("Attemping to collect %dsecs/%.1fMB of data\n",ui_time_to_collect,ul_kmax);
  416.                     break;
  417.                 case 142:
  418.                     ul_kmax = 4.092 * ui_time_to_collect/i_decimate;
  419.                     printf("Attemping to collect %dsecs/%.1fMB of data\n",ui_time_to_collect,ul_kmax);
  420.                     break;
  421.                 default:
  422.                     break;
  423.             }
  424.             // Get the current cursor position
  425.             GetConsoleScreenBufferInfo(hStdout, &bInfo);
  426.             // Set the current cursor to the right position
  427.             SetConsoleCursorPosition(hStdout,  bInfo.dwCursorPosition);
  428.             printf("%3.0f%% date collected\n",1.0);
  429.         }
  430.  
  431.         k++;
  432.         //  Print progress information
  433.         if ((k%250)==0)
  434.         {
  435.             // Set the current cursor to the right position
  436.             SetConsoleCursorPosition(hStdout,  bInfo.dwCursorPosition);
  437.             switch(i_col_mode)
  438.             {
  439.                 case 32:
  440.                     if ((k%1000) == 0)
  441.                     {
  442.                         percentage = k/10/ui_time_to_collect;
  443.                         (percentage>1)?printf("%3.0f%% date collected\n",percentage):printf("%3.0f%% date collected\n",1.0);
  444.                     }
  445.                     break;
  446.                 case 36:
  447.                     if ((k%500) == 0)
  448.                     {
  449.                         percentage = k/10*2/ui_time_to_collect;
  450.                         (percentage>1)?printf("%3.0f%% date collected\n",percentage):printf("%3.0f%% date collected\n",1.0);
  451.                     }
  452.                     break;
  453.                 case 38:
  454.                     percentage = k/10*3/ui_time_to_collect;
  455.                     (percentage>1)?printf("%3.0f%% date collected\n",percentage):printf("%3.0f%% date collected\n",1.0);
  456.                     break;
  457.                 case 42:
  458.                     percentage = k/10*4/ui_time_to_collect;
  459.                     (percentage>1)?printf("%3.0f%% date collected\n",percentage):printf("%3.0f%% date collected\n",1.0);
  460.                     break;
  461.                 case 132:
  462.                     if ((k%1000) == 0)
  463.                     {
  464.                         percentage = k/10/ui_time_to_collect;
  465.                         (percentage>1)?printf("%3.0f%% date collected\n",percentage):printf("%3.0f%% date collected\n",1.0);
  466.                     }
  467.                     break;
  468.                 case 136:
  469.                     if ((k%500) == 0)
  470.                     {
  471.                         percentage = k/10*2/ui_time_to_collect;
  472.                         (percentage>1)?printf("%3.0f%% date collected\n",percentage):printf("%3.0f%% date collected\n",1.0);
  473.                     }
  474.                     break;
  475.                 case 138:
  476.                     percentage = k/10*3/ui_time_to_collect;
  477.                     (percentage>1)?printf("%3.0f%% date collected\n",percentage):printf("%3.0f%% date collected\n",1.0);
  478.                     break;
  479.                 case 142:
  480.                     percentage = k/10*4/ui_time_to_collect;
  481.                     (percentage>1)?printf("%3.0f%% date collected\n",percentage):printf("%3.0f%% date collected\n",1.0);
  482.                     break;
  483.                 default:
  484.                     break;
  485.             }
  486.         }
  487.         //  Check buffer overrun
  488.         fx2_d.check_rx_overrun (&b_overrun );
  489.         if ( b_overrun==true )
  490.         {
  491.             gettimeofday(&tv_now,NULL);
  492.             printf("Buffer Overrun!\n");
  493.             delete []ch_if_data;
  494.             delete []shp_agc_data;
  495.             if(agc_on == 1)
  496.             {
  497.                 fs_agc.close_file();
  498.             }
  499.             fs.close_file();
  500.             switch(i_col_mode)
  501.             {
  502.                 case 32: currK = int(k/1000);break;
  503.                 case 36: currK = int(k/1000*2);break;
  504.                 case 38: currK = int(k/1000*3);break;
  505.                 case 42: currK = int(k/1000*4);break;
  506.                 case 132: currK = int(k/1000); break;
  507.                 case 136: currK = int(k/1000*2);break;
  508.                 case 138: currK = int(k/1000*3);break;
  509.                 case 142: currK = int(k/1000*4);break;
  510.                 default: break;
  511.             }
  512.             printf("%dsec/%dMB data collected\n",currK,(int)(ul_num_bytes_written/1e6));
  513.             fs_agc.close_file();
  514.             DeleteFile(cp_agc_filename);
  515.             fx2_d.close();
  516.             fx2_d.~Fx2_dev();
  517.             return(EXIT_FAILURE);
  518.         }
  519.         //  AGC data
  520.         if ((k==0)&&(version == 2)&&(agc_on == 1))
  521.         {
  522.             fx2_d.usrp_xfer ( VRQ_AGC, 1);
  523.             fx2_d.usrp_xfer ( VRQ_AGC, 2);
  524.             fx2_d.usrp_xfer2(VRQ_FLAGS, 0, uc_flags, 5);
  525.             fx2_d.usrp_xfer ( VRQ_AGC, 2);
  526.             ui_agc_count = 0;
  527.         }
  528.         else if ((k%60 == 0 && k >20)&&(version == 2)&&(agc_on == 1))
  529.         {
  530.  
  531.             fx2_d.read_AGC(shp_agc_data, &b_RFI, &i_RFI_det, &ui_agc_count);
  532.             fx2_d.usrp_xfer ( VRQ_AGC, 2);
  533.             if (ui_agc_count > 0)
  534.             {
  535.                 ui_agc_buf_pos= ui_agc_buf_pos+ui_agc_count;
  536.                 fs_agc.save_data(shp_agc_data,ui_agc_count);
  537.             }
  538.             ui_agc_count = 0;
  539.         }
  540.         //  Read data
  541.         j = fx2_d.read_IF(ch_if_data);
  542.         if ((j>0))
  543.         {
  544.             ul_num_bytes_written +=j;               //  Number of data collection update
  545.             fs.save_data(ch_if_data,j,i_col_mode);  //  Write data buffered to disc
  546.  
  547.         }
  548.         //  Get current time
  549.         gettimeofday(&tv_now,NULL);
  550.     }
  551.     gettimeofday(&tv_now,NULL);
  552.     printf("\n");
  553.     // To modify
  554.     std::cout<<"Total time = "<< (float)((tv_now.tv_sec+tv_now.tv_usec/1e6) - (tv_start.tv_sec+tv_start.tv_usec/1e6))+(tv_now.tv_usec-tv_start.tv_usec)/1e6<<"s"<<endl;
  555.     std::cout<<"Data size = "<<ul_num_bytes_written/1e6<<"MB"<<std::endl;
  556.     std::cout<<"Average speed = "<< (ul_num_bytes_written/((float)(tv_now.tv_sec - tv_start.tv_sec+(tv_now.tv_usec-tv_start.tv_usec)/1e6)))/1e6<<"MB/s"<<endl;
  557.     gettimeofday(&tv_max,NULL);
  558.  
  559.     if ((version == 2)&&(agc_on == 1))
  560.     {
  561.         fx2_d.read_AGC(shp_agc_data,  &b_RFI, &i_RFI_det, &ui_agc_count);
  562.         fx2_d.usrp_xfer ( VRQ_AGC, 2);
  563.         if (ui_agc_count > 0)
  564.         {
  565.             ui_agc_buf_pos= ui_agc_buf_pos+ui_agc_count;
  566.             fs_agc.save_data(shp_agc_data,ui_agc_count);
  567.         }
  568.         fx2_d.usrp_xfer ( VRQ_AGC, 0);
  569.     }
  570.  
  571.     delete []shp_agc_data;
  572.     delete []ch_if_data;
  573.  
  574.     if(agc_on == 1)
  575.     {
  576.         printf("%d bytes of AGC data stored in ",ui_agc_buf_pos);
  577.         printf(cp_agc_filename);
  578.         printf("\n");
  579.         fs_agc.close_file();
  580.     }
  581.     fs.close_file();
  582.     if (agc_on == 0)
  583.     {
  584.         DeleteFile(cp_agc_filename);
  585.     }
  586.     fx2_d.~Fx2_dev();
  587.     fx2_d.close();
  588.     fx2_d.~Fx2_dev();
  589.     printf("success!\n");
  590.  
  591.     return 0;
  592.  }
  593.  
  594.  /* Help screen for PID 0X0B38 */
  595.  void help_lv(void)
  596. {
  597.     printf ( "\n");
  598.     printf ( "**************************************************************************\n" );
  599.     printf ( "* -o filename  : output file name                                        *\n" );
  600.     printf ( "* -s filesize  : Number of sec to collect                                *\n" );
  601.     printf ( "* -h           : help screen                                             *\n" );
  602.     printf ( "**************************************************************************\n" );
  603.     printf ( "\n" );
  604. }
  605.  
  606. /* Help screen for PID 0x0b3a and 0x0b3f */
  607. void help_hv(char version)
  608. {
  609.      printf ("\n");
  610.      printf ( "****************************************************************************\n" );
  611.      printf ( "*   Mode#   *    BW   *    Sample rate    *     Format      *      IF      *\n");
  612.      printf ( "*     1     *  narrow *     16.368MHz     *    2-bit real   *   4.092MHz   *\n");
  613.      printf ( "*     2     *  narrow *      8.184MHz     *    4-bit I/Q    *       0MHz   *\n");
  614.      printf ( "*     3     *  narrow *      5.456MHz     *    2-bit real   *   1.364MHz   *\n");
  615.      printf ( "*     4     *  narrow *      4.092MHz     *    4-bit I/Q    *       0MHz   *\n");
  616.      printf ( "*     5     *   wide  *     16.368MHz     *    2-bit real   *   4.092MHz   *\n");
  617.      printf ( "*     6     *   wide  *      8.184MHz     *    4-bit I/Q    *       0MHz   *\n");
  618.      printf ( "*     7     *   wide  *      5.456MHz     *    2-bit real   *   1.364MHz   *\n");
  619.      printf ( "*     8     *   wide  *      4.092MHz     *    4-bit I/Q    *       0MHz   *\n");
  620.      printf ( "****************************************************************************\n");
  621.      printf ( "* -o filename  : output file name               default: test.bin          *\n");
  622.      printf ( "* -s filesize  : Number of sec to collect       default: 2 sec             *\n");
  623.      printf ( "* -c mode      : collection mode                default: 1                 *\n");
  624.      if(version == 2)
  625.      {
  626.          printf ( "* -p [1,2,4]   : pack 1,2,4 samples per byte    default: 1                 *\n");
  627.          printf ( "* -d n         : save only every [n] byte       default: 1                 *\n");
  628.          printf ( "* -a agc       : agc on - 1; agc off - 0        default: 0                 *\n");
  629.      }
  630.      printf ( "* -h           : help screen                                               *\n");
  631.      printf ( "****************************************************************************\n" );
  632.      printf ( "\n" );
  633. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement