Merge remote-tracking branch 'origin/master' into enhanced_device

This commit is contained in:
john
2018-12-02 11:29:29 +01:00
6 changed files with 81 additions and 34 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[Unit]
Description=ebusd, the daemon for communication with eBUS heating systems.
After=network.target
After=network-online.target
ConditionPathExists=/var/log
[Service]
+1 -1
View File
@@ -781,7 +781,7 @@ result_t NumberDataType::writeRawValue(unsigned int value, size_t offset, size_t
symbol = (value / exp) & 0xff;
exp <<= 8;
}
if (index == start && (m_bitCount % 8) != 0 && offset + index < output->getDataSize()) {
if (index == start && (m_bitCount % 8) != 0 && offset + index < output->getCalculatedDataSize()) {
output->dataAt(offset + index) |= symbol;
} else {
output->dataAt(offset + index) = symbol;
+13 -1
View File
@@ -249,7 +249,7 @@ class SymbolString {
} else if (m_data.size() >= lengthOffset+255) {
return false;
}
m_data[lengthOffset] = (symbol_t)(m_data.size() - 1 - lengthOffset);
m_data[lengthOffset] = (symbol_t)(m_data.size() - lengthOffset - 1);
return true;
}
@@ -272,6 +272,18 @@ class SymbolString {
return m_data.size() < lengthOffset + 1 + ret ? m_data.size() - lengthOffset - 1 : ret;
}
/**
* Return the calculated number of data bytes DD (nnot yet revealed in the length field).
* @return the calculated number of data bytes DD.
*/
size_t getCalculatedDataSize() const {
size_t lengthOffset = (m_isMaster ? 4 : 0);
if (m_data.size() <= lengthOffset) {
return 0;
}
return m_data.size() - lengthOffset - 1;
}
/**
* Return the data byte at the specified index (within DD).
* @param index the index of the data byte (within DD) to return.
+51 -31
View File
@@ -298,7 +298,7 @@ int main() {
{"x,,hcd", "99999999", "10feffff0463636363", "00", ""},
{"x,,hcd", "100000000", "10feffff0463636363", "00", "Rw"},
{"x,,hcd", "", "10feffff0400006400", "00", "rw"},
{"x,,str:16", "0123456789ABCDEF", "10feffff1130313233343536373839414243444546", "00", ""},
{"x,,str:16", "0123456789ABCDEF", "10feffff1030313233343536373839414243444546", "00", ""},
{"x,,uch:17", "", "10feffff00", "00", "c"},
{"x,s,uch", "0", "1025ffff0310111213", "0300010203", "W"},
{"x,s,uch", "0", "1025ffff00", "0100", ""},
@@ -419,13 +419,13 @@ int main() {
{"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", "18.004", "10fe0700020112", "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", "288.06", "10fe0700020112", "00", ""},
{"x,,d2c", "0.00", "10feffff020000", "00", ""},
{"x,,d2c", "-0.06", "10feffff02ffff", "00", ""},
{"x,,d2c", "-", "10feffff020080", "00", ""},
@@ -490,6 +490,15 @@ int main() {
{"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
{"x,,BI0;BI7;BI0", "0;0;0", "ff75b50900", "020000", ""}, // bits
{"x,,BI0;BI7;BI0", "0;0;1", "ff75b50900", "020001", ""}, // bits
{"x,,BI0;BI7;BI0", "0;1;0", "ff75b50900", "028000", ""}, // bits
{"x,,BI0;BI7;BI0", "0;1;1", "ff75b50900", "028001", ""}, // bits
{"x,m,BI0;BI1;BI2;BI3;BI4;BI5;BI6;BI7", "0;0;1;0;0;0;0;0", "ff75b5090104", "00", ""}, // bits
{"x,m,BI0;BI7;BI0", "0;0;0", "ff75b509020000", "00", ""}, // bits
{"x,m,BI0;BI7;BI0", "0;0;1", "ff75b509020001", "00", ""}, // bits
{"x,m,BI0;BI7;BI0", "0;1;0", "ff75b509028000", "00", ""}, // bits
{"x,m,BI0;BI7;BI0", "0;1;1", "ff75b509028001", "00", ""}, // 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 divisor product
@@ -613,42 +622,51 @@ int main() {
cout << "\": create OK" << endl;
ostringstream output;
MasterSymbolString writeMstr;
result = writeMstr.parseHex(mstr.getStr().substr(0, 10));
if (result != RESULT_OK) {
cout << " parse \"" << mstr.getStr().substr(0, 10) << "\" error: " << getResultCode(result) << endl;
error = true;
}
SlaveSymbolString writeSstr;
result = writeSstr.parseHex(sstr.getStr().substr(0, 2));
if (result != RESULT_OK) {
cout << " parse \"" << sstr.getStr().substr(0, 2) << "\" error: " << getResultCode(result) << endl;
error = true;
}
result = fields->read(mstr, 0, false, findName, findIndex, verbosity|(numeric?OF_NUMERIC:0), -1, &output);
if (result >= RESULT_OK) {
result = fields->read(sstr, 0, !output.str().empty(), findName, findIndex, verbosity|(numeric?OF_NUMERIC:0), -1, &output);
}
if (failedRead) {
{
MasterSymbolString writeMstr;
result = writeMstr.parseHex(mstr.getStr().substr(0, 10));
if (result != RESULT_OK) {
cout << " parse \"" << mstr.getStr().substr(0, 10) << "\" error: " << getResultCode(result) << endl;
error = true;
}
SlaveSymbolString writeSstr;
result = writeSstr.parseHex(sstr.getStr().substr(0, 2));
if (result != RESULT_OK) {
cout << " parse \"" << sstr.getStr().substr(0, 2) << "\" error: " << getResultCode(result) << endl;
error = true;
}
result = fields->read(mstr, 0, false, findName, findIndex, verbosity|(numeric?OF_NUMERIC:0), -1, &output);
if (result >= RESULT_OK) {
cout << " failed read " << fields->getName(-1) << " >" << check[2] << " " << check[3]
<< "< error: unexpectedly succeeded" << endl;
result = fields->read(sstr, 0, !output.str().empty(), findName, findIndex, verbosity|(numeric?OF_NUMERIC:0), -1, &output);
}
if (failedRead) {
if (result >= RESULT_OK) {
cout << " failed read " << fields->getName(-1) << " >" << check[2] << " " << check[3]
<< "< error: unexpectedly succeeded" << endl;
error = true;
} else {
cout << " failed read " << fields->getName(-1) << " >" << check[2] << " " << check[3]
<< "< OK" << endl;
}
} else if (result < RESULT_OK) {
cout << " read " << fields->getName(-1) << " >" << check[2] << " " << check[3]
<< "< error: " << getResultCode(result) << endl;
error = true;
} else {
cout << " failed read " << fields->getName(-1) << " >" << check[2] << " " << check[3]
<< "< OK" << endl;
bool match = strcasecmp(output.str().c_str(), expectStr.c_str()) == 0;
verify(failedReadMatch, "read", check[2], match, expectStr, output.str());
}
} else if (result < RESULT_OK) {
cout << " read " << fields->getName(-1) << " >" << check[2] << " " << check[3]
<< "< error: " << getResultCode(result) << endl;
error = true;
} else {
bool match = strcasecmp(output.str().c_str(), expectStr.c_str()) == 0;
verify(failedReadMatch, "read", check[2], match, expectStr, output.str());
}
if (verbosity == 0) {
istringstream input(expectStr);
MasterSymbolString writeMstr;
result = writeMstr.parseHex(mstr.getStr().substr(0, 8));
if (result != RESULT_OK) {
cout << " parse \"" << mstr.getStr().substr(0, 8) << "\" error: " << getResultCode(result) << endl;
error = true;
}
SlaveSymbolString writeSstr;
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeMstr, nullptr);
if (result >= RESULT_OK) {
result = fields->write(UI_FIELD_SEPARATOR, 0, &input, &writeSstr, nullptr);
@@ -667,6 +685,8 @@ int main() {
<< "< error: " << getResultCode(result) << endl;
error = true;
} else {
writeMstr.adjustHeader();
writeSstr.adjustHeader();
bool match = mstr == writeMstr && sstr == writeSstr;
verify(failedWriteMatch, "write", expectStr, match, mstr.getStr() + " " + sstr.getStr(),
writeMstr.getStr() + " " + writeSstr.getStr());
+14
View File
@@ -159,6 +159,20 @@ int main() {
{"r,,x,,,,,6a00,,,UCH,10,bar,,Bit6,,BI6:1,0=B60;1=B61,,,Bit7,,BI7:1,0=B70;1=B71", "1.9;B60;B71", "ff08b509030d6a00", "0213bf", "d" },
{"r,,x,,,,,6a00,,,UCH,10,bar,,Bit6,,BI6:1,0=B60;1=B61,,,Bit7,,BI7:1,0=B70;1=B71", "1.9;B61;B70", "ff08b509030d6a00", "02137f", "d" },
{"r,,x,,,,,6a00,,,UCH,10,bar,,Bit6,,BI6:1,0=B60;1=B61,,,Bit7,,BI7:1,0=B70;1=B71", "1.9;B60;B70", "ff08b509030d6a00", "02133f", "d" },
{"w,,x,,,,,6900,,,UCH,10,bar,,Bit7,,BI7:1,0=B70;1=B71,,,Bit6,,BI6:1,0=B60;1=B61", "1.9;B71;B61", "ff08b509060e6900138040", "00", "di" },
{"w,,x,,,,,6900,,,UCH,10,bar,,Bit7,,BI7:1,0=B70;1=B71,,,Bit6,,BI6:1,0=B60;1=B61", "1.9;B71;B60", "ff08b509060e6900138000", "00", "di" },
{"w,,x,,,,,6900,,,UCH,10,bar,,Bit7,,BI7:1,0=B70;1=B71,,,Bit6,,BI6:1,0=B60;1=B61", "1.9;B70;B61", "ff08b509060e6900130040", "00", "di" },
{"w,,x,,,,,6900,,,UCH,10,bar,,Bit7,,BI7:1,0=B70;1=B71,,,Bit6,,BI6:1,0=B60;1=B61", "1.9;B70;B60", "ff08b509060e6900130000", "00", "di" },
{"w,,x,,,,,6a00,,,UCH,10,bar,,Bit6,,BI6:1,0=B60;1=B61,,,Bit7,,BI7:1,0=B70;1=B71", "1.9;B61;B71", "ff08b509050e6a0013c0", "00", "di" },
{"w,,x,,,,,6a00,,,UCH,10,bar,,Bit6,,BI6:1,0=B60;1=B61,,,Bit7,,BI7:1,0=B70;1=B71", "1.9;B60;B71", "ff08b509050e6a001380", "00", "di" },
{"w,,x,,,,,6a00,,,UCH,10,bar,,Bit6,,BI6:1,0=B60;1=B61,,,Bit7,,BI7:1,0=B70;1=B71", "1.9;B61;B70", "ff08b509050e6a001340", "00", "di" },
{"w,,x,,,,,6a00,,,UCH,10,bar,,Bit6,,BI6:1,0=B60;1=B61,,,Bit7,,BI7:1,0=B70;1=B71", "1.9;B60;B70", "ff08b509050e6a001300", "00", "di" },
{"w,,x,,,,,,,,IGN:1,,,,b0,,BI0:1,,,,b1,,BI1:1,,,,b2,,BI2:1,,,,,,IGN:1,,,,c0,,BI0:1,,,,c1,,BI1:1,,,,c2,,BI2:1", "1;1;1;0;0;0", "ff08b509050e00070000", "00", "di" },
{"w,,x,,,,,,,,IGN:1,,,,b0,,BI0:1,,,,b1,,BI1:1,,,,b2,,BI2:1,,,,,,IGN:1,,,,c0,,BI0:1,,,,c1,,BI1:1,,,,c2,,BI2:1", "1;0;0;0;0;1", "ff08b509050e00010004", "00", "di" },
{"w,,x,,,,,,,,IGN:1,,,,b0,,BI0:1,,,,b1,,BI1:1,,,,b2,,BI2:1,,,,,,IGN:1,,,,c0,,BI0:1,,,,c1,,BI1:1,,,,c2,,BI2:1", "0;0;1;0;1;1", "ff08b509050e00040006", "00", "di" },
{"w,,x,,,,,,b0,,BI0:1,,,,b1,,BI1:1,,,,b2,,BI2:6,,,,c0,,BI0:1,,,,c1,,BI1:1,,,,c2,,BI2:1", "1;1;1;0;0;0", "ff08b509030e0700", "00", "di" },
{"w,,x,,,,,,b0,,BI0:1,,,,b1,,BI1:1,,,,b2,,BI2:6,,,,c0,,BI0:1,,,,c1,,BI1:1,,,,c2,,BI2:1", "1;0;0;0;0;1", "ff08b509030e0104", "00", "di" },
{"w,,x,,,,,,b0,,BI0:1,,,,b1,,BI1:1,,,,b2,,BI2:6,,,,c0,,BI0:1,,,,c1,,BI1:1,,,,c2,,BI2:1", "0;0;1;0;1;1", "ff08b509030e0406", "00", "di" },
{"*r,cir*cuit#level,na*me,com*ment,ff,75,b509,0d", "", "", "", "" },
{"r,CIRCUIT,NAME,COMMENT,,,,0100,field,,UCH", "r,cirCIRCUITcuit,naNAMEme,comCOMMENTment,ff,75,b509,0d0100,field,s,UCH,,,: field=42", "ff75b509030d0100", "012a", "DN"},
{"r,CIRCUIT,NAME,COMMENT,,,,0100,field,,UCH",
+1
View File
@@ -25,6 +25,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_PPOLL
# include <poll.h>
#endif