view rvinterf/lowlevel/format.c @ 1001:7df4c9ae6ba4

loadtools/scripts: w220.{config,init} => chimei.{config,init} Motorola W220, first touched by FreeCalypso in 2019-05, is an ODM phone made by Chi-Mei, and its peculiar property of relevance to loadtools is that it has XRAM on Calypso nCS3 instead of the usual nCS1 - which matters for fc-xram. We are now discovering other Chi-Mei phones including Sony Ericsson J120, and they share the same quirk of XRAM on nCS3 - hence we rename this loadtools target from w220 to chimei.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Dec 2023 17:53:44 +0000
parents fab04df64690
children
line wrap: on
line source

/*
 * This module implements the decoding of Rx packets
 * into human-readable form.
 */

#include <sys/types.h>
#include <ctype.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;

extern void output_line();
extern void output_cont();
extern void output_cont_logpref();

void
print_rv_trace()
{
	int i;
	char fmtbuf[MAX_PKT_FROM_TARGET*4];
	char *dp = fmtbuf;

	strcpy(dp, "RV ");
	dp += 3;
	/* the SWE static ID is sent MSB first */
	for (i = 1; i <= 4; i++) {
		sprintf(dp, "%02X", rxpkt[i]);
		dp += 2;
	}
	/* severity level */
	sprintf(dp, " %d ", rxpkt[5]);
	dp = index(dp, '\0');
	safe_print_trace(rxpkt + 6, (int)rxpkt_len - 6, dp);
	output_line(fmtbuf);
}

void
print_l1_trace()
{
	int i, c;
	char fmtbuf[MAX_PKT_FROM_TARGET*4+1];
	char *dp = fmtbuf;

	strcpy(dp, "L1: ");
	dp += 4;
	for (i = 1; i < rxpkt_len; i++) {
		if ((i+1 < rxpkt_len) &&
		    (rxpkt[i] == '\r' && rxpkt[i+1] == '\n' ||
		     rxpkt[i] == '\n' && rxpkt[i+1] == '\r')) {
			*dp = '\0';
			output_line(fmtbuf);
			if (i+2 == rxpkt_len)
				return;
			dp = fmtbuf;
			*dp++ = '+';
			*dp++ = ' ';
			i++;
			continue;
		}
		c = rxpkt[i];
		switch (c) {
		case '\\':
			*dp++ = '\\';
			*dp++ = '\\';
			continue;
		case '\r':
			*dp++ = '\\';
			*dp++ = 'r';
			continue;
		case '\n':
			*dp++ = '\\';
			*dp++ = 'n';
			continue;
		}
		if (c >= ' ' && c <= '~')
			*dp++ = c;
		else if (c <= 7 && (i+1 == rxpkt_len || !isdigit(rxpkt[i+1]))) {
			sprintf(dp, "\\%d", c);
			dp += 2;
		} else {
			sprintf(dp, "\\x%02X", c);
			dp += 4;
		}
	}
	/* will get here only if no newline sequence at the end */
	*dp = '\0';
	output_line(fmtbuf);
}

void
print_g23_trace()
{
	format_gpf_packet(rxpkt, (unsigned) rxpkt_len, "", output_line,
			  output_cont_logpref);
}

void
print_tm_output_raw()
{
	int i;
	char fmtbuf[MAX_PKT_FROM_TARGET*3+1];
	char *dp = fmtbuf;

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

void
print_unknown_packet()
{
	output_line("Rx unknown packet format");
	packet_hex_dump(rxpkt, (unsigned) rxpkt_len, output_cont);
}