diff rvinterf/trdump.c @ 127:f4f0c8738dcb

rvtdump: satisfactory handling of output from Pirelli's fw
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 31 Oct 2013 23:08:59 +0000
parents 811b138f1bed
children 56b53c289785
line wrap: on
line diff
--- a/rvinterf/trdump.c	Thu Oct 31 19:59:16 2013 +0000
+++ b/rvinterf/trdump.c	Thu Oct 31 23:08:59 2013 +0000
@@ -16,6 +16,10 @@
 {
 	int i, c;
 
+	if (len >= 3 &&
+	    (str[len-2] == '\r' && str[len-1] == '\n' ||
+	     str[len-2] == '\n' && str[len-1] == '\r'))
+		len -= 2;
 	for (i = 0; i < len; i++) {
 		c = str[i];
 		if (c & 0x80) {
@@ -39,6 +43,7 @@
 {
 	int i;
 
+	fputs("RV ", stdout);
 	/* the SWE static ID is sent MSB first */
 	for (i = 1; i <= 4; i++)
 		printf("%02X", rxpkt[i]);
@@ -57,17 +62,33 @@
 }
 
 void
+print_g23_trace()
+{
+	int i;
+
+	fputs("G23:", stdout);
+	for (i = 1; i < rxpkt_len; i++)
+		printf(" %02X", rxpkt[i]);
+	putchar('\n');
+}
+
+void
 print_rx_packet()
 {
 	int i;
 
 	switch (rxpkt[0]) {
 	case RVT_RV_HEADER:
+		if (rxpkt_len < 6)
+			break;
 		print_rv_trace();
 		return;
 	case RVT_L1_HEADER:
 		print_l1_trace();
 		return;
+	case RVT_L23_HEADER:
+		print_g23_trace();
+		return;
 	}
 	/* default case: print the whole packet in hex as an unknown */
 	fputs("UNK:", stdout);