changeset 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 4c3f4231a021
children 8054c1967c32
files autocal/Makefile autocal/txstandbas.c
diffstat 2 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/autocal/Makefile	Tue Feb 13 07:02:17 2018 +0000
+++ b/autocal/Makefile	Tue Feb 13 07:17:31 2018 +0000
@@ -14,7 +14,8 @@
 		txbasis.o txcalchan.o txcalconf.o txlevels.o txpwrmeas.o \
 		txvout.o
 
-TXBASIS_OBJS=	l1tmops.o rvinterf.o tsidsock.o txpwrmeas.o txstandbas.o
+TXBASIS_OBJS=	l1tmops.o rvinterf.o tsidsock.o txpwrmeas.o txstandbas.o \
+		txvout.o
 
 TXCHECK_OBJS=	l1tmops.o rvinterf.o sockopts.o tsidsock.o txpwrmeas.o \
 		txstandchk.o
@@ -33,7 +34,7 @@
 	${CC} -o $@ ${TXBAND_OBJS} -lm
 
 fc-rfcal-txbasis:	${TXBASIS_OBJS}
-	${CC} -o $@ ${TXBASIS_OBJS}
+	${CC} -o $@ ${TXBASIS_OBJS} -lm
 
 fc-rfcal-txcheck:	${TXCHECK_OBJS}
 	${CC} -o $@ ${TXCHECK_OBJS}
--- 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");