summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/gcsd.818
-rw-r--r--doc/gcsd.8.txt21
-rw-r--r--src/main_loop.lua5
-rw-r--r--src/options.c34
-rw-r--r--src/options.h4
5 files changed, 77 insertions, 5 deletions
diff --git a/doc/gcsd.8 b/doc/gcsd.8
index c8daef6..ed03733 100644
--- a/doc/gcsd.8
+++ b/doc/gcsd.8
@@ -32,6 +32,8 @@ gcsd \- generic command sequencer damon
[ \fB\-P|\-\-write\-pid\fR <filename> ]
[ \fB\-L|\-\-log\fR <target>:<level>[,<param1>[,<param2>[\&.\&.]]] ]
[ \fB\-U|\-\-debug\fR ]
+ [ \fB\-o|\-\-output\fR <module>:[<param1>[,<param2>[,<param3>[\&.\&.]]]] ]
+ [ \fB\-i|\-\-input\fR <module>:[<param1>[,<param2>[,<param3>[\&.\&.]]]] ]
.fi
.SH "DESCRIPTION"
.sp
@@ -112,6 +114,22 @@ to run in debug mode\&. It implicits
\fBstdout:5\fR
(logging with maximum level)\&. In future releases there might be additional output when this option is supplied\&.
.RE
+.PP
+\fB\-o, \-\-output <module>:[<param1>[,<param2>[,<param3>[\&.\&.]]]]\fR
+.RS 4
+set and configure the command output module\&. See Modules section for further information on which modules exist and how they can be configured\&. By default the output module is set to
+\fBserial:/dev/ttyS0,9600,8n1\fR
+.RE
+.PP
+\fB\-o, \-\-input <module>:[<param1>[,<param2>[,<param3>[\&.\&.]]]]\fR
+.RS 4
+set and configure command input modules\&. This can be invoked several times\&. gcsd will use all input modules in paralell\&. See Modules section for further information on which modules exist and how they can be configured\&. By default a single input module with the config
+\fBunix:/var/run/gcsd\&.sock,660\fR
+is used\&.
+.RE
+.SH "MODULES"
+.sp
+tba
.SH "EXAMPLES"
.sp
nothing yet\&.\&.
diff --git a/doc/gcsd.8.txt b/doc/gcsd.8.txt
index a76a93d..39181d7 100644
--- a/doc/gcsd.8.txt
+++ b/doc/gcsd.8.txt
@@ -4,7 +4,7 @@ gcsd(8)
NAME
----
-gcsd - generic command sequencer damon
+gcsd - generic command sequencer daemon
SYNOPSIS
@@ -20,6 +20,9 @@ gcsd
[ -P|--write-pid <filename> ]
[ -L|--log <target>:<level>[,<param1>[,<param2>[..]]] ]
[ -U|--debug ]
+ [ -o|--output <module>:[<param1>[,<param2>[,<param3>[..]]]] ]
+ [ -i|--input <module>:[<param1>[,<param2>[,<param3>[..]]]] ]
+
....
@@ -82,6 +85,22 @@ The following options can be passed to the *gcsd* daemon:
*stdout:5* (logging with maximum level). In future releases there might
be additional output when this option is supplied.
+*-o, --output <module>:[<param1>[,<param2>[,<param3>[..]]]]*::
+ set and configure the command output module. See Modules section for further
+ information on which modules exist and how they can be configured. By default
+ the output module is set to *serial:/dev/ttyS0,9600,8n1*
+
+*-i, --input <module>:[<param1>[,<param2>[,<param3>[..]]]]*::
+ set and configure command input modules. This can be invoked several times.
+ gcsd will use all input modules in paralell. See Modules section for further
+ information on which modules exist and how they can be configured. By default
+ a single input module with the config *unix:/var/run/gcsd.sock,660* is used.
+
+
+Modules
+-------
+tba
+
EXAMPLES
--------
diff --git a/src/main_loop.lua b/src/main_loop.lua
index 6501ad2..95749af 100644
--- a/src/main_loop.lua
+++ b/src/main_loop.lua
@@ -36,6 +36,11 @@ function main_loop(opt)
log.printf(log.NOTICE, "main_loop started")
local sig = signal.init()
+ log.printf(log.DEBUG, "gcsd output = %s", opt.cmd_out)
+ for idx, input in ipairs(opt.cmd_ins) do
+ log.printf(log.DEBUG, "gcsd input[%d] = %s", idx, input)
+ end
+
if(opt.debug) then
local ret = debug_shell.init("localhost", 9000)
if(ret == nil) then return -1 end
diff --git a/src/options.c b/src/options.c
index ba84805..a475510 100644
--- a/src/options.c
+++ b/src/options.c
@@ -186,6 +186,8 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-P","--write-pid", opt->pid_file_)
PARSE_STRING_LIST("-L","--log", opt->log_targets_)
PARSE_BOOL_PARAM("-U", "--debug", opt->debug_)
+ PARSE_STRING_PARAM("-o","--output", opt->cmd_out_)
+ PARSE_STRING_LIST("-i","--input", opt->cmd_ins_)
else
return i;
}
@@ -203,6 +205,14 @@ int options_parse(options_t* opt, int argc, char* argv[])
#endif
}
+ if(!opt->cmd_ins_.first_) {
+#ifndef WINVER
+ string_list_add(&opt->cmd_ins_, "unix:/var/run/gcsd.sock,660");
+#else
+ string_list_add(&opt->cmd_ins_, "tcp:127.0.0.1,1234");
+#endif
+ }
+
return 0;
}
@@ -226,6 +236,12 @@ void options_default(options_t* opt)
opt->chroot_dir_ = NULL;
opt->pid_file_ = NULL;
string_list_init(&opt->log_targets_);
+#ifndef WINVER
+ opt->cmd_out_ = strdup("serial:/dev/ttyS0,9600,8n1");
+#else
+ opt->cmd_out_ = strdup("serial:COM0,9600,8n1");
+#endif
+ string_list_init(&opt->cmd_ins_);
opt->debug_ = 0;
}
@@ -250,14 +266,14 @@ void options_lua_push_boolean(lua_State* L, const int tidx, const char* key, con
lua_settable(L, tidx);
}
-void options_lua_push_string_list(lua_State* L, const int tidx, string_list_t* lst)
+void options_lua_push_string_list(lua_State* L, const int tidx, const char* name, string_list_t* lst)
{
if(!lst)
return;
string_list_element_t* tmp = lst->first_;
if(tmp) {
- lua_pushstring(L, "log_targets");
+ lua_pushstring(L, name);
lua_newtable(L);
int i = 1;
while(tmp) {
@@ -280,8 +296,10 @@ void options_lua_push(options_t* opt, lua_State* L)
options_lua_push_string(L, -3, "groupname", opt->groupname_);
options_lua_push_string(L, -3, "chroot_dir", opt->chroot_dir_);
options_lua_push_string(L, -3, "pid_file", opt->pid_file_);
- options_lua_push_string_list(L, -3, &(opt->log_targets_));
+ options_lua_push_string_list(L, -3, "log_targets", &(opt->log_targets_));
options_lua_push_boolean(L, -3, "debug", opt->debug_);
+ options_lua_push_string(L, -3, "cmd_out", opt->cmd_out_);
+ options_lua_push_string_list(L, -3, "cmd_ins", &(opt->cmd_ins_));
}
void options_clear(options_t* opt)
@@ -300,6 +318,9 @@ void options_clear(options_t* opt)
if(opt->pid_file_)
free(opt->pid_file_);
string_list_clear(&opt->log_targets_);
+ if(opt->cmd_out_)
+ free(opt->cmd_out_);
+ string_list_clear(&opt->cmd_ins_);
}
void options_print_usage()
@@ -314,6 +335,10 @@ void options_print_usage()
printf(" [-P|--write-pid] <path> write pid to this file\n");
printf(" [-L|--log] <target>:<level>[,<param1>[,<param2>..]]\n");
printf(" add a log target, can be invoked several times\n");
+ printf(" [-o|--output] <module>:[<param1>[,<param2>[,<param3>[..]]]]\n");
+ printf(" use this as the output module");
+ printf(" [-i|--input] <module>:[<param1>[,<param2>[,<param3>[..]]]]\n");
+ printf(" add a command input module, can be invoked several times\n");
printf(" [-U|--debug] don't daemonize and log to stdout with maximum log level\n");
}
@@ -336,5 +361,8 @@ void options_print(options_t* opt)
printf("pid_file: '%s'\n", opt->pid_file_);
printf("log_targets: \n");
string_list_print(&opt->log_targets_, " '", "'\n");
+ printf("cmd_out: '%s'\n", opt->cmd_out_);
+ printf("cmd_ins: \n");
+ string_list_print(&opt->cmd_ins_, " '", "'\n");
printf("debug: %s\n", !opt->debug_ ? "false" : "true");
}
diff --git a/src/options.h b/src/options.h
index 9beb2bf..447f1f0 100644
--- a/src/options.h
+++ b/src/options.h
@@ -47,6 +47,8 @@ struct options_struct {
char* pid_file_;
string_list_t log_targets_;
int debug_;
+ char* cmd_out_;
+ string_list_t cmd_ins_;
};
typedef struct options_struct options_t;
@@ -58,7 +60,7 @@ void options_default(options_t* opt);
void options_lua_push_string(lua_State* L, const int tidx, const char* key, const char* value);
void options_lua_push_int(lua_State* L, const int tidx, const char* key, const uint32_t value);
void options_lua_push_boolean(lua_State* L, const int tidx, const char* key, const uint32_t value);
-void options_lua_push_string_list(lua_State* L, const int tidx, string_list_t* lst);
+void options_lua_push_string_list(lua_State* L, const int tidx, const char* name, string_list_t* lst);
void options_lua_push(options_t* opt, lua_State* L);
void options_clear(options_t* opt);
void options_print_usage();