New daemon option nodevicecheck added.

This commit is contained in:
Roland Jax
2013-11-29 15:03:07 +01:00
parent 35f980d4e6
commit 11aa98c4fa
6 changed files with 75 additions and 44 deletions
+3
View File
@@ -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)
+3
View File
@@ -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
View File
@@ -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;
+9
View File
@@ -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
+10
View File
@@ -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;
@@ -86,6 +87,7 @@ static struct option opts[] = {
{"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'},
{"nodevicecheck", no_argument, NULL, 'n'},
{"pidfile", required_argument, NULL, 'P'}, {"pidfile", required_argument, NULL, 'P'},
{"port", required_argument, NULL, 'p'}, {"port", required_argument, NULL, 'p'},
{"rawdump", no_argument, NULL, 'r'}, {"rawdump", no_argument, NULL, 'r'},
@@ -108,6 +110,7 @@ static struct config cfg[] = {
{"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 ")"},
{"nodevicecheck", BOL, &nodevicecheck, "don't check serial device"},
{"pidfile", STR, &pidfile, "\tpid file (" DAEMON_PIDFILE ")"}, {"pidfile", STR, &pidfile, "\tpid file (" DAEMON_PIDFILE ")"},
{"port", NUM, &port, "\tport (" NUMSTR(SOCKET_PORT) ")"}, {"port", NUM, &port, "\tport (" NUMSTR(SOCKET_PORT) ")"},
{"rawdump", BOL, &rawdump, "\tdump raw ebus data to file"}, {"rawdump", BOL, &rawdump, "\tdump raw ebus data to file"},
@@ -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);
-3
View File
@@ -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);