Merge branch 'master' of git://github.com/yuhu-/ebusd

Conflicts:
	src/ebusctl/ebusctl.cpp
	src/ebusd/Makefile.am
	src/ebusd/baseloop.cpp
	src/ebusd/baseloop.h
	src/ebusd/bushandler.cpp
	src/ebusd/bushandler.h
	src/lib/ebus/message.cpp
	src/lib/ebus/message.h
	src/lib/ebus/port.cpp
	src/lib/ebus/symbol.cpp
	src/lib/ebus/symbol.h
	src/lib/ebus/test/test_data.cpp
	src/lib/ebus/test/test_message.cpp
This commit is contained in:
john30
2014-12-07 15:19:45 +01:00
19 changed files with 433 additions and 592 deletions
+6 -7
View File
@@ -147,20 +147,19 @@ unsigned char Device::getByte()
result_t DeviceSerial::openDevice(const string deviceName, const bool noDeviceCheck)
{
m_noDeviceCheck = noDeviceCheck;
termios newSettings;
struct termios newSettings;
m_open = false;
// open file descriptor from serial device
// open file descriptor
m_fd = open(deviceName.c_str(), O_RDWR | O_NOCTTY);
if (m_fd < 0)
if (m_fd < 0 || isatty(m_fd) == 0)
return RESULT_ERR_NOTFOUND;
// save current settings of serial device
// save current settings
tcgetattr(m_fd, &m_oldSettings);
// create new settings
memset(&newSettings, '\0', sizeof(newSettings));
newSettings.c_cflag |= (B2400 | CS8 | CLOCAL | CREAD);
@@ -176,7 +175,7 @@ result_t DeviceSerial::openDevice(const string deviceName, const bool noDeviceCh
tcflush(m_fd, TCIFLUSH);
// activate new settings of serial device
tcsetattr(m_fd, TCSANOW, &newSettings);
tcsetattr(m_fd, TCSAFLUSH, &newSettings);
// set serial device into blocking mode
fcntl(m_fd, F_SETFL, fcntl(m_fd, F_GETFL) & ~O_NONBLOCK);
+3 -3
View File
@@ -110,13 +110,13 @@ public:
ssize_t sizeRecvBuffer() const { return m_recvBuffer.size(); }
protected:
/** if of file descriptor */
/** file descriptor from input device */
int m_fd;
/** state of device*/
/** true if device is opened */
bool m_open;
/** state of device check */
/** true if device check is disabled */
bool m_noDeviceCheck;
/** queue for received bytes */
+17 -19
View File
@@ -24,9 +24,9 @@
using namespace std;
Appl& Appl::Instance(const bool command)
Appl& Appl::Instance(const bool command, const bool argument)
{
static Appl instance(command);
static Appl instance(command, argument);
return instance;
}
@@ -107,22 +107,17 @@ void Appl::parseArgs(int argc, char* argv[])
}
// check command
if (m_needCommand == true) {
for (int i = 1; i < argc; i++) {
for (int i = 1; i < argc; i++) {
if (_argv[i].rfind("-", 0) != string::npos) {
i++;
continue;
}
if (_argv[i].rfind("-", 0) != string::npos) {
i++;
continue;
}
if (m_command.size() == 0)
m_command = _argv[i];
else
m_arguments.push_back(_argv[i]);
}
if (m_arguments.size() == 0) {
cerr << endl << "command needed" << endl;
printHelp();
}
}
}
bool Appl::checkOption(const string& option, const string& value)
@@ -130,7 +125,7 @@ bool Appl::checkOption(const string& option, const string& value)
if (strcmp(option.c_str(), "settings") == 0)
printSettings();
if (strcmp(option.c_str(), "v") == 0 || strcmp(option.c_str(), "version") == 0)
if (strcmp(option.c_str(), "version") == 0)
printVersion();
if (strcmp(option.c_str(), "h") == 0 || strcmp(option.c_str(), "help") == 0)
@@ -196,8 +191,11 @@ void Appl::printHelp()
cerr << endl << "Usage:" << endl << " "
<< m_argv[0].substr(m_argv[0].find_last_of("/\\") + 1) << " [OPTIONS...]" ;
if (m_needCommand == true)
cerr << " COMMAND {ARGS...}" << endl << endl;
if (m_withCommand == true)
if (m_withArgument == true)
cerr << " COMMAND {ARGS...}" << endl << endl;
else
cerr << " COMMAND" << endl << endl;
else
cerr << endl << endl;
@@ -213,7 +211,7 @@ void Appl::printHelp()
}
}
cerr << " | --settings\n-v | --version\n-h | --help" << endl << endl;
cerr << endl << " | --settings\n | --version\n-h | --help" << endl << endl;
exit(EXIT_SUCCESS);
}
+47 -9
View File
@@ -118,9 +118,10 @@ public:
/**
* @brief create an instance and return the reference.
* @param command is true if an command is needed.
* @param argument is true if command could have an argument.
* @return the reference to instance.
*/
static Appl& Instance(const bool command=false);
static Appl& Instance(const bool command=false, const bool argument=false);
/**
* @brief destructor.
@@ -175,26 +176,57 @@ public:
* @return number of commands and arguments.
*/
int numArgs() const { return m_arguments.size(); }
/**
* @brief returns the string of an interested argument (0 = command).
* @brief returns the string of an interested argument.
* @param num number of interested argument.
* @return string value.
* @return the argument string.
*/
string getArg(const int num) const { return m_arguments[num]; }
/**
* @brief returns the string of given command.
* @return the command string.
*/
string getCommand() const { return m_command; }
/**
* @brief returns the string of given command.
* @return the command string.
*/
bool missingCommand() const { return (m_command.size() == 0 ? true : false); }
private:
/** private constructor - singleton pattern */
Appl(const bool command) : m_needCommand(command) {}
/**
* @brief private construtor.
* @param command is true if an command is needed.
* @param argument is true if command could have an argument.
*/
Appl(const bool command, const bool argument)
: m_withCommand(command), m_withArgument(argument) {}
/**
* @brief private copy construtor.
* @param reference to an instance.
*/
Appl(const Appl&);
/**
* @brief private = operator.
* @param reference to an instance.
* @return reference to instance.
*/
Appl& operator=(const Appl&);
/** application options */
vector<opt_t> m_opts;
/** application options iterator */
vector<opt_t>::const_iterator o_it;
/** map option - value */
map<const char*, OptVal> m_optvals;
/** map option - value iterator */
map<const char*, OptVal>::iterator ov_it;
/** given arguments */
@@ -203,10 +235,16 @@ private:
/** application version string */
const char* m_version;
/** true if the application need a command */
bool m_needCommand;
/** true if the application could have a command */
bool m_withCommand;
/** arguments (argument 0 = command) string */
/** true if the command could have an argument */
bool m_withArgument;
/** command (argument 0 = command) string */
string m_command;
/** arguments (argument >= 1) string */
vector<string> m_arguments;
/**
+14 -1
View File
@@ -51,9 +51,22 @@ public:
bool status() { return m_status; }
private:
/** private constructor - singleton pattern */
/**
* @brief private construtor.
*/
Daemon() {}
/**
* @brief private copy construtor.
* @param reference to an instance.
*/
Daemon(const Daemon&);
/**
* @brief private = operator.
* @param reference to an instance.
* @return reference to instance.
*/
Daemon& operator=(const Daemon&);
/** status of process; true if we are a daemon */
+16 -1
View File
@@ -302,13 +302,28 @@ public:
virtual void stop();
private:
/** private constructor - singleton pattern */
/**
* @brief private construtor.
*/
Logger() {}
/**
* @brief private copy construtor.
* @param reference to an instance.
*/
Logger(const Logger&);
/**
* @brief private = operator.
* @param reference to an instance.
* @return reference to instance.
*/
Logger& operator=(const Logger&);
/** typedefs for a vector of type LogSink* */
typedef vector<LogSink*> sink_t;
/** typedefs for a vector of type LogSink* iterator */
typedef vector<LogSink*>::iterator sinkCI_t;
/** vector of available logging sinks */
+3 -1
View File
@@ -32,8 +32,10 @@ class TCPSocket
{
public:
/** grant access for friend classes */
/** grant access for friend class TCPClient */
friend class TCPClient;
/** grant access for friend class TCPServer */
friend class TCPServer;
/**