annotate rvinterf/asyncshell/tchrec.c @ 1010:1d144553a5d0 default tip

CHANGES: fc-host-tools-r21 about to be released
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 12 Dec 2023 07:45:56 +0000
parents 2e6764022292
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * TCH downlink recording functionality
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "pktmux.h"
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "tch_feature.h"
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern u_char rvi_msg[];
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern int rvi_msg_len;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
16 static FILE *record_file;
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 static u_long frame_count;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 void
900
8171c5c0d804 rvinterf tree: definitions for new version of TCH tap feature
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
20 tch_dlbits_old_handler()
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
22 u_char *ptr;
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
23 int i;
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
25 if (!record_file)
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 return;
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
27 /* DSP status words */
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
28 ptr = rvi_msg + 3;
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
29 for (i = 0; i < 3; i++) {
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
30 fprintf(record_file, "%02X%02X ", ptr[0], ptr[1]);
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
31 ptr += 2;
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
32 }
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
33 /* frame bits */
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
34 for (i = 0; i < 33; i++) {
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
35 fprintf(record_file, "%02X", *ptr);
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
36 ptr++;
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
37 }
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
38 putc('\n', record_file);
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 frame_count++;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
901
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
42 void
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
43 tch_dlbits_new_handler(mode_kw, databytes)
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
44 char *mode_kw;
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
45 {
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
46 u_char *ptr;
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
47 int i;
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
48
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
49 if (!record_file)
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
50 return;
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
51 /* channel mode */
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
52 fprintf(record_file, "%s ", mode_kw);
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
53 /* DSP status words */
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
54 ptr = rvi_msg + 5;
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
55 for (i = 0; i < 3; i++) {
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
56 fprintf(record_file, "%02X%02X ", ptr[0], ptr[1]);
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
57 ptr += 2;
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
58 }
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
59 /* frame bits */
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
60 for (i = 0; i < databytes; i++) {
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
61 fprintf(record_file, "%02X", *ptr);
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
62 ptr++;
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
63 }
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
64 /* frame number modulo 104 */
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
65 fprintf(record_file, " %u\n", rvi_msg[4]);
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
66 frame_count++;
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
67 }
2e6764022292 fc-shell tch record: add support for new TCH DL format
Mychaela Falconia <falcon@freecalypso.org>
parents: 900
diff changeset
68
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 static void
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 cmd_tch_record_start(filename)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 char *filename;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 {
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
73 if (record_file) {
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 printf("error: tch record session already in progress\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
77 record_file = fopen(filename, "w");
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
78 if (!record_file) {
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 perror(filename);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 printf("Starting TCH DL recording\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 tch_rx_control(1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 send_tch_config_req(1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 frame_count = 0;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 static void
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 cmd_tch_record_stop()
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 {
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
91 if (!record_file) {
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 printf("error: no tch record session in progress\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
95 fclose(record_file);
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
96 record_file = 0;
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 printf("TCH DL recording stopped, captured %lu speech frames\n",
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 frame_count);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 send_tch_config_req(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 void
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 cmd_tch_record(argc, argv)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 char **argv;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 if (argc < 2) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 printf("error: too few arguments\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 return;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 if (strcmp(argv[1], "stop"))
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 cmd_tch_record_start(argv[1]);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 else
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 cmd_tch_record_stop();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 void
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 show_tch_record_status()
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 printf("TCH DL recording: %s\n",
4
971906d7763d fc-shell tch commands: changed to raw hex file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
120 record_file ? "RUNNING" : "not running");
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 }