diff --git a/src/ebusd/bushandler.cpp b/src/ebusd/bushandler.cpp index 94da903d..76d90434 100644 --- a/src/ebusd/bushandler.cpp +++ b/src/ebusd/bushandler.cpp @@ -45,8 +45,7 @@ using namespace std; * @return the string corresponding to the @a BusState. */ const char* getStateCode(BusState state) { - switch (state) - { + switch (state) { case bs_noSignal: return "no signal"; case bs_skip: return "skip"; case bs_ready: return "ready"; @@ -322,8 +321,7 @@ result_t BusHandler::handleSymbol() { BusRequest* startRequest = NULL; // check if another symbol has to be sent and determine timeout for receive - switch (m_state) - { + switch (m_state) { case bs_noSignal: timeout = m_generateSynInterval > 0 ? m_generateSynInterval : SIGNAL_TIMEOUT; break; @@ -489,8 +487,7 @@ result_t BusHandler::handleSymbol() { unsigned int headerLen, crcPos; - switch (m_state) - { + switch (m_state) { case bs_noSignal: return setState(bs_skip, RESULT_OK); @@ -728,7 +725,6 @@ result_t BusHandler::handleSymbol() { return setState(bs_skip, RESULT_OK); } return setState(bs_skip, RESULT_ERR_INVALID_ARG); - } return RESULT_OK; } @@ -740,16 +736,14 @@ result_t BusHandler::setState(BusState state, result_t result, bool firstRepetit m_currentRequest->m_busLostRetries++; m_nextRequests.push(m_currentRequest); // repeat m_currentRequest = NULL; - } - else if (state == bs_sendSyn || (result != RESULT_OK && !firstRepetition)) { + } else if (state == bs_sendSyn || (result != RESULT_OK && !firstRepetition)) { logDebug(lf_bus, "notify request: %s", getResultCode(result)); unsigned char dstAddress = m_currentRequest->m_master[1]; if (result == RESULT_OK) { addSeenAddress(dstAddress); } bool restart = m_currentRequest->notify( - result == RESULT_ERR_SYN && (m_state == bs_recvCmdAck || m_state == bs_recvRes) ? RESULT_ERR_TIMEOUT : result, m_response - ); + result == RESULT_ERR_SYN && (m_state == bs_recvCmdAck || m_state == bs_recvRes) ? RESULT_ERR_TIMEOUT : result, m_response); if (restart) { m_currentRequest->m_busLostRetries = 0; m_nextRequests.push(m_currentRequest); diff --git a/src/ebusd/bushandler.h b/src/ebusd/bushandler.h index c4780718..9c33f24e 100644 --- a/src/ebusd/bushandler.h +++ b/src/ebusd/bushandler.h @@ -93,11 +93,10 @@ class BusHandler; /** * Generic request for sending to and receiving from the bus. */ -class BusRequest -{ +class BusRequest { friend class BusHandler; -public: + public: /** * Constructor. * @param master the escaped master data @a SymbolString to send. @@ -120,8 +119,8 @@ public: */ virtual bool notify(result_t result, SymbolString& slave) = 0; -protected: + protected: /** the escaped master data @a SymbolString to send. */ SymbolString& m_master; @@ -130,18 +129,16 @@ protected: /** whether to automatically delete this @a BusRequest when finished. */ const bool m_deleteOnFinish; - }; /** * A poll @a BusRequest handled by @a BusHandler itself. */ -class PollRequest : public BusRequest -{ +class PollRequest : public BusRequest { friend class BusHandler; -public: + public: /** * Constructor. * @param message the associated @a Message. @@ -164,8 +161,8 @@ public: // @copydoc virtual bool notify(result_t result, SymbolString& slave); -private: + private: /** the escaped master data @a SymbolString. */ SymbolString m_master; @@ -174,18 +171,16 @@ private: /** the current part index in @a m_message. */ unsigned char m_index; - }; /** * A scan @a BusRequest handled by @a BusHandler itself. */ -class ScanRequest : public BusRequest -{ +class ScanRequest : public BusRequest { friend class BusHandler; -public: + public: /** * Constructor. * @param messageMap the @a MessageMap instance. @@ -194,8 +189,7 @@ public: * @param busHandler the @a BusHandler instance to notify of final scan result. */ ScanRequest(MessageMap* messageMap, deque messages, deque slaves, BusHandler* busHandler) - : BusRequest(m_master, true), m_messageMap(messageMap), m_index(0), m_allMessages(messages), m_messages(messages), m_slaves(slaves), m_busHandler(busHandler) - { + : BusRequest(m_master, true), m_messageMap(messageMap), m_index(0), m_allMessages(messages), m_messages(messages), m_slaves(slaves), m_busHandler(busHandler) { m_message = m_messages.front(); m_messages.pop_front(); } @@ -215,8 +209,8 @@ public: // @copydoc virtual bool notify(result_t result, SymbolString& slave); -private: + private: /** the @a MessageMap instance. */ MessageMap* m_messageMap; @@ -243,18 +237,16 @@ private: /** the @a BusHandler instance to notify of final scan result. */ BusHandler* m_busHandler; - }; /** * An active @a BusRequest that can be waited for. */ -class ActiveBusRequest : public BusRequest -{ +class ActiveBusRequest : public BusRequest { friend class BusHandler; -public: + public: /** * Constructor. * @param master the escaped master data @a SymbolString to send. @@ -271,25 +263,21 @@ public: // @copydoc virtual bool notify(result_t result, SymbolString& slave); -private: + private: /** the result of handling the request. */ result_t m_result; /** reference to @a SymbolString for filling in the received slave data. */ SymbolString& m_slave; - }; /** * Helper class for keeping track of grabbed messages. */ -class GrabbedMessage -{ - -public: - +class GrabbedMessage { + public: /** * Construct a new instance. */ @@ -321,8 +309,8 @@ public: */ bool dump(const bool unknown, MessageMap* messages, bool first, ostringstream& output); -private: + private: /** the last master @a SymbolString. */ SymbolString m_lastMaster; @@ -331,17 +319,14 @@ private: /** the number of times this message was seen. */ unsigned int m_count; - }; /** * Handles input from and output to the bus with respect to the eBUS protocol. */ -class BusHandler : public WaitThread -{ -public: - +class BusHandler : public WaitThread { + public: /** * Construct a new instance. * @param device the @a Device instance for accessing the bus. @@ -375,8 +360,7 @@ public: m_symPerSec(0), m_maxSymPerSec(0), m_state(bs_noSignal), m_repeat(false), m_command(false), m_commandCrcValid(false), m_response(false), m_responseCrcValid(false), - m_grabMessages(true) - { + m_grabMessages(true) { memset(m_seenAddresses, 0, sizeof(m_seenAddresses)); } @@ -525,8 +509,8 @@ public: */ void setScanConfigLoaded(unsigned char address, string file); -private: + private: /** * Handle the next symbol on the bus. * @return RESULT_OK on success, or an error code. @@ -664,7 +648,6 @@ private: /** the grabbed messages by key.*/ map m_grabbedMessages; - }; #endif // EBUSD_BUSHANDLER_H_ diff --git a/src/ebusd/datahandler.h b/src/ebusd/datahandler.h index 4c955970..71497fa8 100644 --- a/src/ebusd/datahandler.h +++ b/src/ebusd/datahandler.h @@ -54,9 +54,8 @@ bool datahandler_register(BusHandler* busHandler, MessageMap* messages, list m_updatedMessages; - }; /** * Base class providing data to be sent on the bus. */ -class DataSource : virtual public DataHandler -{ -public: - +class DataSource : virtual public DataHandler { + public: /** * Constructor. * @param busHandler the @a BusHandler instance. @@ -143,11 +136,10 @@ public: // @copydoc virtual bool isDataSource() { return true; } -protected: + protected: /** the @a BusHandler instance. */ BusHandler* m_busHandler; - }; #endif // EBUSD_DATAHANDLER_H_ diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 37179e29..14746c45 100644 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -397,7 +397,7 @@ void MqttHandler::handleTraffic() { if (m_mosquitto) { mosquitto_loop(m_mosquitto, -1 #if (LIBMOSQUITTO_MAJOR >= 1) - ,1 + , 1 #endif ); } diff --git a/src/ebusd/mqtthandler.h b/src/ebusd/mqtthandler.h index 3906c828..65e35ccb 100644 --- a/src/ebusd/mqtthandler.h +++ b/src/ebusd/mqtthandler.h @@ -50,10 +50,8 @@ DataHandler* mqtthandler_register(BusHandler* busHandler, MessageMap* messages); /** * The main class supporting MQTT data handling. */ -class MqttHandler : public DataSink, public DataSource, public Thread -{ -public: - +class MqttHandler : public DataSink, public DataSource, public Thread { + public: /** * Constructor. * @param busHandler the @a BusHandler instance. @@ -76,13 +74,13 @@ public: */ void notifyTopic(string topic, string data); -protected: + protected: // @copydoc virtual void run(); -private: + private: /** * Called regularly to handle MQTT traffic. */ @@ -128,7 +126,6 @@ private: /** the mosquitto structure if initialized, or NULL. */ struct mosquitto* m_mosquitto; - }; -#endif // EBUSD_DATAHANDLER_H_ +#endif // EBUSD_MQTTHANDLER_H_ diff --git a/src/ebusd/network.cpp b/src/ebusd/network.cpp index 39ebcc2c..b21097c1 100644 --- a/src/ebusd/network.cpp +++ b/src/ebusd/network.cpp @@ -141,7 +141,6 @@ void Connection::run() { break; } } - } delete m_socket; @@ -230,7 +229,6 @@ void Network::run() { } #endif #endif - while (true) { #ifdef HAVE_PPOLL // wait for new fd event diff --git a/src/ebusd/network.h b/src/ebusd/network.h index db9d6888..8071ad64 100644 --- a/src/ebusd/network.h +++ b/src/ebusd/network.h @@ -38,17 +38,14 @@ class Connection; /** * Class for data/message transfer between @a Connection and @a MainLoop. */ -class NetMessage -{ - -public: +class NetMessage { + public: /** * Constructor. * @param isHttp whether this is a HTTP message. */ NetMessage(const bool isHttp) - : m_isHttp(isHttp), m_resultSet(false), m_disconnect(false), m_listening(false), m_listenSince(0) - { + : m_isHttp(isHttp), m_resultSet(false), m_disconnect(false), m_listening(false), m_listenSince(0) { pthread_mutex_init(&m_mutex, NULL); pthread_cond_init(&m_cond, NULL); } @@ -56,28 +53,27 @@ public: /** * Destructor. */ - ~NetMessage() - { + ~NetMessage() { pthread_mutex_destroy(&m_mutex); pthread_cond_destroy(&m_cond); } -private: + + private: /** * Hidden copy constructor. * @param src the object to copy from. */ NetMessage(const NetMessage& src); -public: + public: /** * Add request data received from the client. * @param request the request data from the client. * @return true when the request is complete and the response shall be prepared. */ - bool add(string request) - { + bool add(string request) { if (request.length() > 0) { request.erase(remove(request.begin(), request.end(), '\r'), request.end()); m_request.append(request); @@ -125,8 +121,7 @@ public: * Wait for the result being set and return the result string. * @return the result string. */ - string getResult() - { + string getResult() { pthread_mutex_lock(&m_mutex); while (!m_resultSet) @@ -148,8 +143,7 @@ public: * @param listenUntil the end time to which to updates were added (exclusive). * @param disconnect true when the client shall be disconnected. */ - void setResult(const string result, const bool listening, const time_t listenUntil, const bool disconnect) - { + void setResult(const string result, const bool listening, const time_t listenUntil, const bool disconnect) { pthread_mutex_lock(&m_mutex); m_result = result; m_disconnect = disconnect; @@ -173,7 +167,8 @@ public: */ bool isDisconnect() { return m_disconnect; } -private: + + private: /** whether this is a HTTP message. */ const bool m_isHttp; @@ -200,16 +195,13 @@ private: /** start timestamp of listening update. */ time_t m_listenSince; - }; /** * class connection which handle client and baseloop communication. */ -class Connection : public Thread -{ - -public: +class Connection : public Thread { + public: /** * Constructor. * @param socket the @a TCPSocket for communication. @@ -217,8 +209,9 @@ public: * @param netQueue the reference to the @a NetMessage @a Queue. */ Connection(TCPSocket* socket, const bool isHttp, Queue* netQueue) - : Thread(), m_isHttp(isHttp), m_socket(socket), m_netQueue(netQueue) - { m_id = ++m_ids; } + : Thread(), m_isHttp(isHttp), m_socket(socket), m_netQueue(netQueue) { + m_id = ++m_ids; + } virtual ~Connection() { if (m_socket) delete m_socket; } /** @@ -237,7 +230,8 @@ public: */ int getID() { return m_id; } -private: + + private: /** whether this is a HTTP connection. */ const bool m_isHttp; @@ -255,16 +249,13 @@ private: /** the IF of the last opened connection. */ static int m_ids; - }; /** * class network which listening on tcp socket for incoming connections. */ -class Network : public Thread -{ - -public: +class Network : public Thread { + public: /** * create a network instance and listening for incoming connections. * @param local true to accept connections only for local host. @@ -289,7 +280,8 @@ public: */ void stop() const { m_notify.notify(); usleep(100000); } -private: + + private: /** the list of active @a Connection instances. */ list m_connections; @@ -312,7 +304,6 @@ private: * clean inactive connections from container. */ void cleanConnections(); - }; #endif // EBUSD_NETWORK_H_ diff --git a/src/lib/ebus/contrib/contrib.h b/src/lib/ebus/contrib/contrib.h index 3f5c4077..08986a00 100644 --- a/src/lib/ebus/contrib/contrib.h +++ b/src/lib/ebus/contrib/contrib.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef LIB_EBUS_CONTRIB_H_ -#define LIB_EBUS_CONTRIB_H_ +#ifndef LIB_EBUS_CONTRIB_CONTRIB_H_ +#define LIB_EBUS_CONTRIB_CONTRIB_H_ /** @file contrib.h * Contributed sources that may be excluded from regular builds. @@ -32,4 +32,4 @@ using namespace std; */ bool libebus_contrib_register(); -#endif // LIB_EBUS_CONTRIB_H_ +#endif // LIB_EBUS_CONTRIB_CONTRIB_H_ diff --git a/src/lib/ebus/contrib/tem.h b/src/lib/ebus/contrib/tem.h index 06e1cf98..2f0bafb9 100644 --- a/src/lib/ebus/contrib/tem.h +++ b/src/lib/ebus/contrib/tem.h @@ -40,10 +40,8 @@ using namespace std; * A special variant of @a NumberDataType for TEM/Dungs ParamID in master/slave * data. */ -class TemParamDataType : public NumberDataType -{ -public: - +class TemParamDataType : public NumberDataType { + public: /** * Constructs a new instance. * @param id the type identifier. @@ -63,7 +61,6 @@ public: virtual result_t writeSymbols(istringstream& input, const unsigned char offset, const unsigned char length, SymbolString& output, const bool isMaster, unsigned char* usedLength); - }; /** diff --git a/src/lib/ebus/data.cpp b/src/lib/ebus/data.cpp index 113ecb0c..ecf55a20 100644 --- a/src/lib/ebus/data.cpp +++ b/src/lib/ebus/data.cpp @@ -340,8 +340,7 @@ result_t SingleDataField::read(const PartType partType, if (partType != m_partType) { return RESULT_EMPTY; } - switch (m_partType) - { + switch (m_partType) { case pt_masterData: offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN break; @@ -368,8 +367,7 @@ result_t SingleDataField::read(const PartType partType, if (partType != m_partType) { return RESULT_OK; } - switch (m_partType) - { + switch (m_partType) { case pt_masterData: offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN break; @@ -435,8 +433,7 @@ result_t SingleDataField::write(istringstream& input, if (partType != m_partType) { return RESULT_OK; } - switch (m_partType) - { + switch (m_partType) { case pt_masterData: offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN break; diff --git a/src/lib/ebus/data.h b/src/lib/ebus/data.h index 85711d4f..0469a1cd 100644 --- a/src/lib/ebus/data.h +++ b/src/lib/ebus/data.h @@ -53,10 +53,8 @@ class SingleDataField; /** * Base class for all kinds of data fields. */ -class DataField -{ -public: - +class DataField { + public: /** * Constructs a new instance. * @param name the field name. @@ -205,24 +203,21 @@ public: const PartType partType, SymbolString& data, unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL) = 0; -protected: + protected: /** the field name. */ const string m_name; /** the field comment. */ const string m_comment; - }; /** * A single @a DataField holding a value. */ -class SingleDataField : public DataField -{ -public: - +class SingleDataField : public DataField { + public: /** * Constructs a new instance. * @param name the field name. @@ -325,8 +320,8 @@ public: const PartType partType, SymbolString& data, unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL); -protected: + protected: /** * Internal method for reading the field from a @a SymbolString. * @param input the unescaped @a SymbolString to read the binary value from. @@ -353,8 +348,6 @@ protected: const unsigned char offset, SymbolString& output, const bool isMaster, unsigned char* usedLength); -protected: - /** the value unit. */ const string m_unit; @@ -366,17 +359,14 @@ protected: /** the number of symbols in the message part in which the field is stored. */ const unsigned char m_length; - }; /** * A numeric data field with a list of value=text assignments and a string representation. */ -class ValueListDataField : public SingleDataField -{ -public: - +class ValueListDataField : public SingleDataField { + public: /** * Constructs a new instance. * @param name the field name. @@ -410,8 +400,8 @@ public: // @copydoc virtual void dump(ostream& output); -protected: + protected: // @copydoc virtual result_t readSymbols(SymbolString& input, const bool isMaster, const unsigned char offset, @@ -422,21 +412,18 @@ protected: const unsigned char offset, SymbolString& output, const bool isMaster, unsigned char* usedLength); -private: + private: /** the value=text assignments. */ map m_values; - }; /** * A data field with a constant value. */ -class ConstantDataField : public SingleDataField -{ -public: - +class ConstantDataField : public SingleDataField { + public: /** * Constructs a new instance. * @param name the field name. @@ -471,8 +458,8 @@ public: // @copydoc virtual void dump(ostream& output); -protected: + protected: // @copydoc virtual result_t readSymbols(SymbolString& input, const bool isMaster, const unsigned char offset, @@ -483,24 +470,21 @@ protected: const unsigned char offset, SymbolString& output, const bool isMaster, unsigned char* usedLength); -private: + private: /** the constant value. */ const string m_value; /** whether to verify the read value against the constant value. */ const bool m_verify; - }; /** * A set of @a DataField instances. */ -class DataFieldSet : public DataField -{ -public: - +class DataFieldSet : public DataField { + public: /** * Get the @a DataFieldSet for parsing the identification message (service 0x07 0x04). * @return the @a DataFieldSet for parsing the identification message. This is:
    @@ -522,8 +506,7 @@ public: DataFieldSet(const string name, const string comment, const vector fields) : DataField(name, comment), - m_fields(fields) - { + m_fields(fields) { bool uniqueNames = true; map names; for (vector::const_iterator it = fields.begin(); it != fields.end(); it++) { @@ -603,8 +586,8 @@ public: const PartType partType, SymbolString& data, unsigned char offset, char separator = UI_FIELD_SEPARATOR, unsigned char* length = NULL); -private: + private: /** the @a DataFieldSet containing the ident message @a SingleDataField instances, or NULL. */ static DataFieldSet* s_identFields; @@ -613,17 +596,14 @@ private: /** whether all fields have a unique name. */ bool m_uniqueNames; - }; /** * A map of template @a DataField instances. */ -class DataFieldTemplates : public FileReader -{ -public: - +class DataFieldTemplates : public FileReader { + public: /** * Constructs a new instance. */ @@ -670,11 +650,10 @@ public: */ DataField* get(string name); -private: + private: /** the known template @a DataField instances by name. */ map m_fieldsByName; - }; #endif // LIB_EBUS_DATA_H_ diff --git a/src/lib/ebus/datatype.cpp b/src/lib/ebus/datatype.cpp index f5deb7c5..21870f2d 100644 --- a/src/lib/ebus/datatype.cpp +++ b/src/lib/ebus/datatype.cpp @@ -123,8 +123,7 @@ void printErrorPos(ostream& out, vector::iterator begin, const vector> 4) * 10 + (ch & 0x0f)); } - switch (type) - { + switch (type) { case 2: // date only if (!hasFlag(REQ) && ch == m_replacement) { if (i + 1 != length) { @@ -440,10 +438,9 @@ result_t DateTimeDataType::writeSymbols(istringstream& input, size_t i = 0, offset; int type = (m_hasDate?2:0) | (m_hasTime?1:0); bool skip = false; - for (offset = start; i < count; offset += skip?0:incr, i++) { + for (offset = start; i < count; offset += skip ? 0 : incr, i++) { skip = false; - switch (type) - { + switch (type) { case 2: // date only if (length == 4 && i == 2) { continue; // skip weekday in between @@ -584,8 +581,7 @@ unsigned char NumberDataType::calcPrecision(const int divisor) { return precision; } -bool NumberDataType::dump(ostream& output, unsigned char length) const -{ +bool NumberDataType::dump(ostream& output, unsigned char length) const { if (m_bitCount < 8) { DataType::dump(output, m_bitCount); } else { diff --git a/src/lib/ebus/datatype.h b/src/lib/ebus/datatype.h index e3d2dded..202c6f38 100644 --- a/src/lib/ebus/datatype.h +++ b/src/lib/ebus/datatype.h @@ -146,10 +146,8 @@ void printErrorPos(ostream& out, vector::iterator begin, const vector m_typesById; @@ -596,7 +582,6 @@ private: /** true when contributed datatypes were successfully initialized. */ static bool s_contrib_initialized; #endif - }; #endif // LIB_EBUS_DATATYPE_H_ diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index d71a2989..a135661e 100644 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -258,7 +258,7 @@ result_t NetworkDevice::open() { value = 1; setsockopt(m_fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&value, sizeof(value)); } - if (ret == 0) { + if (ret == 0) { ret = connect(m_fd, (struct sockaddr*)&m_address, sizeof(m_address)); } if (ret < 0) { @@ -269,7 +269,8 @@ result_t NetworkDevice::open() { if (ioctl(m_fd, FIONREAD, &cnt) >= 0 && cnt > 1) { // skip buffered input unsigned char buf[256]; - while (::read(m_fd, &buf, 256) > 0); + while (::read(m_fd, &buf, 256) > 0) { + } } if (m_bufSize == 0) { m_bufSize = MAX_LEN+1; diff --git a/src/lib/ebus/device.h b/src/lib/ebus/device.h index d13c94b1..f6b18ca7 100644 --- a/src/lib/ebus/device.h +++ b/src/lib/ebus/device.h @@ -41,10 +41,8 @@ using namespace std; /** * Interface for listening to data received on/sent to a device. */ -class DeviceListener -{ -public: - +class DeviceListener { + public: /** * Destructor. */ @@ -56,17 +54,14 @@ public: * @param received @a true on reception, @a false on sending. */ virtual void notifyDeviceData(const unsigned char byte, bool received) = 0; // abstract - }; /** * The base class for accessing an eBUS. */ -class Device -{ - -public: +class Device { + public: /** * Construct a new instance. * @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). @@ -150,7 +145,8 @@ public: */ void setListener(DeviceListener* listener) { m_listener = listener; } -protected: + + protected: /** * Check if the device is still available and close it if not. */ @@ -176,7 +172,6 @@ protected: */ virtual ssize_t read(unsigned char& value) { return ::read(m_fd, &value, 1); } -protected: /** the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). */ const char* m_name; @@ -192,19 +187,17 @@ protected: /** the opened file descriptor, or -1. */ int m_fd; -private: + private: /** the @a DeviceListener, or NULL. */ DeviceListener* m_listener; - }; /** * The @a Device for directly connected serial interfaces (tty). */ -class SerialDevice : public Device -{ -public: +class SerialDevice : public Device { + public: /** * Construct a new instance. * @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). @@ -221,22 +214,22 @@ public: // @copydoc virtual void close(); -protected: + + protected: // @copydoc virtual void checkDevice(); -private: + + private: /** the previous settings of the device for restoring. */ termios m_oldSettings; - }; /** * The @a Device for remote network interfaces. */ -class NetworkDevice : public Device -{ -public: +class NetworkDevice : public Device { + public: /** * Construct a new instance. * @param name the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). @@ -256,7 +249,8 @@ public: // @copydoc virtual result_t open(); -protected: + + protected: // @copydoc virtual void checkDevice(); @@ -269,7 +263,8 @@ protected: // @copydoc virtual ssize_t read(unsigned char& value); -private: + + private: /** the socket address of the device. */ const struct sockaddr_in m_address; @@ -287,7 +282,6 @@ private: /** the buffer read position. */ unsigned char m_bufPos; - }; #endif // LIB_EBUS_DEVICE_H_ diff --git a/src/lib/ebus/filereader.h b/src/lib/ebus/filereader.h index 393b067e..843e0e9a 100644 --- a/src/lib/ebus/filereader.h +++ b/src/lib/ebus/filereader.h @@ -60,10 +60,8 @@ extern unsigned int parseInt(const char* str, int base, const unsigned int minVa /** * An abstract class that support reading definitions from a file. */ -class FileReader -{ -public: - +class FileReader { + public: /** * Construct a new instance. */ @@ -85,8 +83,7 @@ public: * @return @a RESULT_OK on success, or an error code. */ virtual result_t readFromFile(const string filename, bool verbose = false, - string defaultDest = "", string defaultCircuit = "", string defaultSuffix = "") - { + string defaultDest = "", string defaultCircuit = "", string defaultSuffix = "") { ifstream ifs; ifs.open(filename.c_str(), ifstream::in); if (!ifs.is_open()) { @@ -177,8 +174,7 @@ public: */ virtual result_t addDefaultFromFile(vector< vector >& defaults, vector& row, vector::iterator& begin, string defaultDest, string defaultCircuit, string defaultSuffix, - const string& filename, unsigned int lineNo) - { + const string& filename, unsigned int lineNo) { defaults.push_back(row); begin = row.end(); return RESULT_OK; @@ -204,8 +200,7 @@ public: * Left and right trim the string. * @param str the @a string to trim. */ - static void trim(string& str) - { + static void trim(string& str) { size_t pos = str.find_first_not_of(" \t"); if (pos != string::npos) { str.erase(0, pos); @@ -220,8 +215,7 @@ public: * Convert all upper case characters in the string to lower case. * @param str the @a string to convert. */ - static void tolower(string& str) - { + static void tolower(string& str) { transform(str.begin(), str.end(), str.begin(), ::tolower); } @@ -232,8 +226,7 @@ public: * @param lineNo the current line number (incremented with each line read). * @return true if there are more lines to read, false when there are no more lines left. */ - static bool splitFields(istream& ifs, vector& row, unsigned int& lineNo) - { + static bool splitFields(istream& ifs, vector& row, unsigned int& lineNo) { row.clear(); string line; bool quotedText = false, wasQuoted = false; @@ -251,8 +244,7 @@ public: } for (size_t pos = 0; pos < length; pos++) { char ch = line[pos]; - switch (ch) - { + switch (ch) { case FIELD_SEPARATOR: if (quotedText) { field << ch; @@ -317,8 +309,7 @@ public: * @return true if at least the address and the identification part were extracted, false otherwise. */ static bool extractDefaultsFromFilename(string name, unsigned char& dest, string& ident, string& circuit, - string& suffix, unsigned int& software, unsigned int& hardware) - { + string& suffix, unsigned int& software, unsigned int& hardware) { ident = circuit = suffix = ""; software = hardware = UINT_MAX; if (name.length() > 4 && name.substr(name.length()-4) == ".csv") { @@ -374,16 +365,15 @@ public: return true; } -private: + private: /** whether this instance supports rows with defaults (starting with a star). */ bool m_supportsDefaults; -protected: + protected: /** a @a string describing the last error position. */ string m_lastError; - }; #endif // LIB_EBUS_FILEREADER_H_ diff --git a/src/lib/ebus/message.cpp b/src/lib/ebus/message.cpp index 91b766f7..e41f008c 100644 --- a/src/lib/ebus/message.cpp +++ b/src/lib/ebus/message.cpp @@ -834,8 +834,7 @@ ChainedMessage::ChainedMessage(const string circuit, const string name, srcAddress, dstAddress, id, data, deleteData, pollPriority, condition), m_ids(ids), m_lengths(lengths), - m_maxTimeDiff(m_ids.size()*15) // 15 seconds per message -{ + m_maxTimeDiff(m_ids.size()*15) { // 15 seconds per message size_t cnt = ids.size(); m_lastMasterDatas = (SymbolString**)calloc(cnt, sizeof(SymbolString*)); m_lastSlaveDatas = (SymbolString**)calloc(cnt, sizeof(SymbolString*)); @@ -1334,7 +1333,7 @@ result_t SimpleCondition::resolve(MessageMap* messages, ostringstream& errorMess } else { Message* first = getFirstAvailable(*derived, message); if (first == NULL) { - errorMessage << ": conditional derived message " << message->getCircuit() << "." << message->getName() << " for " << hex << setw(2) << setfill('0') << static_cast(m_dstAddress) << " not found" ; + errorMessage << ": conditional derived message " << message->getCircuit() << "." << message->getName() << " for " << hex << setw(2) << setfill('0') << static_cast(m_dstAddress) << " not found"; return RESULT_ERR_INVALID_ARG; } message = first; diff --git a/src/lib/ebus/message.h b/src/lib/ebus/message.h index 40e886e8..6363bb98 100644 --- a/src/lib/ebus/message.h +++ b/src/lib/ebus/message.h @@ -93,11 +93,9 @@ class MessageMap; /** * Defines parameters of a message sent or received on the bus. */ -class Message -{ +class Message { friend class MessageMap; -public: - + public: /** * Construct a new instance. * @param circuit the optional circuit name. @@ -122,7 +120,8 @@ public: const unsigned char pollPriority = 0, Condition* condition = NULL); -private: + + private: /** * Construct a new scan @a Message instance. * @param circuit the circuit name, or empty for not storing by name. @@ -140,7 +139,8 @@ private: const unsigned char pb, const unsigned char sb, DataField* data, const bool deleteData); -public: + + public: /** * Destructor. */ @@ -394,8 +394,8 @@ public: istringstream& input, char separator = UI_FIELD_SEPARATOR, const unsigned char dstAddress = SYN, unsigned char index = 0); -protected: + protected: /** * Prepare a part of the master data @a SymbolString for sending (everything including NN). * @param master the master data @a SymbolString for writing symbols to. @@ -406,8 +406,8 @@ protected: */ virtual result_t prepareMasterPart(SymbolString& master, istringstream& input, char separator, unsigned char index); -public: + public: /** * Prepare the slave @a SymbolString for sending an answer to the bus. * @param input the @a istringstream to parse the formatted value(s) from. @@ -521,8 +521,8 @@ public: */ virtual void dumpColumn(ostream& output, size_t column, bool withConditions = false); -protected: + protected: /** the optional circuit name. */ const string m_circuit; @@ -606,17 +606,14 @@ protected: /** the system time when this message was last polled for, 0 for never. */ time_t m_lastPollTime; - }; /** * A chained @a Message that needs more than one read/write on the bus to collect/send the data. */ -class ChainedMessage : public Message -{ -public: - +class ChainedMessage : public Message { + public: /** * Construct a new instance. * @param circuit the optional circuit name. @@ -659,26 +656,26 @@ public: // @copydoc virtual unsigned char getCount() { return (unsigned char)m_ids.size(); } -protected: + protected: // @copydoc virtual result_t prepareMasterPart(SymbolString& master, istringstream& input, char separator, unsigned char index); -public: + public: // @copydoc virtual result_t storeLastData(SymbolString& master, SymbolString& slave); // @copydoc virtual result_t storeLastData(const PartType partType, SymbolString& data, unsigned char index); -protected: + protected: // @copydoc virtual void dumpColumn(ostream& output, size_t column, bool withConditions = false); -private: + private: /** the primary, secondary, and optional further ID bytes for each part of the chain. */ const vector< vector > m_ids; @@ -699,21 +696,20 @@ private: /** array of the system times when the corresponding slave data was last updated, 0 for never. */ time_t* m_lastSlaveUpdateTimes; - }; /** * A function that compares the weighted poll priority of two @a Message instances. */ -struct compareMessagePriority : binary_function { +struct compareMessagePriority : binary_function { /** * Compare the weighted poll priority of the two @a Message instances. * @param x the first @a Message. * @param y the second @a Message. * @return whether @a x is smaller than @a y with regard to their weighted poll priority. */ - bool operator() (Message* x, Message* y) const { return x->isLessPollWeight(y); }; + bool operator() (Message* x, Message* y) const { return x->isLessPollWeight(y); } }; @@ -721,15 +717,13 @@ struct compareMessagePriority : binary_function { * Helper class extending @a priority_queue to hold distinct values only. */ class MessagePriorityQueue - : public priority_queue, compareMessagePriority> -{ -public: + : public priority_queue, compareMessagePriority> { + public: /** * Add data to the queue and ensure it is contained only once. * @param __x the element to add. */ - void push(const value_type& __x) - { + void push(const value_type& __x) { for (vector::iterator it = c.begin(); it != c.end(); it++) { if (*it == __x) { c.erase(it); @@ -744,10 +738,8 @@ public: /** * An abstract condition based on the value of one or more @a Message instances. */ -class Condition -{ -public: - +class Condition { + public: /** * Construct a new instance. */ @@ -776,7 +768,7 @@ public: * @param valueList the @a string with the new list of values. * @return the derived @a SimpleCondition instance, or NULL if the value list is invalid. */ - virtual SimpleCondition* derive(string valueList) { return NULL; }; + virtual SimpleCondition* derive(string valueList) { return NULL; } /** * Write the condition definition or resolved expression to the @a ostream. @@ -807,24 +799,21 @@ public: */ virtual bool isTrue() = 0; -protected: + protected: /** the system time when the condition was last checked, 0 for never. */ time_t m_lastCheckTime; /** whether the condition was @a true during the last check. */ bool m_isTrue; - }; /** * A simple @a Condition based on the value of one @a Message. */ -class SimpleCondition : public Condition -{ -public: - +class SimpleCondition : public Condition { + public: /** * Construct a new instance. * @param condName the name of the condition. @@ -865,8 +854,8 @@ public: */ virtual bool isNumeric() { return true; } -protected: + protected: /** * Check the values against the field in the @a Message. * @param message the @a Message to check against. @@ -878,8 +867,8 @@ protected: /** the value that matched in @a checkValue. */ string m_matchedValue; -private: + private: /** the condition name. */ const string m_condName; @@ -903,17 +892,14 @@ private: /** the resolved @a Message instance, or NULL. */ Message* m_message; - }; /** * A simple @a Condition based on the numeric value of one @a Message. */ -class SimpleNumericCondition : public SimpleCondition -{ -public: - +class SimpleNumericCondition : public SimpleCondition { + public: /** * Construct a new instance. * @param condName the name of the condition. @@ -933,26 +919,23 @@ public: */ virtual ~SimpleNumericCondition() {} -protected: + protected: // @copydoc virtual bool checkValue(Message* message, const string field); -private: + private: /** the valid value ranges (pairs of from/to inclusive), empty for @a m_message seen check. */ const vector m_valueRanges; - }; /** * A simple @a Condition based on the string value of one @a Message. */ -class SimpleStringCondition : public SimpleCondition -{ -public: - +class SimpleStringCondition : public SimpleCondition { + public: /** * Construct a new instance. * @param condName the name of the condition. @@ -975,26 +958,23 @@ public: // @copydoc virtual bool isNumeric() { return false; } -protected: + protected: // @copydoc virtual bool checkValue(Message* message, const string field); -private: + private: /** the valid values. */ const vector m_values; - }; /** * A @a Condition combining two or more @a SimpleCondition instances with a logical and. */ -class CombinedCondition : public Condition -{ -public: - +class CombinedCondition : public Condition { + public: /** * Construct a new instance. */ @@ -1018,21 +998,18 @@ public: // @copydoc virtual bool isTrue(); -private: + private: /** the @a Condition instances used. */ vector m_conditions; - }; /** * An abstract instruction based on the value of one or more @a Message instances. */ -class Instruction -{ -public: - +class Instruction { + public: /** * Construct a new instance. * @param condition the @a Condition this instruction requires, or null. @@ -1092,16 +1069,16 @@ public: */ virtual result_t execute(MessageMap* messages, ostringstream& log, Condition* condition) = 0; -private: + private: /** the @a Condition this instruction requires, or null. */ Condition* m_condition; /** whether this @a Instruction belongs to a set of instructions of which only the first one may be executed for the same source file. */ bool m_singleton; -protected: + protected: /** the default destination address, or empty. */ const string m_defaultDest; @@ -1110,17 +1087,14 @@ protected: /** the default circuit name suffix (starting with a "."), or empty. */ const string m_defaultSuffix; - }; /** * An @a Instruction allowing to load another file. */ -class LoadInstruction : public Instruction -{ -public: - +class LoadInstruction : public Instruction { + public: /** * Construct a new instance. * @param condition the @a Condition this instruction requires, or null. @@ -1141,28 +1115,24 @@ public: // @copydoc virtual result_t execute(MessageMap* messages, ostringstream& log, Condition* condition); -private: + private: /** the name of the file to load. */ const string m_filename; - }; /** * Holds a map of all known @a Message instances. */ -class MessageMap : public FileReader -{ -public: - +class MessageMap : public FileReader { + public: /** * Construct a new instance. * @param addAll whether to add all messages, even if duplicate. */ MessageMap(const bool addAll = false) : FileReader::FileReader(true), - m_addAll(addAll), m_maxIdLength(0), m_messageCount(0), m_conditionalMessageCount(0), m_passiveMessageCount(0) - { + m_addAll(addAll), m_maxIdLength(0), m_messageCount(0), m_conditionalMessageCount(0), m_passiveMessageCount(0) { m_scanMessage = Message::createScanMessage(); } @@ -1368,8 +1338,8 @@ public: */ void dump(ostream& output, bool withConditions = false); -private: + private: /** whether to add all messages, even if duplicate. */ const bool m_addAll; @@ -1405,7 +1375,6 @@ private: /** the list of @a Instruction instances by filename. */ map > m_instructions; - }; #endif // LIB_EBUS_MESSAGE_H_ diff --git a/src/lib/ebus/symbol.cpp b/src/lib/ebus/symbol.cpp index d813066c..0dc7933c 100644 --- a/src/lib/ebus/symbol.cpp +++ b/src/lib/ebus/symbol.cpp @@ -28,8 +28,7 @@ using namespace std; /** * CRC8 lookup table for the polynom 0x9b = x^8 + x^7 + x^4 + x^3 + x^1 + 1. */ -static const unsigned char CRC_LOOKUP_TABLE[] = -{ +static const unsigned char CRC_LOOKUP_TABLE[] = { 0x00, 0x9b, 0xad, 0x36, 0xc1, 0x5a, 0x6c, 0xf7, 0x19, 0x82, 0xb4, 0x2f, 0xd8, 0x43, 0x75, 0xee, 0x32, 0xa9, 0x9f, 0x04, 0xf3, 0x68, 0x5e, 0xc5, 0x2b, 0xb0, 0x86, 0x1d, 0xea, 0x71, 0x47, 0xdc, 0x64, 0xff, 0xc9, 0x52, 0xa5, 0x3e, 0x08, 0x93, 0x7d, 0xe6, 0xd0, 0x4b, 0xbc, 0x27, 0x11, 0x8a, @@ -194,8 +193,7 @@ void SymbolString::addCRC(const unsigned char value) { * @return the 1-based index of the upper or lower 4 bits of a master address (1 to 5), or 0. */ unsigned char getMasterPartIndex(unsigned char bits) { - switch (bits) - { + switch (bits) { case 0x0: return 1; case 0x1: diff --git a/src/lib/ebus/symbol.h b/src/lib/ebus/symbol.h index 03dd08b8..d284c99c 100644 --- a/src/lib/ebus/symbol.h +++ b/src/lib/ebus/symbol.h @@ -75,10 +75,8 @@ static const unsigned char BROADCAST = 0xFE; //!< the broadcast destination addr /** * A string of escaped or unescaped bus symbols. */ -class SymbolString -{ - -public: +class SymbolString { + public: /** * Creates a new empty escaped or unescaped instance. * @param escaped whether to create an escaped instance. @@ -186,8 +184,8 @@ public: */ void clear(const bool escape) { m_data.clear(); m_unescapeState = escape ? 0 : 1; m_crc = 0; } -private: + private: /** * Hidden copy constructor. * @param str the @a SymbolString to copy from. diff --git a/src/lib/ebus/test/test_data.cpp b/src/lib/ebus/test/test_data.cpp index 15ea4b6d..09f06de2 100644 --- a/src/lib/ebus/test/test_data.cpp +++ b/src/lib/ebus/test/test_data.cpp @@ -86,45 +86,45 @@ int main() { {"x,,hex:5, == 48 61 6c 6c 6f", "", "10fe070005ababababab", "00", "rW"}, {"x,,hex:5,=48 61 6c 6c 6f", "", "10fe07000548616c6c6f", "00", ""}, {"x,,hex:5, == 48 61 6c 6c 6f", "", "10fe07000548616c6c6f", "00", ""}, - {"x,,bda", "26.10.2014","10fe07000426100614", "00", ""}, // Sunday - {"x,,bda", "01.01.2000","10fe07000401010500", "00", ""}, // Saturday - {"x,,bda", "31.12.2099","10fe07000431120399", "00", ""}, // Thursday - {"x,,bda", "-.-.-", "10fe070004ffff00ff", "00", ""}, - {"x,,bda", "", "10fe07000432100014", "00", "rw"}, - {"x,,bda:3", "26.10.2014","10fe070003261014", "00", ""}, - {"x,,bda:3", "01.01.2000","10fe070003010100", "00", ""}, - {"x,,bda:3", "31.12.2099","10fe070003311299", "00", ""}, - {"x,,bda:3", "-.-.-", "10fe070003ffffff", "00", ""}, - {"x,,bda:3", "", "10fe070003321299", "00", "rw"}, - {"x,,bda,2", "", "", "", "c"}, - {"x,,hda", "26.10.2014","10fe0700041a0a070e", "00", ""}, // Sunday - {"x,,hda", "01.01.2000","10fe07000401010600", "00", ""}, // Saturday - {"x,,hda", "31.12.2099","10fe0700041f0c0463", "00", ""}, // Thursday - {"x,,hda", "-.-.-", "10fe070004ffff00ff", "00", ""}, - {"x,,hda", "", "10fe070004200c0463", "00", "rw"}, - {"x,,hda:3", "26.10.2014","10fe0700031a0a0e", "00", ""}, - {"x,,hda:3", "01.01.2000","10fe070003010100", "00", ""}, - {"x,,hda:3", "31.12.2099","10fe0700031f0c63", "00", ""}, - {"x,,hda:3", "-.-.-", "10fe070003ffffff", "00", ""}, - {"x,,hda:3", "", "10fe070003200c63", "00", "rw"}, - {"x,,hda,2", "", "", "", "c"}, - {"x,,day", "26.10.2014","10fe070002d0a3", "00", ""}, - {"x,,day", "01.01.2000","10fe070002ac8e", "00", ""}, - {"x,,day", "31.12.2078","10fe07000262ff", "00", ""}, - {"x,,day", "-.-.-", "10fe070002ffff", "00", ""}, - {"x,,day", "", "10fe0700020000", "00", "Rw"}, - {"x,,bti", "21:04:58", "10fe070003580421", "00", ""}, - {"x,,bti", "00:00:00", "10fe070003000000", "00", ""}, - {"x,,bti", "23:59:59", "10fe070003595923", "00", ""}, - {"x,,bti", "-:-:-", "10fe070003ffffff", "00", ""}, - {"x,,bti", "", "10fe070003605923", "00", "rw"}, - {"x,,bti,2", "", "", "", "c"}, - {"x,,hti", "21:04:58", "10fe07000315043a", "00", ""}, - {"x,,hti", "-:-:-", "10fe070003ffffff", "00", ""}, - {"x,,hti,2", "", "", "", "c"}, - {"x,,vti", "21:04:58", "10fe0700033a0415", "00", ""}, - {"x,,vti", "-:-:-", "10fe070003636363", "00", ""}, - {"x,,vti,2", "", "", "", "c"}, + {"x,,bda", "26.10.2014", "10fe07000426100614", "00", ""}, // Sunday + {"x,,bda", "01.01.2000", "10fe07000401010500", "00", ""}, // Saturday + {"x,,bda", "31.12.2099", "10fe07000431120399", "00", ""}, // Thursday + {"x,,bda", "-.-.-", "10fe070004ffff00ff", "00", ""}, + {"x,,bda", "", "10fe07000432100014", "00", "rw"}, + {"x,,bda:3", "26.10.2014", "10fe070003261014", "00", ""}, + {"x,,bda:3", "01.01.2000", "10fe070003010100", "00", ""}, + {"x,,bda:3", "31.12.2099", "10fe070003311299", "00", ""}, + {"x,,bda:3", "-.-.-", "10fe070003ffffff", "00", ""}, + {"x,,bda:3", "", "10fe070003321299", "00", "rw"}, + {"x,,bda,2", "", "", "", "c"}, + {"x,,hda", "26.10.2014", "10fe0700041a0a070e", "00", ""}, // Sunday + {"x,,hda", "01.01.2000", "10fe07000401010600", "00", ""}, // Saturday + {"x,,hda", "31.12.2099", "10fe0700041f0c0463", "00", ""}, // Thursday + {"x,,hda", "-.-.-", "10fe070004ffff00ff", "00", ""}, + {"x,,hda", "", "10fe070004200c0463", "00", "rw"}, + {"x,,hda:3", "26.10.2014", "10fe0700031a0a0e", "00", ""}, + {"x,,hda:3", "01.01.2000", "10fe070003010100", "00", ""}, + {"x,,hda:3", "31.12.2099", "10fe0700031f0c63", "00", ""}, + {"x,,hda:3", "-.-.-", "10fe070003ffffff", "00", ""}, + {"x,,hda:3", "", "10fe070003200c63", "00", "rw"}, + {"x,,hda,2", "", "", "", "c"}, + {"x,,day", "26.10.2014", "10fe070002d0a3", "00", ""}, + {"x,,day", "01.01.2000", "10fe070002ac8e", "00", ""}, + {"x,,day", "31.12.2078", "10fe07000262ff", "00", ""}, + {"x,,day", "-.-.-", "10fe070002ffff", "00", ""}, + {"x,,day", "", "10fe0700020000", "00", "Rw"}, + {"x,,bti", "21:04:58", "10fe070003580421", "00", ""}, + {"x,,bti", "00:00:00", "10fe070003000000", "00", ""}, + {"x,,bti", "23:59:59", "10fe070003595923", "00", ""}, + {"x,,bti", "-:-:-", "10fe070003ffffff", "00", ""}, + {"x,,bti", "", "10fe070003605923", "00", "rw"}, + {"x,,bti,2", "", "", "", "c"}, + {"x,,hti", "21:04:58", "10fe07000315043a", "00", ""}, + {"x,,hti", "-:-:-", "10fe070003ffffff", "00", ""}, + {"x,,hti,2", "", "", "", "c"}, + {"x,,vti", "21:04:58", "10fe0700033a0415", "00", ""}, + {"x,,vti", "-:-:-", "10fe070003636363", "00", ""}, + {"x,,vti,2", "", "", "", "c"}, {"x,,btm", "21:04", "10fe0700020421", "00", ""}, {"x,,btm", "00:00", "10fe0700020000", "00", ""}, {"x,,btm", "23:59", "10fe0700025923", "00", ""}, @@ -191,9 +191,9 @@ int main() { {"x,,hdy", "Mon", "10fe07000101", "00", ""}, {"x,,hdy", "Sun", "10fe07000107", "00", ""}, {"x,,hdy", "8", "10fe07000108", "00", "w"}, - {"x,,pin","1234", "10feffff021234", "00", ""}, - {"x,,pin","0000", "10feffff020000", "00", ""}, - {"x,,pin","9999", "10feffff029999", "00", ""}, + {"x,,pin", "1234", "10feffff021234", "00", ""}, + {"x,,pin", "0000", "10feffff020000", "00", ""}, + {"x,,pin", "9999", "10feffff029999", "00", ""}, {"x,,pin", "", "10feffff020000", "00", "Rw"}, {"x,,pin", "100", "10feffff020100", "00", "R"}, {"x,,bcd", "26", "10feffff0126", "00", ""}, @@ -202,194 +202,194 @@ int main() { {"x,,bcd", "100", "10feffff0199", "00", "Rw"}, {"x,,bcd", "-", "10feffff01ff", "00", ""}, {"x,,bcd", "", "10feffff019a", "00", "rw"}, - {"x,,bcd:1","26", "10feffff0126", "00", ""}, - {"x,,bcd:1","0", "10feffff0100", "00", ""}, - {"x,,bcd:1","99", "10feffff0199", "00", ""}, - {"x,,bcd:1","100", "10feffff0199", "00", "Rw"}, - {"x,,bcd:1","-", "10feffff01ff", "00", ""}, - {"x,,bcd:1","", "10feffff019a", "00", "rw"}, - {"x,,bcd:2","126", "10feffff022601", "00", ""}, - {"x,,bcd:2","0", "10feffff020000", "00", ""}, - {"x,,bcd:2","9999", "10feffff029999", "00", ""}, - {"x,,bcd:2","10000","10feffff029999", "00", "Rw"}, - {"x,,bcd:2","-", "10feffff02ffff", "00", ""}, - {"x,,bcd:2","", "10feffff029a00", "00", "rw"}, - {"x,,bcd:3","12346", "10feffff03462301", "00", ""}, - {"x,,bcd:3","0", "10feffff03000000", "00", ""}, - {"x,,bcd:3","999999", "10feffff03999999", "00", ""}, - {"x,,bcd:3","1000000","10feffff03999999", "00", "Rw"}, - {"x,,bcd:3","-", "10feffff03ffffff", "00", ""}, - {"x,,bcd:3","", "10feffff03009a00", "00", "rw"}, - {"x,,bcd:4","1234567", "10feffff0467452301", "00", ""}, - {"x,,bcd:4","0", "10feffff0400000000", "00", ""}, - {"x,,bcd:4","99999999", "10feffff0499999999", "00", ""}, - {"x,,bcd:4","100000000","10feffff0499999999", "00", "Rw"}, - {"x,,bcd:4","-", "10feffff04ffffffff", "00", ""}, - {"x,,bcd:4","", "10feffff0400009a00", "00", "rw"}, - {"x,,hcd:1", "26", "10feffff011a", "00", ""}, - {"x,,hcd:1", "0", "10feffff0100", "00", ""}, - {"x,,hcd:1", "99", "10feffff0163", "00", ""}, - {"x,,hcd:1", "100", "10feffff0163", "00", "Rw"}, - {"x,,hcd:1", "", "10feffff019a", "00", "rw"}, - {"x,,hcd:2", "126", "10feffff021a01", "00", ""}, - {"x,,hcd:2", "0", "10feffff020000", "00", ""}, - {"x,,hcd:2", "9999", "10feffff026363", "00", ""}, - {"x,,hcd:2", "10000", "10feffff026363", "00", "Rw"}, - {"x,,hcd:2", "", "10feffff029a00", "00", "rw"}, - {"x,,hcd:3","12346", "10feffff032e1701", "00", ""}, - {"x,,hcd:3","0", "10feffff03000000", "00", ""}, - {"x,,hcd:3","999999", "10feffff03636363", "00", ""}, - {"x,,hcd:3","1000000", "10feffff03636363", "00", "Rw"}, - {"x,,hcd:3","", "10feffff03009a00", "00", "rw"}, - {"x,,hcd:4","1234567", "10feffff04432d1701", "00", ""}, - {"x,,hcd:4","0", "10feffff0400000000", "00", ""}, - {"x,,hcd:4","99999999", "10feffff0463636363", "00", ""}, - {"x,,hcd:4","100000000","10feffff0463636363", "00", "Rw"}, - {"x,,hcd","", "10feffff0400006400", "00", "rw"}, - {"x,,hcd","1234567", "10feffff04432d1701", "00", ""}, - {"x,,hcd","0", "10feffff0400000000", "00", ""}, - {"x,,hcd","99999999", "10feffff0463636363", "00", ""}, - {"x,,hcd","100000000", "10feffff0463636363", "00", "Rw"}, - {"x,,hcd","", "10feffff0400006400", "00", "rw"}, - {"x,,str:16", "0123456789ABCDEF", "10feffff1130313233343536373839414243444546", "00", ""}, - {"x,,uch:17", "", "10feffff00", "00", "c"}, - {"x,s,uch", "0", "1025ffff0310111213", "0300010203", "W"}, - {"x,s,uch", "0", "1025ffff00", "0100", ""}, - {"x,s,uch,,,,y,m,uch", "3;2","1025ffff0103", "0102", ""}, - {"x,,uch", "38", "10feffff0126", "00", ""}, - {"x,,uch", "38.5", "10feffff0126", "00", "R"}, - {"x,,uch", "0", "10feffff0100", "00", ""}, - {"x,,uch", "254", "10feffff01fe", "00", ""}, - {"x,,uch", "-", "10feffff01ff", "00", ""}, - {"x,,uch,10", "3.8", "10feffff0126", "00", ""}, - {"x,,uch,-10", "380","10feffff0126", "00", ""}, - {"x,,uch,=48", "", "10feffff01ab", "00", "W"}, + {"x,,bcd:1", "26", "10feffff0126", "00", ""}, + {"x,,bcd:1", "0", "10feffff0100", "00", ""}, + {"x,,bcd:1", "99", "10feffff0199", "00", ""}, + {"x,,bcd:1", "100", "10feffff0199", "00", "Rw"}, + {"x,,bcd:1", "-", "10feffff01ff", "00", ""}, + {"x,,bcd:1", "", "10feffff019a", "00", "rw"}, + {"x,,bcd:2", "126", "10feffff022601", "00", ""}, + {"x,,bcd:2", "0", "10feffff020000", "00", ""}, + {"x,,bcd:2", "9999", "10feffff029999", "00", ""}, + {"x,,bcd:2", "10000", "10feffff029999", "00", "Rw"}, + {"x,,bcd:2", "-", "10feffff02ffff", "00", ""}, + {"x,,bcd:2", "", "10feffff029a00", "00", "rw"}, + {"x,,bcd:3", "12346", "10feffff03462301", "00", ""}, + {"x,,bcd:3", "0", "10feffff03000000", "00", ""}, + {"x,,bcd:3", "999999", "10feffff03999999", "00", ""}, + {"x,,bcd:3", "1000000", "10feffff03999999", "00", "Rw"}, + {"x,,bcd:3", "-", "10feffff03ffffff", "00", ""}, + {"x,,bcd:3", "", "10feffff03009a00", "00", "rw"}, + {"x,,bcd:4", "1234567", "10feffff0467452301", "00", ""}, + {"x,,bcd:4", "0", "10feffff0400000000", "00", ""}, + {"x,,bcd:4", "99999999", "10feffff0499999999", "00", ""}, + {"x,,bcd:4", "100000000", "10feffff0499999999", "00", "Rw"}, + {"x,,bcd:4", "-", "10feffff04ffffffff", "00", ""}, + {"x,,bcd:4", "", "10feffff0400009a00", "00", "rw"}, + {"x,,hcd:1", "26", "10feffff011a", "00", ""}, + {"x,,hcd:1", "0", "10feffff0100", "00", ""}, + {"x,,hcd:1", "99", "10feffff0163", "00", ""}, + {"x,,hcd:1", "100", "10feffff0163", "00", "Rw"}, + {"x,,hcd:1", "", "10feffff019a", "00", "rw"}, + {"x,,hcd:2", "126", "10feffff021a01", "00", ""}, + {"x,,hcd:2", "0", "10feffff020000", "00", ""}, + {"x,,hcd:2", "9999", "10feffff026363", "00", ""}, + {"x,,hcd:2", "10000", "10feffff026363", "00", "Rw"}, + {"x,,hcd:2", "", "10feffff029a00", "00", "rw"}, + {"x,,hcd:3", "12346", "10feffff032e1701", "00", ""}, + {"x,,hcd:3", "0", "10feffff03000000", "00", ""}, + {"x,,hcd:3", "999999", "10feffff03636363", "00", ""}, + {"x,,hcd:3", "1000000", "10feffff03636363", "00", "Rw"}, + {"x,,hcd:3", "", "10feffff03009a00", "00", "rw"}, + {"x,,hcd:4", "1234567", "10feffff04432d1701", "00", ""}, + {"x,,hcd:4", "0", "10feffff0400000000", "00", ""}, + {"x,,hcd:4", "99999999", "10feffff0463636363", "00", ""}, + {"x,,hcd:4", "100000000", "10feffff0463636363", "00", "Rw"}, + {"x,,hcd", "", "10feffff0400006400", "00", "rw"}, + {"x,,hcd", "1234567", "10feffff04432d1701", "00", ""}, + {"x,,hcd", "0", "10feffff0400000000", "00", ""}, + {"x,,hcd", "99999999", "10feffff0463636363", "00", ""}, + {"x,,hcd", "100000000", "10feffff0463636363", "00", "Rw"}, + {"x,,hcd", "", "10feffff0400006400", "00", "rw"}, + {"x,,str:16", "0123456789ABCDEF", "10feffff1130313233343536373839414243444546", "00", ""}, + {"x,,uch:17", "", "10feffff00", "00", "c"}, + {"x,s,uch", "0", "1025ffff0310111213", "0300010203", "W"}, + {"x,s,uch", "0", "1025ffff00", "0100", ""}, + {"x,s,uch,,,,y,m,uch", "3;2", "1025ffff0103", "0102", ""}, + {"x,,uch", "38", "10feffff0126", "00", ""}, + {"x,,uch", "38.5", "10feffff0126", "00", "R"}, + {"x,,uch", "0", "10feffff0100", "00", ""}, + {"x,,uch", "254", "10feffff01fe", "00", ""}, + {"x,,uch", "-", "10feffff01ff", "00", ""}, + {"x,,uch,10", "3.8", "10feffff0126", "00", ""}, + {"x,,uch,-10", "380", "10feffff0126", "00", ""}, + {"x,,uch,=48", "", "10feffff01ab", "00", "W"}, {"x,,uch, == 48", "", "10feffff01ab", "00", "rW"}, - {"x,,uch,=48", "", "10feffff0130", "00", ""}, + {"x,,uch,=48", "", "10feffff0130", "00", ""}, {"x,,uch, == 48", "", "10feffff0130", "00", ""}, - {"x,,sch", "-90", "10feffff01a6", "00", ""}, - {"x,,sch", "0", "10feffff0100", "00", ""}, - {"x,,sch", "-1", "10feffff01ff", "00", ""}, - {"x,,sch", "-", "10feffff0180", "00", ""}, - {"x,,sch", "-127", "10feffff0181", "00", ""}, - {"x,,sch", "127", "10feffff017f", "00", ""}, - {"x,,sch,10", "-9.0","10feffff01a6", "00", ""}, - {"x,,sch,-10","-900","10feffff01a6", "00", ""}, - {"x,,d1b", "-90", "10feffff01a6", "00", ""}, - {"x,,d1b", "0", "10feffff0100", "00", ""}, - {"x,,d1b", "-1", "10feffff01ff", "00", ""}, - {"x,,d1b", "-", "10feffff0180", "00", ""}, - {"x,,d1b", "-127", "10feffff0181", "00", ""}, - {"x,,d1b", "127", "10feffff017f", "00", ""}, - {"x,,d1b,-10","-900","10feffff01a6", "00", ""}, + {"x,,sch", "-90", "10feffff01a6", "00", ""}, + {"x,,sch", "0", "10feffff0100", "00", ""}, + {"x,,sch", "-1", "10feffff01ff", "00", ""}, + {"x,,sch", "-", "10feffff0180", "00", ""}, + {"x,,sch", "-127", "10feffff0181", "00", ""}, + {"x,,sch", "127", "10feffff017f", "00", ""}, + {"x,,sch,10", "-9.0", "10feffff01a6", "00", ""}, + {"x,,sch,-10", "-900", "10feffff01a6", "00", ""}, + {"x,,d1b", "-90", "10feffff01a6", "00", ""}, + {"x,,d1b", "0", "10feffff0100", "00", ""}, + {"x,,d1b", "-1", "10feffff01ff", "00", ""}, + {"x,,d1b", "-", "10feffff0180", "00", ""}, + {"x,,d1b", "-127", "10feffff0181", "00", ""}, + {"x,,d1b", "127", "10feffff017f", "00", ""}, + {"x,,d1b,-10", "-900", "10feffff01a6", "00", ""}, {"x,,d1c", "19.5", "10feffff0127", "00", ""}, {"x,,d1c", "0.0", "10feffff0100", "00", ""}, {"x,,d1c", "100.0", "10feffff01c8", "00", ""}, {"x,,d1c", "-", "10feffff01ff", "00", ""}, - {"x,,uin", "38", "10feffff022600", "00", ""}, - {"x,,uin", "0", "10feffff020000", "00", ""}, - {"x,,uin", "65534", "10feffff02feff", "00", ""}, - {"x,,uin", "-", "10feffff02ffff", "00", ""}, - {"x,,uin,10", "3.8", "10feffff022600", "00", ""}, - {"x,,uin,-10","380", "10feffff022600", "00", ""}, - {"x,,uir", "38", "10feffff020026", "00", ""}, - {"x,,uir", "0", "10feffff020000", "00", ""}, - {"x,,uir", "65534", "10feffff02fffe", "00", ""}, - {"x,,uir", "-", "10feffff02ffff", "00", ""}, - {"x,,uir,10", "3.8", "10feffff020026", "00", ""}, - {"x,,uir,-10","380", "10feffff020026", "00", ""}, - {"uin10,uin,-10","", "", "", "t"}, // template - {"x,,uin10","380", "10feffff022600", "00", ""}, // template reference - {"x,,uin10,-10","3800","10feffff022600", "00", ""}, // template reference, valid divider product - {"x,,uin10,10","","", "", "c"}, // template reference, invalid divider product - {"x,,sin", "-90", "10feffff02a6ff", "00", ""}, - {"x,,sin", "0", "10feffff020000", "00", ""}, - {"x,,sin", "-1", "10feffff02ffff", "00", ""}, - {"x,,sin", "-", "10feffff020080", "00", ""}, - {"x,,sin", "-32767", "10feffff020180", "00", ""}, - {"x,,sin", "32767", "10feffff02ff7f", "00", ""}, - {"x,,sin,10","-9.0", "10feffff02a6ff", "00", ""}, - {"x,,sin,-10","-900","10feffff02a6ff", "00", ""}, - {"x,,sir", "-90", "10feffff02ffa6", "00", ""}, - {"x,,sir", "0", "10feffff020000", "00", ""}, - {"x,,sir", "-1", "10feffff02ffff", "00", ""}, - {"x,,sir", "-", "10feffff028000", "00", ""}, - {"x,,sir", "-32767", "10feffff028001", "00", ""}, - {"x,,sir", "32767", "10feffff027fff", "00", ""}, - {"x,,sir,10","-9.0", "10feffff02ffa6", "00", ""}, - {"x,,sir,-10","-900","10feffff02ffa6", "00", ""}, - {"x,,u3n", "38", "10feffff03260000", "00", ""}, - {"x,,u3n", "0", "10feffff03000000", "00", ""}, + {"x,,uin", "38", "10feffff022600", "00", ""}, + {"x,,uin", "0", "10feffff020000", "00", ""}, + {"x,,uin", "65534", "10feffff02feff", "00", ""}, + {"x,,uin", "-", "10feffff02ffff", "00", ""}, + {"x,,uin,10", "3.8", "10feffff022600", "00", ""}, + {"x,,uin,-10", "380", "10feffff022600", "00", ""}, + {"x,,uir", "38", "10feffff020026", "00", ""}, + {"x,,uir", "0", "10feffff020000", "00", ""}, + {"x,,uir", "65534", "10feffff02fffe", "00", ""}, + {"x,,uir", "-", "10feffff02ffff", "00", ""}, + {"x,,uir,10", "3.8", "10feffff020026", "00", ""}, + {"x,,uir,-10", "380", "10feffff020026", "00", ""}, + {"uin10,uin,-10", "", "", "", "t"}, // template + {"x,,uin10", "380", "10feffff022600", "00", ""}, // template reference + {"x,,uin10,-10", "3800", "10feffff022600", "00", ""}, // template reference, valid divider product + {"x,,uin10,10", "", "", "", "c"}, // template reference, invalid divider product + {"x,,sin", "-90", "10feffff02a6ff", "00", ""}, + {"x,,sin", "0", "10feffff020000", "00", ""}, + {"x,,sin", "-1", "10feffff02ffff", "00", ""}, + {"x,,sin", "-", "10feffff020080", "00", ""}, + {"x,,sin", "-32767", "10feffff020180", "00", ""}, + {"x,,sin", "32767", "10feffff02ff7f", "00", ""}, + {"x,,sin,10", "-9.0", "10feffff02a6ff", "00", ""}, + {"x,,sin,-10", "-900", "10feffff02a6ff", "00", ""}, + {"x,,sir", "-90", "10feffff02ffa6", "00", ""}, + {"x,,sir", "0", "10feffff020000", "00", ""}, + {"x,,sir", "-1", "10feffff02ffff", "00", ""}, + {"x,,sir", "-", "10feffff028000", "00", ""}, + {"x,,sir", "-32767", "10feffff028001", "00", ""}, + {"x,,sir", "32767", "10feffff027fff", "00", ""}, + {"x,,sir,10", "-9.0", "10feffff02ffa6", "00", ""}, + {"x,,sir,-10", "-900", "10feffff02ffa6", "00", ""}, + {"x,,u3n", "38", "10feffff03260000", "00", ""}, + {"x,,u3n", "0", "10feffff03000000", "00", ""}, {"x,,u3n", "16777214", "10feffff03feffff", "00", ""}, - {"x,,u3n", "-", "10feffff03ffffff", "00", ""}, - {"x,,u3n,10", "3.8", "10feffff03260000", "00", ""}, - {"x,,u3n,-10","380", "10feffff03260000", "00", ""}, - {"x,,u3r", "38", "10feffff03000026", "00", ""}, - {"x,,u3r", "0", "10feffff03000000", "00", ""}, + {"x,,u3n", "-", "10feffff03ffffff", "00", ""}, + {"x,,u3n,10", "3.8", "10feffff03260000", "00", ""}, + {"x,,u3n,-10", "380", "10feffff03260000", "00", ""}, + {"x,,u3r", "38", "10feffff03000026", "00", ""}, + {"x,,u3r", "0", "10feffff03000000", "00", ""}, {"x,,u3r", "16777214", "10feffff03fffffe", "00", ""}, - {"x,,u3r", "-", "10feffff03ffffff", "00", ""}, - {"x,,u3r,10", "3.8", "10feffff03000026", "00", ""}, - {"x,,u3r,-10","380", "10feffff03000026", "00", ""}, - {"x,,s3n", "-90", "10feffff03a6ffff", "00", ""}, - {"x,,s3n", "0", "10feffff03000000", "00", ""}, - {"x,,s3n", "-1", "10feffff03ffffff", "00", ""}, - {"x,,s3n", "-", "10feffff03000080", "00", ""}, + {"x,,u3r", "-", "10feffff03ffffff", "00", ""}, + {"x,,u3r,10", "3.8", "10feffff03000026", "00", ""}, + {"x,,u3r,-10", "380", "10feffff03000026", "00", ""}, + {"x,,s3n", "-90", "10feffff03a6ffff", "00", ""}, + {"x,,s3n", "0", "10feffff03000000", "00", ""}, + {"x,,s3n", "-1", "10feffff03ffffff", "00", ""}, + {"x,,s3n", "-", "10feffff03000080", "00", ""}, {"x,,s3n", "-8388607", "10feffff03010080", "00", ""}, {"x,,s3n", "8388607", "10feffff03ffff7f", "00", ""}, - {"x,,s3n,10","-9.0", "10feffff03a6ffff", "00", ""}, - {"x,,s3n,-10","-900","10feffff03a6ffff", "00", ""}, - {"x,,s3r", "-90", "10feffff03ffffa6", "00", ""}, - {"x,,s3r", "0", "10feffff03000000", "00", ""}, - {"x,,s3r", "-1", "10feffff03ffffff", "00", ""}, - {"x,,s3r", "-", "10feffff03800000", "00", ""}, + {"x,,s3n,10", "-9.0", "10feffff03a6ffff", "00", ""}, + {"x,,s3n,-10", "-900", "10feffff03a6ffff", "00", ""}, + {"x,,s3r", "-90", "10feffff03ffffa6", "00", ""}, + {"x,,s3r", "0", "10feffff03000000", "00", ""}, + {"x,,s3r", "-1", "10feffff03ffffff", "00", ""}, + {"x,,s3r", "-", "10feffff03800000", "00", ""}, {"x,,s3r", "-8388607", "10feffff03800001", "00", ""}, {"x,,s3r", "8388607", "10feffff037fffff", "00", ""}, - {"x,,s3r,10","-9.0", "10feffff03ffffa6", "00", ""}, - {"x,,s3r,-10","-900","10feffff03ffffa6", "00", ""}, + {"x,,s3r,10", "-9.0", "10feffff03ffffa6", "00", ""}, + {"x,,s3r,-10", "-900", "10feffff03ffffa6", "00", ""}, {"x,,flt", "-0.090", "10feffff02a6ff", "00", ""}, {"x,,flt", "0.000", "10feffff020000", "00", ""}, {"x,,flt", "-0.001", "10feffff02ffff", "00", ""}, {"x,,flt", "-", "10feffff020080", "00", ""}, - {"x,,flt","-32.767", "10feffff020180", "00", ""}, + {"x,,flt", "-32.767", "10feffff020180", "00", ""}, {"x,,flt", "32.767", "10feffff02ff7f", "00", ""}, {"x,,flr", "-0.090", "10feffff02ffa6", "00", ""}, {"x,,flr", "0.000", "10feffff020000", "00", ""}, {"x,,flr", "-0.001", "10feffff02ffff", "00", ""}, {"x,,flr", "-", "10feffff028000", "00", ""}, - {"x,,flr","-32.767", "10feffff028001", "00", ""}, + {"x,,flr", "-32.767", "10feffff028001", "00", ""}, {"x,,flr", "32.767", "10feffff027fff", "00", ""}, {"x,,exp", "-0.09", "10feffff04ec51b8bd", "00", ""}, {"x,,exp", "0.0", "10feffff0400000000", "00", ""}, {"x,,exp", "-0.001", "10feffff046f1283ba", "00", ""}, {"x,,exp", "-", "10feffff040000807f", "00", ""}, - {"x,,exp","-32.767", "10feffff04681103c2", "00", ""}, + {"x,,exp", "-32.767", "10feffff04681103c2", "00", ""}, {"x,,exp,1000", "-0.000090000", "10feffff04ec51b8bd", "00", ""}, {"x,,exp,-100", "-9", "10feffff04ec51b8bd", "00", ""}, {"x,,exr", "-0.09", "10feffff04bdb851ec", "00", ""}, {"x,,exr", "0.0", "10feffff0400000000", "00", ""}, {"x,,exr", "-0.001", "10feffff04ba83126f", "00", ""}, {"x,,exr", "-", "10feffff047f800000", "00", ""}, - {"x,,exr","-32.767", "10feffff04c2031168", "00", ""}, - {"x,,exr,1000", "-0.000090000", "10feffff04bdb851ec", "00", ""}, + {"x,,exr", "-32.767", "10feffff04c2031168", "00", ""}, + {"x,,exr,1000", "-0.000090000", "10feffff04bdb851ec", "00", ""}, {"x,,exr,-100", "-9", "10feffff04bdb851ec", "00", ""}, - {"x,,d2b", "18.004", "10fe0700090112", "00", ""}, - {"x,,d2b", "0.000", "10feffff020000", "00", ""}, - {"x,,d2b", "-0.004", "10feffff02ffff", "00", ""}, - {"x,,d2b", "-", "10feffff020080", "00", ""}, - {"x,,d2b","-127.996","10feffff020180", "00", ""}, - {"x,,d2b", "127.996","10feffff02ff7f", "00", ""}, - {"x,,d2c", "288.06", "10fe0700090112", "00", ""}, - {"x,,d2c", "0.00", "10feffff020000", "00", ""}, - {"x,,d2c", "-0.06", "10feffff02ffff", "00", ""}, - {"x,,d2c", "-", "10feffff020080", "00", ""}, - {"x,,d2c","-2047.94","10feffff020180", "00", ""}, - {"x,,d2c", "2047.94","10feffff02ff7f", "00", ""}, + {"x,,d2b", "18.004", "10fe0700090112", "00", ""}, + {"x,,d2b", "0.000", "10feffff020000", "00", ""}, + {"x,,d2b", "-0.004", "10feffff02ffff", "00", ""}, + {"x,,d2b", "-", "10feffff020080", "00", ""}, + {"x,,d2b", "-127.996", "10feffff020180", "00", ""}, + {"x,,d2b", "127.996", "10feffff02ff7f", "00", ""}, + {"x,,d2c", "288.06", "10fe0700090112", "00", ""}, + {"x,,d2c", "0.00", "10feffff020000", "00", ""}, + {"x,,d2c", "-0.06", "10feffff02ffff", "00", ""}, + {"x,,d2c", "-", "10feffff020080", "00", ""}, + {"x,,d2c", "-2047.94", "10feffff020180", "00", ""}, + {"x,,d2c", "2047.94", "10feffff02ff7f", "00", ""}, {"x,,ulg", "38", "10feffff0426000000", "00", ""}, {"x,,ulg", "0", "10feffff0400000000", "00", ""}, {"x,,ulg", "4294967294", "10feffff04feffffff", "00", ""}, {"x,,ulg", "-", "10feffff04ffffffff", "00", ""}, - {"x,,ulg,10","3.8", "10feffff0426000000", "00", ""}, - {"x,,ulg,-10","380", "10feffff0426000000", "00", ""}, + {"x,,ulg,10", "3.8", "10feffff0426000000", "00", ""}, + {"x,,ulg,-10", "380", "10feffff0426000000", "00", ""}, {"x,,ulg,0x0FF0F00F = VRT 350 ;0x33CCCC33=VRT 360;0x3CC3C33C=SD 17;0x66999966=SD 37;0x69969669=VRT 360+", "VRT 350", "10feffff040FF0F00F", "00", ""}, {"x,,ulg,0x=test", "", "10feffff040FF0F00F", "00", "c"}, @@ -397,8 +397,8 @@ int main() { {"x,,ulr", "0", "10feffff0400000000", "00", ""}, {"x,,ulr", "4294967294", "10feffff04fffffffe", "00", ""}, {"x,,ulr", "-", "10feffff04ffffffff", "00", ""}, - {"x,,ulr,10","3.8", "10feffff0400000026", "00", ""}, - {"x,,ulr,-10","380", "10feffff0400000026", "00", ""}, + {"x,,ulr,10", "3.8", "10feffff0400000026", "00", ""}, + {"x,,ulr,-10", "380", "10feffff0400000026", "00", ""}, {"x,,slg", "-90", "10feffff04a6ffffff", "00", ""}, {"x,,slg", "0", "10feffff0400000000", "00", ""}, {"x,,slg", "-1", "10feffff04ffffffff", "00", ""}, @@ -409,53 +409,53 @@ int main() { {"x,,slr", "-1", "10feffff04ffffffff", "00", ""}, {"x,,slr,10", "-9.0", "10feffff04ffffffa6", "00", ""}, {"x,,slr,-10", "-900", "10feffff04ffffffa6", "00", ""}, - {"x,,bi3", "1", "10feffff0108", "00", ""}, - {"x,,bi3", "0", "10feffff0100", "00", ""}, - {"x,,bi3,0=off;1=on","on", "10feffff0108", "00", ""}, - {"x,,bi3,0=off;1=on","off","10feffff0100", "00", ""}, + {"x,,bi3", "1", "10feffff0108", "00", ""}, + {"x,,bi3", "0", "10feffff0100", "00", ""}, + {"x,,bi3,0=off;1=on", "on", "10feffff0108", "00", ""}, + {"x,,bi3,0=off;1=on", "off", "10feffff0100", "00", ""}, {"x,,bi3:2", "1", "10feffff0108", "00", ""}, {"x,,bi3:2", "1", "10feffff01ef", "00", "W"}, {"x,,bi3:2", "0", "10feffff0100", "00", ""}, {"x,,bi3:2", "3", "10feffff0118", "00", ""}, - {"x,,bi3:2,1=on","on", "10feffff0108", "00", ""}, - {"x,,bi3:2,1=on","-", "10feffff0100", "00", ""}, - {"x,,bi3:2,0=off;1=on;2=auto;3=eco","auto", "10feffff0110", "00", ""}, - {"x,,bi3:2,0=off;1=on;2=auto;3=eco","2.5", "10feffff0110", "00", "R"}, - {"x,,bi3:2,0=off;1=on","on", "10feffff0108", "00", ""}, - {"x,,bi3:2,0=off;1=on","off","10feffff0100", "00", ""}, - {"x,,bi3:2,0=off;1=on","1", "10feffff0108", "00", "n"}, - {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","x=on ja/nein [Wahrheitswert]", "10feffff0108", "00", "vvv"}, - {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","x=1 ja/nein [Wahrheitswert]", "10feffff0108", "00", "vvvn"}, - {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"x\": {\"value\": \"on\"}", "10feffff0108", "00", "vj"}, - {",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "vj"}, - {",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "j"}, - {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"x\": {\"value\": \"on\", \"unit\": \"ja/nein\", \"comment\": \"Wahrheitswert\"}", "10feffff0108", "00", "vvvj"}, - {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"x\": {\"value\": 1}", "10feffff0108", "00", "vnj"}, - {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"x\": {\"value\": 1, \"unit\": \"ja/nein\", \"comment\": \"Wahrheitswert\"}", "10feffff0108", "00", "vvvnj"}, - {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert","\n \"0\": {\"name\": \"x\", \"value\": 1}", "10feffff0108", "00", "nj"}, - {"x,,uch,1=test;2=high;3=off;0x10=on","on","10feffff0110", "00", ""}, - {"x,s,uch","3","1050ffff00", "0103", ""}, - {"x,,d2b,,°C,Aussentemperatur","x=18.004 °C [Aussentemperatur]","10fe0700090112", "00", "vvv"}, - {"x,,bti,,,,y,,bda,,,,z,,bdy", "21:04:58;26.10.2014;Sun","10fe0700085804212610061406", "00", ""}, // combination + {"x,,bi3:2,1=on", "on", "10feffff0108", "00", ""}, + {"x,,bi3:2,1=on", "-", "10feffff0100", "00", ""}, + {"x,,bi3:2,0=off;1=on;2=auto;3=eco", "auto", "10feffff0110", "00", ""}, + {"x,,bi3:2,0=off;1=on;2=auto;3=eco", "2.5", "10feffff0110", "00", "R"}, + {"x,,bi3:2,0=off;1=on", "on", "10feffff0108", "00", ""}, + {"x,,bi3:2,0=off;1=on", "off", "10feffff0100", "00", ""}, + {"x,,bi3:2,0=off;1=on", "1", "10feffff0108", "00", "n"}, + {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "x=on ja/nein [Wahrheitswert]", "10feffff0108", "00", "vvv"}, + {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "x=1 ja/nein [Wahrheitswert]", "10feffff0108", "00", "vvvn"}, + {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"x\": {\"value\": \"on\"}", "10feffff0108", "00", "vj"}, + {",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "vj"}, + {",,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"\", \"value\": \"on\"}", "10feffff0108", "00", "j"}, + {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"x\": {\"value\": \"on\", \"unit\": \"ja/nein\", \"comment\": \"Wahrheitswert\"}", "10feffff0108", "00", "vvvj"}, + {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"x\": {\"value\": 1}", "10feffff0108", "00", "vnj"}, + {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"x\": {\"value\": 1, \"unit\": \"ja/nein\", \"comment\": \"Wahrheitswert\"}", "10feffff0108", "00", "vvvnj"}, + {"x,,bi3:2,0=off;1=on,ja/nein,Wahrheitswert", "\n \"0\": {\"name\": \"x\", \"value\": 1}", "10feffff0108", "00", "nj"}, + {"x,,uch,1=test;2=high;3=off;0x10=on", "on", "10feffff0110", "00", ""}, + {"x,s,uch", "3", "1050ffff00", "0103", ""}, + {"x,,d2b,,°C,Aussentemperatur", "x=18.004 °C [Aussentemperatur]", "10fe0700090112", "00", "vvv"}, + {"x,,bti,,,,y,,bda,,,,z,,bdy", "21:04:58;26.10.2014;Sun", "10fe0700085804212610061406", "00", ""}, // combination {"x,,bi3,,,,y,,bi5", "1;0", "10feffff0108", "00", ""}, // bit combination {"x,,bi3,,,,y,,bi5", "1;1", "10feffff0128", "00", ""}, // bit combination {"x,,bi3,,,,y,,bi5", "0;1", "10feffff0120", "00", ""}, // bit combination {"x,,bi3,,,,y,,bi5", "0;0", "10feffff0100", "00", ""}, // bit combination - {"x,,bi3,,,,y,,bi7,,,,t,,uch", "0;0;9","10feffff020009", "00", ""}, // bit combination - {"x,,bi6:2,,,,y,,bi0:2,,,,t,,uch", "2;1;9","10feffff03800109", "00", ""}, // bit combination - {"x,,BI0;BI1;BI2;BI3;BI4;BI5;BI6;BI7", "0;0;1;0;0;0;0;0","ff75b50900", "0104", ""}, // bits - {"temp,d2b,,°C,Aussentemperatur","","", "", "t"}, // template with relative pos - {"x,,temp","18.004","10fe0700020112", "00", ""}, // reference to template - {"x,,temp,10","1.8004","10fe0700020112", "00", ""}, // reference to template, valid divider product - {"x,,temp,-10","","", "", "c"}, // reference to template, invalid divider product - {"relrel,d2b,,,,y,d1c","","", "", "t"}, // template struct with relative pos - {"x,,relrel","18.004;9.5","10fe070003011213", "00", ""}, // reference to template struct - {"trelrel,temp;temp","","", "", "t"}, // template struct with relative pos and ref to templates - {"x,,trelrel","18.004;19.008","10fe07000401120213", "00", ""}, // reference to template struct - {"x,,temp,,,,y,,d1c","18.004;9.5","10fe070003011213", "00", ""}, // reference to template, normal def - {"x,,temp;HEX:2","18.004;13 14","10fe07000401121314", "00", ""}, // reference to template and base type - {"x,,temp;HEX:2","temp=18.004;=13 14","10fe07000401121314", "00", "v"}, // reference to template and base type - {"x,,temp:degrees;HEX:2","degrees=18.004;=13 14","10fe07000401121314", "00", "v"}, // reference to template and base type + {"x,,bi3,,,,y,,bi7,,,,t,,uch", "0;0;9", "10feffff020009", "00", ""}, // bit combination + {"x,,bi6:2,,,,y,,bi0:2,,,,t,,uch", "2;1;9", "10feffff03800109", "00", ""}, // bit combination + {"x,,BI0;BI1;BI2;BI3;BI4;BI5;BI6;BI7", "0;0;1;0;0;0;0;0", "ff75b50900", "0104", ""}, // bits + {"temp,d2b,,°C,Aussentemperatur", "", "", "", "t"}, // template with relative pos + {"x,,temp", "18.004", "10fe0700020112", "00", ""}, // reference to template + {"x,,temp,10", "1.8004", "10fe0700020112", "00", ""}, // reference to template, valid divider product + {"x,,temp,-10", "", "", "", "c"}, // reference to template, invalid divider product + {"relrel,d2b,,,,y,d1c", "", "", "", "t"}, // template struct with relative pos + {"x,,relrel", "18.004;9.5", "10fe070003011213", "00", ""}, // reference to template struct + {"trelrel,temp;temp", "", "", "", "t"}, // template struct with relative pos and ref to templates + {"x,,trelrel", "18.004;19.008", "10fe07000401120213", "00", ""}, // reference to template struct + {"x,,temp,,,,y,,d1c", "18.004;9.5", "10fe070003011213", "00", ""}, // reference to template, normal def + {"x,,temp;HEX:2", "18.004;13 14", "10fe07000401121314", "00", ""}, // reference to template and base type + {"x,,temp;HEX:2", "temp=18.004;=13 14", "10fe07000401121314", "00", "v"}, // reference to template and base type + {"x,,temp:degrees;HEX:2", "degrees=18.004;=13 14", "10fe07000401121314", "00", "v"}, // reference to template and base type }; DataFieldTemplates* templates = new DataFieldTemplates(); DataField* fields = NULL; diff --git a/src/lib/ebus/test/test_device.cpp b/src/lib/ebus/test/test_device.cpp index f88d23a9..f38bd48c 100644 --- a/src/lib/ebus/test/test_device.cpp +++ b/src/lib/ebus/test/test_device.cpp @@ -22,7 +22,7 @@ using namespace std; -int main () { +int main() { Device* device = Device::create("/dev/ttyUSB20", true, false, false); if (device == NULL) { cout << "unable to create device" << endl; diff --git a/src/lib/ebus/test/test_message.cpp b/src/lib/ebus/test/test_message.cpp index 77158034..f1d982fa 100644 --- a/src/lib/ebus/test/test_message.cpp +++ b/src/lib/ebus/test/test_message.cpp @@ -71,7 +71,7 @@ int main() { {"pumpstate,UCH,0=off;1=on;2=overrun,,Pumpenstatus", "", "", "", "template"}, {"tempsensor,temp;sensor,,Temperatursensor", "", "", "", "template"}, {"tempsensorc,temp;sensorc,,Temperatursensor", "", "", "", "template"}, - {"r,,Status01,VL/RL/AussenTemp/VLWW/SpeicherTemp/Status,,08,B511,01,,,temp1;temp1;temp2;temp1;temp1;pumpstate","28.0;24.0;4.938;35.0;41.0;4","ff08b5110101","093830f00446520400ff","d"}, + {"r,,Status01,VL/RL/AussenTemp/VLWW/SpeicherTemp/Status,,08,B511,01,,,temp1;temp1;temp2;temp1;temp1;pumpstate", "28.0;24.0;4.938;35.0;41.0;4", "ff08b5110101", "093830f00446520400ff", "d"}, {"r,message circuit,message name,message comment,,25,B509,0d2800,,,tempsensor", "temp=-14.00 Temperatursensor [Temperatur];sensor=ok [Fühlerstatus]", "ff25b509030d2800", "0320ff00", "mD"}, {"r,message circuit,message name,message comment,,25,B509,0d2800,,,tempsensor,,field unit,field comment", "temp=-14.00 field unit [field comment];sensor=ok [Fühlerstatus]", "ff25b509030d2800", "0320ff00", "mD"}, {"r,message circuit,message name,message comment,,25,B509,0d2800,,,tempsensor,,field unit,field comment", "\n \"temp\": {\"value\": -14.00},\n \"sensor\": {\"value\": \"ok\"}", "ff25b509030d2800", "0320ff00", "mj"}, @@ -99,8 +99,8 @@ int main() { {"r,ehp,error,,,08,b509,0d2800,index,m,UCH,,,,,,time", "index=3;time=15:00:17", "ff08b509040d280003", "0311000f", "mD"}, {"u,ehp,ActualEnvironmentPower,Energiebezug,,08,B509,29BA00,,s,IGN:2,,,,,s,power", "8", "1008b5090329ba00", "03ba0008", "pm"}, {"uw,ehp,test,Test,,08,B5de,ab,,,power,,,,,s,hex:1", "8;39", "1008b5de02ab08", "0139", "pm"}, - {"u,ehp,hwTankTemp,Speichertemperatur IST,,25,B509,290000,,,IGN:2,,,,,,tempsensor", "","","","M"}, - {"", "55.50;ok","1025b50903290000","050000780300","d"}, + {"u,ehp,hwTankTemp,Speichertemperatur IST,,25,B509,290000,,,IGN:2,,,,,,tempsensor", "", "", "", "M"}, + {"", "55.50;ok", "1025b50903290000", "050000780300", "d"}, {"r,ehp,datetime,Datum Uhrzeit,,50,B504,00,,,dcfstate,,,,time,,BTI,,,,date,,BDA,,,,temp,,temp2", "valid;08:24:51;31.12.2014;-0.875", "1050b5040100", "0a035124083112031420ff", "md" }, {"r,ehp,bad,invalid pos,,50,B5ff,000102,,m,HEX:8;tempsensor;tempsensor;tempsensor;tempsensor;power;power,,,", "", "", "", "c" }, {"r,ehp,bad,invalid pos,,50,B5ff,,,s,HEX:8;tempsensor;tempsensor;tempsensor;tempsensor;tempsensor;power;power,,,", "", "", "", "c" }, @@ -418,5 +418,4 @@ int main() { delete *it; } return 0; - } diff --git a/src/lib/utils/notify.h b/src/lib/utils/notify.h index 93afbae4..bca64ddc 100644 --- a/src/lib/utils/notify.h +++ b/src/lib/utils/notify.h @@ -27,15 +27,12 @@ /** * class to notify other thread per pipe. */ -class Notify -{ - -public: +class Notify { + public: /** * constructs a new instance and do notifying. */ - Notify() - { + Notify() { int pipefd[2]; int ret = pipe(pipefd); @@ -62,15 +59,14 @@ public: * write notify event to file descriptor. * @return result of writing notification. */ - int notify() const { return write(m_sendfd,"1",1); } + int notify() const { return write(m_sendfd, "1", 1); } -private: + private: /** file descriptor to watch */ int m_recvfd; /** file descriptor to notify */ int m_sendfd; - }; #endif // LIB_UTILS_NOTIFY_H_ diff --git a/src/lib/utils/queue.h b/src/lib/utils/queue.h index 7556146e..1a6d8a85 100644 --- a/src/lib/utils/queue.h +++ b/src/lib/utils/queue.h @@ -33,15 +33,12 @@ using namespace std; * @param T the item type. */ template -class Queue -{ - -public: +class Queue { + public: /** * Constructor. */ - Queue() - { + Queue() { pthread_mutex_init(&m_mutex, NULL); pthread_cond_init(&m_cond, NULL); } @@ -49,28 +46,26 @@ public: /** * Destructor. */ - ~Queue() - { + ~Queue() { pthread_mutex_destroy(&m_mutex); pthread_cond_destroy(&m_cond); } -private: + private: /** * Hidden copy constructor. * @param src the object to copy from. */ Queue(const Queue& src); -public: + public: /** * Add an item to the end of queue. * @param item the item to add. */ - void push(T item) - { + void push(T item) { pthread_mutex_lock(&m_mutex); m_queue.push_back(item); pthread_cond_broadcast(&m_cond); @@ -82,8 +77,7 @@ public: * @param timeout the maximum time in seconds to wait for the queue being filled, or 0 for no wait. * @return the item, or NULL if no item is available within the specified time. */ - T pop(int timeout = 0) - { + T pop(int timeout = 0) { T item; pthread_mutex_lock(&m_mutex); if (timeout > 0) { @@ -112,8 +106,7 @@ public: * @param wait true to wait for the item to appear in the queue. * @return whether the item was removed. */ - bool remove(T item, bool wait = false) - { + bool remove(T item, bool wait = false) { bool ret = false; pthread_mutex_lock(&m_mutex); do { @@ -135,8 +128,7 @@ public: * Return the first item in the queue without removing it. * @return the item, or NULL if no item is available. */ - T peek() - { + T peek() { T item; pthread_mutex_lock(&m_mutex); if (m_queue.empty()) { @@ -148,7 +140,8 @@ public: return item; } -private: + + private: /** the queue itself */ list m_queue; @@ -157,7 +150,6 @@ private: /** condition variable for exclusive lock */ pthread_cond_t m_cond; - }; #endif // LIB_UTILS_QUEUE_H_ diff --git a/src/lib/utils/rotatefile.cpp b/src/lib/utils/rotatefile.cpp index 7e74f8b6..527cc0a2 100644 --- a/src/lib/utils/rotatefile.cpp +++ b/src/lib/utils/rotatefile.cpp @@ -64,8 +64,7 @@ void RotateFile::write(unsigned char* value, unsigned int size, bool received) { fprintf(m_stream, "%04d-%02d-%02d %02d:%02d:%02d.%03ld %c", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, ts.tv_nsec/1000000, - received ? '<' : '>' - ); + received ? '<' : '>'); for (unsigned int pos = 0; pos < size; pos++) { fprintf(m_stream, "%2.2x ", value[pos]); } diff --git a/src/lib/utils/rotatefile.h b/src/lib/utils/rotatefile.h index 2d85a069..6a4c6a3d 100644 --- a/src/lib/utils/rotatefile.h +++ b/src/lib/utils/rotatefile.h @@ -33,9 +33,8 @@ using namespace std; /** * Helper class for writing to a rotating file with maximum size. */ -class RotateFile -{ -public: +class RotateFile { + public: /** * Construct a new instance. * @param fileName the name of the file write to. @@ -71,7 +70,8 @@ public: */ void write(unsigned char* value, unsigned int size, bool received = true); -private: + + private: /** whether writing to the file is enabled. */ bool m_enabled; @@ -89,7 +89,6 @@ private: /** the number of bytes already written to the @a m_file. */ unsigned long m_fileSize; - }; #endif // LIB_UTILS_ROTATEFILE_H_ diff --git a/src/lib/utils/tcpsocket.h b/src/lib/utils/tcpsocket.h index 4ef54f87..e16f5eea 100644 --- a/src/lib/utils/tcpsocket.h +++ b/src/lib/utils/tcpsocket.h @@ -37,10 +37,8 @@ using namespace std; /** * class for low level tcp socket operations. (open, close, send, receive). */ -class TCPSocket -{ - -public: +class TCPSocket { + public: /** grant access for friend class TCPClient */ friend class TCPClient; @@ -92,7 +90,8 @@ public: */ bool isValid(); -private: + + private: /** file descriptor from tcp socket */ int m_sfd; @@ -108,16 +107,13 @@ private: * @param address struct which holds the ip address. */ TCPSocket(int sfd, struct sockaddr_in* address); - }; /** * class to initiate a tcp socket connection to a listening server. */ -class TCPClient -{ - -public: +class TCPClient { + public: /** * initiate a tcp socket connection to a listening server. * @param server the server name or ip address to connect. @@ -125,16 +121,13 @@ public: * @return pointer to an opened tcp socket. */ TCPSocket* connect(const string& server, const uint16_t& port); - }; /** * class for a tcp based network server. */ -class TCPServer -{ - -public: +class TCPServer { + public: /** * creates a new instance of a listening tcp server. * @param port the tcp port. @@ -166,7 +159,8 @@ public: */ int getFD() const { return m_lfd; } -private: + + private: /** file descriptor from listening tcp socket */ int m_lfd; @@ -178,7 +172,6 @@ private: /** true if object is already listening */ bool m_listening; - }; #endif // LIB_UTILS_TCPSOCKET_H_ diff --git a/src/lib/utils/thread.cpp b/src/lib/utils/thread.cpp index 90dd6cbf..3132c0cc 100644 --- a/src/lib/utils/thread.cpp +++ b/src/lib/utils/thread.cpp @@ -36,37 +36,28 @@ Thread::~Thread() { } bool Thread::start(const char* name) { - int result = pthread_create(&m_threadid, NULL, runThread, this); - if (result == 0) { - #ifdef HAVE_PTHREAD_SETNAME_NP #ifndef __MACH__ pthread_setname_np(m_threadid, name); #endif #endif - m_started = true; - return true; } - return false; } bool Thread::join() { int result = -1; - if (m_started) { m_stopped = true; result = pthread_join(m_threadid, NULL); - if (result == 0) { m_started = false; } } - return result == 0; } diff --git a/src/lib/utils/thread.h b/src/lib/utils/thread.h index 405e3140..a056033c 100644 --- a/src/lib/utils/thread.h +++ b/src/lib/utils/thread.h @@ -26,10 +26,8 @@ /** * wrapper class for pthread. */ -class Thread -{ - -public: +class Thread { + public: /** * constructor. */ @@ -77,15 +75,15 @@ public: */ pthread_t self() { return m_threadid; } -protected: + protected: /** * Thread entry method to be overridden by derived class. */ virtual void run() = 0; -private: + private: /** * Enter the Thread loop by calling run(). */ @@ -102,17 +100,14 @@ private: /** Whether the thread was stopped by @a stop() or @a join(). */ bool m_stopped; - }; /** * A @a Thread that can be waited on. */ -class WaitThread : public Thread -{ - -public: +class WaitThread : public Thread { + public: /** * Constructor. */ @@ -136,13 +131,13 @@ public: */ bool Wait(int seconds); -private: + + private: /** the mutex for waiting. */ pthread_mutex_t m_mutex; /** the condition for waiting. */ pthread_cond_t m_cond; - }; #endif // LIB_UTILS_THREAD_H_ diff --git a/src/tools/ebusctl.cpp b/src/tools/ebusctl.cpp index 1897bcb0..828ee8e1 100644 --- a/src/tools/ebusctl.cpp +++ b/src/tools/ebusctl.cpp @@ -36,8 +36,7 @@ using namespace std; /** A structure holding all program options. */ -struct options -{ +struct options { const char* server; //!< ebusd server host (name or ip) [localhost] uint16_t port; //!< ebusd server port [8888] @@ -229,7 +228,6 @@ string fetchData(TCPSocket* socket, bool& listening) { } void connect(const char* host, uint16_t port, char* const *args, int argCount) { - TCPClient* client = new TCPClient(); TCPSocket* socket = client->connect(host, port); @@ -242,8 +240,7 @@ void connect(const char* host, uint16_t port, char* const *args, int argCount) { if (!once) { cout << host << ": "; getline(cin, message); - } - else { + } else { for (int i = 0; i < argCount; i++) { if (i > 0) { message += " "; diff --git a/src/tools/ebusfeed.cpp b/src/tools/ebusfeed.cpp index 59b802f9..48fd6156 100644 --- a/src/tools/ebusfeed.cpp +++ b/src/tools/ebusfeed.cpp @@ -32,8 +32,7 @@ using namespace std; /** A structure holding all program options. */ -struct options -{ +struct options { const char* device; //!< device to write to [/dev/ttyUSB60] unsigned int time; //!< delay between bytes in us [10000] @@ -111,8 +110,9 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) { return EINVAL; } opt->dumpFile = arg; - } else + } else { return ARGP_ERR_UNKNOWN; + } break; default: return ARGP_ERR_UNKNOWN;