summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8b652b5)
raw | patch | inline | side by side (parent: 8b652b5)
author | vwan@ti.com <vwan@ti.com> | |
Fri, 21 Feb 2014 22:21:57 +0000 (14:21 -0800) | ||
committer | Chris Ring <cring@ti.com> | |
Sun, 23 Feb 2014 19:27:30 +0000 (11:27 -0800) |
This commit adds a command line parameter to ipc_trace_daemon to set the
polling interval. The default is now set to 0.5 sec as the previous
default was too long. This addresses SDOCM00105472.
Signed-off-by: VW <vwan@ti.com>
polling interval. The default is now set to 0.5 sec as the previous
default was too long. This addresses SDOCM00105472.
Signed-off-by: VW <vwan@ti.com>
qnx/src/ipc3x_dev/ti/syslink/build/Qnx/traceDaemon/IpcTraceDaemon.c | patch | blob | history |
diff --git a/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/traceDaemon/IpcTraceDaemon.c b/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/traceDaemon/IpcTraceDaemon.c
index 22eb1ef764ea38b6632739916e9d62e95eb39ab2..3bb9f248091f76889a39f50f68d3b85b9d8b10e5 100644 (file)
*
* ============================================================================
*
- * Copyright (c) 2010-2013, Texas Instruments Incorporated
+ * Copyright (c) 2010-2014, Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#define TRACE_BUFFER_SIZE 0x8000
-#define TIMEOUT_SECS 1
+/* Default polling interval */
+#define TIMEOUT_USECS 500000
static char traceBuffer[TRACE_BUFFER_SIZE];
+static useconds_t timeout = TIMEOUT_USECS;
static FILE *log;
sem_t semPrint; /* Semaphore to allow only one thread to print at once */
perror ("\nError reading from ipc-trace");
break;
}
- sleep (TIMEOUT_SECS);
+ usleep(timeout);
} while(1);
close(fd);
/** print usage and exit */
static void printUsageExit (char * app)
{
- printf ("%s: [-h] [-l logfile] [-f]\n", app);
+ printf ("%s: [-h] [-l logfile] [-f] [-t interval]\n", app);
printf (" -h show this help message\n");
printf (" -l select file to log to (default stdout)\n");
printf (" -f run in foreground (do not fork daemon process)\n");
+ printf (" -t polling interval in microseconds (default %d)\n",
+ TIMEOUT_USECS);
exit (EXIT_SUCCESS);
}
char * log_file = NULL;
bool daemon = true;
int i;
- struct stat sbuf;
+ struct stat sbuf;
char names[MultiProc_MAXPROCESSORS][_POSIX_PATH_MAX];
+ int c;
/* parse cmd-line args */
- for (i = 1; i < argc; i++) {
- if (!strcmp ("-l", argv[i])) {
- if (++i >= argc)
+ while (1) {
+ c = getopt(argc, argv, "l:fht:");
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 'l':
+ log_file = optarg;
+ break;
+
+ case 'f':
+ daemon = false;
+ break;
+
+ case 'h':
printUsageExit (argv[0]);
- log_file = argv[i];
- } else if (!strcmp ("-f", argv[i])) {
- daemon = false;
- } else if (!strcmp ("-h", argv[i])) {
- printUsageExit (argv[0]);
+ break;
+
+ case 't':
+ timeout = atoi(optarg);
+ printf("Using polling interval of %d us\n", timeout);
+ break;
+
+ default:
+ fprintf (stderr, "Unrecognized argument\n");
+ }
+ }
+
+ if (!log_file) {
+ log = stdout;
+ }
+ else {
+ log = fopen (log_file, "a+");
+ if (log == NULL) {
+ printf("Bad filename specified for log file\n");
+ printUsageExit(argv[0]);
}
}
procmgr_daemon(0, PROCMGR_DAEMON_NOCLOSE|PROCMGR_DAEMON_NODEVNULL);
}
- if (!log_file) {
- log = stdout;
- } else {
- log = fopen (log_file, "a+");
- }
-
sem_init(&semPrint, 0, 1);
for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
snprintf (names[i], _POSIX_PATH_MAX, "/dev/ipc-trace%d", i);