annotate ater/record_ctrl.c @ 15:98ae717734d6

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