allow less than 8 bits for non-numeric types as well, corrected TTQ/TTH decoding
This commit is contained in:
+10
-4
@@ -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<NumberDataType*>(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<NumberDataType*>(m_dataType);
|
||||
firstBit = num->getFirstBit();
|
||||
} else {
|
||||
firstBit = 0;
|
||||
}
|
||||
return (m_dataType->getBitCount() % 8) == 0
|
||||
|| (after && firstBit + (m_dataType->getBitCount() % 8) >= 8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -349,6 +349,9 @@ result_t DateTimeDataType::readSymbols(SymbolString& input,
|
||||
output << setw(2) << dec << setfill('0') << static_cast<unsigned>(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
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user