# HG changeset patch # User Mychaela Falconia # Date 1464655380 0 # Node ID 71bbddbcc6a1fa3723fa813bb2ce422412bd0f3d # Parent 1178befeda762a3f699cef1f051bac7a1e70db9c fc-shell: tch record implemented diff -r 1178befeda76 -r 71bbddbcc6a1 rvinterf/asyncshell/Makefile --- a/rvinterf/asyncshell/Makefile Mon May 30 23:19:30 2016 +0000 +++ b/rvinterf/asyncshell/Makefile Tue May 31 00:43:00 2016 +0000 @@ -2,7 +2,7 @@ CFLAGS= -O2 -I../include PROG= fc-shell OBJS= at.o init.o main.o oneshot.o parse.o pktsort.o poweroff.o rxctl.o \ - sendarb.o sendsp.o tchcmd.o usercmd.o + sendarb.o sendsp.o tchcmd.o tchrec.o usercmd.o LIBS= ../libasync/libasync.a ../libg23/libg23.a INSTBIN=/usr/local/bin diff -r 1178befeda76 -r 71bbddbcc6a1 rvinterf/asyncshell/tchcmd.c --- a/rvinterf/asyncshell/tchcmd.c Mon May 30 23:19:30 2016 +0000 +++ b/rvinterf/asyncshell/tchcmd.c Tue May 31 00:43:00 2016 +0000 @@ -112,7 +112,9 @@ /* TCH UL play code will hook in here */ return; case TCH_DLBITS_IND: - /* TCH DL record code will hook in here */ + if (rvi_msg_len != 43) + goto inv; + tch_dlbits_handler(); return; default: goto inv; @@ -145,6 +147,7 @@ printf("error: too many arguments\n"); return; } + show_tch_record_status(); printf("TCH raw dump mode is %s\n", tch_rawdump_mode ? "enabled" : "disabled"); } @@ -163,6 +166,10 @@ cmd_tch_dumpraw(argc, argv); return; } + if (!strcmp(argv[0], "record")) { + cmd_tch_record(argc, argv); + return; + } if (!strcmp(argv[0], "status")) { cmd_tch_status(argc, argv); return; diff -r 1178befeda76 -r 71bbddbcc6a1 rvinterf/asyncshell/tchrec.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/asyncshell/tchrec.c Tue May 31 00:43:00 2016 +0000 @@ -0,0 +1,80 @@ +/* + * TCH downlink recording functionality + */ + +#include +#include +#include +#include +#include +#include "pktmux.h" +#include "tch_feature.h" + +extern u_char rvi_msg[]; +extern int rvi_msg_len; + +static FILE *gsm_data_file; +static u_long frame_count; + +void +tch_dlbits_handler() +{ + if (!gsm_data_file) + return; + fwrite(rvi_msg + 9, 33, 1, gsm_data_file); + frame_count++; +} + +static void +cmd_tch_record_start(filename) + char *filename; +{ + if (gsm_data_file) { + printf("error: tch record session already in progress\n"); + return; + } + gsm_data_file = fopen(filename, "w"); + if (!gsm_data_file) { + perror(filename); + return; + } + printf("Starting TCH DL recording\n"); + tch_rx_control(1); + send_tch_config_req(1); + frame_count = 0; +} + +static void +cmd_tch_record_stop() +{ + if (!gsm_data_file) { + printf("error: no tch record session in progress\n"); + return; + } + fclose(gsm_data_file); + gsm_data_file = 0; + printf("TCH DL recording stopped, captured %lu speech frames\n", + frame_count); + send_tch_config_req(0); +} + +void +cmd_tch_record(argc, argv) + char **argv; +{ + if (argc < 2) { + printf("error: too few arguments\n"); + return; + } + if (strcmp(argv[1], "stop")) + cmd_tch_record_start(argv[1]); + else + cmd_tch_record_stop(); +} + +void +show_tch_record_status() +{ + printf("TCH DL recording: %s\n", + gsm_data_file ? "RUNNING" : "not running"); +}