annotate rvinterf/asyncshell/tchplay.c @ 1029:333015c662bc

fc-shell: tch play implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 31 May 2016 01:53:04 +0000
parents
children 194967e11b2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1029
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * TCH uplink play-from-file functionality
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "pktmux.h"
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "tch_feature.h"
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern u_char rvi_msg[];
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern int rvi_msg_len;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern void async_msg_output();
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static FILE *gsm_data_file;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 static int queued_frames;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #define QUEUE_LIMIT 3
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 static void
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 sync_msgout(msg)
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 char *msg;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 printf("%s\n", msg);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 static void
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 fill_uplink(msgout)
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 void (*msgout)();
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 u_char sendpkt[35];
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 int cc;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 sendpkt[0] = RVT_TCH_HEADER;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 sendpkt[1] = TCH_ULBITS_REQ;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 while (queued_frames < QUEUE_LIMIT) {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 cc = fread(sendpkt + 2, 1, 33, gsm_data_file);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (cc < 33) {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (cc)
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 msgout("TCH UL: extra bytes at the end of the file");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 msgout("TCH UL: file play finished");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 gsm_data_file = 0;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 return;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 send_pkt_to_target(sendpkt, 35);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 queued_frames++;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 void
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 tch_ulbits_conf()
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 if (queued_frames > 0)
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 queued_frames--;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 if (gsm_data_file)
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 fill_uplink(async_msg_output);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 static void
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 cmd_tch_play_start(filename)
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 char *filename;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 if (gsm_data_file) {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 printf("error: tch play session already in progress\n");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 return;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 gsm_data_file = fopen(filename, "r");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 if (!gsm_data_file) {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 perror(filename);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 return;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 printf("Starting TCH UL play from file\n");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 tch_rx_control(1);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 fill_uplink(sync_msgout);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 static void
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 cmd_tch_play_stop()
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (!gsm_data_file) {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 printf("error: no tch play session in progress\n");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 return;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 fclose(gsm_data_file);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 gsm_data_file = 0;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 printf("TCH UL play from file terminated\n");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 void
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 cmd_tch_play(argc, argv)
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 char **argv;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 if (argc < 2) {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 printf("error: too few arguments\n");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 return;
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 if (strcmp(argv[1], "stop"))
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 cmd_tch_play_start(argv[1]);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 else
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 cmd_tch_play_stop();
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 }
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 void
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 show_tch_play_status()
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 {
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 printf("TCH UL play from file: %s\n",
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 gsm_data_file ? "RUNNING" : "not running");
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 printf("Outstanding UL frames: %d\n", queued_frames);
333015c662bc fc-shell: tch play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 }