view rvinterf/lowlevel/clientcmd.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 e7502631a0f9
children
line wrap: on
line source

/*
 * This rvinterf module implements the handling of client commands.
 */

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include "../include/pktmux.h"
#include "../include/limits.h"
#include "../include/localsock.h"
#include "client.h"

void
process_msg_from_client(cli)
	struct client *cli;
{
	int c;

	switch (cli->rx_buf[0]) {
	case CLI2RVI_WANT_RVTRACE:
		if (cli->rx_msglen != 9) {
			send_local_msg_to_client(cli, "-Bad command length");
			return;
		}
		c = cli->int_rvt_count;
		if (c >= MAX_RVT_INTEREST) {
			send_local_msg_to_client(cli,
					"-Error: too many RVT interests");
			return;
		}
		cli->int_rvt_mask[c] = cli->rx_buf[1] << 24 |
					cli->rx_buf[2] << 16 |
					cli->rx_buf[3] << 8 | cli->rx_buf[4];
		cli->int_rvt_match[c] = cli->rx_buf[5] << 24 |
					cli->rx_buf[6] << 16 |
					cli->rx_buf[7] << 8 | cli->rx_buf[8];
		cli->int_rvt_count++;
		send_local_msg_to_client(cli, "+OK");
		return;
	case CLI2RVI_WANT_MUXPROTO:
		if (cli->rx_msglen != 2) {
			send_local_msg_to_client(cli, "-Bad command length");
			return;
		}
		if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x1D) {
			send_local_msg_to_client(cli,
					"-Unsupported protocol MUX value");
			return;
		}
		cli->int_proto[cli->rx_buf[1] - 0x12] = 1;
		send_local_msg_to_client(cli, "+OK");
		return;
	case CLI2RVI_DROP_MUXPROTO:
		if (cli->rx_msglen != 2) {
			send_local_msg_to_client(cli, "-Bad command length");
			return;
		}
		if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x1D) {
			send_local_msg_to_client(cli,
					"-Unsupported protocol MUX value");
			return;
		}
		cli->int_proto[cli->rx_buf[1] - 0x12] = 0;
		send_local_msg_to_client(cli, "+OK");
		return;
	case CLI2RVI_RESET_PACKET_RX:
		cli->int_rvt_count = 0;
		bzero(cli->int_proto, sizeof(cli->int_proto));
		send_local_msg_to_client(cli, "+OK");
		return;
	case CLI2RVI_PKT_TO_TARGET:
		c = cli->rx_msglen - 1;
		if (c < 1 || c > MAX_PKT_TO_TARGET) {
			send_local_msg_to_client(cli,
						 "-Invalid Tx packet length");
			return;
		}
		send_pkt_to_target(cli->rx_buf + 1, c);
		log_sent_packet(cli->rx_buf + 1, c);
		return;
	case CLI2RVI_RAWBYTES_TO_TARGET:
		/* To be implemented */
	default:
		send_local_msg_to_client(cli, "-Unimplemented command");
	}
}