view rfcal/cmu200/init.c @ 231:a58a7bbc0618

CHANGES: first changes since fc-host-tools-r5
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 03 Aug 2017 03:21:39 +0000
parents 31d43f0e469a
children
line wrap: on
line source

/*
 * 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");
}