FreeCalypso > hg > freecalypso-tools
changeset 644:69acf5e0a21d
loadagent: implemented sertimeout calibration command
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 01 Mar 2020 23:49:31 +0000 |
parents | cd031e2501fa |
children | 880c6d31e487 |
files | target-utils/loadagent/Makefile target-utils/loadagent/cmdtab.c target-utils/loadagent/sertimeout.c |
diffstat | 3 files changed, 36 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/target-utils/loadagent/Makefile Sun Mar 01 21:30:49 2020 +0000 +++ b/target-utils/loadagent/Makefile Sun Mar 01 23:49:31 2020 +0000 @@ -7,7 +7,7 @@ INSTDIR=/opt/freecalypso/target-bin PROG= loadagent -OBJS= crt0.o bindump.o cmdtab.o main.o +OBJS= crt0.o bindump.o cmdtab.o main.o sertimeout.o LIBS= ../libload/libload.a ../libcommon/libcommon.a ../libprintf/libprintf.a \ ../libbase/libbase.a ../libc/libc.a LIBGCC= `${CC} -print-file-name=libgcc.a`
--- a/target-utils/loadagent/cmdtab.c Sun Mar 01 21:30:49 2020 +0000 +++ b/target-utils/loadagent/cmdtab.c Sun Mar 01 23:49:31 2020 +0000 @@ -12,6 +12,7 @@ extern void cmd_r8(); extern void cmd_r16(); extern void cmd_r32(); +extern void cmd_sertimeout(); extern void cmd_w8(); extern void cmd_w16(); extern void cmd_w32(); @@ -49,6 +50,7 @@ {"r8", cmd_r8}, {"r16", cmd_r16}, {"r32", cmd_r32}, + {"sertimeout", cmd_sertimeout}, {"w8", cmd_w8}, {"w16", cmd_w16}, {"w32", cmd_w32},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target-utils/loadagent/sertimeout.c Sun Mar 01 23:49:31 2020 +0000 @@ -0,0 +1,33 @@ +/* + * Here we are going to implement a function for serial input with a timeout. + */ + +#include <stdlib.h> + +serial_in_timeout(count) + unsigned count; +{ + int c; + + do + c = serial_in_poll(); + while (c < 0 && --count); + return c; +} + +void +cmd_sertimeout(argbulk) + char *argbulk; +{ + char *argv[2]; + int count, c; + + if (parse_args(argbulk, 1, 1, argv, 0) < 0) + return; + count = atoi(argv[0]); + c = serial_in_timeout(count); + if (c >= 0) + printf("Got char\n"); + else + printf("Timeout\n"); +}