Merge remote-tracking branch 'origin/master' into enhanced_device
# Conflicts: # docs/enhanced_proto.md # src/ebusd/bushandler.cpp # src/lib/ebus/device.cpp # src/lib/ebus/device.h
This commit is contained in:
Executable → Regular
+1
@@ -30,6 +30,7 @@ app.info
|
|||||||
/src/lib/utils/libutils.a
|
/src/lib/utils/libutils.a
|
||||||
/src/lib/ebus/libebus.a
|
/src/lib/ebus/libebus.a
|
||||||
/src/lib/ebus/contrib/test/test_tem
|
/src/lib/ebus/contrib/test/test_tem
|
||||||
|
/src/lib/ebus/test/test_device
|
||||||
/src/lib/ebus/test/test_symbol
|
/src/lib/ebus/test/test_symbol
|
||||||
/src/lib/ebus/test/test_data
|
/src/lib/ebus/test/test_data
|
||||||
/src/lib/ebus/test/test_message
|
/src/lib/ebus/test/test_message
|
||||||
|
|||||||
+18
-3
@@ -1,3 +1,21 @@
|
|||||||
|
# 3.5 (2020-12-?)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
* fix for publishing several MQTT updates at once
|
||||||
|
* optimized keep alive option for net devices
|
||||||
|
* fix for duplicate entry "minarbitrationmicros" in HTTP GET
|
||||||
|
* fix for extra send retry
|
||||||
|
* fix for newer compiler versions
|
||||||
|
* fix for potential illegal string usages
|
||||||
|
* fix for named net device not being resolvable during startup
|
||||||
|
|
||||||
|
## Features
|
||||||
|
* added Raspberry Pi docker image
|
||||||
|
* added support for Cygwin build
|
||||||
|
* added option to use "\*" as trailing wildcard for circuit and name in MQTT /list topic
|
||||||
|
* added "--mqttinsecure" option
|
||||||
|
|
||||||
|
|
||||||
# 3.4 (2019-10-27)
|
# 3.4 (2019-10-27)
|
||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
@@ -39,9 +57,6 @@
|
|||||||
* added support for single quotes to all commands
|
* added support for single quotes to all commands
|
||||||
* added "--mqttlog" and "--mqttversion" options
|
* added "--mqttlog" and "--mqttversion" options
|
||||||
|
|
||||||
## Breaking Changes
|
|
||||||
* added support for enhanced network protocol mode for recent [ebusd-esp firmware](https://github.com/john30/ebusd-esp/) that allows the arbitration to be done directly by the Wemos
|
|
||||||
|
|
||||||
|
|
||||||
# 3.2 (2018-05-10)
|
# 3.2 (2018-05-10)
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Features
|
|||||||
|
|
||||||
The main features of the daemon are:
|
The main features of the daemon are:
|
||||||
|
|
||||||
* use USB serial, TCP connected or UDP device, or enhanced ebusd protocol for recent [ebusd-esp firmware](https://github.com/john30/ebusd-esp/) (allows arbitration to be done directly by the Wemos)
|
* use USB serial, TCP connected, or UDP device
|
||||||
* actively send messages to and receive answers from the eBUS
|
* actively send messages to and receive answers from the eBUS
|
||||||
* passively listen to messages sent on the eBUS
|
* passively listen to messages sent on the eBUS
|
||||||
* regularly poll for messages
|
* regularly poll for messages
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ Using a network device
|
|||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
When using a network device, the "--device" argument to docker can be omitted, but the device information has to be passed on to ebusd:
|
When using a network device, the "--device" argument to docker can be omitted, but the device information has to be passed on to ebusd:
|
||||||
> docker run --rm -it -p 8888 john30/ebusd -f --scanconfig -d udp:192.168.178.123:10000 --latency=80
|
> docker run --rm -it -p 8888 john30/ebusd -f --scanconfig -d udp:192.168.178.123:10000 --latency=80000
|
||||||
|
|
||||||
Note: the "-f" and "--scanconfig" arguments are only passed to ebusd if it is called without any additional arguments. So when passing further arguments, these two usually need to be added as well.
|
Note: the "-f" and "--scanconfig" arguments are only passed to ebusd if it is called without any additional arguments. So when passing further arguments, these two usually need to be added as well.
|
||||||
|
|
||||||
|
|||||||
@@ -478,6 +478,12 @@ result_t BusHandler::handleSymbol() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case bs_ready:
|
||||||
|
if (m_currentRequest != nullptr) {
|
||||||
|
setState(bs_ready, RESULT_ERR_TIMEOUT); // just to be sure an old BusRequest is cleaned up
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case bs_recvCmd:
|
case bs_recvCmd:
|
||||||
case bs_recvCmdCrc:
|
case bs_recvCmdCrc:
|
||||||
timeout = m_slaveRecvTimeout;
|
timeout = m_slaveRecvTimeout;
|
||||||
|
|||||||
+20
-19
@@ -45,23 +45,20 @@ namespace ebusd {
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
/** the default time [ms] for retrieving a symbol from an addressed slave. */
|
/** the default time [us] for retrieving a symbol from an addressed slave. */
|
||||||
#define SLAVE_RECV_TIMEOUT 15
|
#define SLAVE_RECV_TIMEOUT 15000
|
||||||
|
|
||||||
/** the maximum allowed time [ms] for retrieving the AUTO-SYN symbol (45ms + 2*1,2% + 1 Symbol). */
|
/** the maximum allowed time [us] for retrieving the AUTO-SYN symbol (45ms + 2*1,2% + 1 Symbol). */
|
||||||
#define SYN_TIMEOUT 51
|
#define SYN_TIMEOUT 50800
|
||||||
|
|
||||||
/** the time [ms] for determining bus signal availability (AUTO-SYN timeout * 5). */
|
/** the time [us] for determining bus signal availability (AUTO-SYN timeout * 5). */
|
||||||
#define SIGNAL_TIMEOUT 250
|
#define SIGNAL_TIMEOUT 250000
|
||||||
|
|
||||||
/** the maximum duration [us] of a single symbol (Start+8Bit+Stop+Extra @ 2400Bd-2*1,2%). */
|
/** the maximum duration [us] of a single symbol (Start+8Bit+Stop+Extra @ 2400Bd-2*1,2%). */
|
||||||
#define SYMBOL_DURATION_MICROS 4700
|
#define SYMBOL_DURATION 4700
|
||||||
|
|
||||||
/** the maximum duration [ms] of a single symbol (Start+8Bit+Stop+Extra @ 2400Bd-2*1,2%). */
|
/** the maximum allowed time [us] for retrieving back a sent symbol (2x symbol duration). */
|
||||||
#define SYMBOL_DURATION 5
|
#define SEND_TIMEOUT (2*SYMBOL_DURATION)
|
||||||
|
|
||||||
/** the maximum allowed time [ms] for retrieving back a sent symbol (2x symbol duration). */
|
|
||||||
#define SEND_TIMEOUT ((int)((2*SYMBOL_DURATION_MICROS+999)/1000))
|
|
||||||
|
|
||||||
/** the possible bus states. */
|
/** the possible bus states. */
|
||||||
enum BusState {
|
enum BusState {
|
||||||
@@ -371,8 +368,9 @@ class BusHandler : public WaitThread {
|
|||||||
* @param answer whether to answer queries for the own master/slave address.
|
* @param answer whether to answer queries for the own master/slave address.
|
||||||
* @param busLostRetries the number of times a send is repeated due to lost arbitration.
|
* @param busLostRetries the number of times a send is repeated due to lost arbitration.
|
||||||
* @param failedSendRetries the number of times a failed send is repeated (other than lost arbitration).
|
* @param failedSendRetries the number of times a failed send is repeated (other than lost arbitration).
|
||||||
* @param busAcquireTimeout the maximum time in milliseconds for bus acquisition.
|
* @param transferLatency the bus transfer latency in microseconds.
|
||||||
* @param slaveRecvTimeout the maximum time in milliseconds an addressed slave is expected to acknowledge.
|
* @param busAcquireTimeout the maximum time in microseconds for bus acquisition.
|
||||||
|
* @param slaveRecvTimeout the maximum time in microseconds an addressed slave is expected to acknowledge.
|
||||||
* @param lockCount the number of AUTO-SYN symbols before sending is allowed after lost arbitration, or 0 for auto detection.
|
* @param lockCount the number of AUTO-SYN symbols before sending is allowed after lost arbitration, or 0 for auto detection.
|
||||||
* @param generateSyn whether to enable AUTO-SYN symbol generation.
|
* @param generateSyn whether to enable AUTO-SYN symbol generation.
|
||||||
* @param pollInterval the interval in seconds in which poll messages are cycled, or 0 if disabled.
|
* @param pollInterval the interval in seconds in which poll messages are cycled, or 0 if disabled.
|
||||||
@@ -380,14 +378,14 @@ class BusHandler : public WaitThread {
|
|||||||
BusHandler(Device* device, MessageMap* messages,
|
BusHandler(Device* device, MessageMap* messages,
|
||||||
symbol_t ownAddress, bool answer,
|
symbol_t ownAddress, bool answer,
|
||||||
unsigned int busLostRetries, unsigned int failedSendRetries,
|
unsigned int busLostRetries, unsigned int failedSendRetries,
|
||||||
unsigned int busAcquireTimeout, unsigned int slaveRecvTimeout,
|
unsigned int transferLatency, unsigned int busAcquireTimeout, unsigned int slaveRecvTimeout,
|
||||||
unsigned int lockCount, bool generateSyn,
|
unsigned int lockCount, bool generateSyn,
|
||||||
unsigned int pollInterval)
|
unsigned int pollInterval)
|
||||||
: WaitThread(), m_device(device), m_reconnect(false), m_messages(messages),
|
: WaitThread(), m_device(device), m_reconnect(false), m_messages(messages),
|
||||||
m_ownMasterAddress(ownAddress), m_ownSlaveAddress(getSlaveAddress(ownAddress)),
|
m_ownMasterAddress(ownAddress), m_ownSlaveAddress(getSlaveAddress(ownAddress)),
|
||||||
m_answer(answer), m_addressConflict(false),
|
m_answer(answer), m_addressConflict(false),
|
||||||
m_busLostRetries(busLostRetries), m_failedSendRetries(failedSendRetries),
|
m_busLostRetries(busLostRetries), m_failedSendRetries(failedSendRetries),
|
||||||
m_busAcquireTimeout(busAcquireTimeout), m_slaveRecvTimeout(slaveRecvTimeout),
|
m_transferLatency(transferLatency), m_busAcquireTimeout(busAcquireTimeout), m_slaveRecvTimeout(slaveRecvTimeout),
|
||||||
m_masterCount(device->isReadOnly()?0:1), m_autoLockCount(lockCount == 0),
|
m_masterCount(device->isReadOnly()?0:1), m_autoLockCount(lockCount == 0),
|
||||||
m_lockCount(lockCount <= 3 ? 3 : lockCount), m_remainLockCount(m_autoLockCount ? 1 : 0),
|
m_lockCount(lockCount <= 3 ? 3 : lockCount), m_remainLockCount(m_autoLockCount ? 1 : 0),
|
||||||
m_generateSynInterval(generateSyn ? SYN_TIMEOUT*getMasterNumber(ownAddress)+SYMBOL_DURATION : 0),
|
m_generateSynInterval(generateSyn ? SYN_TIMEOUT*getMasterNumber(ownAddress)+SYMBOL_DURATION : 0),
|
||||||
@@ -688,10 +686,13 @@ class BusHandler : public WaitThread {
|
|||||||
/** the number of times a failed send is repeated (other than lost arbitration). */
|
/** the number of times a failed send is repeated (other than lost arbitration). */
|
||||||
const unsigned int m_failedSendRetries;
|
const unsigned int m_failedSendRetries;
|
||||||
|
|
||||||
/** the maximum time in milliseconds for bus acquisition. */
|
/** the bus transfer latency in microseconds. */
|
||||||
|
const unsigned int m_transferLatency;
|
||||||
|
|
||||||
|
/** the maximum time in microseconds for bus acquisition. */
|
||||||
const unsigned int m_busAcquireTimeout;
|
const unsigned int m_busAcquireTimeout;
|
||||||
|
|
||||||
/** the maximum time in milliseconds an addressed slave is expected to acknowledge. */
|
/** the maximum time in microseconds an addressed slave is expected to acknowledge. */
|
||||||
const unsigned int m_slaveRecvTimeout;
|
const unsigned int m_slaveRecvTimeout;
|
||||||
|
|
||||||
/** the number of masters already seen. */
|
/** the number of masters already seen. */
|
||||||
@@ -706,7 +707,7 @@ class BusHandler : public WaitThread {
|
|||||||
/** the remaining number of AUTO-SYN symbols before sending is allowed again. */
|
/** the remaining number of AUTO-SYN symbols before sending is allowed again. */
|
||||||
unsigned int m_remainLockCount;
|
unsigned int m_remainLockCount;
|
||||||
|
|
||||||
/** the interval in milliseconds after which to generate an AUTO-SYN symbol, or 0 if disabled. */
|
/** the interval in microseconds after which to generate an AUTO-SYN symbol, or 0 if disabled. */
|
||||||
unsigned int m_generateSynInterval;
|
unsigned int m_generateSynInterval;
|
||||||
|
|
||||||
/** the interval in seconds in which poll messages are cycled, or 0 if disabled. */
|
/** the interval in seconds in which poll messages are cycled, or 0 if disabled. */
|
||||||
|
|||||||
+15
-19
@@ -79,7 +79,7 @@ static struct options opt = {
|
|||||||
false, // noDeviceCheck
|
false, // noDeviceCheck
|
||||||
false, // readOnly
|
false, // readOnly
|
||||||
false, // initialSend
|
false, // initialSend
|
||||||
0, // extraLatency
|
-1, // latency
|
||||||
|
|
||||||
CONFIG_PATH, // configPath
|
CONFIG_PATH, // configPath
|
||||||
false, // scanConfig
|
false, // scanConfig
|
||||||
@@ -92,7 +92,7 @@ static struct options opt = {
|
|||||||
|
|
||||||
0x31, // address
|
0x31, // address
|
||||||
false, // answer
|
false, // answer
|
||||||
10, // acquireTimeout
|
9400, // acquireTimeout
|
||||||
3, // acquireRetries
|
3, // acquireRetries
|
||||||
2, // sendRetries
|
2, // sendRetries
|
||||||
SLAVE_RECV_TIMEOUT*5/3, // receiveTimeout
|
SLAVE_RECV_TIMEOUT*5/3, // receiveTimeout
|
||||||
@@ -184,7 +184,7 @@ static const struct argp_option argpoptions[] = {
|
|||||||
{"nodevicecheck", 'n', nullptr, 0, "Skip serial eBUS device test", 0 },
|
{"nodevicecheck", 'n', nullptr, 0, "Skip serial eBUS device test", 0 },
|
||||||
{"readonly", 'r', nullptr, 0, "Only read from device, never write to it", 0 },
|
{"readonly", 'r', nullptr, 0, "Only read from device, never write to it", 0 },
|
||||||
{"initsend", O_INISND, nullptr, 0, "Send an initial escape symbol after connecting device", 0 },
|
{"initsend", O_INISND, nullptr, 0, "Send an initial escape symbol after connecting device", 0 },
|
||||||
{"latency", O_DEVLAT, "MSEC", 0, "Extra transfer latency in ms [0]", 0 },
|
{"latency", O_DEVLAT, "USEC", 0, "Transfer latency in us [0 for USB, 10000 for IP]", 0 },
|
||||||
|
|
||||||
{nullptr, 0, nullptr, 0, "Message configuration options:", 2 },
|
{nullptr, 0, nullptr, 0, "Message configuration options:", 2 },
|
||||||
{"configpath", 'c', "PATH", 0, "Read CSV config files from PATH (local folder or HTTP URL) [" CONFIG_PATH
|
{"configpath", 'c', "PATH", 0, "Read CSV config files from PATH (local folder or HTTP URL) [" CONFIG_PATH
|
||||||
@@ -204,10 +204,10 @@ static const struct argp_option argpoptions[] = {
|
|||||||
{nullptr, 0, nullptr, 0, "eBUS options:", 3 },
|
{nullptr, 0, nullptr, 0, "eBUS options:", 3 },
|
||||||
{"address", 'a', "ADDR", 0, "Use ADDR as own bus address [31]", 0 },
|
{"address", 'a', "ADDR", 0, "Use ADDR as own bus address [31]", 0 },
|
||||||
{"answer", O_ANSWER, nullptr, 0, "Actively answer to requests from other masters", 0 },
|
{"answer", O_ANSWER, nullptr, 0, "Actively answer to requests from other masters", 0 },
|
||||||
{"acquiretimeout", O_ACQTIM, "MSEC", 0, "Stop bus acquisition after MSEC ms [10]", 0 },
|
{"acquiretimeout", O_ACQTIM, "USEC", 0, "Stop bus acquisition after USEC us [9400]", 0 },
|
||||||
{"acquireretries", O_ACQRET, "COUNT", 0, "Retry bus acquisition COUNT times [3]", 0 },
|
{"acquireretries", O_ACQRET, "COUNT", 0, "Retry bus acquisition COUNT times [3]", 0 },
|
||||||
{"sendretries", O_SNDRET, "COUNT", 0, "Repeat failed sends COUNT times [2]", 0 },
|
{"sendretries", O_SNDRET, "COUNT", 0, "Repeat failed sends COUNT times [2]", 0 },
|
||||||
{"receivetimeout", O_RCVTIM, "MSEC", 0, "Expect a slave to answer within MSEC us [25]", 0 },
|
{"receivetimeout", O_RCVTIM, "USEC", 0, "Expect a slave to answer within USEC us [25000]", 0 },
|
||||||
{"numbermasters", O_MASCNT, "COUNT", 0, "Expect COUNT masters on the bus, 0 for auto detection [0]", 0 },
|
{"numbermasters", O_MASCNT, "COUNT", 0, "Expect COUNT masters on the bus, 0 for auto detection [0]", 0 },
|
||||||
{"generatesyn", O_GENSYN, nullptr, 0, "Enable AUTO-SYN symbol generation", 0 },
|
{"generatesyn", O_GENSYN, nullptr, 0, "Enable AUTO-SYN symbol generation", 0 },
|
||||||
|
|
||||||
@@ -267,7 +267,6 @@ static map<string, DataFieldTemplates*> s_templatesByPath;
|
|||||||
error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
||||||
struct options *opt = (struct options*)state->input;
|
struct options *opt = (struct options*)state->input;
|
||||||
result_t result = RESULT_OK;
|
result_t result = RESULT_OK;
|
||||||
unsigned int value;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
// Device options:
|
// Device options:
|
||||||
@@ -296,13 +295,12 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||||||
}
|
}
|
||||||
opt->initialSend = true;
|
opt->initialSend = true;
|
||||||
break;
|
break;
|
||||||
case O_DEVLAT: // --latency=10
|
case O_DEVLAT: // --latency=10000
|
||||||
value = parseInt(arg, 10, 0, 200000, &result); // backwards compatible (micros)
|
opt->latency = parseInt(arg, 10, 0, 200000, &result);
|
||||||
if (result != RESULT_OK || (value<=1000 && value>200)) { // backwards compatible (micros)
|
if (result != RESULT_OK) {
|
||||||
argp_error(state, "invalid latency");
|
argp_error(state, "invalid latency");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
opt->extraLatency = value > 1000 ? value/1000 : value; // backwards compatible (micros)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Message configuration options:
|
// Message configuration options:
|
||||||
@@ -378,13 +376,12 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||||||
}
|
}
|
||||||
opt->answer = true;
|
opt->answer = true;
|
||||||
break;
|
break;
|
||||||
case O_ACQTIM: // --acquiretimeout=10
|
case O_ACQTIM: // --acquiretimeout=9400
|
||||||
value = parseInt(arg, 10, 1, 100000, &result); // backwards compatible (micros)
|
opt->acquireTimeout = parseInt(arg, 10, 1000, 100000, &result);
|
||||||
if (result != RESULT_OK || (value<=1000 && value>100)) { // backwards compatible (micros)
|
if (result != RESULT_OK) {
|
||||||
argp_error(state, "invalid acquiretimeout");
|
argp_error(state, "invalid acquiretimeout");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
opt->acquireTimeout = value > 1000 ? value/1000 : value; // backwards compatible (micros)
|
|
||||||
break;
|
break;
|
||||||
case O_ACQRET: // --acquireretries=3
|
case O_ACQRET: // --acquireretries=3
|
||||||
opt->acquireRetries = parseInt(arg, 10, 0, 10, &result);
|
opt->acquireRetries = parseInt(arg, 10, 0, 10, &result);
|
||||||
@@ -400,13 +397,12 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case O_RCVTIM: // --receivetimeout=25
|
case O_RCVTIM: // --receivetimeout=25000
|
||||||
value = parseInt(arg, 10, 1, 100000, &result); // backwards compatible (micros)
|
opt->receiveTimeout = parseInt(arg, 10, 1000, 100000, &result);
|
||||||
if (result != RESULT_OK || (value<=1000 && value>100)) { // backwards compatible (micros)
|
if (result != RESULT_OK) {
|
||||||
argp_error(state, "invalid receivetimeout");
|
argp_error(state, "invalid receivetimeout");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
opt->receiveTimeout = value > 1000 ? value/1000 : value; // backwards compatible (micros)
|
|
||||||
break;
|
break;
|
||||||
case O_MASCNT: // --numbermasters=0
|
case O_MASCNT: // --numbermasters=0
|
||||||
opt->masterCount = parseInt(arg, 10, 0, 25, &result);
|
opt->masterCount = parseInt(arg, 10, 0, 25, &result);
|
||||||
@@ -1310,7 +1306,7 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// open the device
|
// open the device
|
||||||
Device *device = Device::create(opt.device, opt.extraLatency, !opt.noDeviceCheck, opt.readOnly, opt.initialSend);
|
Device *device = Device::create(opt.device, !opt.noDeviceCheck, opt.readOnly, opt.initialSend);
|
||||||
if (device == nullptr) {
|
if (device == nullptr) {
|
||||||
logError(lf_main, "unable to create device %s", opt.device);
|
logError(lf_main, "unable to create device %s", opt.device);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|||||||
+3
-3
@@ -39,7 +39,7 @@ struct options {
|
|||||||
bool noDeviceCheck; //!< skip serial eBUS device test
|
bool noDeviceCheck; //!< skip serial eBUS device test
|
||||||
bool readOnly; //!< read-only access to the device
|
bool readOnly; //!< read-only access to the device
|
||||||
bool initialSend; //!< send an initial escape symbol after connecting device
|
bool initialSend; //!< send an initial escape symbol after connecting device
|
||||||
unsigned int extraLatency; //!< extra transfer latency in ms [0 for USB, 10 for IP]
|
int latency; //!< transfer latency in us [0 for USB, 10000 for IP]
|
||||||
|
|
||||||
const char* configPath; //!< path to CSV configuration files [http://ebusd.eu/config/]
|
const char* configPath; //!< path to CSV configuration files [http://ebusd.eu/config/]
|
||||||
bool scanConfig; //!< pick configuration files matching initial scan
|
bool scanConfig; //!< pick configuration files matching initial scan
|
||||||
@@ -54,10 +54,10 @@ struct options {
|
|||||||
|
|
||||||
symbol_t address; //!< own bus address [31]
|
symbol_t address; //!< own bus address [31]
|
||||||
bool answer; //!< answer to requests from other masters
|
bool answer; //!< answer to requests from other masters
|
||||||
unsigned int acquireTimeout; //!< bus acquisition timeout in ms [10]
|
unsigned int acquireTimeout; //!< bus acquisition timeout in us [9400]
|
||||||
unsigned int acquireRetries; //!< number of retries for bus acquisition [3]
|
unsigned int acquireRetries; //!< number of retries for bus acquisition [3]
|
||||||
unsigned int sendRetries; //!< number of retries for failed sends [2]
|
unsigned int sendRetries; //!< number of retries for failed sends [2]
|
||||||
unsigned int receiveTimeout; //!< timeout for receiving answer from slave in ms [25]
|
unsigned int receiveTimeout; //!< timeout for receiving answer from slave in us [25000]
|
||||||
unsigned int masterCount; //!< expected number of masters for arbitration [0]
|
unsigned int masterCount; //!< expected number of masters for arbitration [0]
|
||||||
bool generateSyn; //!< enable AUTO-SYN symbol generation
|
bool generateSyn; //!< enable AUTO-SYN symbol generation
|
||||||
|
|
||||||
|
|||||||
+9
-17
@@ -141,10 +141,16 @@ MainLoop::MainLoop(const struct options& opt, Device *device, MessageMap* messag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create BusHandler
|
// create BusHandler
|
||||||
|
unsigned int latency;
|
||||||
|
if (opt.latency < 0) {
|
||||||
|
latency = device->getLatency();
|
||||||
|
} else {
|
||||||
|
latency = (unsigned int)opt.latency;
|
||||||
|
}
|
||||||
m_busHandler = new BusHandler(m_device, m_messages,
|
m_busHandler = new BusHandler(m_device, m_messages,
|
||||||
m_address, opt.answer,
|
m_address, opt.answer,
|
||||||
opt.acquireRetries, opt.sendRetries,
|
opt.acquireRetries, opt.sendRetries,
|
||||||
opt.acquireTimeout, opt.receiveTimeout,
|
latency, opt.acquireTimeout, opt.receiveTimeout,
|
||||||
opt.masterCount, opt.generateSyn,
|
opt.masterCount, opt.generateSyn,
|
||||||
opt.pollInterval);
|
opt.pollInterval);
|
||||||
m_busHandler->start("bushandler");
|
m_busHandler->start("bushandler");
|
||||||
@@ -467,18 +473,12 @@ void MainLoop::notifyDeviceData(symbol_t symbol, bool received) {
|
|||||||
}
|
}
|
||||||
if (m_logRawBuffer.tellp() == 0 || received != m_logRawLastReceived) {
|
if (m_logRawBuffer.tellp() == 0 || received != m_logRawLastReceived) {
|
||||||
m_logRawLastReceived = received;
|
m_logRawLastReceived = received;
|
||||||
if (m_logRawBuffer.tellp() == 0 && m_logRawLastSymbol != SYN) {
|
|
||||||
m_logRawBuffer << "...";
|
|
||||||
}
|
|
||||||
m_logRawBuffer << (received ? "<" : ">");
|
m_logRawBuffer << (received ? "<" : ">");
|
||||||
}
|
}
|
||||||
m_logRawBuffer << setw(2) << setfill('0') << hex << static_cast<unsigned>(symbol);
|
m_logRawBuffer << setw(2) << setfill('0') << hex << static_cast<unsigned>(symbol);
|
||||||
|
m_logRawLastSymbol = symbol;
|
||||||
}
|
}
|
||||||
m_logRawLastSymbol = symbol;
|
if (symbol == SYN && m_logRawBuffer.tellp() > 0) { // flush
|
||||||
if (m_logRawBuffer.tellp() > (symbol == SYN ? 0 : 64)) { // flush: direction+5 hdr+24 max data+crc+direction+ack+1
|
|
||||||
if (symbol != SYN) {
|
|
||||||
m_logRawBuffer << "...";
|
|
||||||
}
|
|
||||||
const string bufStr = m_logRawBuffer.str();
|
const string bufStr = m_logRawBuffer.str();
|
||||||
const char* str = bufStr.c_str();
|
const char* str = bufStr.c_str();
|
||||||
if (m_logRawFile) {
|
if (m_logRawFile) {
|
||||||
@@ -490,14 +490,6 @@ void MainLoop::notifyDeviceData(symbol_t symbol, bool received) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainLoop::notifyStatus(bool error, const char* message) {
|
|
||||||
if (error) {
|
|
||||||
logError(lf_bus, "device status: %s", message);
|
|
||||||
} else {
|
|
||||||
logNotice(lf_bus, "device status: %s", message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result_t MainLoop::decodeMessage(const string &data, bool isHttp, bool* connected, ClientSettings* settings,
|
result_t MainLoop::decodeMessage(const string &data, bool isHttp, bool* connected, ClientSettings* settings,
|
||||||
string* user, bool* reload, ostringstream* ostream) {
|
string* user, bool* reload, ostringstream* ostream) {
|
||||||
string token, previous;
|
string token, previous;
|
||||||
|
|||||||
@@ -132,9 +132,6 @@ class MainLoop : public Thread, DeviceListener {
|
|||||||
// @copydoc
|
// @copydoc
|
||||||
void notifyDeviceData(symbol_t symbol, bool received) override;
|
void notifyDeviceData(symbol_t symbol, bool received) override;
|
||||||
|
|
||||||
// @copydoc
|
|
||||||
void notifyStatus(bool error, const char* message) override;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// @copydoc
|
// @copydoc
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ const char* getResultCode(result_t resultCode) {
|
|||||||
case RESULT_ERR_DUPLICATE: return "ERR: duplicate entry";
|
case RESULT_ERR_DUPLICATE: return "ERR: duplicate entry";
|
||||||
case RESULT_ERR_DUPLICATE_NAME: return "ERR: duplicate name";
|
case RESULT_ERR_DUPLICATE_NAME: return "ERR: duplicate name";
|
||||||
case RESULT_ERR_BUS_LOST: return "ERR: arbitration lost";
|
case RESULT_ERR_BUS_LOST: return "ERR: arbitration lost";
|
||||||
case RESULT_ERR_ARB_RUNNING: return "ERR: arbitration running";
|
|
||||||
case RESULT_ERR_CRC: return "ERR: CRC error";
|
case RESULT_ERR_CRC: return "ERR: CRC error";
|
||||||
case RESULT_ERR_ACK: return "ERR: ACK error";
|
case RESULT_ERR_ACK: return "ERR: ACK error";
|
||||||
case RESULT_ERR_NAK: return "ERR: NAK received";
|
case RESULT_ERR_NAK: return "ERR: NAK received";
|
||||||
|
|||||||
@@ -56,16 +56,15 @@ enum result_t {
|
|||||||
RESULT_ERR_DUPLICATE_NAME = -17, //!< duplicate entry (name)
|
RESULT_ERR_DUPLICATE_NAME = -17, //!< duplicate entry (name)
|
||||||
|
|
||||||
RESULT_ERR_BUS_LOST = -18, //!< arbitration lost
|
RESULT_ERR_BUS_LOST = -18, //!< arbitration lost
|
||||||
RESULT_ERR_ARB_RUNNING = -19, //!< arbitration running
|
RESULT_ERR_CRC = -19, //!< CRC error
|
||||||
RESULT_ERR_CRC = -20, //!< CRC error
|
RESULT_ERR_ACK = -20, //!< ACK error
|
||||||
RESULT_ERR_ACK = -21, //!< ACK error
|
RESULT_ERR_NAK = -21, //!< NAK received
|
||||||
RESULT_ERR_NAK = -22, //!< NAK received
|
|
||||||
|
|
||||||
RESULT_ERR_NO_SIGNAL = -23, //!< no signal found on the bus
|
RESULT_ERR_NO_SIGNAL = -22, //!< no signal found on the bus
|
||||||
RESULT_ERR_SYN = -24, //!< SYN received instead of answer
|
RESULT_ERR_SYN = -23, //!< SYN received instead of answer
|
||||||
RESULT_ERR_SYMBOL = -25, //!< wrong symbol received instead of sent symbol
|
RESULT_ERR_SYMBOL = -24, //!< wrong symbol received instead of sent symbol
|
||||||
|
|
||||||
RESULT_ERR_NOTAUTHORIZED = -26 //!< not authorized for this action
|
RESULT_ERR_NOTAUTHORIZED = -25 //!< not authorized for this action
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,19 +72,19 @@ using std::vector;
|
|||||||
typedef unsigned char symbol_t;
|
typedef unsigned char symbol_t;
|
||||||
|
|
||||||
/** escape symbol, either followed by 0x00 for the value 0xA9, or 0x01 for the value 0xAA. */
|
/** escape symbol, either followed by 0x00 for the value 0xA9, or 0x01 for the value 0xAA. */
|
||||||
#define ESC ((symbol_t)0xA9)
|
#define ESC 0xA9
|
||||||
|
|
||||||
/** synchronization symbol. */
|
/** synchronization symbol. */
|
||||||
#define SYN ((symbol_t)0xAA)
|
#define SYN 0xAA
|
||||||
|
|
||||||
/** positive acknowledge symbol. */
|
/** positive acknowledge symbol. */
|
||||||
#define ACK ((symbol_t)0x00)
|
#define ACK 0x00
|
||||||
|
|
||||||
/** negative acknowledge symbol. */
|
/** negative acknowledge symbol. */
|
||||||
#define NAK ((symbol_t)0xFF)
|
#define NAK 0xFF
|
||||||
|
|
||||||
/** the broadcast destination address. */
|
/** the broadcast destination address. */
|
||||||
#define BROADCAST ((symbol_t)0xFE)
|
#define BROADCAST 0xFE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an unsigned int value.
|
* Parse an unsigned int value.
|
||||||
|
|||||||
Executable → Regular
+4
@@ -11,6 +11,10 @@ add_executable(test_filereader test_filereader.cpp)
|
|||||||
target_link_libraries(test_filereader ebus pthread)
|
target_link_libraries(test_filereader ebus pthread)
|
||||||
add_test(filereader test_filereader)
|
add_test(filereader test_filereader)
|
||||||
|
|
||||||
|
add_executable(test_device test_device.cpp)
|
||||||
|
target_link_libraries(test_device ebus pthread ${test_LIBS})
|
||||||
|
add_test(device test_device)
|
||||||
|
|
||||||
add_executable(test_symbol test_symbol.cpp)
|
add_executable(test_symbol test_symbol.cpp)
|
||||||
target_link_libraries(test_symbol ebus pthread)
|
target_link_libraries(test_symbol ebus pthread)
|
||||||
add_test(symbol test_symbol)
|
add_test(symbol test_symbol)
|
||||||
|
|||||||
Executable → Regular
+5
@@ -3,6 +3,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/src \
|
|||||||
-Wno-unused-parameter
|
-Wno-unused-parameter
|
||||||
|
|
||||||
noinst_PROGRAMS = test_filereader \
|
noinst_PROGRAMS = test_filereader \
|
||||||
|
test_device \
|
||||||
test_symbol \
|
test_symbol \
|
||||||
test_data \
|
test_data \
|
||||||
test_message
|
test_message
|
||||||
@@ -10,6 +11,9 @@ noinst_PROGRAMS = test_filereader \
|
|||||||
test_filereader_SOURCES = test_filereader.cpp
|
test_filereader_SOURCES = test_filereader.cpp
|
||||||
test_filereader_LDADD = ../libebus.a -lpthread
|
test_filereader_LDADD = ../libebus.a -lpthread
|
||||||
|
|
||||||
|
test_device_SOURCES = test_device.cpp
|
||||||
|
test_device_LDADD = ../libebus.a -lpthread
|
||||||
|
|
||||||
test_symbol_SOURCES = test_symbol.cpp
|
test_symbol_SOURCES = test_symbol.cpp
|
||||||
test_symbol_LDADD = ../libebus.a -lpthread
|
test_symbol_LDADD = ../libebus.a -lpthread
|
||||||
|
|
||||||
@@ -20,6 +24,7 @@ test_message_SOURCES = test_message.cpp
|
|||||||
test_message_LDADD = ../libebus.a -lpthread
|
test_message_LDADD = ../libebus.a -lpthread
|
||||||
|
|
||||||
if CONTRIB
|
if CONTRIB
|
||||||
|
test_device_LDADD += ../contrib/libebuscontrib.a
|
||||||
test_data_LDADD += ../contrib/libebuscontrib.a
|
test_data_LDADD += ../contrib/libebuscontrib.a
|
||||||
test_message_LDADD += ../contrib/libebuscontrib.a
|
test_message_LDADD += ../contrib/libebuscontrib.a
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -175,9 +175,6 @@ void closeLogFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool needsLog(const LogFacility facility, const LogLevel level) {
|
bool needsLog(const LogFacility facility, const LogLevel level) {
|
||||||
if (s_logFile == nullptr && !s_useSyslog) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return s_facilityLogLevel[facility] >= level;
|
return s_facilityLogLevel[facility] >= level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,22 +50,6 @@ bool RotateFile::setEnabled(bool enabled) {
|
|||||||
if (enabled) {
|
if (enabled) {
|
||||||
m_stream = fopen(m_fileName.c_str(), m_textMode ? "w" : "wb");
|
m_stream = fopen(m_fileName.c_str(), m_textMode ? "w" : "wb");
|
||||||
m_fileSize = 0;
|
m_fileSize = 0;
|
||||||
#ifdef FORWARD_RAW_TTY
|
|
||||||
if (!m_textMode && isatty(fileno(m_stream)) == 1) {
|
|
||||||
int fd = fileno(m_stream);
|
|
||||||
struct termios newSettings;
|
|
||||||
memset(&newSettings, 0, sizeof(newSettings));
|
|
||||||
|
|
||||||
cfsetspeed(&newSettings, B2400);
|
|
||||||
newSettings.c_cflag |= (CS8 | CLOCAL);
|
|
||||||
newSettings.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // non-canonical mode
|
|
||||||
newSettings.c_iflag |= IGNPAR; // ignore parity errors
|
|
||||||
newSettings.c_oflag &= ~OPOST;
|
|
||||||
|
|
||||||
// activate new settings of serial device
|
|
||||||
tcsetattr(fd, TCSANOW, &newSettings);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -207,7 +207,7 @@ r,,SoftwareVersion,,,,,"0000",,,HEX:4,,,
|
|||||||
EOF
|
EOF
|
||||||
echo "test,testpass,installer" > ./passwd
|
echo "test,testpass,installer" > ./passwd
|
||||||
#ebusd:
|
#ebusd:
|
||||||
./src/ebusd/ebusd -d tcp:127.0.0.1:8876 --initsend --latency 10 -n -c "$PWD/contrib/etc/ebusd" --pollinterval=10 -s -a 31 --acquireretries 3 --answer --generatesyn --receivetimeout 40000 --sendretries 1 --enablehex --htmlpath "$PWD/contrib/html" --httpport 8878 --pidfile "$PWD/ebusd.pid" --localhost -p 8877 -l "$PWD/ebusd.log" --logareas all --loglevel debug --lograwdata=bytes --lograwdatafile "$PWD/ebusd.raw" --lograwdatasize 1 --dumpfile "$PWD/ebusd.dump" --dumpsize 100 -D --scanconfig --aclfile=./passwd --mqttport=1883
|
./src/ebusd/ebusd -d tcp:127.0.0.1:8876 --initsend --latency 10000 -n -c "$PWD/contrib/etc/ebusd" --pollinterval=10 -s -a 31 --acquireretries 3 --answer --generatesyn --receivetimeout 40000 --sendretries 1 --enablehex --htmlpath "$PWD/contrib/html" --httpport 8878 --pidfile "$PWD/ebusd.pid" --localhost -p 8877 -l "$PWD/ebusd.log" --logareas all --loglevel debug --lograwdata=bytes --lograwdatafile "$PWD/ebusd.raw" --lograwdatasize 1 --dumpfile "$PWD/ebusd.dump" --dumpsize 100 -D --scanconfig --aclfile=./passwd --mqttport=1883
|
||||||
sleep 3
|
sleep 3
|
||||||
pid=`head -n 1 "$PWD/ebusd.pid"`
|
pid=`head -n 1 "$PWD/ebusd.pid"`
|
||||||
if [ -z "$pid" ]; then
|
if [ -z "$pid" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user