# HG changeset patch # User Mychaela Falconia # Date 1726133635 0 # Node ID 349fb785a414596989cc728ea94b22fd05e64762 # Parent 16715bd149e001e491ac2b041c4c95ad478b088c ater: add dset command for setting Dn bits diff -r 16715bd149e0 -r 349fb785a414 ater/Makefile --- a/ater/Makefile Thu Sep 12 09:01:50 2024 +0000 +++ b/ater/Makefile Thu Sep 12 09:33:55 2024 +0000 @@ -1,5 +1,5 @@ PROG= itt-ater-16 -OBJS= activate.o main.o out_frame.o play_cmd.o read_file.o read_ts.o \ +OBJS= activate.o dbits.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 diff -r 16715bd149e0 -r 349fb785a414 ater/dbits.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ater/dbits.c Thu Sep 12 09:33:55 2024 +0000 @@ -0,0 +1,62 @@ +/* + * Here we implement the command for setting Dn bit patterns + * in data-mode TRAU-UL frames. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "globals.h" +#include "submux.h" + +void cmd_set_dbits(int argc, char **argv) +{ + int nr; + struct ater_subslot *at; + struct osmo_trau_frame *fr; + unsigned d_offset; + char *bits; + + if (argc != 4) { +usage: fprintf(stderr, "usage: %s 0|1|2|3 D-offset bits\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->is_data) { + fprintf(stderr, "error: subslot %d is not in data mode\n", nr); + return; + } + fr = &at->ul_frame; + d_offset = atoi(argv[2]); + if (d_offset >= 252) { + fprintf(stderr, "error: specified offset is out of range\n"); + return; + } + for (bits = argv[3]; *bits; bits++) { + if (*bits < '0' || *bits > '1') { + fprintf(stderr, "error: invalid bit string argument\n"); + return; + } + if (d_offset >= 252) { + fprintf(stderr, + "error: given bit string extends past the end of Dn bits\n"); + return; + } + fr->d_bits[d_offset++] = *bits - '0'; + } +} diff -r 16715bd149e0 -r 349fb785a414 ater/globals.h --- a/ater/globals.h Thu Sep 12 09:01:50 2024 +0000 +++ b/ater/globals.h Thu Sep 12 09:33:55 2024 +0000 @@ -21,3 +21,4 @@ void cmd_deact(int argc, char **argv); void cmd_play_file(int argc, char **argv); void cmd_play_stop(int argc, char **argv); +void cmd_set_dbits(int argc, char **argv); diff -r 16715bd149e0 -r 349fb785a414 ater/user_cmd.c --- a/ater/user_cmd.c Thu Sep 12 09:01:50 2024 +0000 +++ b/ater/user_cmd.c Thu Sep 12 09:33:55 2024 +0000 @@ -20,6 +20,7 @@ {"activ", cmd_activate}, {"activ-d", cmd_activate_csd}, {"deact", cmd_deact}, + {"dset", cmd_set_dbits}, {"play", cmd_play_file}, {"play-stop", cmd_play_stop}, {"print-rx", cmd_print_rx},