annotate ft16/record_ctrl.c @ 2:5c18cd38c8ad

ft16: import from ice1-trau-tester/abis
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 29 Aug 2024 13:07:16 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Here we implement stdin commands that control recording of E1 timeslot
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * read stream.
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdint.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdbool.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <osmocom/core/select.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "globals.h"
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 void cmd_record_start(int argc, char **argv)
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (argc != 2) {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 printf("error: record command needs 1 argument\n");
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 }
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (record_file) {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 printf("error: recording already in progress\n");
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 record_file = fopen(argv[1], "w");
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (!record_file)
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 perror(argv[1]);
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 void cmd_record_stop(int argc, char **argv)
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (!record_file) {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 printf("error: no recording in progress\n");
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 fclose(record_file);
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 record_file = NULL;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 void cmd_print_rx(int argc, char **argv)
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 int i, j, off;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 off = 0;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 for (i = 0; i < 10; i++) {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 for (j = 0; j < 16; j++)
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 printf(" %02X", readbuf[off++]);
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 putchar('\n');
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }