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