annotate lcdpoll/interf.c @ 3:06e900c54ae3

fc-lcdpoll program put together, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 14 Mar 2018 23:04:44 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement our synchronous interface to the target
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * via rvinterf.
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <unistd.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <rvinterf/limits.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <rvinterf/localsock.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <rvinterf/pktmux.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <rvinterf/exitcodes.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern int sock;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 int rx_enable_state;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 u_char rvi_msg[LOCALSOCK_MAX_MSG];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int rvi_msg_len;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 static void
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 collect_bytes_from_rvi(buf, nbytes)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 u_char *buf;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 int cc;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 while (nbytes) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 cc = read(sock, buf, nbytes);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (cc <= 0) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 perror("read from rvinterf socket");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 exit(ERROR_RVINTERF);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 buf += cc;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 nbytes -= cc;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 collect_rvi_msg()
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 u_char lenbuf[2];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 collect_bytes_from_rvi(lenbuf, 2);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 rvi_msg_len = lenbuf[0] << 8 | lenbuf[1];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (rvi_msg_len < 1 || rvi_msg_len > LOCALSOCK_MAX_MSG) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 fprintf(stderr, "Invalid length from rvinterf: %02X%02X\n",
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 lenbuf[0], lenbuf[1]);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 exit(ERROR_RVINTERF);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 collect_bytes_from_rvi(rvi_msg, rvi_msg_len);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 return(0);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 send_rvimisc_command(cmdpkt, cmdlen)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 u_char *cmdpkt;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 u_char lenbuf[2];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 lenbuf[0] = 0;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 lenbuf[1] = cmdlen;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 write(sock, lenbuf, 2);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 write(sock, cmdpkt, cmdlen);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 rx_control(enable)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 u_char cmdpkt[2];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 int cmdlen;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 /* are we already in the desired state? */
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 if (rx_enable_state == enable)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 return(0);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 /* no, do the work */
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if (enable) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 cmdpkt[0] = CLI2RVI_WANT_MUXPROTO;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 cmdpkt[1] = RVT_TM_HEADER;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 cmdlen = 2;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 } else {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 cmdpkt[0] = CLI2RVI_RESET_PACKET_RX;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 cmdlen = 1;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 send_rvimisc_command(cmdpkt, cmdlen);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 collect_rvi_msg();
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (rvi_msg[0] != RVI2CLI_LOCAL_CMD_RESP || rvi_msg_len < 2) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 fprintf(stderr,
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 "error: unexpected response to rvinterf local command\n");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 exit(ERROR_RVINTERF);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 if (rvi_msg[1] != '+') {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 fprintf(stderr, "Error from rvinterf: %.*s\n", rvi_msg_len - 1,
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 rvi_msg + 1);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 exit(ERROR_RVINTERF);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 rx_enable_state = enable;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 return(0);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 send_pkt_to_target(pkt, pktlen)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 u_char *pkt;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 u_char hdrbuf[3];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 int len1;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 len1 = pktlen + 1;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 hdrbuf[0] = len1 >> 8;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 hdrbuf[1] = len1 & 0xFF;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 hdrbuf[2] = CLI2RVI_PKT_TO_TARGET;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 write(sock, hdrbuf, 3);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 write(sock, pkt, pktlen);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 target_pkt_exch(outpkt, outpktlen)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 u_char *outpkt;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 rx_control(1);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 send_pkt_to_target(outpkt, outpktlen);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 collect_rvi_msg();
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 if (rvi_msg[0] != RVI2CLI_PKT_FROM_TARGET) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 fprintf(stderr,
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 "error: unexpected response type from rvinterf\n");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 exit(ERROR_RVINTERF);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 return(0);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 etm_pkt_exch(outbuf, outlen)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 u_char *outbuf;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 int i, c;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 outbuf[0] = RVT_TM_HEADER;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 c = 0;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 for (i = 1; i <= outlen; i++)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 c ^= outbuf[i];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 outbuf[i] = c;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 target_pkt_exch(outbuf, outlen + 2);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 if (rvi_msg[1] != RVT_TM_HEADER) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 printf("error: packet from target is not ETM!\n");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 return(ERROR_TARGET);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 if (rvi_msg_len < 5) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 printf("error: ETM response packet is too short\n");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 return(ERROR_TARGET);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 c = 0;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 for (i = 2; i < rvi_msg_len; i++)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 c ^= rvi_msg[i];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 if (c) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 printf("ETM response checksum error!\n");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 return(ERROR_TARGET);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 if (rvi_msg[2] != outbuf[1]) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 printf("error: target response is from wrong ETM component\n");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 return(ERROR_TARGET);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 return(0);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 }