FreeCalypso > hg > freecalypso-tools
comparison rvinterf/lowlevel/rviftmode.c @ 935:d203a9c7c4e6
rvinterf TM log: beginning of TM/ETM classification
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 23 May 2023 07:51:13 +0000 |
parents | 0d6be90ae74f |
children | f4e6f6b6548e |
comparison
equal
deleted
inserted
replaced
934:0d6be90ae74f | 935:d203a9c7c4e6 |
---|---|
7 | 7 |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <string.h> | 10 #include <string.h> |
11 #include <strings.h> | 11 #include <strings.h> |
12 #include "../include/etm.h" | |
13 #include "../include/tm3.h" | |
12 | 14 |
13 extern u_char rxpkt[]; | 15 extern u_char rxpkt[]; |
14 extern size_t rxpkt_len; | 16 extern size_t rxpkt_len; |
15 | 17 |
16 extern int verbose; | 18 extern int verbose; |
17 extern FILE *logF; | 19 extern FILE *logF; |
20 | |
21 static int | |
22 verify_cksum(pkt, pktlen) | |
23 u_char *pkt; | |
24 unsigned pktlen; | |
25 { | |
26 int i, c; | |
27 | |
28 c = 0; | |
29 for (i = 1; i < pktlen; i++) | |
30 c ^= pkt[i]; | |
31 if (c == 0) | |
32 return(0); | |
33 else | |
34 return(-1); | |
35 } | |
36 | |
37 static void | |
38 etm_core_classify(pkt, pktlen, outbuf) | |
39 u_char *pkt; | |
40 unsigned pktlen; | |
41 char *outbuf; | |
42 { | |
43 /* classification code to be filled */ | |
44 strcpy(outbuf, "ETM_CORE"); | |
45 } | |
46 | |
47 static void | |
48 tmffs2_cmd_classify(pkt, pktlen, outbuf) | |
49 u_char *pkt; | |
50 unsigned pktlen; | |
51 char *outbuf; | |
52 { | |
53 /* classification code to be filled */ | |
54 strcpy(outbuf, "FFS2"); | |
55 } | |
56 | |
57 static void | |
58 audio_cmd_classify(pkt, pktlen, outbuf) | |
59 u_char *pkt; | |
60 unsigned pktlen; | |
61 char *outbuf; | |
62 { | |
63 /* classification code to be filled */ | |
64 strcpy(outbuf, "ETM_AUDIO"); | |
65 } | |
66 | |
67 static void | |
68 tm_classify(pkt, pktlen, is_cmd, outbuf) | |
69 u_char *pkt; | |
70 unsigned pktlen; | |
71 char *outbuf; | |
72 { | |
73 if (pktlen < 3) { | |
74 strcpy(outbuf, "RUNT"); | |
75 return; | |
76 } | |
77 if (verify_cksum(pkt, pktlen) < 0) { | |
78 strcpy(outbuf, "BAD CKSUM"); | |
79 return; | |
80 } | |
81 switch (pkt[1]) { | |
82 case ETM_CORE: | |
83 if (is_cmd) | |
84 etm_core_classify(pkt, pktlen, outbuf); | |
85 else | |
86 strcpy(outbuf, "ETM_CORE"); | |
87 return; | |
88 case ETM_FFS1: | |
89 strcpy(outbuf, "FFS1"); | |
90 return; | |
91 case ETM_FFS2: | |
92 if (is_cmd) | |
93 tmffs2_cmd_classify(pkt, pktlen, outbuf); | |
94 else | |
95 strcpy(outbuf, "FFS2"); | |
96 return; | |
97 case ETM_AUDIO: | |
98 if (is_cmd) | |
99 audio_cmd_classify(pkt, pktlen, outbuf); | |
100 else | |
101 strcpy(outbuf, "ETM_AUDIO"); | |
102 return; | |
103 case ETM_BSIM: | |
104 strcpy(outbuf, "BSIM"); | |
105 return; | |
106 /* TM3 */ | |
107 case MEM_READ: | |
108 strcpy(outbuf, "omr"); | |
109 return; | |
110 case MEM_WRITE: | |
111 strcpy(outbuf, "omw"); | |
112 return; | |
113 case CODEC_READ: | |
114 strcpy(outbuf, "oabbr"); | |
115 return; | |
116 case CODEC_WRITE: | |
117 strcpy(outbuf, "oabbw"); | |
118 return; | |
119 /* L1TM */ | |
120 case TM_INIT: | |
121 strcpy(outbuf, "tminit"); | |
122 return; | |
123 case TM_MODE_SET: | |
124 strcpy(outbuf, "tms"); | |
125 return; | |
126 case VERSION_GET: | |
127 strcpy(outbuf, "tm3ver"); | |
128 return; | |
129 case RF_ENABLE: | |
130 strcpy(outbuf, "rfe"); | |
131 return; | |
132 case STATS_READ: | |
133 strcpy(outbuf, "sr"); | |
134 return; | |
135 case STATS_CONFIG_WRITE: | |
136 strcpy(outbuf, "scw"); | |
137 return; | |
138 case STATS_CONFIG_READ: | |
139 strcpy(outbuf, "scr"); | |
140 return; | |
141 case RF_PARAM_WRITE: | |
142 strcpy(outbuf, "rfpw"); | |
143 return; | |
144 case RF_PARAM_READ: | |
145 strcpy(outbuf, "rfpr"); | |
146 return; | |
147 case RF_TABLE_WRITE: | |
148 strcpy(outbuf, "rftw"); | |
149 return; | |
150 case RF_TABLE_READ: | |
151 strcpy(outbuf, "rftr"); | |
152 return; | |
153 case RX_PARAM_WRITE: | |
154 strcpy(outbuf, "rxpw"); | |
155 return; | |
156 case RX_PARAM_READ: | |
157 strcpy(outbuf, "rxpr"); | |
158 return; | |
159 case TX_PARAM_WRITE: | |
160 strcpy(outbuf, "txpw"); | |
161 return; | |
162 case TX_PARAM_READ: | |
163 strcpy(outbuf, "txpr"); | |
164 return; | |
165 case TX_TEMPLATE_WRITE: | |
166 strcpy(outbuf, "ttw"); | |
167 return; | |
168 case TX_TEMPLATE_READ: | |
169 strcpy(outbuf, "ttr"); | |
170 return; | |
171 case MISC_PARAM_WRITE: | |
172 strcpy(outbuf, "mpw"); | |
173 return; | |
174 case MISC_PARAM_READ: | |
175 strcpy(outbuf, "mpr"); | |
176 return; | |
177 case MISC_ENABLE: | |
178 strcpy(outbuf, "me"); | |
179 return; | |
180 default: | |
181 sprintf(outbuf, "mid 0x%02X", pkt[1]); | |
182 } | |
183 } | |
18 | 184 |
19 static void | 185 static void |
20 hexdump_out(line) | 186 hexdump_out(line) |
21 char *line; | 187 char *line; |
22 { | 188 { |
28 | 194 |
29 void | 195 void |
30 log_sent_tm(pkt, pktlen) | 196 log_sent_tm(pkt, pktlen) |
31 u_char *pkt; | 197 u_char *pkt; |
32 { | 198 { |
33 output_line("Sent Test Mode packet"); | 199 char summary[32], headline[80]; |
200 | |
201 tm_classify(pkt, pktlen, 1, summary); | |
202 sprintf(headline, "Sent Test Mode cmd (%s)", summary); | |
203 output_line(headline); | |
34 if (verbose >= 1) | 204 if (verbose >= 1) |
35 packet_hex_dump(pkt, pktlen, hexdump_out); | 205 packet_hex_dump(pkt, pktlen, hexdump_out); |
36 } | 206 } |
37 | 207 |
38 void | 208 void |
39 print_tm_output_new() | 209 print_tm_output_new() |
40 { | 210 { |
41 output_line("Rx Test Mode packet"); | 211 char summary[32], headline[80]; |
212 | |
213 tm_classify(rxpkt, (unsigned) rxpkt_len, 0, summary); | |
214 sprintf(headline, "Rx Test Mode resp (%s)", summary); | |
215 output_line(headline); | |
42 if (verbose >= 1) | 216 if (verbose >= 1) |
43 packet_hex_dump(rxpkt, (unsigned) rxpkt_len, hexdump_out); | 217 packet_hex_dump(rxpkt, (unsigned) rxpkt_len, hexdump_out); |
44 } | 218 } |