FreeCalypso > hg > freecalypso-tools
changeset 32:ea061975c883
fc-tmsh: implemented sending of ETM audio load and save commands
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 23 Oct 2016 21:52:29 +0000 |
parents | 5b4e345095c4 |
children | cefdc6623322 |
files | rvinterf/tmsh/Makefile rvinterf/tmsh/audiocmd.c rvinterf/tmsh/usercmd.c |
diffstat | 3 files changed, 93 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/tmsh/Makefile Sun Oct 23 18:38:07 2016 +0000 +++ b/rvinterf/tmsh/Makefile Sun Oct 23 21:52:29 2016 +0000 @@ -4,8 +4,8 @@ INSTBIN=/usr/local/bin LIBS= ../libasync/libasync.a -TMSH_OBJS= abb.o etmbasic.o ffs2.o ffs2resp.o ffs2wr.o init.o main.o \ - misc.o omr.o pktsort.o tmcore.o usercmd.o +TMSH_OBJS= abb.o audiocmd.o etmbasic.o ffs2.o ffs2resp.o ffs2wr.o init.o \ + main.o misc.o omr.o pktsort.o tmcore.o usercmd.o all: ${PROGS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/tmsh/audiocmd.c Sun Oct 23 21:52:29 2016 +0000 @@ -0,0 +1,89 @@ +/* + * ETM audio commands + */ + +#include <sys/types.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include "limits.h" +#include "localtypes.h" +#include "etm.h" + +void +cmd_audio_load(argc, argv) + char **argv; +{ + u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; + int slen; + + slen = strlen(argv[1]); + if (slen > 9) { + printf("error: audio config name is limited to 9 chars\n"); + return; + } + dp = cmdpkt + 1; + *dp++ = ETM_AUDIO; + *dp++ = 'L'; + strcpy(dp, argv[1]); + dp += slen + 1; + send_etm_cmd(cmdpkt, dp - cmdpkt - 1); +} + +void +cmd_audio_save(argc, argv) + char **argv; +{ + u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; + int slen; + + slen = strlen(argv[1]); + if (slen > 9) { + printf("error: audio config name is limited to 9 chars\n"); + return; + } + dp = cmdpkt + 1; + *dp++ = ETM_AUDIO; + *dp++ = 'S'; + strcpy(dp, argv[1]); + dp += slen + 1; + send_etm_cmd(cmdpkt, dp - cmdpkt - 1); +} + +static struct cmdtab { + char *cmd; + int minargs; + int maxargs; + void (*func)(); +} audio_cmds[] = { + {"load", 1, 1, cmd_audio_load}, + {"save", 1, 1, cmd_audio_save}, + {0, 0, 0, 0} +}; + +void +cmd_audio(argc, argv) + char **argv; +{ + struct cmdtab *tp; + int extargs; + + for (tp = audio_cmds; tp->cmd; tp++) + if (!strcmp(tp->cmd, argv[1])) + break; + if (!tp->func) { + printf("error: no such audio command\n"); + return; + } + extargs = argc - 2; + if (extargs > tp->maxargs) { + printf("error: too many arguments\n"); + return; + } + if (extargs < tp->minargs) { + printf("error: too few arguments\n"); + return; + } + tp->func(argc - 1, argv + 1); +}
--- a/rvinterf/tmsh/usercmd.c Sun Oct 23 18:38:07 2016 +0000 +++ b/rvinterf/tmsh/usercmd.c Sun Oct 23 21:52:29 2016 +0000 @@ -13,6 +13,7 @@ extern void cmd_abbr(); extern void cmd_abbw(); +extern void cmd_audio(); extern void cmd_check_ffs1(); extern void cmd_dieid(); extern void cmd_etmpkt(); @@ -46,6 +47,7 @@ } cmdtab[] = { {"abbr", 2, 2, cmd_abbr}, {"abbw", 3, 3, cmd_abbw}, + {"audio", 2, 2, cmd_audio}, {"check-ffs1", 0, 0, cmd_check_ffs1}, {"dieid", 0, 0, cmd_dieid}, {"etmpkt", 1, 253, cmd_etmpkt},