diff --git a/ChangeLog b/ChangeLog index e3db988d..06794316 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ ebus Daemon (ebusd) - ChangeLog =============================== +2013-11-29: +* New daemon option nodevicecheck added. + 2013-11-19: * Data type of struct commands.s_type changed from integer to char[2]. Possible data types are: BR, MM, MS. (BroadCast, MasterMaster, MasterSlave) diff --git a/contrib/etc/ebusd/ebusd.conf b/contrib/etc/ebusd/ebusd.conf index 0b0f5145..59b12c17 100644 --- a/contrib/etc/ebusd/ebusd.conf +++ b/contrib/etc/ebusd/ebusd.conf @@ -21,6 +21,9 @@ # log file (/var/log/ebusd.log) #logfile=/var/log/ebusd.log +# don't check serial device (NO | YES/NO) +#nodevicecheck=YES + # pid file (/var/run/ebusd.pid) #pidfile=/var/run/ebusd.pid diff --git a/lib/ebus-bus.c b/lib/ebus-bus.c index f194faa0..3a783b3c 100644 --- a/lib/ebus-bus.c +++ b/lib/ebus-bus.c @@ -52,6 +52,7 @@ static struct send_data send_data; static struct recv_data recv_data; +static int nodevicecheck = NO; static int rawdump = NO; static int showraw = NO; @@ -74,6 +75,14 @@ static FILE *rawfp = NULL; + + +void +eb_set_nodevicecheck(int check) +{ + nodevicecheck = check; +} + void eb_set_rawdump(int dump) { @@ -185,7 +194,7 @@ eb_serial_valid() { int serial; - if (ioctl(sfd, TIOCMGET, &serial) < 0) + if (ioctl(sfd, TIOCMGET, &serial) < 0 && nodevicecheck == NO) return -1; else return 0; diff --git a/lib/ebus-bus.h b/lib/ebus-bus.h index feb9c982..b1bfa7a9 100644 --- a/lib/ebus-bus.h +++ b/lib/ebus-bus.h @@ -64,6 +64,15 @@ struct recv_data { + + +/** + * @brief set nodevicecheck + * @param [in] YES | NO + * @return none + */ +void eb_set_nodevicecheck(int check); + /** * @brief set rawdump * @param [in] YES | NO diff --git a/src/ebusd.c b/src/ebusd.c index f6c85388..03ef1ff0 100644 --- a/src/ebusd.c +++ b/src/ebusd.c @@ -60,6 +60,7 @@ static char extension[10]; static int foreground = UNSET; static char loglevel[CFG_LINELEN]; static char logfile[CFG_LINELEN]; +static int nodevicecheck = UNSET; static char pidfile[CFG_LINELEN]; static int port = UNSET; static int rawdump = UNSET; @@ -78,50 +79,52 @@ static int print_size = UNSET; static char options[] = "a:c:C:d:e:fl:L:P:p:rR:sStvh"; static struct option opts[] = { - {"address", required_argument, NULL, 'a'}, - {"cfgfdir", required_argument, NULL, 'c'}, - {"cfgfile", required_argument, NULL, 'C'}, - {"device", required_argument, NULL, 'd'}, - {"extension", required_argument, NULL, 'e'}, - {"foreground", no_argument, NULL, 'f'}, - {"loglevel", required_argument, NULL, 'l'}, - {"logfile", required_argument, NULL, 'L'}, - {"pidfile", required_argument, NULL, 'P'}, - {"port", required_argument, NULL, 'p'}, - {"rawdump", no_argument, NULL, 'r'}, - {"rawfile", required_argument, NULL, 'R'}, - {"showraw", no_argument, NULL, 's'}, - {"settings", no_argument, NULL, 'S'}, - {"localhost", no_argument, NULL, 't'}, - {"version", no_argument, NULL, 'v'}, - {"help", no_argument, NULL, 'h'}, - {NULL, no_argument, NULL, 0 }, + {"address", required_argument, NULL, 'a'}, + {"cfgfdir", required_argument, NULL, 'c'}, + {"cfgfile", required_argument, NULL, 'C'}, + {"device", required_argument, NULL, 'd'}, + {"extension", required_argument, NULL, 'e'}, + {"foreground", no_argument, NULL, 'f'}, + {"loglevel", required_argument, NULL, 'l'}, + {"logfile", required_argument, NULL, 'L'}, + {"nodevicecheck", no_argument, NULL, 'n'}, + {"pidfile", required_argument, NULL, 'P'}, + {"port", required_argument, NULL, 'p'}, + {"rawdump", no_argument, NULL, 'r'}, + {"rawfile", required_argument, NULL, 'R'}, + {"showraw", no_argument, NULL, 's'}, + {"settings", no_argument, NULL, 'S'}, + {"localhost", no_argument, NULL, 't'}, + {"version", no_argument, NULL, 'v'}, + {"help", no_argument, NULL, 'h'}, + {NULL, no_argument, NULL, 0 }, }; static struct config cfg[] = { -{"address", STR, &address, "\tbus address (" NUMSTR(EBUS_QQ) ")"}, -{"cfgdir", STR, &cfgdir, "\tconfiguration directory of command files (" DAEMON_CFGDIR ")"}, -{"cfgfile", STR, &cfgfile, "\tdaemon configuration file (" DAEMON_CFGFILE ")"}, -{"device", STR, &device, "\tserial device (" SERIAL_DEVICE ")"}, -{"extension", STR, &extension, "extension of command files (" DAEMON_EXTENSION ")"}, -{"foreground", BOL, &foreground, "run in foreground"}, -{"loglevel", STR, &loglevel, "\tlog level (INF | " LOGTXT ")"}, -{"logfile", STR, &logfile, "\tlog file (" DAEMON_LOGFILE ")"}, -{"pidfile", STR, &pidfile, "\tpid file (" DAEMON_PIDFILE ")"}, -{"port", NUM, &port, "\tport (" NUMSTR(SOCKET_PORT) ")"}, -{"rawdump", BOL, &rawdump, "\tdump raw ebus data to file"}, -{"rawfile", STR, &rawfile, "\traw file (" DAEMON_RAWFILE ")"}, -{"showraw", BOL, &showraw, "\tprint raw data"}, -{"settings", BOL, &settings, "\tprint daemon settings"}, -{"localhost", BOL, &localhost, "allow only connection from localhost"}, -{"get_retry", NUM, &get_retry, NULL}, -{"skip_ack", NUM, &skip_ack, NULL}, -{"max_wait", NUM, &max_wait, NULL}, -{"send_retry", NUM, &send_retry, NULL}, -{"print_size", NUM, &print_size, NULL}, -{"version", STR, NULL, "\tprint version information"}, -{"help", STR, NULL, "\tprint this message"} +{"address", STR, &address, "\tbus address (" NUMSTR(EBUS_QQ) ")"}, +{"cfgdir", STR, &cfgdir, "\tconfiguration directory of command files (" DAEMON_CFGDIR ")"}, +{"cfgfile", STR, &cfgfile, "\tdaemon configuration file (" DAEMON_CFGFILE ")"}, +{"device", STR, &device, "\tserial device (" SERIAL_DEVICE ")"}, +{"extension", STR, &extension, "extension of command files (" DAEMON_EXTENSION ")"}, +{"foreground", BOL, &foreground, "run in foreground"}, +{"loglevel", STR, &loglevel, "\tlog level (INF | " LOGTXT ")"}, +{"logfile", STR, &logfile, "\tlog file (" DAEMON_LOGFILE ")"}, +{"nodevicecheck", BOL, &nodevicecheck, "don't check serial device"}, +{"pidfile", STR, &pidfile, "\tpid file (" DAEMON_PIDFILE ")"}, +{"port", NUM, &port, "\tport (" NUMSTR(SOCKET_PORT) ")"}, +{"rawdump", BOL, &rawdump, "\tdump raw ebus data to file"}, +{"rawfile", STR, &rawfile, "\traw file (" DAEMON_RAWFILE ")"}, +{"showraw", BOL, &showraw, "\tprint raw data"}, +{"settings", BOL, &settings, "\tprint daemon settings"}, +{"localhost", BOL, &localhost, "allow only connection from localhost"}, +{"get_retry", NUM, &get_retry, NULL}, +{"skip_ack", NUM, &skip_ack, NULL}, +{"max_wait", NUM, &max_wait, NULL}, +{"send_retry", NUM, &send_retry, NULL}, +{"print_size", NUM, &print_size, NULL}, +{"version", STR, NULL, "\tprint version information"}, +{"help", STR, NULL, "\tprint this message"} }; const int cfglen = sizeof(cfg) / sizeof(cfg[0]); @@ -189,6 +192,9 @@ cmdline(int *argc, char ***argv) case 'L': strncpy(logfile, optarg, strlen(optarg)); break; + case 'n': + nodevicecheck = YES; + break; case 'P': strncpy(pidfile, optarg, strlen(optarg)); break; @@ -250,6 +256,9 @@ set_unset(void) if (*logfile == '\0') strncpy(logfile , DAEMON_LOGFILE, strlen(DAEMON_LOGFILE)); + if (nodevicecheck == UNSET) + nodevicecheck = NO; + if (*pidfile == '\0') strncpy(pidfile , DAEMON_PIDFILE, strlen(DAEMON_PIDFILE)); @@ -669,6 +678,7 @@ main(int argc, char *argv[]) /* set ebus configuration */ + eb_set_nodevicecheck(nodevicecheck); eb_set_rawdump(rawdump); eb_set_showraw(showraw); diff --git a/src/ebusd.h b/src/ebusd.h index 04a844b4..5dc67eb6 100644 --- a/src/ebusd.h +++ b/src/ebusd.h @@ -28,13 +28,10 @@ #define DAEMON_CFGDIR "/etc/ebusd" #define DAEMON_CFGFILE DAEMON_CFGDIR"/ebusd.conf" #define DAEMON_EXTENSION "csv" -#define DAEMON_FOREGROUND NO #define DAEMON_LOGLEVEL "INF" #define DAEMON_LOGFILE "/var/log/ebusd.log" -#define DAEMON_NOSYN NO #define DAEMON_PIDFILE "/var/run/ebusd.pid" #define DAEMON_RAWFILE "/tmp/ebusd.bin" -#define DAEMON_RAWDUMP NO void usage(void);