view cmu200/init.c @ 60:81e8f7e99d89

fc-rfcal-rxband: upload of GMagic to DUT implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 27 May 2017 23:35:06 +0000
parents bd62be88259d
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");
}