diff 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
line wrap: on
line diff
--- a/autocal/txstandbas.c	Tue Feb 13 07:02:17 2018 +0000
+++ b/autocal/txstandbas.c	Tue Feb 13 07:17:31 2018 +0000
@@ -12,10 +12,12 @@
 #include <rvinterf/l1tm.h>
 #include <rvinterf/exitcodes.h>
 #include "stdband.h"
+#include "txvout.h"
 
 extern char *rvif_socket_pathname, *tsid_socket_pathname;
 
 extern double tx_power_meas();
+extern vout_t dbm_to_vout();
 
 static struct band {
 	char		*name;
@@ -30,6 +32,7 @@
 };
 static struct band *selected_band;
 static unsigned arfcn, arfcn_set;
+static int do_slope;
 
 cmdline_options(argc, argv)
 	char **argv;
@@ -37,12 +40,15 @@
 	extern char *optarg;
 	int c;
 
-	while ((c = getopt(argc, argv, "a:s:t:")) != EOF) {
+	while ((c = getopt(argc, argv, "a:ls:t:")) != EOF) {
 		switch (c) {
 		case 'a':
 			arfcn = atoi(optarg);
 			arfcn_set = 1;
 			continue;
+		case 'l':
+			do_slope = 1;
+			continue;
 		case 's':
 			rvif_socket_pathname = optarg;
 			continue;
@@ -81,8 +87,10 @@
 	char **argv;
 {
 	extern int optind;
-	int apc;
+	int apc, apc_prev;
 	double meas;
+	vout_t vout, vout_prev;
+	int nanflag = 0, first;
 
 	cmdline_options(argc, argv);
 	if (argc - optind < 2) {
@@ -106,12 +114,23 @@
 	printf("Starting RF Tx on the DUT\n");
 	do_rfe(RX_TX_TCH);
 
-	for (; optind < argc; optind++) {
+	for (first = 1; optind < argc; optind++) {
 		apc = atoi(argv[optind]);
 		do_txpw(TX_APC_DAC, apc);
 		usleep(20000);
 		meas = tx_power_meas();
 		printf("APC DAC=%d: %.2f dBm\n", apc, meas);
+		if (isnan(meas))
+			nanflag = 1;
+		if (do_slope && !nanflag) {
+			vout = dbm_to_vout(meas);
+			if (!first)
+				printf("slope=%f\n",
+					(vout - vout_prev) / (apc - apc_prev));
+			apc_prev = apc;
+			vout_prev = vout;
+		}
+		first = 0;
 	}
 
 	printf("Stopping RF Tx on the DUT\n");