# HG changeset patch # User Mychaela Falconia # Date 1719254916 0 # Node ID f49e57b0d1a2d54edb235f887f69776a0595615c # Parent 0d70444b50706e7423c31c92dc662af9b9959cc8 ater: implement activ command diff -r 0d70444b5070 -r f49e57b0d1a2 ater/Makefile --- a/ater/Makefile Mon Jun 24 18:21:01 2024 +0000 +++ b/ater/Makefile Mon Jun 24 18:48:36 2024 +0000 @@ -1,6 +1,6 @@ PROG= itt-ater-16 -OBJS= 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 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 diff -r 0d70444b5070 -r f49e57b0d1a2 ater/activate.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ater/activate.c Mon Jun 24 18:48:36 2024 +0000 @@ -0,0 +1,73 @@ +/* + * Here we implement the operation of activating a new TRAU channel + * on a sub-timeslot. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "globals.h" +#include "submux.h" +#include "read_file.h" +#include "out_frame.h" + +void cmd_activate(int argc, char **argv) +{ + int nr, rc; + bool is_efr, dtxd; + struct ater_subslot *at; + uint8_t *init_frame; + unsigned init_frame_count; + + if (argc < 4 || argc > 5) { +usage: fprintf(stderr, + "usage: %s 0|1|2|3 fr|efr initial-frame.tul [dtxd]\n", + argv[0]); + return; + } + if (argv[1][0] < '0' || argv[1][0] > '3' || argv[1][1]) + goto usage; + nr = argv[1][0] - '0'; + if (!strcmp(argv[2], "fr")) + is_efr = false; + else if (!strcmp(argv[2], "efr")) + is_efr = true; + else + goto usage; + if (argv[4]) { + if (strcmp(argv[4], "dtxd")) + goto usage; + dtxd = true; + } else + dtxd = false; + + at = &subslots[nr]; + if (at->is_active) { + fprintf(stderr, "error: subslot %d is already active\n", nr); + return; + } + rc = read_binary_file(argv[3], is_efr, &init_frame, &init_frame_count); + if (rc < 0) + return; /* error msg already printed */ + if (init_frame_count != 1) { + free(init_frame); + fprintf(stderr, "error: %s contains more than one frame\n", + argv[3]); + return; + } + + /* good to proceed now */ + at->is_active = true; + at->is_efr = is_efr; + init_trau_ul_frame(nr); + at->ul_frame.c_bits[16] = dtxd; + trau_frame_from_record(init_frame, is_efr, &at->ul_frame); + free(init_frame); +} diff -r 0d70444b5070 -r f49e57b0d1a2 ater/globals.h --- a/ater/globals.h Mon Jun 24 18:21:01 2024 +0000 +++ b/ater/globals.h Mon Jun 24 18:48:36 2024 +0000 @@ -16,3 +16,4 @@ void cmd_record_start(int argc, char **argv); void cmd_record_stop(int argc, char **argv); void cmd_print_rx(int argc, char **argv); +void cmd_activate(int argc, char **argv); diff -r 0d70444b5070 -r f49e57b0d1a2 ater/user_cmd.c --- a/ater/user_cmd.c Mon Jun 24 18:21:01 2024 +0000 +++ b/ater/user_cmd.c Mon Jun 24 18:48:36 2024 +0000 @@ -17,6 +17,7 @@ char *cmd; void (*func)(int argc, char **argv); } cmdtab[] = { + {"activ", cmd_activate}, {"print-rx", cmd_print_rx}, {"record", cmd_record_start}, {"record-stop", cmd_record_stop},