FreeCalypso > hg > freecalypso-sw
comparison rvinterf/etm/etmbasic.c @ 188:9f4f331ac24d
fc-tmsh: implemented handling of ETM_CORE responses
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 25 Nov 2013 02:11:47 +0000 |
parents | 4714fdfca39c |
children | a95d253ef952 |
comparison
equal
deleted
inserted
replaced
187:f5f8776f7c66 | 188:9f4f331ac24d |
---|---|
7 #include <string.h> | 7 #include <string.h> |
8 #include <strings.h> | 8 #include <strings.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include "../pktmux.h" | 10 #include "../pktmux.h" |
11 #include "../limits.h" | 11 #include "../limits.h" |
12 #include "etm.h" | |
12 | 13 |
13 extern u_char rvi_msg[]; | 14 extern u_char rvi_msg[]; |
14 extern int rvi_msg_len; | 15 extern int rvi_msg_len; |
15 | 16 |
16 void | 17 void |
18 print_etm_pkt_raw(err) | |
19 char *err; | |
20 { | |
21 char buf[MAX_PKT_FROM_TARGET*3+80], *dp; | |
22 int i; | |
23 | |
24 sprintf(buf, "%s:", err); | |
25 dp = index(buf, '\0'); | |
26 for (i = 2; i < rvi_msg_len; i++) { | |
27 sprintf(dp, " %02X", rvi_msg[i]); | |
28 dp += 3; | |
29 } | |
30 async_msg_output(buf); | |
31 } | |
32 | |
33 void | |
17 etm_packet_rx() | 34 etm_packet_rx() |
18 { | 35 { |
19 char buf[MAX_PKT_FROM_TARGET*3+80], *dp; | |
20 int i, c; | 36 int i, c; |
21 | 37 |
22 if (rvi_msg_len < 4) { | 38 if (rvi_msg_len < 4) { |
23 async_msg_output("!!! Short ETM Rx packet !!!"); | 39 runt: print_etm_pkt_raw("ETM Runt"); |
24 return; | 40 return; |
25 } | 41 } |
26 strcpy(buf, "Pkt from ETM:"); | |
27 dp = index(buf, '\0'); | |
28 c = 0; | 42 c = 0; |
29 for (i = 2; i < rvi_msg_len; i++) { | 43 for (i = 2; i < rvi_msg_len; i++) |
30 sprintf(dp, " %02X", rvi_msg[i]); | |
31 dp += 3; | |
32 c ^= rvi_msg[i]; | 44 c ^= rvi_msg[i]; |
45 if (c) { | |
46 print_etm_pkt_raw("BAD CKSUM"); | |
47 return; | |
33 } | 48 } |
34 sprintf(dp, " chksum %s", c ? "BAD" : "OK"); | 49 switch (rvi_msg[2]) { |
35 async_msg_output(buf); | 50 case ETM_CORE: |
51 if (rvi_msg_len < 6) | |
52 goto runt; | |
53 tmcore_msg_rx(); | |
54 return; | |
55 default: | |
56 print_etm_pkt_raw("ETM Unknown"); | |
57 } | |
36 } | 58 } |
37 | 59 |
38 void | 60 void |
39 cmd_etmpkt(argc, argv) | 61 cmd_etmpkt(argc, argv) |
40 char **argv; | 62 char **argv; |