summaryrefslogtreecommitdiff
path: root/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'options.c')
-rw-r--r--options.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/options.c b/options.c
index 358766e..d4f05f3 100644
--- a/options.c
+++ b/options.c
@@ -192,6 +192,10 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-d","--device", opt->serial_dev_)
PARSE_STRING_PARAM("-t","--type", opt->type_)
#endif
+#ifdef OPT_HEARTBEATCLIENT
+ PARSE_STRING_PARAM("-d","--device", opt->serial_dev_)
+ PARSE_INT_PARAM("-t","--timeout", opt->timeout_)
+#endif
else
return i;
}
@@ -290,6 +294,9 @@ void options_default(options_t* opt)
#ifdef OPT_STDIOCLIENT
opt->progname_ = strdup("stdioclient");
#endif
+#ifdef OPT_HEARTBEATCLIENT
+ opt->progname_ = strdup("heartbeatclient");
+#endif
/* common */
opt->daemonize_ = 1;
@@ -309,9 +316,14 @@ void options_default(options_t* opt)
opt->switch_dev_ = strdup("/dev/audioswitch");
key_value_storage_init(&opt->alias_table_);
-/* serialclient */
+/* serialclient and heartbeatclient */
opt->serial_dev_ = strdup("/dev/ttyUSB0");
+
+/* serialclient only */
opt->type_ = NULL;
+
+/* heartbeatclient only */
+ opt->timeout_ = 15;
}
void options_clear(options_t* opt)
@@ -342,9 +354,11 @@ void options_clear(options_t* opt)
free(opt->switch_dev_);
key_value_storage_clear(&opt->alias_table_);
-/* serialclient */
+/* serialclient and heartbeatclient */
if(opt->serial_dev_)
free(opt->serial_dev_);
+
+/* serialclient only */
if(opt->type_)
free(opt->type_);
}
@@ -361,6 +375,9 @@ void options_print_usage()
#ifdef OPT_STDIOCLIENT
printf("serialclient\n");
#endif
+#ifdef OPT_HEARTBEATCLIENT
+ printf("heartbeatclient\n");
+#endif
printf(" [-h|--help] prints this...\n");
#ifndef OPT_STDIOCLIENT
printf(" [-D|--nodaemonize] don't run in background\n");
@@ -385,6 +402,10 @@ void options_print_usage()
printf(" [-d|--device] <tty> the tty to connect to e.g. /dev/ttyUSB0\n");
printf(" [-t|--type] <type> use this client type\n");
#endif
+#ifdef OPT_HEARTBEATCLIENT
+ printf(" [-d|--device] <tty> the tty to connect to e.g. /dev/ttyUSB0\n");
+ printf(" [-t|--timeout] <timeout> heartbeat timeout in tenths of a second e.g. 15 -> 1.5s\n");
+#endif
}
void options_print(options_t* opt)
@@ -434,4 +455,9 @@ void options_print(options_t* opt)
printf("serial_dev: '%s'\n", opt->serial_dev_);
printf("type: '%s'\n", opt->type_);
#endif
+
+#ifdef OPT_HEARTBEATCLIENT
+ printf("serial_dev: '%s'\n", opt->serial_dev_);
+ printf("timeout: %d\m", opt->timeout_);
+#endif
}