annotate rvinterf/tmsh/audioresp.c @ 990:f34261bb3355

pln-ppb-test: implement PPB erase
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 00:20:14 +0000
parents ce7479d28b02
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
159
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we are going to implement the handling of ETM_AUDIO responses.
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "pktmux.h"
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "limits.h"
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "localtypes.h"
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "etm.h"
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern u_char rvi_msg[];
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern int rvi_msg_len;
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static void
160
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
19 aul_aus_response(op)
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
20 char *op;
159
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
160
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
22 char buf[80];
159
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
160
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
24 if (rvi_msg_len != 6) {
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
25 sprintf(buf, "%s response wrong length", op);
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
26 print_etm_pkt_raw(buf);
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
27 return;
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
28 }
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
29 if (rvi_msg[3])
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
30 sprintf(buf, "%s error %u (0x%02X)", op,
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
31 rvi_msg[3], rvi_msg[3]);
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
32 else
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
33 sprintf(buf, "%s OK", op);
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
34 async_msg_output(buf);
159
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 static void
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 aur_response()
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 {
162
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
40 char buf[80], *dp;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
41 unsigned i, j, l, size;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
42
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
43 if (rvi_msg_len < 7) {
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
44 tooshort: print_etm_pkt_raw("aur response too short");
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
45 return;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
46 }
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
47 if (rvi_msg[3]) {
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
48 if (rvi_msg_len == 7) {
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
49 sprintf(buf, "aur %u error %u (0x%02X)", rvi_msg[5],
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
50 rvi_msg[3], rvi_msg[3]);
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
51 async_msg_output(buf);
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
52 } else
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
53 print_etm_pkt_raw("aur long error response");
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
54 return;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
55 }
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
56 if (rvi_msg_len < 8)
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
57 goto tooshort;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
58 size = rvi_msg_len - 7;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
59 sprintf(buf, "aur %u: %u byte%s", rvi_msg[5], size,
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
60 size != 1 ? "s" : "");
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
61 async_msg_output(buf);
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
62 for (i = 0; i < size; ) {
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
63 l = size - i;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
64 if (l > 16)
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
65 l = 16;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
66 sprintf(buf, "offset %02X:", i);
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
67 dp = index(buf, '\0');
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
68 for (j = 0; j < l; j++) {
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
69 if (j == 0 || j == 8)
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
70 *dp++ = ' ';
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
71 sprintf(dp, " %02X", rvi_msg[i + 6]);
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
72 i++;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
73 dp += 3;
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
74 }
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
75 async_msg_output(buf);
ce7479d28b02 fc-tmsh: aur response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 161
diff changeset
76 }
159
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 static void
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 auw_response()
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 {
161
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
82 char buf[80];
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
83
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
84 if (rvi_msg_len != 7) {
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
85 print_etm_pkt_raw("auw response wrong length");
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
86 return;
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
87 }
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
88 if (rvi_msg[3])
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
89 sprintf(buf, "auw %u error %u (0x%02X)", rvi_msg[5],
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
90 rvi_msg[3], rvi_msg[3]);
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
91 else
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
92 sprintf(buf, "auw %u OK", rvi_msg[5]);
da6950e936bf fc-tmsh: proper handling of auw responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 160
diff changeset
93 async_msg_output(buf);
159
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 void
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 etm_audio_msg_rx()
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 {
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 switch (rvi_msg[4]) {
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 case 'L':
160
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
101 aul_aus_response("aul");
159
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 return;
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 case 'S':
160
e4c98a2c1673 fc-tmsh: implemented proper handling of aul and aus responses
Mychaela Falconia <falcon@freecalypso.org>
parents: 159
diff changeset
104 aul_aus_response("aus");
159
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 return;
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 case 'R':
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 aur_response();
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 return;
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 case 'W':
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 auw_response();
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 return;
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 default:
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 unknown:
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 print_etm_pkt_raw("ETM_AUDIO");
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 }
8fac4aaec230 fc-tmsh: beginning of intelligent ETM_AUDIO response handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 }