# HG changeset patch # User Mychaela Falconia # Date 1730100293 0 # Node ID 315428573a251c9d028d0ab1e3885e163cf5e7e9 # Parent 23555b9a1c2089b6cba160d0ead5d5cd527dd9a9 fc-mcsi-rxtx: implement record function diff -r 23555b9a1c20 -r 315428573a25 sw/mcsi-rxtx/Makefile --- a/sw/mcsi-rxtx/Makefile Mon Oct 28 06:52:33 2024 +0000 +++ b/sw/mcsi-rxtx/Makefile Mon Oct 28 07:24:53 2024 +0000 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 PROG= fc-mcsi-rxtx -OBJS= main.o mainloop.o rx_samples.o ttymagic.o tx_func.o usercmd.o +OBJS= main.o mainloop.o record.o rx_samples.o ttymagic.o tx_func.o usercmd.o LIBS= ../libserial/libserial.a INSTALL_PREFIX= /opt/freecalypso diff -r 23555b9a1c20 -r 315428573a25 sw/mcsi-rxtx/mainloop.c --- a/sw/mcsi-rxtx/mainloop.c Mon Oct 28 06:52:33 2024 +0000 +++ b/sw/mcsi-rxtx/mainloop.c Mon Oct 28 07:24:53 2024 +0000 @@ -47,6 +47,7 @@ off); async_msg_output(buf); off = 0; + record_auto_stop(); continue; } if (FD_ISSET(0, &fds)) diff -r 23555b9a1c20 -r 315428573a25 sw/mcsi-rxtx/record.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sw/mcsi-rxtx/record.c Mon Oct 28 07:24:53 2024 +0000 @@ -0,0 +1,59 @@ +/* + * Here we implement the functionality of recording MCSI Rx streams + * into robe files. + */ + +#include +#include +#include + +extern u_short rx_pcm_samples[160]; + +static FILE *record_file; + +void +record_process() +{ + unsigned n, samp; + + if (!record_file) + return; + for (n = 0; n < 160; n++) { + samp = rx_pcm_samples[n]; + putc(samp >> 8, record_file); + putc(samp, record_file); + } +} + +void +record_auto_stop() +{ + if (!record_file) + return; + fclose(record_file); + record_file = 0; +} + +void +cmd_record(argc, argv) + char **argv; +{ + if (record_file) { + printf("error: recording already in progress\n"); + return; + } + record_file = fopen(argv[1], "w"); + if (!record_file) + perror(argv[1]); +} + +void +cmd_record_stop() +{ + if (!record_file) { + printf("error: no recording in progress\n"); + return; + } + fclose(record_file); + record_file = 0; +} diff -r 23555b9a1c20 -r 315428573a25 sw/mcsi-rxtx/rx_samples.c --- a/sw/mcsi-rxtx/rx_samples.c Mon Oct 28 06:52:33 2024 +0000 +++ b/sw/mcsi-rxtx/rx_samples.c Mon Oct 28 07:24:53 2024 +0000 @@ -21,6 +21,7 @@ samp = ((unsigned) sp[1] << 8) | ((unsigned) sp[0]); rx_pcm_samples[n] = samp; } + record_process(); } void diff -r 23555b9a1c20 -r 315428573a25 sw/mcsi-rxtx/usercmd.c --- a/sw/mcsi-rxtx/usercmd.c Mon Oct 28 06:52:33 2024 +0000 +++ b/sw/mcsi-rxtx/usercmd.c Mon Oct 28 07:24:53 2024 +0000 @@ -13,6 +13,8 @@ extern void cmd_pcm_fill(); extern void cmd_print_rx(); +extern void cmd_record(); +extern void cmd_record_stop(); static void cmd_exit() @@ -31,6 +33,9 @@ {"pcm-fill", 0, 1, cmd_pcm_fill}, {"print-rx", 0, 0, cmd_print_rx}, {"quit", 0, 0, cmd_exit}, + {"record", 1, 1, cmd_record}, + {"record-stop", 0, 0, cmd_record_stop}, + /* table search terminator */ {0, 0, 0, 0} };