view autocal/txpwrmeas.c @ 133:c99b1dce04ec default tip

fc-rfcal-txcheck: check and report ramp tolerance
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 20 Dec 2021 04:22:19 +0000
parents 94e8a410d6bd
children
line wrap: on
line source

/*
 * This module contains the Tx power measurement function.
 */

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <rvinterf/exitcodes.h>

extern char tsid_response[];

do_txpwr_cal_setup(band, arfcn)
	char *band;
	unsigned arfcn;
{
	char cmd[80];

	sprintf(cmd, "txpwr-cal-setup %s %u\n", band, arfcn);
	tsid_command(cmd);
	return(0);
}

pass_pcl_to_tester(pcl)
	unsigned pcl;
{
	char cmd[80];

	sprintf(cmd, "txpwr-cal-pcl %u\n", pcl);
	tsid_command(cmd);
	return(0);
}

double
tx_power_meas()
{
	double meas;

	tsid_command("power-meas\n");
	meas = atof(tsid_response + 1);
	return(meas);
}

double
tx_power_meas_ramp(rstat)
	char **rstat;
{
	double meas;
	char *cp;

	tsid_command("power-meas ramp\n");
	for (cp = tsid_response + 1; isspace(*cp); cp++)
		;
	if (!*cp) {
inv:		fprintf(stderr,
			"error: bad TSID response to power-meas ramp\n");
		exit(ERROR_RFTEST);
	}
	meas = atof(cp);
	while (*cp && !isspace(*cp))
		cp++;
	if (!*cp)
		goto inv;
	while (isspace(*cp))
		cp++;
	if (!*cp)
		goto inv;
	*rstat = cp;
	return(meas);
}