# HG changeset patch # User Mychaela Falconia # Date 1521161560 0 # Node ID 8c7e86bc137e4c94051e1a88bd3d633cd99281c2 # Parent 4477d28c77bcb5f06df800e34eb41e46ebeff84a fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims diff -r 4477d28c77bc -r 8c7e86bc137e rvinterf/asyncshell/Makefile --- a/rvinterf/asyncshell/Makefile Thu Mar 15 04:59:32 2018 +0000 +++ b/rvinterf/asyncshell/Makefile Fri Mar 16 00:52:40 2018 +0000 @@ -1,8 +1,9 @@ CC= gcc CFLAGS= -O2 -I../include PROG= fc-shell -OBJS= at.o help.o init.o main.o oneshot.o parse.o pktsort.o poweroff.o \ - rxctl.o sendarb.o sendsp.o tchcmd.o tchplay.o tchrec.o usercmd.o +OBJS= at.o help.o init.o keypress.o main.o oneshot.o parse.o pktsort.o \ + poweroff.o rxctl.o sendarb.o sendsp.o tchcmd.o tchplay.o tchrec.o \ + usercmd.o LIBS= ../libasync/libasync.a ../libg23/libg23.a INSTBIN=/opt/freecalypso/bin INSTHELP=/opt/freecalypso/helpfiles diff -r 4477d28c77bc -r 8c7e86bc137e rvinterf/asyncshell/keypress.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/asyncshell/keypress.c Fri Mar 16 00:52:40 2018 +0000 @@ -0,0 +1,100 @@ +/* + * Functions for sending simulated keystrokes via GPF MMI CONFIG sysprims. + */ + +#include +#include +#include +#include +#include +#include +#include "pktmux.h" +#include "limits.h" +#include "exitcodes.h" + +send_mmi_config_pair(key, value) + char *key, *value; +{ + unsigned intlen; + u_char sendpkt[MAX_PKT_TO_TARGET+1]; + unsigned pktlen; + + intlen = 12 + 7 + strlen(key) + 1 + strlen(value); + pktlen = intlen + 4; + if (pktlen > MAX_PKT_TO_TARGET) { + printf("error: max pkt to target limit exceeded\n"); + return(ERROR_USAGE); + } + /* fill out the packet */ + sendpkt[0] = RVT_L23_HEADER; + sendpkt[1] = 0xB7; /* system prim */ + sendpkt[2] = intlen; + sendpkt[3] = intlen >> 8; + /* send zeros for the timestamp */ + sendpkt[4] = 0; + sendpkt[5] = 0; + sendpkt[6] = 0; + sendpkt[7] = 0; + /* as far as TI's sw is concerned, we are PCO */ + sprintf(sendpkt + 8, "PCO MMI CONFIG %s=%s", key, value); + /* send it! */ + send_pkt_to_target(sendpkt, pktlen); + return(0); +} + +void +cmd_key_interactive(arg) + char *arg; +{ + while (isspace(*arg)) + arg++; + if (!*arg) { + printf("error: missing string argument\n"); + return; + } + send_mmi_config_pair("KEY_SEQUENCE", arg); +} + +cmd_key_oneshot(argc, argv) + char **argv; +{ + return send_mmi_config_pair("KEY_SEQUENCE", argv[1]); +} + +void +cmd_keydown_interactive(arg) + char *arg; +{ + while (isspace(*arg)) + arg++; + if (!*arg) { + printf("error: missing string argument\n"); + return; + } + send_mmi_config_pair("KEY_PRESS", arg); +} + +cmd_keydown_oneshot(argc, argv) + char **argv; +{ + return send_mmi_config_pair("KEY_PRESS", argv[1]); +} + +void +cmd_keyup_interactive(arg) + char *arg; +{ + while (isspace(*arg)) + arg++; + if (!*arg) { + printf("error: missing string argument\n"); + return; + } + send_mmi_config_pair("KEY_RELEASE", arg); +} + +cmd_keyup_oneshot(argc, argv) + char **argv; +{ + return send_mmi_config_pair("KEY_RELEASE", argv[1]); +} diff -r 4477d28c77bc -r 8c7e86bc137e rvinterf/asyncshell/oneshot.c --- a/rvinterf/asyncshell/oneshot.c Thu Mar 15 04:59:32 2018 +0000 +++ b/rvinterf/asyncshell/oneshot.c Fri Mar 16 00:52:40 2018 +0000 @@ -9,6 +9,9 @@ #include "limits.h" #include "exitcodes.h" +extern int cmd_key_oneshot(); +extern int cmd_keydown_oneshot(); +extern int cmd_keyup_oneshot(); extern int cmd_poweroff(); extern int cmd_send_oneshot(); extern int cmd_sp_oneshot(); @@ -22,6 +25,9 @@ int maxargs; int (*func)(); } cmdtab[] = { + {"key", 1, 1, cmd_key_oneshot}, + {"keydown", 1, 1, cmd_keydown_oneshot}, + {"keyup", 1, 1, cmd_keyup_oneshot}, {"poweroff", 0, 0, cmd_poweroff}, {"send", 1, MAX_PKT_TO_TARGET, cmd_send_oneshot}, {"sp", 2, 2, cmd_sp_oneshot}, diff -r 4477d28c77bc -r 8c7e86bc137e rvinterf/asyncshell/usercmd.c --- a/rvinterf/asyncshell/usercmd.c Thu Mar 15 04:59:32 2018 +0000 +++ b/rvinterf/asyncshell/usercmd.c Fri Mar 16 00:52:40 2018 +0000 @@ -14,6 +14,9 @@ extern void cmd_disable(); extern void cmd_enable(); extern void cmd_help(); +extern void cmd_key_interactive(); +extern void cmd_keydown_interactive(); +extern void cmd_keyup_interactive(); extern void cmd_poweroff(); extern void cmd_sendat(); extern void cmd_send_interactive(); @@ -37,6 +40,9 @@ {"enable", cmd_enable}, {"exit", cmd_exit}, {"help", cmd_help}, + {"key", cmd_key_interactive}, + {"keydown", cmd_keydown_interactive}, + {"keyup", cmd_keyup_interactive}, {"poweroff", cmd_poweroff}, {"quit", cmd_exit}, {"send", cmd_send_interactive},