view cmu200/dispatch.c @ 87:34a1e06a8587

checking in cableconf and txlevels config files
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 17 Jul 2017 00:03:27 +0000
parents 3f4221ef916a
children fbfbd813c9b4
line wrap: on
line source

/*
 * This module contains the code that dispatches client commands.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

extern char *client_cmd_fields[];
extern int client_cmd_nfields;

extern int cmd_freq_meas();
extern int cmd_power_meas();
extern int cmd_rfan_setup();
extern int cmd_signal_gen_off();
extern int cmd_signal_gen_sine();
extern int cmd_signal_gen_setup();

cmd_ping()
{
	send_socket_response("+Pong\n");
	return(0);
}

static struct cmdtab {
	char	*cmd_kw;
	int	(*handler)();
} cmdtab[] = {
	{"freq-meas", cmd_freq_meas},
	{"ping", cmd_ping},
	{"power-meas", cmd_power_meas},
	{"rfan-setup", cmd_rfan_setup},
	{"signal-gen-off", cmd_signal_gen_off},
	{"signal-gen-sine", cmd_signal_gen_sine},
	{"signal-gen-setup", cmd_signal_gen_setup},
	{"txpwr-cal-setup", cmd_rfan_setup},
	{"vcxo-cal-setup", cmd_rfan_setup},
	{0, 0}
};

dispatch_client_command()
{
	struct cmdtab *tp;

	for (tp = cmdtab; tp->cmd_kw; tp++)
		if (!strcmp(client_cmd_fields[0], tp->cmd_kw))
			break;
	if (tp->handler)
		return tp->handler();
	send_socket_response("-Unknown or unimplemented command\n");
	return(0);
}