view rvinterf/etmsync/fsuploadrf.c @ 497:74610c4f10f7

target-utils: added 10 ms delay at the end of abb_power_off() The deosmification of the ABB access code (replacement of osmo_delay_ms() bogus delays with correctly-timed ones, which are significantly shorter) had one annoying side effect: when executing the poweroff command from any of the programs, one last '=' prompt character was being sent (and received by the x86 host) as the Calypso board powers off. With delays being shorter now, the abb_power_off() function was returning and the standalone program's main loop was printing its prompt before the Iota chip fully executed the switch-off sequence! I thought about inserting an endless tight loop at the end of the abb_power_off() function, but the implemented solution of a 10 ms delay is a little nicer IMO because if the DEVOFF operation doesn't happen for some reason in a manual hacking scenario, there won't be an artificial blocker in the form of a tight loop keeping us from further poking around.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 25 May 2019 20:44:05 +0000
parents 67d57375e3ad
children 7f30f92a6e35
line wrap: on
line source

/*
 * upload-rf-table implementation
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "etm.h"
#include "ffs.h"
#include "tmffs2.h"
#include "limits.h"
#include "exitcodes.h"

static struct map {
	char	*format;
	char	*pathname;
	int	need_band;
} map_table[] = {
	{"afcparams",         "/gsm/rf/afcparams",       0},
	{"agc-global-params", "/gsm/rf/rx/agcglobals",   0},
	{"agc-table",         "/gsm/rf/rx/agcwords",     0},
	{"tx-ramps",          "/gsm/rf/tx/ramps.%s",     1},
	{"tx-levels",         "/gsm/rf/tx/levels.%s",    1},
	{"tx-calchan",        "/gsm/rf/tx/calchan.%s",   1},
	{"tx-caltemp",        "/gsm/rf/tx/caltemp.%s",   1},
	{"rx-calchan",        "/gsm/rf/rx/calchan.%s",   1},
	{"rx-caltemp",        "/gsm/rf/rx/caltemp.%s",   1},
	{"rx-agc-params",     "/gsm/rf/rx/agcparams.%s", 1},
	{0,                   0,                         0}
};

cmd_upload_rf_table(argc, argv)
	char **argv;
{
	u_char buf[512];
	char *format, pathname[32];
	struct map *map;
	unsigned size;
	int rc;

	rc = read_rf_table_ext(argv[1], buf, 1, &format, &size);
	if (rc)
		return(rc);
	for (map = map_table; map->format; map++)
		if (!strcmp(map->format, format))
			break;
	if (!map->format) {
		printf("error: %s tables cannot be uploaded\n", format);
		return(ERROR_USAGE);
	}
	if (map->need_band) {
		if (!argv[2]) {
			printf("error: band not specified for %s table\n",
				format);
			return(ERROR_USAGE);
		}
		if (strlen(argv[2]) > 7) {
			printf("error: band name argument is too long\n");
			return(ERROR_USAGE);
		}
		sprintf(pathname, map->pathname, argv[2]);
	} else {
		if (argv[2]) {
			printf("error: band not applicable for %s table\n",
				format);
			return(ERROR_USAGE);
		}
		strcpy(pathname, map->pathname);
	}
	return write_buf_to_file(pathname, buf, size);
}