view rvinterf/lowlevel/format_fc.c @ 416:30f6d1c32c6f

doc/Flash-boot-defect article removed (no longer relevant) This article is no longer relevant because the issue in question only affected one (1) defective FCDEV3B board which was not and never will be sold.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 26 Oct 2018 07:11:08 +0000
parents e7502631a0f9
children 4e243402f453
line wrap: on
line source

/*
 * This module has been split off from format.c; it implements the decoding
 * of those Rx packet types which have been invented in FreeCalypso.
 */

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include "../include/pktmux.h"
#include "../include/limits.h"

extern u_char rxpkt[];
extern size_t rxpkt_len;

static char fmtbuf[MAX_PKT_FROM_TARGET*8];	/* size it generously */

void
print_ati_output()
{
	int i, c;
	char *dp;

	dp = fmtbuf;
	strcpy(dp, "ATI: ");
	dp += 5;
	for (i = 1; i < rxpkt_len; i++) {
		c = rxpkt[i];
		if (c & 0x80) {
			*dp++ = 'M';
			*dp++ = '-';
			c &= 0x7F;
		}
		if (c < 0x20) {
			*dp++ = '^';
			*dp++ = c + '@';
		} else if (c == 0x7F) {
			*dp++ = '^';
			*dp++ = '?';
		} else
			*dp++ = c;
	}
	*dp = '\0';
	output_line(fmtbuf);
}

void
print_fc_lld_msg()
{
	int i, c;
	char *dp;

	dp = fmtbuf;
	strcpy(dp, "LLD: ");
	dp += 5;
	for (i = 1; i < rxpkt_len; i++) {
		c = rxpkt[i];
		if (c & 0x80) {
			*dp++ = 'M';
			*dp++ = '-';
			c &= 0x7F;
		}
		if (c < 0x20) {
			*dp++ = '^';
			*dp++ = c + '@';
		} else if (c == 0x7F) {
			*dp++ = '^';
			*dp++ = '?';
		} else
			*dp++ = c;
	}
	*dp = '\0';
	output_line(fmtbuf);
}

void
print_tch_output_raw()
{
	int i;
	char *dp;

	dp = fmtbuf;
	strcpy(dp, "TCH:");
	dp += 4;
	for (i = 1; i < rxpkt_len; i++) {
		sprintf(dp, " %02X", rxpkt[i]);
		dp += 3;
	}
	*dp = '\0';
	output_line(fmtbuf);
}

void
report_extui_packet()
{
	sprintf(fmtbuf, "LCD OUT: row %u col %u-%u", rxpkt[1], rxpkt[2],
		rxpkt[2] + (rxpkt_len - 3) / 2 - 1);
	output_line(fmtbuf);
}