FreeCalypso > hg > fc-rfcal-tools
comparison autocal/txstandbas.c @ 118:6a7f8d201859
fc-rfcal-txbasis: added -l option to show slope (check linearity)
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 13 Feb 2018 07:17:31 +0000 |
| parents | c9bd1f75029f |
| children |
comparison
equal
deleted
inserted
replaced
| 117:4c3f4231a021 | 118:6a7f8d201859 |
|---|---|
| 10 #include <strings.h> | 10 #include <strings.h> |
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 #include <rvinterf/l1tm.h> | 12 #include <rvinterf/l1tm.h> |
| 13 #include <rvinterf/exitcodes.h> | 13 #include <rvinterf/exitcodes.h> |
| 14 #include "stdband.h" | 14 #include "stdband.h" |
| 15 #include "txvout.h" | |
| 15 | 16 |
| 16 extern char *rvif_socket_pathname, *tsid_socket_pathname; | 17 extern char *rvif_socket_pathname, *tsid_socket_pathname; |
| 17 | 18 |
| 18 extern double tx_power_meas(); | 19 extern double tx_power_meas(); |
| 20 extern vout_t dbm_to_vout(); | |
| 19 | 21 |
| 20 static struct band { | 22 static struct band { |
| 21 char *name; | 23 char *name; |
| 22 unsigned rfpw_std_band; | 24 unsigned rfpw_std_band; |
| 23 unsigned default_arfcn; | 25 unsigned default_arfcn; |
| 28 {"1900", RFPW_STD_BAND_1900, 660}, | 30 {"1900", RFPW_STD_BAND_1900, 660}, |
| 29 {0, 0, 0} | 31 {0, 0, 0} |
| 30 }; | 32 }; |
| 31 static struct band *selected_band; | 33 static struct band *selected_band; |
| 32 static unsigned arfcn, arfcn_set; | 34 static unsigned arfcn, arfcn_set; |
| 35 static int do_slope; | |
| 33 | 36 |
| 34 cmdline_options(argc, argv) | 37 cmdline_options(argc, argv) |
| 35 char **argv; | 38 char **argv; |
| 36 { | 39 { |
| 37 extern char *optarg; | 40 extern char *optarg; |
| 38 int c; | 41 int c; |
| 39 | 42 |
| 40 while ((c = getopt(argc, argv, "a:s:t:")) != EOF) { | 43 while ((c = getopt(argc, argv, "a:ls:t:")) != EOF) { |
| 41 switch (c) { | 44 switch (c) { |
| 42 case 'a': | 45 case 'a': |
| 43 arfcn = atoi(optarg); | 46 arfcn = atoi(optarg); |
| 44 arfcn_set = 1; | 47 arfcn_set = 1; |
| 48 continue; | |
| 49 case 'l': | |
| 50 do_slope = 1; | |
| 45 continue; | 51 continue; |
| 46 case 's': | 52 case 's': |
| 47 rvif_socket_pathname = optarg; | 53 rvif_socket_pathname = optarg; |
| 48 continue; | 54 continue; |
| 49 case 't': | 55 case 't': |
| 79 | 85 |
| 80 main(argc, argv) | 86 main(argc, argv) |
| 81 char **argv; | 87 char **argv; |
| 82 { | 88 { |
| 83 extern int optind; | 89 extern int optind; |
| 84 int apc; | 90 int apc, apc_prev; |
| 85 double meas; | 91 double meas; |
| 92 vout_t vout, vout_prev; | |
| 93 int nanflag = 0, first; | |
| 86 | 94 |
| 87 cmdline_options(argc, argv); | 95 cmdline_options(argc, argv); |
| 88 if (argc - optind < 2) { | 96 if (argc - optind < 2) { |
| 89 fprintf(stderr, "usage: %s band apc...\n", argv[0]); | 97 fprintf(stderr, "usage: %s band apc...\n", argv[0]); |
| 90 exit(ERROR_USAGE); | 98 exit(ERROR_USAGE); |
| 104 do_rfpw(TCH_ARFCN, arfcn); | 112 do_rfpw(TCH_ARFCN, arfcn); |
| 105 do_rfpw(AFC_ENA_FLAG, 0); | 113 do_rfpw(AFC_ENA_FLAG, 0); |
| 106 printf("Starting RF Tx on the DUT\n"); | 114 printf("Starting RF Tx on the DUT\n"); |
| 107 do_rfe(RX_TX_TCH); | 115 do_rfe(RX_TX_TCH); |
| 108 | 116 |
| 109 for (; optind < argc; optind++) { | 117 for (first = 1; optind < argc; optind++) { |
| 110 apc = atoi(argv[optind]); | 118 apc = atoi(argv[optind]); |
| 111 do_txpw(TX_APC_DAC, apc); | 119 do_txpw(TX_APC_DAC, apc); |
| 112 usleep(20000); | 120 usleep(20000); |
| 113 meas = tx_power_meas(); | 121 meas = tx_power_meas(); |
| 114 printf("APC DAC=%d: %.2f dBm\n", apc, meas); | 122 printf("APC DAC=%d: %.2f dBm\n", apc, meas); |
| 123 if (isnan(meas)) | |
| 124 nanflag = 1; | |
| 125 if (do_slope && !nanflag) { | |
| 126 vout = dbm_to_vout(meas); | |
| 127 if (!first) | |
| 128 printf("slope=%f\n", | |
| 129 (vout - vout_prev) / (apc - apc_prev)); | |
| 130 apc_prev = apc; | |
| 131 vout_prev = vout; | |
| 132 } | |
| 133 first = 0; | |
| 115 } | 134 } |
| 116 | 135 |
| 117 printf("Stopping RF Tx on the DUT\n"); | 136 printf("Stopping RF Tx on the DUT\n"); |
| 118 do_rfe(STOP_ALL); | 137 do_rfe(STOP_ALL); |
| 119 exit(0); | 138 exit(0); |
