Skip to content

Commit

Permalink
Fix decoding of %c (used in BESTUTM)
Browse files Browse the repository at this point in the history
Was always being decoded as 0.
  • Loading branch information
valgur committed Oct 23, 2024
1 parent a1afa88 commit 9c2d205
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions python/test/test_novatel_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def test_ASCII_UCHAR_BYTE_INVALID(helper):
assert intermediate_format.INT_1 == 0


@pytest.mark.xfail(reason="%c is broken")
def test_ASCII_CHAR_VALID(helper):
helper.create_base_field("CHAR_1", FIELD_TYPE.SIMPLE, "%c", 1, DATA_TYPE.CHAR)
helper.create_base_field("CHAR_2", FIELD_TYPE.SIMPLE, "%c", 1, DATA_TYPE.CHAR)
Expand All @@ -167,7 +166,6 @@ def test_ASCII_CHAR_VALID(helper):
assert intermediate_format.CHAR_3 == ord(';')


@pytest.mark.xfail(reason="%c is broken")
def test_ASCII_CHAR_INVALID(helper):
helper.create_base_field("CHAR", FIELD_TYPE.SIMPLE, "%c", 2, DATA_TYPE.CHAR)
input = b""
Expand Down
Binary file modified regression/targets/BESTUTMBIN.GPS.ABBREV_ASCII
Binary file not shown.
Binary file modified regression/targets/BESTUTMBIN.GPS.ASCII
Binary file not shown.
Binary file modified regression/targets/BESTUTMBIN.GPS.BINARY
Binary file not shown.
Binary file modified regression/targets/BESTUTMBIN.GPS.FLATTENED_BINARY
Binary file not shown.
Binary file modified regression/targets/BESTUTMBIN.GPS.JSON
Binary file not shown.
8 changes: 7 additions & 1 deletion src/decoders/oem/src/message_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ void MessageDecoder::InitOemFieldMaps()
// =========================================================
// ASCII Field Mapping
// =========================================================
asciiFieldMap[CalculateBlockCrc32("c")] = SimpleAsciiMapEntry<uint32_t>();
asciiFieldMap[CalculateBlockCrc32("c")] = [](std::vector<FieldContainer>& vIntermediateFormat_, BaseField::ConstPtr pstMessageDataType_,
const char** ppcToken_, [[maybe_unused]] const size_t tokenLength_,
[[maybe_unused]] JsonReader& pclMsgDb_) {
// TODO: check that the character is printable
// if (!isprint(**ppcToken_)) { throw ... }
vIntermediateFormat_.emplace_back(static_cast<uint32_t>(**ppcToken_), pstMessageDataType_);
};
asciiFieldMap[CalculateBlockCrc32("k")] = SimpleAsciiMapEntry<float>();
asciiFieldMap[CalculateBlockCrc32("lk")] = SimpleAsciiMapEntry<double>();

Expand Down

0 comments on commit 9c2d205

Please sign in to comment.