changeset 56:df827df6db82

fc-rfcal-txbasis written, ready to test
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 27 May 2017 20:02:10 +0000
parents b313884c79fd
children 2588f9eed11a
files .hgignore autocal/Makefile autocal/txbasis.c
diffstat 3 files changed, 125 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat May 27 19:44:08 2017 +0000
+++ b/.hgignore	Sat May 27 20:02:10 2017 +0000
@@ -3,6 +3,7 @@
 \.[oa]$
 
 ^autocal/fc-rfcal-gmagic$
+^autocal/fc-rfcal-txbasis$
 ^autocal/fc-rfcal-txcheck$
 ^autocal/fc-rfcal-vcxo$
 
--- a/autocal/Makefile	Sat May 27 19:44:08 2017 +0000
+++ b/autocal/Makefile	Sat May 27 20:02:10 2017 +0000
@@ -1,11 +1,13 @@
 CC=	gcc
 CFLAGS=	-O2 -I/opt/freecalypso/include
-PROGS=	fc-rfcal-gmagic fc-rfcal-txcheck fc-rfcal-vcxo
+PROGS=	fc-rfcal-gmagic fc-rfcal-txbasis fc-rfcal-txcheck fc-rfcal-vcxo
 INSTBIN=/opt/freecalypso/bin
 
 GMAGIC_OBJS=	gmagicmain.o l1meas.o l1tmops.o rvinterf.o rxcommon.o \
 		sockopts.o tsidsock.o
 
+TXBASIS_OBJS=	l1tmops.o rvinterf.o tsidsock.o txbasis.o txpwrmeas.o
+
 TXCHECK_OBJS=	l1tmops.o rvinterf.o sockopts.o tsidsock.o txchkmain.o \
 		txpwrmeas.o
 
@@ -16,6 +18,9 @@
 fc-rfcal-gmagic:	${GMAGIC_OBJS}
 	${CC} -o $@ ${GMAGIC_OBJS}
 
+fc-rfcal-txbasis:	${TXBASIS_OBJS}
+	${CC} -o $@ ${TXBASIS_OBJS}
+
 fc-rfcal-txcheck:	${TXCHECK_OBJS}
 	${CC} -o $@ ${TXCHECK_OBJS}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autocal/txbasis.c	Sat May 27 20:02:10 2017 +0000
@@ -0,0 +1,118 @@
+/*
+ * This module contains the main() function for fc-rfcal-txbasis.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+#include <rvinterf/l1tm.h>
+#include <rvinterf/exitcodes.h>
+#include "stdband.h"
+
+extern char *rvif_socket_pathname, *tsid_socket_pathname;
+
+extern double tx_power_meas();
+
+static struct band {
+	char		*name;
+	unsigned	rfpw_std_band;
+	unsigned	default_arfcn;
+} bands[] = {
+	{"850",  RFPW_STD_BAND_850,  190},
+	{"900",  RFPW_STD_BAND_900,   40},
+	{"1800", RFPW_STD_BAND_1800, 700},
+	{"1900", RFPW_STD_BAND_1900, 660},
+	{0,	 0,		     0}
+};
+static struct band *selected_band;
+static unsigned arfcn, arfcn_set;
+
+cmdline_options(argc, argv)
+	char **argv;
+{
+	extern char *optarg;
+	int c;
+
+	while ((c = getopt(argc, argv, "a:s:t:")) != EOF) {
+		switch (c) {
+		case 'a':
+			arfcn = atoi(optarg);
+			arfcn_set = 1;
+			continue;
+		case 's':
+			rvif_socket_pathname = optarg;
+			continue;
+		case 't':
+			tsid_socket_pathname = optarg;
+			continue;
+		case '?':
+		default:
+			/* error msg already printed */
+			exit(ERROR_USAGE);
+		}
+	}
+	return(0);
+}
+
+select_band(bandname)
+	char *bandname;
+{
+	struct band *band;
+
+	for (band = bands; band->name; band++)
+		if (!strcmp(band->name, bandname))
+			break;
+	if (!band->name) {
+		fprintf(stderr, "error: \"%s\" is not a known band\n",
+			bandname);
+		exit(ERROR_USAGE);
+	}
+	selected_band = band;
+	if (!arfcn_set)
+		arfcn = band->default_arfcn;
+	return(0);
+}
+
+main(argc, argv)
+	char **argv;
+{
+	extern int optind;
+	int apc;
+	double meas;
+
+	cmdline_options(argc, argv);
+	if (argc - optind < 2) {
+		fprintf(stderr, "usage: %s band apc...\n", argv[0]);
+		exit(ERROR_USAGE);
+	}
+	select_band(argv[optind++]);
+
+	connect_rvinterf_socket();
+	connect_tsid_socket();
+	setlinebuf(stdout);	/* to allow logging with tee */
+	printf("Preparing RF test system for %s MHz Tx calibration\n",
+		selected_band->name);
+	do_txpwr_cal_setup(selected_band->name, arfcn);
+
+	printf("Putting the DUT into Test Mode\n");
+	do_tms(1);
+	do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band);
+	do_rfpw(TCH_ARFCN, arfcn);
+	do_rfpw(AFC_ENA_FLAG, 0);
+	printf("Starting RF Tx on the DUT\n");
+	do_rfe(RX_TX_TCH);
+
+	for (; 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);
+	}
+
+	printf("Stopping RF Tx on the DUT\n");
+	do_rfe(STOP_ALL);
+	exit(0);
+}