summaryrefslogtreecommitdiff
path: root/options.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2009-11-14 00:16:16 (GMT)
committerChristian Pointner <equinox@helsinki.at>2009-11-14 00:16:16 (GMT)
commita5e4a809402eb929e55072573a176d8c2ed44712 (patch)
tree88ada41b94d9a74949202bcce4c839cc63d6ab8b /options.c
parentdf4967d2f9d158711038c054aa0edf543d21e8d3 (diff)
added baudrate parameter
Diffstat (limited to 'options.c')
-rw-r--r--options.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/options.c b/options.c
index 5d652a9..020e0f0 100644
--- a/options.c
+++ b/options.c
@@ -160,6 +160,7 @@ int options_parse(options_t* opt, int argc, char* argv[])
char* mode = NULL;
char* channel = NULL;
+ char* baudrate = NULL;
int i;
for(i=1; argc > 0; ++i)
@@ -176,6 +177,7 @@ 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_STRING_PARAM("-s","--socket", opt->command_sock_)
+ PARSE_STRING_PARAM("-b","--baudrate", baudrate)
#ifdef OPT_SWITCHCTL
PARSE_STRING_PARAM("-f","--config", opt->conf_file_)
PARSE_STRING_PARAM("-d","--device", opt->switch_dev_)
@@ -214,6 +216,22 @@ int options_parse(options_t* opt, int argc, char* argv[])
free(channel);
}
+ if(baudrate) {
+ int b = atoi(baudrate);
+ free(baudrate);
+ switch(b) {
+ case 1200: opt->baudrate_ = B1200; break;
+ case 2400: opt->baudrate_ = B2400; break;
+ case 4800: opt->baudrate_ = B4800; break;
+ case 9600: opt->baudrate_ = B9600; break;
+ case 19200: opt->baudrate_ = B19200; break;
+ case 38400: opt->baudrate_ = B38400; break;
+ case 57600: opt->baudrate_ = B57600; break;
+ case 115200: opt->baudrate_ = B115200; break;
+ default: return -5;
+ }
+ }
+
return 0;
}
@@ -275,6 +293,7 @@ void options_default(options_t* opt)
string_list_init(&opt->log_targets_);
opt->command_sock_ = strdup("/var/run/rhctl/switchctl.sock");
+ opt->baudrate_ = B19200;
/* switchctl */
opt->mode_ = MODE_MASTER;
@@ -341,9 +360,10 @@ void options_print_usage()
printf(" [-L|--log] <target>:<level>[,<param1>[,<param2>..]]\n");
printf(" add a log target, can be invoked several times\n");
printf(" [-s|--command-sock] <unix sock> the command socket e.g. /var/run/rhctl/switchctl.sock\n");
+ printf(" [-b|--baudrate] <baudrate> the baudrate of the tty to use e.g. 19200\n");
#ifdef OPT_SWITCHCTL
- printf(" [-f|--config] <file> the configuration file e.g. /etc/rhctl/switchctl.conf\n");
printf(" [-d|--device] <tty> the tty the audio switch is connected to e.g. /dev/audioswitch\n");
+ printf(" [-f|--config] <file> the configuration file e.g. /etc/rhctl/switchctl.conf\n");
printf(" [-m|--mode] <mode> the initial mode to use e.g. master\n");
printf(" [-c|--channel] <channel> the initial channel to use e.g. main\n");
#endif
@@ -369,6 +389,20 @@ void options_print(options_t* opt)
printf("command_sock: '%s'\n", opt->command_sock_);
+ char* br;
+ switch(opt->baudrate_) {
+ case B1200: br = "1200"; break;
+ case B2400: br = "2400"; break;
+ case B4800: br = "4800"; break;
+ case B9600: br = "9600"; break;
+ case B19200: br = "19200"; break;
+ case B38400: br = "38400"; break;
+ case B57600: br = "57600"; break;
+ case B115200: br = "115200"; break;
+ default: br = "invalid"; break;
+ }
+ printf("baudrate: '%s'\n", br);
+
#ifdef OPT_SWITCHCTL
printf("mode: '%s'\n", opt->mode_ == MODE_MASTER ? "master" : "standby");
printf("channel: '%s'\n", opt->channel_ == CHAN_MAIN ? "main" : "music");