changeset 53:bc2397f62bdb

rf-cal-txcheck started
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 27 May 2017 15:41:54 +0000
parents e93b5e727230
children 21f6dba5c4df
files .hgignore autocal/Makefile autocal/txchkmain.c
diffstat 3 files changed, 88 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat May 27 07:53:36 2017 +0000
+++ b/.hgignore	Sat May 27 15:41:54 2017 +0000
@@ -3,6 +3,7 @@
 \.[oa]$
 
 ^autocal/fc-rfcal-gmagic$
+^autocal/fc-rfcal-txcheck$
 ^autocal/fc-rfcal-vcxo$
 
 ^cmu200/fc-cmu200d$
--- a/autocal/Makefile	Sat May 27 07:53:36 2017 +0000
+++ b/autocal/Makefile	Sat May 27 15:41:54 2017 +0000
@@ -1,11 +1,13 @@
 CC=	gcc
 CFLAGS=	-O2 -I/opt/freecalypso/include
-PROGS=	fc-rfcal-gmagic fc-rfcal-vcxo
+PROGS=	fc-rfcal-gmagic 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
 
+TXCHECK_OBJS=	l1tmops.o rvinterf.o sockopts.o tsidsock.o txchkmain.o
+
 VCXO_OBJS=	l1tmops.o rvinterf.o sockopts.o tsidsock.o vcxomain.o vcxomeas.o
 
 all:	${PROGS}
@@ -13,6 +15,9 @@
 fc-rfcal-gmagic:	${GMAGIC_OBJS}
 	${CC} -o $@ ${GMAGIC_OBJS}
 
+fc-rfcal-txcheck:	${TXCHECK_OBJS}
+	${CC} -o $@ ${TXCHECK_OBJS}
+
 fc-rfcal-vcxo:	${VCXO_OBJS}
 	${CC} -o $@ ${VCXO_OBJS}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autocal/txchkmain.c	Sat May 27 15:41:54 2017 +0000
@@ -0,0 +1,81 @@
+/*
+ * This module contains the main() function for fc-rfcal-txcheck.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <rvinterf/l1tm.h>
+#include <rvinterf/exitcodes.h>
+#include "stdband.h"
+
+static struct band {
+	char		*name;
+	unsigned	rfpw_std_band;
+	unsigned	default_arfcn;
+	unsigned	start_plnum;
+	unsigned	end_plnum;
+} bands[] = {
+	{"850",  RFPW_STD_BAND_850,  190, 5, 19},
+	{"900",  RFPW_STD_BAND_900,   40, 5, 19},
+	{"1800", RFPW_STD_BAND_1800, 700, 0, 15},
+	{"1900", RFPW_STD_BAND_1900, 660, 0, 15},
+	{0,	 0,		     0}
+};
+static struct band *selected_band;
+static unsigned arfcn;
+
+finish_cmdline(argc, argv)
+	char **argv;
+{
+	extern int optind;
+	struct band *band;
+
+	if (argc - optind < 1 || argc - optind > 2) {
+		fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]);
+		exit(ERROR_USAGE);
+	}
+	for (band = bands; band->name; band++)
+		if (!strcmp(band->name, argv[optind]))
+			break;
+	if (!band->name) {
+		fprintf(stderr, "error: \"%s\" is not a known band\n",
+			argv[optind]);
+		exit(ERROR_USAGE);
+	}
+	selected_band = band;
+	if (argv[optind+1])
+		arfcn = atoi(argv[optind+1]);
+	else
+		arfcn = band->default_arfcn;
+	return(0);
+}
+
+prepare_rf_test_system()
+{
+	char cmd[80];
+
+	printf("Preparing RF test system for %s MHz Tx calibration\n",
+		selected_band->name);
+	sprintf(cmd, "txpwr-cal-setup %s %u\n", selected_band->name, arfcn);
+	tsid_command(cmd);
+	return(0);
+}
+
+main(argc, argv)
+	char **argv;
+{
+	socket_pathname_options(argc, argv);
+	finish_cmdline(argc, argv);
+	connect_rvinterf_socket();
+	connect_tsid_socket();
+	setlinebuf(stdout);	/* to allow logging with tee */
+	prepare_rf_test_system();
+
+	printf("Putting the DUT into Test Mode\n");
+	do_tms(1);
+	do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band);
+
+
+}