changeset 40:2fb9768fc1e2

fc-cmu200d: VCXO calibration mode generalized into RF analyzer mode
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 27 May 2017 02:38:28 +0000
parents 34c6fbe38daa
children 3f4221ef916a
files cmu200/Makefile cmu200/dispatch.c cmu200/mode.h cmu200/rfanalyzer.c cmu200/vcxocal.c
diffstat 5 files changed, 83 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/cmu200/Makefile	Sat May 27 02:17:00 2017 +0000
+++ b/cmu200/Makefile	Sat May 27 02:38:28 2017 +0000
@@ -3,8 +3,8 @@
 PROGS=	fc-cmu200d fc-serscpi
 INSTBIN=/opt/freecalypso/bin
 
-CMU200D_OBJS=	band.o dispatch.o init.o main.o mode.o openport.o sercmd.o \
-		session.o signalgen.o socket.o vcxocal.o
+CMU200D_OBJS=	band.o dispatch.o init.o main.o mode.o openport.o rfanalyzer.o \
+		sercmd.o session.o signalgen.o socket.o
 
 SERSCPI_OBJS=	openport.o sertool.o
 
--- a/cmu200/dispatch.c	Sat May 27 02:17:00 2017 +0000
+++ b/cmu200/dispatch.c	Sat May 27 02:38:28 2017 +0000
@@ -11,10 +11,10 @@
 extern int client_cmd_nfields;
 
 extern int cmd_freq_meas();
+extern int cmd_rfan_setup();
 extern int cmd_signal_gen_off();
 extern int cmd_signal_gen_sine();
 extern int cmd_signal_gen_setup();
-extern int cmd_vcxo_cal_setup();
 
 cmd_ping()
 {
@@ -28,10 +28,12 @@
 } cmdtab[] = {
 	{"freq-meas", cmd_freq_meas},
 	{"ping", cmd_ping},
+	{"rfan-setup", cmd_rfan_setup},
 	{"signal-gen-off", cmd_signal_gen_off},
 	{"signal-gen-sine", cmd_signal_gen_sine},
 	{"signal-gen-setup", cmd_signal_gen_setup},
-	{"vcxo-cal-setup", cmd_vcxo_cal_setup},
+	{"txpwr-cal-setup", cmd_rfan_setup},
+	{"vcxo-cal-setup", cmd_rfan_setup},
 	{0, 0}
 };
 
--- a/cmu200/mode.h	Sat May 27 02:17:00 2017 +0000
+++ b/cmu200/mode.h	Sat May 27 02:38:28 2017 +0000
@@ -2,4 +2,4 @@
 
 #define	OP_MODE_UNDEF		0
 #define	OP_MODE_SIGNAL_GEN	1
-#define	OP_MODE_VCXO_CAL	2
+#define	OP_MODE_GSM_RFAN	2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmu200/rfanalyzer.c	Sat May 27 02:38:28 2017 +0000
@@ -0,0 +1,76 @@
+/*
+ * This module implements the RF analyzer functionality
+ * for VCXO and Tx power level calibration support.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include "mode.h"
+#include "band.h"
+
+extern int cmu200_rf_port;
+
+extern char *client_cmd_fields[];
+extern int client_cmd_nfields;
+
+extern int current_mode;
+extern struct band *current_band;
+
+extern char instrument_response[];
+
+cmd_rfan_setup()
+{
+	int rc;
+	unsigned arfcn;
+	char cmdstr[32];
+
+	if (client_cmd_nfields != 3) {
+		send_socket_response("-Wrong number of arguments\n");
+		return(0);
+	}
+	stop_signal_gen();
+	current_mode = OP_MODE_UNDEF;
+	rc = find_named_band(client_cmd_fields[1]);
+	if (rc < 0) {
+		send_socket_response("-Invalid band argument\n");
+		return(0);
+	}
+	arfcn = atoi(client_cmd_fields[2]);
+	if (verify_arfcn(arfcn, 0, 0) < 0) {
+		send_socket_response("-Invalid ARFCN\n");
+		return(0);
+	}
+	sprintf(cmdstr, "*SEC %d\n", current_band->secaddr);
+	send_scpi_cmd(cmdstr);
+	sprintf(cmdstr, "INP RF%d\n", cmu200_rf_port);
+	send_scpi_cmd(cmdstr);
+	sprintf(cmdstr, "RFAN:CHAN %uCH\n", arfcn);
+	send_scpi_cmd(cmdstr);
+	send_scpi_cmd("RFAN:TSEQ GSM5\n");
+	current_mode = OP_MODE_GSM_RFAN;
+	send_socket_response("+OK\n");
+	return(0);
+}
+
+cmd_freq_meas()
+{
+	char *resp_fields[11];
+	char client_resp[128];
+
+	if (current_mode != OP_MODE_GSM_RFAN) {
+		send_socket_response("-Wrong mode\n");
+		return(0);
+	}
+	send_scpi_cmd("READ:MOD?\n");
+	collect_instr_response();
+	if (parse_commasep_response(resp_fields, 11) < 0) {
+		send_socket_response
+			("-CMU200 response has wrong number of fields\n");
+		return(0);
+	}
+	sprintf(client_resp, "+ %s\n", resp_fields[7]);
+	send_socket_response(client_resp);
+	return(0);
+}
--- a/cmu200/vcxocal.c	Sat May 27 02:17:00 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * This module implements the VCXO calibration support functionality.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include "mode.h"
-#include "band.h"
-
-extern int cmu200_rf_port;
-
-extern char *client_cmd_fields[];
-extern int client_cmd_nfields;
-
-extern int current_mode;
-extern struct band *current_band;
-
-extern char instrument_response[];
-
-cmd_vcxo_cal_setup()
-{
-	int rc;
-	unsigned arfcn;
-	char cmdstr[32];
-
-	if (client_cmd_nfields != 3) {
-		send_socket_response("-Wrong number of arguments\n");
-		return(0);
-	}
-	stop_signal_gen();
-	current_mode = OP_MODE_UNDEF;
-	rc = find_named_band(client_cmd_fields[1]);
-	if (rc < 0) {
-		send_socket_response("-Invalid band argument\n");
-		return(0);
-	}
-	arfcn = atoi(client_cmd_fields[2]);
-	if (verify_arfcn(arfcn, 0, 0) < 0) {
-		send_socket_response("-Invalid ARFCN\n");
-		return(0);
-	}
-	sprintf(cmdstr, "*SEC %d\n", current_band->secaddr);
-	send_scpi_cmd(cmdstr);
-	sprintf(cmdstr, "INP RF%d\n", cmu200_rf_port);
-	send_scpi_cmd(cmdstr);
-	sprintf(cmdstr, "RFAN:CHAN %uCH\n", arfcn);
-	send_scpi_cmd(cmdstr);
-	send_scpi_cmd("RFAN:TSEQ GSM5\n");
-	current_mode = OP_MODE_VCXO_CAL;
-	send_socket_response("+OK\n");
-	return(0);
-}
-
-cmd_freq_meas()
-{
-	char *resp_fields[11];
-	char client_resp[128];
-
-	if (current_mode != OP_MODE_VCXO_CAL) {
-		send_socket_response("-Wrong mode\n");
-		return(0);
-	}
-	send_scpi_cmd("READ:MOD?\n");
-	collect_instr_response();
-	if (parse_commasep_response(resp_fields, 11) < 0) {
-		send_socket_response
-			("-CMU200 response has wrong number of fields\n");
-		return(0);
-	}
-	sprintf(client_resp, "+ %s\n", resp_fields[7]);
-	send_socket_response(client_resp);
-	return(0);
-}