FreeCalypso > hg > freecalypso-tools
changeset 646:0d199c6a6ea4
fc-loadtool: timeout-cal internal developer command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 02 Mar 2020 00:21:12 +0000 |
parents | 880c6d31e487 |
children | dfe6ba3611cd |
files | loadtools/ltdispatch.c loadtools/ltmisc.c |
diffstat | 2 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/loadtools/ltdispatch.c Sun Mar 01 23:56:35 2020 +0000 +++ b/loadtools/ltdispatch.c Mon Mar 02 00:21:12 2020 +0000 @@ -17,6 +17,7 @@ extern int cmd_exit(); extern int cmd_flash(); extern int cmd_help(); +extern int cmd_timeout_cal(); extern int loadtool_cmd_passthru(); static struct cmdtab { @@ -42,6 +43,7 @@ {"r8", 1, 1, loadtool_cmd_passthru}, {"r16", 1, 1, loadtool_cmd_passthru}, {"r32", 1, 1, loadtool_cmd_passthru}, + {"timeout-cal", 1, 1, cmd_timeout_cal}, {"w8", 2, 2, loadtool_cmd_passthru}, {"w16", 2, 2, loadtool_cmd_passthru}, {"w32", 2, 2, loadtool_cmd_passthru},
--- a/loadtools/ltmisc.c Sun Mar 01 23:56:35 2020 +0000 +++ b/loadtools/ltmisc.c Mon Mar 02 00:21:12 2020 +0000 @@ -4,6 +4,7 @@ */ #include <sys/types.h> +#include <sys/time.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> @@ -58,3 +59,29 @@ printf("Saved to %s\n", argv[1]); return(0); } + +cmd_timeout_cal(argc, argv) + char **argv; +{ + char *targv[3]; + struct timeval time1, time2, diff; + int rc; + + targv[0] = "sertimeout"; + targv[1] = argv[1]; + targv[2] = 0; + if (tpinterf_make_cmd(argv) < 0) { + fprintf(stderr, "error: unable to form target command\n"); + return(-1); + } + if (tpinterf_send_cmd() < 0) + return(-1); + gettimeofday(&time1, 0); + rc = tpinterf_pass_output(60); + gettimeofday(&time2, 0); + if (rc) + return(rc); + timersub(&time2, &time1, &diff); + printf("%u.%06u s\n", (unsigned) diff.tv_sec, (unsigned) diff.tv_usec); + return(0); +}