diff rvinterf/tmsh/l1resp.c @ 134:4c78649101f1

fc-tmsh: l1tm stats response display
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 20 Feb 2017 01:30:10 +0000
parents 4aa1c18c7a2f
children 40807eb35ffe
line wrap: on
line diff
--- a/rvinterf/tmsh/l1resp.c	Sun Feb 19 21:33:58 2017 +0000
+++ b/rvinterf/tmsh/l1resp.c	Mon Feb 20 01:30:10 2017 +0000
@@ -4,6 +4,7 @@
 
 #include <sys/types.h>
 #include <stdio.h>
+#include "l1tm.h"
 
 extern u_char rvi_msg[];
 extern int rvi_msg_len;
@@ -20,7 +21,8 @@
 		return;
 	}
 	if (rvi_msg[3])
-		sprintf(buf, "%s error %u (0x%x)", op, rvi_msg[3], rvi_msg[3]);
+		sprintf(buf, "%s error %u (0x%02X)", op,
+			rvi_msg[3], rvi_msg[3]);
 	else
 		sprintf(buf, "%s OK", op);
 	async_msg_output(buf);
@@ -98,8 +100,165 @@
 		async_msg_output("RF operation finished");
 		return;
 	default:
-		sprintf(buf, "rfe error %u (0x%x)", rvi_msg[3], rvi_msg[3]);
+		sprintf(buf, "rfe error %u (0x%02X)", rvi_msg[3], rvi_msg[3]);
 		async_msg_output(buf);
 		return;
 	}
 }
+
+void
+l1tm_stats_response()
+{
+	char buf[80];
+	unsigned type, bitmask, val, offset;
+	int expect_len;
+
+	if (rvi_msg_len < 5) {
+wrong_len:	print_etm_pkt_raw("STATS_READ response wrong length");
+		return;
+	}
+	if (rvi_msg[3]) {
+		if (rvi_msg_len != 5)
+			goto wrong_len;
+		sprintf(buf, "sr error %u (0x%02X)", rvi_msg[3], rvi_msg[3]);
+		async_msg_output(buf);
+		return;
+	}
+	if (rvi_msg_len < 9)
+		goto wrong_len;
+	type = rvi_msg[4] | (rvi_msg[5] << 8);
+	bitmask = rvi_msg[6] | (rvi_msg[7] << 8);
+	if (type < 1 || type > 2 || (bitmask & 0x0300)) {
+		print_etm_pkt_raw("STATS_READ response unable to parse");
+		return;
+	}
+	expect_len = 9;
+	if (bitmask & RSSI)
+		expect_len += 2;
+	if (bitmask & DSP_PM)
+		expect_len += 2;
+	if (bitmask & ANGLE_MEAN)
+		expect_len += 4;
+	if (bitmask & ANGLE_VAR)
+		expect_len += 4;
+	if (bitmask & ANGLE_MIN)
+		expect_len += 4;
+	if (bitmask & ANGLE_MAX)
+		expect_len += 4;
+	if (bitmask & SNR_MEAN)
+		expect_len += 4;
+	if (bitmask & SNR_VAR)
+		expect_len += 4;
+	if (bitmask & TOA_MEAN)
+		expect_len += 4;
+	if (bitmask & TOA_VAR)
+		expect_len += 4;
+	if (bitmask & FRAME_NUMBER)
+		expect_len += 4;
+	if (bitmask & RUNS)
+		expect_len += 4;
+	if (bitmask & SUCCESSES)
+		expect_len += 4;
+	if (bitmask & BSIC)
+		expect_len += 2;
+	if (rvi_msg_len != expect_len)
+		goto wrong_len;
+	sprintf(buf, "Stats type %u bitmask %04X:", type, bitmask);
+	async_msg_output(buf);
+	offset = 8;
+	if (bitmask & RSSI) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8);
+		offset += 2;
+		sprintf(buf, "RSSI: %u (0x%04X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & DSP_PM) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8);
+		offset += 2;
+		sprintf(buf, "DSP_PM: %u (0x%04X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & ANGLE_MEAN) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "ANGLE_MEAN: %d (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & ANGLE_VAR) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "ANGLE_VAR: %u (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & ANGLE_MIN) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "ANGLE_MIN: %d (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & ANGLE_MAX) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "ANGLE_MAX: %d (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & SNR_MEAN) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "SNR_MEAN: %u (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & SNR_VAR) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "SNR_VAR: %u (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & TOA_MEAN) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "TOA_MEAN: %u (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & TOA_VAR) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "TOA_VAR: %u (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & FRAME_NUMBER) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "FRAME_NUMBER: %u (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & RUNS) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "RUNS: %u (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & SUCCESSES) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) |
+			(rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24);
+		offset += 4;
+		sprintf(buf, "SUCCESSES: %u (0x%08X)", val, val);
+		async_msg_output(buf);
+	}
+	if (bitmask & BSIC) {
+		val = rvi_msg[offset] | (rvi_msg[offset+1] << 8);
+		offset += 2;
+		sprintf(buf, "BSIC: %u (0x%04X)", val, val);
+		async_msg_output(buf);
+	}
+}