From 94c3b639ca9b109d304497c41f0908c50a99be9c Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 26 Sep 2015 17:28:25 +0200 Subject: [PATCH] added base type TTH --- src/lib/ebus/data.cpp | 12 +++++++----- src/lib/ebus/test/test_data.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lib/ebus/data.cpp b/src/lib/ebus/data.cpp index ececd6e0..cafe2d26 100644 --- a/src/lib/ebus/data.cpp +++ b/src/lib/ebus/data.cpp @@ -53,7 +53,8 @@ static const dataType_t dataTypes[] = { {"HTI", 24, bt_tim, REQ, 0, 8, 8, 0}, // time, 00:00:00 - 23:59:59 (0x00,0x00,0x00 - 0x17,0x3b,0x3b) {"VTI", 24, bt_tim, REV, 0x63, 8, 8, 0}, // time, 00:00:00 - 23:59:59 (0x00,0x00,0x00 - 0x3b,0x3b,0x17, replacement 0x63) [Vaillant type] {"HTM", 16, bt_tim, REQ, 0, 5, 5, 0}, // time as hh:mm, 00:00 - 23:59 (0x00,0x00 - 0x17,0x3b) - {"TTM", 8, bt_tim, 0, 0x90, 5, 5, 0}, // truncated time (only multiple of 10 minutes), 00:00 - 24:00 (minutes div 10 + hour * 6 as integer) + {"TTM", 8, bt_tim, 0, 0x90, 5, 5, 10}, // truncated time (only multiple of 10 minutes), 00:00 - 24:00 (minutes div 10 + hour * 6 as integer) + {"TTH", 8, bt_tim, 0, 0, 5, 5, 30}, // truncated time (only multiple of 30 minutes), 00:30 - 24:00 (minutes div 30 + hour * 2 as integer) {"BDY", 8, bt_num, DAY|LST, 0x07, 0, 6, 1}, // weekday, "Mon" - "Sun" (0x00 - 0x06) [eBUS type] {"HDY", 8, bt_num, DAY|LST, 0x00, 1, 7, 1}, // weekday, "Mon" - "Sun" (0x01 - 0x07) [Vaillant type] {"BCD", 8, bt_num, BCD|LST, 0xff, 0, 0x99, 1}, // unsigned decimal in BCD, 0 - 99 @@ -613,12 +614,12 @@ result_t StringDataField::readSymbols(SymbolString& input, const unsigned char b } if (m_length == 1) { // truncated time if (i == 0) { - ch /= 6; // hours + ch = (unsigned char)(ch/(60/m_dataType.divisorOrFirstBit)); // convert to hours offset -= incr; // repeat for minutes count++; } else - ch = (unsigned char)((ch % 6) * 10); // minutes + ch = (unsigned char)((ch % (60/m_dataType.divisorOrFirstBit)) * m_dataType.divisorOrFirstBit); // convert to minutes } if (i == 0) { if (ch > 24) @@ -755,9 +756,10 @@ result_t StringDataField::writeSymbols(istringstream& input, count++; continue; } - if ((value % 10) != 0) + + if ((value % m_dataType.divisorOrFirstBit) != 0) return RESULT_ERR_INVALID_NUM; // invalid truncated time minutes - value = last * 6 + (value / 10); + value = (last * 60 + value)/m_dataType.divisorOrFirstBit; if (value > 24 * 6) return RESULT_ERR_OUT_OF_RANGE; // invalid time } diff --git a/src/lib/ebus/test/test_data.cpp b/src/lib/ebus/test/test_data.cpp index c69c961e..f4fcb9a5 100644 --- a/src/lib/ebus/test/test_data.cpp +++ b/src/lib/ebus/test/test_data.cpp @@ -104,6 +104,12 @@ int main() {"x,,ttm", "-:-", "10fe07000190", "00", ""}, {"x,,ttm", "", "10fe07000191", "00", "rw"}, {"x,,ttm,2", "", "", "", "c"}, + {"x,,tth", "22:30", "10fe0700012d", "00", ""}, + {"x,,tth", "00:30", "10fe07000101", "00", ""}, + {"x,,tth", "24:00", "10fe07000130", "00", ""}, + {"x,,tth", "-:-", "10fe07000100", "00", ""}, + {"x,,tth", "", "10fe07000131", "00", "rw"}, + {"x,,tth,2", "", "", "", "c"}, {"x,,bdy", "Mon", "10fe07000300", "00", ""}, {"x,,bdy", "Sun", "10fe07000306", "00", ""}, {"x,,bdy", "", "10fe07000308", "00", "rw"},