comparison loadtools/ltmisc.c @ 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 5385aca4d813
children dfe6ba3611cd
comparison
equal deleted inserted replaced
645:880c6d31e487 646:0d199c6a6ea4
2 * This module is a place to implement little miscellaneous fc-loadtool 2 * This module is a place to implement little miscellaneous fc-loadtool
3 * commands which don't belong anywhere else. 3 * commands which don't belong anywhere else.
4 */ 4 */
5 5
6 #include <sys/types.h> 6 #include <sys/types.h>
7 #include <sys/time.h>
7 #include <stdio.h> 8 #include <stdio.h>
8 #include <stdint.h> 9 #include <stdint.h>
9 #include <stdlib.h> 10 #include <stdlib.h>
10 11
11 cmd_crc32(argc, argv) 12 cmd_crc32(argc, argv)
56 fprintf(of, "%08lX: %04X\n", (u_long)addrs[i], (int)data[i]); 57 fprintf(of, "%08lX: %04X\n", (u_long)addrs[i], (int)data[i]);
57 fclose(of); 58 fclose(of);
58 printf("Saved to %s\n", argv[1]); 59 printf("Saved to %s\n", argv[1]);
59 return(0); 60 return(0);
60 } 61 }
62
63 cmd_timeout_cal(argc, argv)
64 char **argv;
65 {
66 char *targv[3];
67 struct timeval time1, time2, diff;
68 int rc;
69
70 targv[0] = "sertimeout";
71 targv[1] = argv[1];
72 targv[2] = 0;
73 if (tpinterf_make_cmd(argv) < 0) {
74 fprintf(stderr, "error: unable to form target command\n");
75 return(-1);
76 }
77 if (tpinterf_send_cmd() < 0)
78 return(-1);
79 gettimeofday(&time1, 0);
80 rc = tpinterf_pass_output(60);
81 gettimeofday(&time2, 0);
82 if (rc)
83 return(rc);
84 timersub(&time2, &time1, &diff);
85 printf("%u.%06u s\n", (unsigned) diff.tv_sec, (unsigned) diff.tv_usec);
86 return(0);
87 }