FreeCalypso > hg > ice1-trau-tester
diff pcm/pcm_tx.c @ 8:70aa8cbdbde9
pcm: implement pcm-fill command
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 23 Jun 2024 19:30:40 +0000 |
parents | ca351324187a |
children | e3d16d490ce2 |
line wrap: on
line diff
--- 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 <ctype.h> #include <stdint.h> #include <stdbool.h> #include <stdio.h> @@ -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; +}