diff --git a/src/lib/ebus/data.cpp b/src/lib/ebus/data.cpp index 21301bd3..9cecc867 100644 --- a/src/lib/ebus/data.cpp +++ b/src/lib/ebus/data.cpp @@ -515,12 +515,18 @@ size_t SingleDataField::getLength(PartType partType, size_t maxLength) { } bool SingleDataField::hasFullByteOffset(bool after) { - if (m_length > 1 || !m_dataType->isNumeric()) { + if (m_length > 1) { return true; } - NumberDataType* num = reinterpret_cast(m_dataType); - return (num->getBitCount() % 8) == 0 - || (after && num->getFirstBit() + (num->getBitCount() % 8) >= 8); + int16_t firstBit; + if (m_dataType->isNumeric()) { + NumberDataType* num = reinterpret_cast(m_dataType); + firstBit = num->getFirstBit(); + } else { + firstBit = 0; + } + return (m_dataType->getBitCount() % 8) == 0 + || (after && firstBit + (m_dataType->getBitCount() % 8) >= 8); } diff --git a/src/lib/ebus/datatype.cpp b/src/lib/ebus/datatype.cpp index bff07415..e595110d 100644 --- a/src/lib/ebus/datatype.cpp +++ b/src/lib/ebus/datatype.cpp @@ -349,6 +349,9 @@ result_t DateTimeDataType::readSymbols(SymbolString& input, output << setw(2) << dec << setfill('0') << static_cast(hour); symbol = (symbol_t)(minutes % 60); } else if (length == 1) { // truncated time + if (m_bitCount < 8) { + symbol = (symbol_t)((1 << m_bitCount) - 1); + } if (i == 0) { symbol = (symbol_t)(symbol/(60/m_resolution)); // convert to hours index -= incr; // repeat for minutes diff --git a/src/lib/ebus/test/test_data.cpp b/src/lib/ebus/test/test_data.cpp index 37b2935e..2ae908d9 100644 --- a/src/lib/ebus/test/test_data.cpp +++ b/src/lib/ebus/test/test_data.cpp @@ -187,6 +187,8 @@ int main() { {"x,,ttq", "-:-", "10fe07000100", "00", ""}, {"x,,ttq", "", "10fe07000161", "00", "rw"}, {"x,,ttq,2", "", "", "", "c"}, + {"x,,ttq,,,,y,,bi7", "23:45;0", "10fe0700015f", "00", ""}, // bit combination + {"x,,ttq,,,,y,,bi7", "23:45;1", "10fe070001df", "00", ""}, // bit combination {"x,,bdy", "Mon", "10fe07000100", "00", ""}, {"x,,bdy", "Sun", "10fe07000106", "00", ""}, {"x,,bdy", "8", "10fe07000108", "00", "w"},