added null terminated and filled string
This commit is contained in:
+10
-4
@@ -42,6 +42,7 @@ static const dataType_t uchDataType = {
|
|||||||
static const dataType_t dataTypes[] = {
|
static const dataType_t dataTypes[] = {
|
||||||
{"IGN",MAX_LEN*8,bt_str, IGN|ADJ, 0, 1, 0, 0}, // >= 1 byte ignored data
|
{"IGN",MAX_LEN*8,bt_str, IGN|ADJ, 0, 1, 0, 0}, // >= 1 byte ignored data
|
||||||
stringDataType,
|
stringDataType,
|
||||||
|
{"NTS",MAX_LEN*8,bt_str, ADJ, 0, 1, 0, 0}, // >= 1 byte character string filled up with 0x00 (null terminated string)
|
||||||
{"HEX",MAX_LEN*8,bt_hexstr, ADJ, 0, 2, 47, 0}, // >= 1 byte hex digit string, usually separated by space, e.g. 0a 1b 2c 3d
|
{"HEX",MAX_LEN*8,bt_hexstr, ADJ, 0, 2, 47, 0}, // >= 1 byte hex digit string, usually separated by space, e.g. 0a 1b 2c 3d
|
||||||
{"BDA", 32, bt_dat, BCD, 0xff, 10, 10, 0}, // date with weekday in BCD, 01.01.2000 - 31.12.2099 (0x01,0x01,WW,0x00 - 0x31,0x12,WW,0x99, WW is weekday Mon=0x00 - Sun=0x06, replacement 0xff)
|
{"BDA", 32, bt_dat, BCD, 0xff, 10, 10, 0}, // date with weekday in BCD, 01.01.2000 - 31.12.2099 (0x01,0x01,WW,0x00 - 0x31,0x12,WW,0x99, WW is weekday Mon=0x00 - Sun=0x06, replacement 0xff)
|
||||||
{"BDA", 24, bt_dat, BCD, 0xff, 10, 10, 0}, // date in BCD, 01.01.2000 - 31.12.2099 (0x01,0x01,0x00 - 0x31,0x12,0x99, replacement 0xff)
|
{"BDA", 24, bt_dat, BCD, 0xff, 10, 10, 0}, // date in BCD, 01.01.2000 - 31.12.2099 (0x01,0x01,0x00 - 0x31,0x12,0x99, replacement 0xff)
|
||||||
@@ -724,6 +725,7 @@ result_t StringDataField::readSymbols(SymbolString& input, const unsigned char b
|
|||||||
default:
|
default:
|
||||||
if (ch < 0x20)
|
if (ch < 0x20)
|
||||||
ch = (unsigned char)m_dataType.replacement;
|
ch = (unsigned char)m_dataType.replacement;
|
||||||
|
if (ch != 0x00)
|
||||||
output << setw(0) << dec << static_cast<char>(ch);
|
output << setw(0) << dec << static_cast<char>(ch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -859,18 +861,22 @@ result_t StringDataField::writeSymbols(istringstream& input,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (input.eof())
|
if (input.eof()) {
|
||||||
value = m_dataType.replacement;
|
value = m_dataType.replacement;
|
||||||
else {
|
} else {
|
||||||
value = input.get();
|
value = input.get();
|
||||||
if (input.eof() || value < 0x20)
|
if (input.eof() || value < 0x20)
|
||||||
value = m_dataType.replacement;
|
value = m_dataType.replacement;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (remainder && input.eof() && i > 0)
|
if (remainder && input.eof() && i > 0) {
|
||||||
|
if (value == 0x00 && m_dataType.type == bt_str) {
|
||||||
|
output[baseOffset + offset] = 0;
|
||||||
|
offset += incr;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
lastLast = last;
|
lastLast = last;
|
||||||
last = value;
|
last = value;
|
||||||
if ((m_dataType.flags & BCD) != 0 && ((m_dataType.flags & REQ) != 0 || value != m_dataType.replacement)) {
|
if ((m_dataType.flags & BCD) != 0 && ((m_dataType.flags & REQ) != 0 || value != m_dataType.replacement)) {
|
||||||
|
|||||||
@@ -52,11 +52,21 @@ int main()
|
|||||||
{"x,,str:10", "Hallo, Du!", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
{"x,,str:10", "Hallo, Du!", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||||
{"x,,str:10", "Hallo, Du ", "10fe07000a48616c6c6f2c20447520", "00", ""},
|
{"x,,str:10", "Hallo, Du ", "10fe07000a48616c6c6f2c20447520", "00", ""},
|
||||||
{"x,,str:10", " ", "10fe07000a20202020202020202020", "00", ""},
|
{"x,,str:10", " ", "10fe07000a20202020202020202020", "00", ""},
|
||||||
{"x,,str:10", " ", "10fe07000a20202020202020202020", "00", ""},
|
{"x,,str:10", "", "10fe07000a20202020202020202020", "00", "R"},
|
||||||
{"x,,str:11", "", "10fe07000a20202020202020202020", "00", "rW"},
|
{"x,,str:11", "", "10fe07000a20202020202020202020", "00", "rW"},
|
||||||
{"x,,str:24", "abcdefghijklmnopqrstuvwx", "10fe0700186162636465666768696a6b6c6d6e6f707172737475767778", "00", ""},
|
{"x,,str:24", "abcdefghijklmnopqrstuvwx", "10fe0700186162636465666768696a6b6c6d6e6f707172737475767778", "00", ""},
|
||||||
{"x,,str:*", "abcde", "10fe0700056162636465", "00", ""},
|
{"x,,str:*", "abcde", "10fe0700056162636465", "00", ""},
|
||||||
{"x,,str,2", "", "", "", "c"},
|
{"x,,str,2", "", "", "", "c"},
|
||||||
|
{"x,,nts:10", "Hallo, Du!", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||||
|
{"x,,nts:10", "Hallo, Du!", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||||
|
{"x,,nts:10", "Hallo, Du", "10fe07000a48616c6c6f2c20447500", "00", ""},
|
||||||
|
{"x,,nts:10", " ", "10fe07000a20202020202020202020", "00", ""},
|
||||||
|
{"x,,nts:10", "", "10fe07000a00000000000000000000", "00", ""},
|
||||||
|
{"x,,nts:11", "", "10fe07000a20202020202020202020", "00", "rW"},
|
||||||
|
{"x,,nts:24", "abcdefghijklmnopqrstuvwx", "10fe0700186162636465666768696a6b6c6d6e6f707172737475767778", "00", ""},
|
||||||
|
{"x,,nts:*", "abcde", "10fe0700056162636465", "00", "W"},
|
||||||
|
{"x,,nts:*", "abcde", "10fe070006616263646500", "00", ""},
|
||||||
|
{"x,,nts,2", "", "", "", "c"},
|
||||||
{"x,,hex", "20", "10fe07000120", "00", ""},
|
{"x,,hex", "20", "10fe07000120", "00", ""},
|
||||||
{"x,,hex:10", "48 61 6c 6c 6f 2c 20 44 75 21", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
{"x,,hex:10", "48 61 6c 6c 6f 2c 20 44 75 21", "10fe07000a48616c6c6f2c20447521", "00", ""},
|
||||||
{"x,,hex:*", "48 61 6c 6c 6f", "10fe07000548616c6c6f", "00", ""},
|
{"x,,hex:*", "48 61 6c 6c 6f", "10fe07000548616c6c6f", "00", ""},
|
||||||
|
|||||||
Reference in New Issue
Block a user