view target-utils/libcommon/abbcmd.c @ 407:19e5a3e2f9c0

fcup-settime: moved time() retrieval a little closer to the output A fundamental problem with all simple time transfer tools is that there is always some delay between the time retrieval on the source system and that transmitted time being set on the destination, and the resulting time on the destination system is off by that delay amount. This delay cannot be fully eliminated when working in a simple environment like ours, but we should make our best effort to minimize it. In the present case, moving the atinterf_init() call before the time() retrieval should make a teensy-tiny improvement.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Aug 2018 21:52:17 +0000
parents 4be951811791
children 44a1de4264d8
line wrap: on
line source

/*
 * abbr pg reg		-- read ABB register
 * abbw pg reg val	-- write ABB register
 */

#include <sys/types.h>
#include "types.h"
#include "abbdefs.h"

extern u_long strtoul();

extern u16 abb_reg_read();
extern void abb_reg_write();

void
cmd_abbr(argbulk)
	char *argbulk;
{
	char *argv[3];
	u32 pg, reg, val;

	if (parse_args(argbulk, 2, 2, argv, 0) < 0)
		return;
	pg = strtoul(argv[0], 0, 0);
	reg = strtoul(argv[1], 0, 0);
	if (pg > 1 || reg > 31) {
		printf("ERROR: argument(s) out of range\n");
		return;
	}
	abb_init();
	val = abb_reg_read(PAGE(pg) | reg);
	printf("%03X\n", val);
}

void
cmd_abbw(argbulk)
	char *argbulk;
{
	char *argv[4];
	u32 pg, reg, val;

	if (parse_args(argbulk, 3, 3, argv, 0) < 0)
		return;
	pg = strtoul(argv[0], 0, 0);
	reg = strtoul(argv[1], 0, 0);
	val = strtoul(argv[2], 0, 16);
	if (pg > 1 || reg > 31 || val > 0x3FF) {
		printf("ERROR: argument(s) out of range\n");
		return;
	}
	abb_init();
	abb_reg_write(PAGE(pg) | reg, val);
}