# HG changeset patch # User Mychaela Falconia # Date 1719171040 0 # Node ID 70aa8cbdbde91b862934712e5342ae9a1175abda # Parent ca351324187a7c794a7693a8583b519aac5e5e5a pcm: implement pcm-fill command diff -r ca351324187a -r 70aa8cbdbde9 pcm/globals.h --- a/pcm/globals.h Sun Jun 23 19:21:00 2024 +0000 +++ b/pcm/globals.h Sun Jun 23 19:30:40 2024 +0000 @@ -14,3 +14,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_pcm_fill(int argc, char **argv); diff -r ca351324187a -r 70aa8cbdbde9 pcm/pcm_tx.c --- a/pcm/pcm_tx.c Sun Jun 23 19:21:00 2024 +0000 +++ b/pcm/pcm_tx.c Sun Jun 23 19:30:40 2024 +0000 @@ -2,6 +2,7 @@ * In this module we implement PCM Tx toward the TRAU. */ +#include #include #include #include @@ -54,3 +55,24 @@ memset(buf, pcm_fill_octet, 160); write(ts_fd, buf, 160); } + +void cmd_pcm_fill(int argc, char **argv) +{ + u_long val; + char *cp; + + if (argc != 2) { + printf("error: pcm-fill command needs 1 argument\n"); + return; + } + if (!isxdigit(argv[1][0])) { +inv_arg: printf("error: argument is not a valid hex octet\n"); + return; + } + val = strtoul(argv[1], &cp, 16); + if (*cp) + goto inv_arg; + if (val > 0xFF) + goto inv_arg; + pcm_fill_octet = val; +} diff -r ca351324187a -r 70aa8cbdbde9 pcm/user_cmd.c --- a/pcm/user_cmd.c Sun Jun 23 19:21:00 2024 +0000 +++ b/pcm/user_cmd.c Sun Jun 23 19:30:40 2024 +0000 @@ -17,6 +17,7 @@ char *cmd; void (*func)(int argc, char **argv); } cmdtab[] = { + {"pcm-fill", cmd_pcm_fill}, {"print-rx", cmd_print_rx}, {"record", cmd_record_start}, {"record-stop", cmd_record_stop},