From 89349e7d2190a69cd427acbd7c487d01d8f54797 Mon Sep 17 00:00:00 2001 From: john30 Date: Sun, 25 Jan 2015 19:04:28 +0100 Subject: [PATCH] reworked main loop, switched command line argument parsing to argp --- src/ebusd/main.h | 136 +++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/ebusd/main.h b/src/ebusd/main.h index cac44102..15c55dfe 100644 --- a/src/ebusd/main.h +++ b/src/ebusd/main.h @@ -1,68 +1,68 @@ -/* - * Copyright (C) John Baier 2014-2015 - * - * This file is part of ebusd. - * - * ebusd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ebusd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ebusd. If not, see http://www.gnu.org/licenses/. - */ - -#ifndef MAIN_H_ -#define MAIN_H_ - -#include "result.h" -#include "data.h" -#include "message.h" - -/** \file main.h */ - -/** A structure holding all program options. */ -struct options -{ - const char* device; //!< eBUS device (serial device or ip:port) [/dev/ttyUSB0] - bool noDeviceCheck; //!< skip serial eBUS device test - - const char* configPath; //!< path to CSV configuration files [/etc/ebusd] - bool checkConfig; //!< only check CSV config files, then stop - int pollInterval; //!< poll interval in seconds, 0 to disable [5] - - unsigned char address; //!< own bus address [FF] - bool answer; //!< answer to requests from other masters - int acquireTimeout; //!< bus acquisition timeout in us [9400] - int acquireRetries; //!< number of retries for bus acquisition [2] - int sendRetries; //!< number of retries for failed sends [2] - int receiveTimeout; //!< timeout for receiving answer from slave in us [15000] - int numberMasters; //!< expected number of masters for arbitration [5] - - bool foreground; //!< run in foreground - int port; //!< port to listen for client connections [8888] - bool localhost; //!< listen on 127.0.0.1 interface only - - const char* logFile; //!< log file name [/var/log/ebusd.log] - bool logRaw; //!< log each received/sent byte on the bus - - bool dump; //!< dump received bytes - const char* dumpFile; //!< dump file name [/tmp/ebus_dump.bin] - int dumpSize; //!< maximum size of dump file in kB [100] -}; - -/** - * Load the message definitions from the configuration files. - * @param templates the @a DataFieldTemplates to load the templates into. - * @param messages the @a MessageMap to load the messages into. - * @param verbose whether to verbosely log problems. - * @return the result code. - */ -result_t loadConfigFiles(DataFieldTemplates* templates, MessageMap* messages, bool verbose=false); - -#endif // MAIN_H_ +/* + * Copyright (C) John Baier 2014-2015 + * + * This file is part of ebusd. + * + * ebusd is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ebusd is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ebusd. If not, see http://www.gnu.org/licenses/. + */ + +#ifndef MAIN_H_ +#define MAIN_H_ + +#include "result.h" +#include "data.h" +#include "message.h" + +/** \file main.h */ + +/** A structure holding all program options. */ +struct options +{ + const char* device; //!< eBUS device (serial device or ip:port) [/dev/ttyUSB0] + bool noDeviceCheck; //!< skip serial eBUS device test + + const char* configPath; //!< path to CSV configuration files [/etc/ebusd] + bool checkConfig; //!< only check CSV config files, then stop + int pollInterval; //!< poll interval in seconds, 0 to disable [5] + + unsigned char address; //!< own bus address [FF] + bool answer; //!< answer to requests from other masters + int acquireTimeout; //!< bus acquisition timeout in us [9400] + int acquireRetries; //!< number of retries for bus acquisition [2] + int sendRetries; //!< number of retries for failed sends [2] + int receiveTimeout; //!< timeout for receiving answer from slave in us [15000] + int numberMasters; //!< expected number of masters for arbitration [5] + + bool foreground; //!< run in foreground + int port; //!< port to listen for client connections [8888] + bool localhost; //!< listen on 127.0.0.1 interface only + + const char* logFile; //!< log file name [/var/log/ebusd.log] + bool logRaw; //!< log each received/sent byte on the bus + + bool dump; //!< dump received bytes + const char* dumpFile; //!< dump file name [/tmp/ebus_dump.bin] + int dumpSize; //!< maximum size of dump file in kB [100] +}; + +/** + * Load the message definitions from the configuration files. + * @param templates the @a DataFieldTemplates to load the templates into. + * @param messages the @a MessageMap to load the messages into. + * @param verbose whether to verbosely log problems. + * @return the result code. + */ +result_t loadConfigFiles(DataFieldTemplates* templates, MessageMap* messages, bool verbose=false); + +#endif // MAIN_H_