diff cmu200/init.c @ 0:bd62be88259d

initial import of rfcal code and docs from freecalypso-tools repository
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 May 2017 18:49:35 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmu200/init.c	Sat May 20 18:49:35 2017 +0000
@@ -0,0 +1,48 @@
+/*
+ * This module contains the code that fc-cmu200d runs at startup,
+ * to put the CMU200 into a known state at the global level.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include "secaddr.h"
+
+extern char instrument_response[];
+
+static char id_string[] = "Rohde&Schwarz,CMU";
+
+static void
+assign_secondary_addr(addr, func)
+	char *func;
+{
+	char cmdbuf[80];
+
+	sprintf(cmdbuf, "SYST:REM:ADDR:SEC %d,\"%s\"\n", addr, func);
+	send_scpi_cmd(cmdbuf);
+}
+
+init_cmu200()
+{
+	/* Test if we are connected to a CMU */
+	send_scpi_cmd("*IDN?\n");
+	collect_instr_response();
+	if (strncasecmp(instrument_response, id_string, strlen(id_string))) {
+		fprintf(stderr, "error: not connected to a CMU200\n");
+		exit(1);
+	}
+	/* init commands */
+	send_scpi_cmd("*SEC 0\n");
+	send_scpi_cmd("*RST;*OPC?\n");
+	collect_staropc_response();
+	send_scpi_cmd("SYST:NONV:DIS\n");
+	assign_secondary_addr(SECADDR_RF_NSIG, "RF_NSig");
+	assign_secondary_addr(SECADDR_GSM900MS_NSIG, "GSM900MS_NSig");
+	assign_secondary_addr(SECADDR_GSM1800MS_NSIG, "GSM1800MS_NSig");
+	assign_secondary_addr(SECADDR_GSM1900MS_NSIG, "GSM1900MS_NSig");
+	assign_secondary_addr(SECADDR_GSM850MS_NSIG, "GSM850MS_NSig");
+	send_scpi_cmd("*OPC?\n");
+	collect_staropc_response();
+	printf("CMU200 init complete\n");
+}