code style

This commit is contained in:
john30
2017-12-26 14:27:44 +01:00
parent 631f05ab3f
commit b0e20b7c7c
7 changed files with 19 additions and 11 deletions
Executable → Regular
+2 -2
View File
@@ -692,7 +692,7 @@ result_t BusHandler::handleSymbol() {
long long latencyLong = (sentTime.tv_sec*1000000000 + sentTime.tv_nsec long long latencyLong = (sentTime.tv_sec*1000000000 + sentTime.tv_nsec
- m_lastSynReceiveTime.tv_sec*1000000000 - m_lastSynReceiveTime.tv_nsec)/1000; - m_lastSynReceiveTime.tv_sec*1000000000 - m_lastSynReceiveTime.tv_nsec)/1000;
if (latencyLong >= 0 && latencyLong <= 10000) { // skip clock skew or out of reasonable range if (latencyLong >= 0 && latencyLong <= 10000) { // skip clock skew or out of reasonable range
int latency = (int)latencyLong; int latency = static_cast<int>(latencyLong);
logDebug(lf_bus, "arbitration delay %d micros", latency); logDebug(lf_bus, "arbitration delay %d micros", latency);
if (m_arbitrationDelayMin < 0 || (latency < m_arbitrationDelayMin || latency > m_arbitrationDelayMax)) { if (m_arbitrationDelayMin < 0 || (latency < m_arbitrationDelayMin || latency > m_arbitrationDelayMax)) {
if (m_arbitrationDelayMin == -1 || latency < m_arbitrationDelayMin) { if (m_arbitrationDelayMin == -1 || latency < m_arbitrationDelayMin) {
@@ -1022,7 +1022,7 @@ void BusHandler::measureLatency(struct timespec* sentTime, struct timespec* recv
if (latencyLong < 0 || latencyLong > 1000) { if (latencyLong < 0 || latencyLong > 1000) {
return; // clock skew or out of reasonable range return; // clock skew or out of reasonable range
} }
int latency = (int)latencyLong; int latency = static_cast<int>(latencyLong);
logDebug(lf_bus, "send/receive symbol latency %d ms", latency); logDebug(lf_bus, "send/receive symbol latency %d ms", latency);
if (m_symbolLatencyMin >= 0 && (latency >= m_symbolLatencyMin && latency <= m_symbolLatencyMax)) { if (m_symbolLatencyMin >= 0 && (latency >= m_symbolLatencyMin && latency <= m_symbolLatencyMax)) {
return; return;
Executable → Regular
+8 -2
View File
@@ -698,10 +698,16 @@ class BusHandler : public WaitThread {
/** the maximal measured latency between send and receive of a symbol in milliseconds, -1 if not yet known. */ /** the maximal measured latency between send and receive of a symbol in milliseconds, -1 if not yet known. */
int m_symbolLatencyMax; int m_symbolLatencyMax;
/** the minimal measured delay between received SYN and sent own master address in microseconds, -1 if not yet known. */ /**
* the minimal measured delay between received SYN and sent own master address in microseconds,
* -1 if not yet known.
*/
int m_arbitrationDelayMin; int m_arbitrationDelayMin;
/** the maximal measured delay between received SYN and sent own master address in microseconds, -1 if not yet known. */ /**
* the maximal measured delay between received SYN and sent own master address in microseconds,
* -1 if not yet known.
*/
int m_arbitrationDelayMax; int m_arbitrationDelayMax;
/** the time of the last received SYN symbol, or 0 for never. */ /** the time of the last received SYN symbol, or 0 for never. */
+3 -2
View File
@@ -1197,8 +1197,9 @@ int main(int argc, char* argv[]) {
signal(SIGTERM, signalHandler); signal(SIGTERM, signalHandler);
logNotice(lf_main, PACKAGE_STRING "." REVISION " started%s", logNotice(lf_main, PACKAGE_STRING "." REVISION " started%s",
opt.scanConfig ? opt.initialScan == ESC ? " with auto scan" : opt.initialScan == BROADCAST ? " with broadcast scan" opt.scanConfig ? opt.initialScan == ESC ? " with auto scan"
: opt.initialScan == SYN ? " with full scan" : " with single scan" : ""); : opt.initialScan == BROADCAST ? " with broadcast scan" : opt.initialScan == SYN ? " with full scan"
: " with single scan" : "");
// load configuration files // load configuration files
loadConfigFiles(s_messageMap); loadConfigFiles(s_messageMap);
Executable → Regular
+2 -2
View File
@@ -722,7 +722,7 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
result_t ret; result_t ret;
symbol_t address = (symbol_t)parseInt(args[argPos].c_str(), 16, 0, 0xff, &ret); symbol_t address = (symbol_t)parseInt(args[argPos].c_str(), 16, 0, 0xff, &ret);
if (ret != RESULT_OK || !isValidAddress(address, dest) || (dest == isMaster(address))) { if (ret != RESULT_OK || !isValidAddress(address, dest) || (dest == isMaster(address))) {
return RESULT_ERR_INVALID_ADDR; // deny send from slave address and to master addresses return RESULT_ERR_INVALID_ADDR; // deny send from slave address and to master addresses
} }
if (dest) { if (dest) {
dstAddress = address; dstAddress = address;
@@ -949,7 +949,7 @@ result_t MainLoop::executeWrite(const vector<string>& args, const string levels,
result_t ret; result_t ret;
symbol_t address = (symbol_t)parseInt(args[argPos].c_str(), 16, 0, 0xff, &ret); symbol_t address = (symbol_t)parseInt(args[argPos].c_str(), 16, 0, 0xff, &ret);
if (ret != RESULT_OK || !isValidAddress(address, dest) || (!dest && !isMaster(address))) { if (ret != RESULT_OK || !isValidAddress(address, dest) || (!dest && !isMaster(address))) {
return RESULT_ERR_INVALID_ADDR; // deny send from slave address return RESULT_ERR_INVALID_ADDR; // deny send from slave address
} }
if (dest) { if (dest) {
dstAddress = address; dstAddress = address;
+2 -1
View File
@@ -658,7 +658,8 @@ bool SingleDataField::hasFullByteOffset(bool after) const {
} }
size_t SingleDataField::getCount(PartType partType, const char* fieldName) const { size_t SingleDataField::getCount(PartType partType, const char* fieldName) const {
return isIgnored() || (partType != pt_any && partType != m_partType) || (fieldName != NULL && m_name != fieldName) ? 0 : 1; return isIgnored() || (partType != pt_any && partType != m_partType) || (fieldName != NULL && m_name != fieldName)
? 0 : 1;
} }
+1 -1
View File
@@ -279,7 +279,7 @@ result_t NetworkDevice::open() {
return RESULT_ERR_GENERIC_IO; return RESULT_ERR_GENERIC_IO;
} }
if (!m_udp) { if (!m_udp) {
usleep(25000); // wait 25ms for potential initial garbage usleep(25000); // wait 25ms for potential initial garbage
} }
int cnt; int cnt;
symbol_t buf[MTU]; symbol_t buf[MTU];
+1 -1
View File
@@ -747,7 +747,7 @@ result_t Message::decodeLastData(bool leadingSeparator, const char* fieldName,
fieldIndex -= m_data->getCount(pt_masterData, fieldName); fieldIndex -= m_data->getCount(pt_masterData, fieldName);
if (fieldIndex < 0) { if (fieldIndex < 0) {
skipSlaveData = true; skipSlaveData = true;
fieldIndex = 0; fieldIndex = 0;
} }
} }
if (!skipSlaveData) { if (!skipSlaveData) {