changeset 135:40807eb35ffe

fc-tmsh: rftr response handling implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 20 Feb 2017 02:04:27 +0000
parents 4c78649101f1
children da4d4af80fdd
files rvinterf/tmsh/etmbasic.c rvinterf/tmsh/l1resp.c
diffstat 2 files changed, 48 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/tmsh/etmbasic.c	Mon Feb 20 01:30:10 2017 +0000
+++ b/rvinterf/tmsh/etmbasic.c	Mon Feb 20 02:04:27 2017 +0000
@@ -112,7 +112,9 @@
 		l1tm_response_index("rftw");
 		return;
 	case RF_TABLE_READ:
-		print_etm_pkt_raw("RF_TABLE_READ response");
+		if (rvi_msg_len < 5)
+			goto runt;
+		l1tm_rftr_response();
 		return;
 	case RX_PARAM_WRITE:
 		if (rvi_msg_len < 5)
--- a/rvinterf/tmsh/l1resp.c	Mon Feb 20 01:30:10 2017 +0000
+++ b/rvinterf/tmsh/l1resp.c	Mon Feb 20 02:04:27 2017 +0000
@@ -4,11 +4,16 @@
 
 #include <sys/types.h>
 #include <stdio.h>
+#include <string.h>
+#include <strings.h>
 #include "l1tm.h"
 
 extern u_char rvi_msg[];
 extern int rvi_msg_len;
 
+unsigned rftr_table_index, rftr_table_size;
+u_char rftr_table_data[MAX_RF_TABLE_SIZE];
+
 void
 l1tm_response_nodata(op)
 	char *op;
@@ -262,3 +267,43 @@
 		async_msg_output(buf);
 	}
 }
+
+void
+l1tm_rftr_response()
+{
+	char buf[80], *dp;
+	unsigned i, j, l;
+
+	if (rvi_msg[3]) {
+		if (rvi_msg_len == 5) {
+			sprintf(buf, "rftr error %u (0x%02X)",
+				rvi_msg[3], rvi_msg[3]);
+			async_msg_output(buf);
+		} else
+			print_etm_pkt_raw("rftr long error response");
+		return;
+	}
+	if (rvi_msg_len < 7 || rvi_msg_len > MAX_RF_TABLE_SIZE + 6) {
+		print_etm_pkt_raw("rftr response wrong length");
+		return;
+	}
+	rftr_table_index = rvi_msg[4];
+	rftr_table_size = rvi_msg_len - 6;
+	bcopy(rvi_msg + 5, rftr_table_data, rftr_table_size);
+	sprintf(buf, "rftr index %u (0x%02X): %u bytes",
+		rftr_table_index, rftr_table_index, rftr_table_size);
+	async_msg_output(buf);
+	for (i = 0; i < rftr_table_size; ) {
+		l = rftr_table_size - i;
+		if (l > 16)
+			l = 16;
+		sprintf(buf, "offset %02X:", i);
+		dp = index(buf, '\0');
+		for (j = 0; j < l; j++) {
+			if (j == 0 || j == 8)
+				*dp++ = ' ';
+			sprintf(dp, " %02X", rftr_table_data[i++]);
+		}
+		async_msg_output(buf);
+	}
+}