diff rvinterf/lowlevel/format.c @ 327:05874f1ddacb

rvinterf & rvtdump: new decoding of G23/GPF packets
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 20 Apr 2014 20:39:53 +0000
parents 2f285f20d617
children 2ac2f6d88bb2
line wrap: on
line diff
--- a/rvinterf/lowlevel/format.c	Sat Apr 19 05:23:11 2014 +0000
+++ b/rvinterf/lowlevel/format.c	Sun Apr 20 20:39:53 2014 +0000
@@ -13,14 +13,15 @@
 extern u_char rxpkt[];
 extern size_t rxpkt_len;
 
+char fmtbuf[MAX_PKT_FROM_TARGET*8];	/* size it generously */
+
 void
 print_rv_trace()
 {
-	char buf[MAX_PKT_FROM_TARGET*4];
 	int i, c;
 	char *dp;
 
-	dp = buf;
+	dp = fmtbuf;
 	strcpy(dp, "RV ");
 	dp += 3;
 	/* the SWE static ID is sent MSB first */
@@ -48,17 +49,16 @@
 			*dp++ = c;
 	}
 	*dp = '\0';
-	output_line(buf);
+	output_line(fmtbuf);
 }
 
 void
 print_l1_trace()
 {
-	char buf[MAX_PKT_FROM_TARGET*4+1];
 	int i, c;
 	char *dp;
 
-	dp = buf;
+	dp = fmtbuf;
 	strcpy(dp, "L1: ");
 	dp += 4;
 	for (i = 1; i < rxpkt_len; i++) {
@@ -66,10 +66,10 @@
 		    (rxpkt[i] == '\r' && rxpkt[i+1] == '\n' ||
 		     rxpkt[i] == '\n' && rxpkt[i+1] == '\r')) {
 			*dp = '\0';
-			output_line(buf);
+			output_line(fmtbuf);
 			if (i+2 == rxpkt_len)
 				return;
-			dp = buf;
+			dp = fmtbuf;
 			*dp++ = '+';
 			*dp++ = ' ';
 			i++;
@@ -92,17 +92,16 @@
 	}
 	/* will get here only if no newline sequence at the end */
 	*dp = '\0';
-	output_line(buf);
+	output_line(fmtbuf);
 }
 
 void
 print_etm_output_raw()
 {
-	char buf[MAX_PKT_FROM_TARGET*3+2];
 	int i;
 	char *dp;
 
-	dp = buf;
+	dp = fmtbuf;
 	strcpy(dp, "ETM:");
 	dp += 4;
 	for (i = 1; i < rxpkt_len; i++) {
@@ -110,17 +109,16 @@
 		dp += 3;
 	}
 	*dp = '\0';
-	output_line(buf);
+	output_line(fmtbuf);
 }
 
 void
 print_unknown_packet()
 {
-	char buf[MAX_PKT_FROM_TARGET*3+5];
 	int i;
 	char *dp;
 
-	dp = buf;
+	dp = fmtbuf;
 	strcpy(dp, "UNK:");
 	dp += 4;
 	for (i = 0; i < rxpkt_len; i++) {
@@ -128,5 +126,5 @@
 		dp += 3;
 	}
 	*dp = '\0';
-	output_line(buf);
+	output_line(fmtbuf);
 }