diff autocal/l1tmops.c @ 16:1c4abfe8bcd9

autocal/l1tmops.c started
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 22 May 2017 17:45:30 +0000
parents
children 0645344feee5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autocal/l1tmops.c	Mon May 22 17:45:30 2017 +0000
@@ -0,0 +1,49 @@
+/*
+ * In this module we are going to implement the functions for executing
+ * various L1TM operations on the DUT.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <rvinterf/pktmux.h>
+#include <rvinterf/tm3.h>
+#include <rvinterf/l1tm.h>
+#include <rvinterf/exitcodes.h>
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+l1tm_pkt_exch(outbuf, outlen)
+	u_char *outbuf;
+{
+	int i, c;
+
+	outbuf[0] = RVT_TM_HEADER;
+	c = 0;
+	for (i = 1; i <= outlen; i++)
+		c ^= outbuf[i];
+	outbuf[i] = c;
+	target_pkt_exch(outbuf, outlen + 2);
+	if (rvi_msg[1] != RVT_TM_HEADER) {
+		fprintf(stderr,
+			"DUT error: response packet is not on TM channel\n");
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg_len < 5) {
+		fprintf(stderr, "DUT error: TM response packet is too short\n");
+		exit(ERROR_TARGET);
+	}
+	c = 0;
+	for (i = 2; i < rvi_msg_len; i++)
+		c ^= rvi_msg[i];
+	if (c) {
+		fprintf(stderr, "DUT error: TM response bad checksum\n");
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg[2] != outbuf[1]) {
+		fprintf(stderr, "DUT error: TM response has wrong CID\n");
+		exit(ERROR_TARGET);
+	}
+	return(0);
+}