FreeCalypso > hg > ice1-trau-tester
changeset 27:2742dbea95f1
ater: implement play command
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 24 Jun 2024 20:31:29 +0000 |
parents | 237687e2be6c |
children | fa341317c844 |
files | ater/Makefile ater/globals.h ater/play_cmd.c ater/tx_func.c ater/user_cmd.c |
diffstat | 5 files changed, 50 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ater/Makefile Mon Jun 24 20:15:42 2024 +0000 +++ b/ater/Makefile Mon Jun 24 20:31:29 2024 +0000 @@ -1,6 +1,6 @@ PROG= itt-ater-16 -OBJS= activate.o main.o out_frame.o read_file.o read_ts.o record_ctrl.o \ - subslot_rx.o tx_func.o user_cmd.o +OBJS= activate.o main.o out_frame.o play_cmd.o read_file.o read_ts.o \ + record_ctrl.o subslot_rx.o tx_func.o user_cmd.o HDRS= globals.h out_frame.h read_file.h submux.h LIBUTIL=../libutil/libutil.a
--- a/ater/globals.h Mon Jun 24 20:15:42 2024 +0000 +++ b/ater/globals.h Mon Jun 24 20:31:29 2024 +0000 @@ -18,3 +18,5 @@ void cmd_print_rx(int argc, char **argv); void cmd_activate(int argc, char **argv); void cmd_deact(int argc, char **argv); +void cmd_play_file(int argc, char **argv); +void cmd_play_stop(int argc, char **argv);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ater/play_cmd.c Mon Jun 24 20:31:29 2024 +0000 @@ -0,0 +1,44 @@ +/* + * Here we implement user commands controlling file play functionality. + */ + +#include <stdint.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <osmocom/core/select.h> + +#include "globals.h" +#include "submux.h" +#include "read_file.h" + +void cmd_play_file(int argc, char **argv) +{ + int nr, rc; + struct ater_subslot *at; + + if (argc != 3) { +usage: fprintf(stderr, "usage: %s 0|1|2|3 play-file.tul\n", argv[0]); + return; + } + if (argv[1][0] < '0' || argv[1][0] > '3' || argv[1][1]) + goto usage; + nr = argv[1][0] - '0'; + at = &subslots[nr]; + if (!at->is_active) { + fprintf(stderr, "error: subslot %d is not active\n", nr); + return; + } + if (at->play_buffer) { + fprintf(stderr, "error: file play already in progress\n"); + return; + } + rc = read_binary_file(argv[2], at->is_efr, &at->play_buffer, + &at->play_buf_total); + if (rc < 0) + return; /* error msg already printed */ + at->play_buf_ptr = 0; + at->play_wait_align = true; +}
--- a/ater/tx_func.c Mon Jun 24 20:15:42 2024 +0000 +++ b/ater/tx_func.c Mon Jun 24 20:31:29 2024 +0000 @@ -44,6 +44,7 @@ return; free(at->play_buffer); at->play_buffer = NULL; + printf("file play finished\n"); } static void tx_service_subslot(int nr)
--- a/ater/user_cmd.c Mon Jun 24 20:15:42 2024 +0000 +++ b/ater/user_cmd.c Mon Jun 24 20:31:29 2024 +0000 @@ -19,6 +19,7 @@ } cmdtab[] = { {"activ", cmd_activate}, {"deact", cmd_deact}, + {"play", cmd_play_file}, {"print-rx", cmd_print_rx}, {"record", cmd_record_start}, {"record-stop", cmd_record_stop},