FreeCalypso > hg > fc-rfcal-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
15:724e16223187 | 16:1c4abfe8bcd9 |
---|---|
1 /* | |
2 * In this module we are going to implement the functions for executing | |
3 * various L1TM operations on the DUT. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include <rvinterf/pktmux.h> | |
10 #include <rvinterf/tm3.h> | |
11 #include <rvinterf/l1tm.h> | |
12 #include <rvinterf/exitcodes.h> | |
13 | |
14 extern u_char rvi_msg[]; | |
15 extern int rvi_msg_len; | |
16 | |
17 l1tm_pkt_exch(outbuf, outlen) | |
18 u_char *outbuf; | |
19 { | |
20 int i, c; | |
21 | |
22 outbuf[0] = RVT_TM_HEADER; | |
23 c = 0; | |
24 for (i = 1; i <= outlen; i++) | |
25 c ^= outbuf[i]; | |
26 outbuf[i] = c; | |
27 target_pkt_exch(outbuf, outlen + 2); | |
28 if (rvi_msg[1] != RVT_TM_HEADER) { | |
29 fprintf(stderr, | |
30 "DUT error: response packet is not on TM channel\n"); | |
31 exit(ERROR_TARGET); | |
32 } | |
33 if (rvi_msg_len < 5) { | |
34 fprintf(stderr, "DUT error: TM response packet is too short\n"); | |
35 exit(ERROR_TARGET); | |
36 } | |
37 c = 0; | |
38 for (i = 2; i < rvi_msg_len; i++) | |
39 c ^= rvi_msg[i]; | |
40 if (c) { | |
41 fprintf(stderr, "DUT error: TM response bad checksum\n"); | |
42 exit(ERROR_TARGET); | |
43 } | |
44 if (rvi_msg[2] != outbuf[1]) { | |
45 fprintf(stderr, "DUT error: TM response has wrong CID\n"); | |
46 exit(ERROR_TARGET); | |
47 } | |
48 return(0); | |
49 } |