From 596a4e19df55f0ff84351d7a5a85e0d0e8ac69ae Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 23 Oct 2024 12:14:10 +0300 Subject: [PATCH] Fix decoding of %c (used in BESTUTM) Was always being decoded as 0. --- .gitattributes | 1 + .../targets/BESTUTMBIN.GPS.ABBREV_ASCII | Bin 415 -> 410 bytes regression/targets/BESTUTMBIN.GPS.ASCII | Bin 408 -> 406 bytes regression/targets/BESTUTMBIN.GPS.BINARY | Bin 256 -> 256 bytes .../targets/BESTUTMBIN.GPS.FLATTENED_BINARY | Bin 2308 -> 2308 bytes regression/targets/BESTUTMBIN.GPS.JSON | Bin 1279 -> 1279 bytes src/decoders/oem/src/message_decoder.cpp | 8 +++++++- 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index e50acf163..f055836c9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,7 @@ * text=auto # These are unit test files and should use crlf +regression/targets/* eol=crlf *.ASC text eol=crlf *.asc text eol=crlf *.txt text eol=crlf diff --git a/regression/targets/BESTUTMBIN.GPS.ABBREV_ASCII b/regression/targets/BESTUTMBIN.GPS.ABBREV_ASCII index df391a9663c6d9f456ebad59108f481a10035018..048be2054d75fadbdc8e7cf2eba2453b470c5c9c 100644 GIT binary patch delta 58 zcmbQwJd1gPt1Op|0tf{A`@}o@`v!!DxVk8WJ30m{7#b>sPE5|7c+rg$s>V=ZvJzu8 GBNqU_><*3q delta 64 zcmbQmJfC@js~j(vjRFV+`}@Q@`}+ojhPb*YggZJ0D;OFoFicF!W#pZB-i;fk%us=M LvK(VI6E7D4`zQ{0 diff --git a/regression/targets/BESTUTMBIN.GPS.ASCII b/regression/targets/BESTUTMBIN.GPS.ASCII index 4081a22fcbec7c8a0cd14cc89cd3fb812bf7d598..3d295b877c80f538219df82a56d2a898b6129127 100644 GIT binary patch delta 25 hcmbQiJdJrm3}fiT*gOtHv&6I{Gb781R}L|90RU;v2tEJ+ delta 27 jcmbQnJcD^c3?swD*gQ@%L&MZWb4v@}iI)#C@p1tGZ>R^^ diff --git a/regression/targets/BESTUTMBIN.GPS.BINARY b/regression/targets/BESTUTMBIN.GPS.BINARY index 3856b74a1d7c0411b11b0ca744d4cdca878b988a..4d6188967a91e704d5d67b3babc4f440f9e4ace5 100644 GIT binary patch delta 19 bcmZo*YG9h6!5BJG)0t(_2Kx;Y3nl;nI{XIa delta 19 acmZo*YG9h6!N@RC)0xF;)y|lS1rq=@76wTG diff --git a/regression/targets/BESTUTMBIN.GPS.FLATTENED_BINARY b/regression/targets/BESTUTMBIN.GPS.FLATTENED_BINARY index 7a59573cd82710e03b64b7f632e3917bbcf7816e..850735215910f688667386933dc56f5afcf46de2 100644 GIT binary patch delta 20 ccmZn>Y7v^C!5BJG)0t(_2Kx;g3#M=Y07Xg%IsgCw delta 20 bcmZn>Y7v^C!N@RC)0xF;)y|lW1yeWxKF0=~ diff --git a/regression/targets/BESTUTMBIN.GPS.JSON b/regression/targets/BESTUTMBIN.GPS.JSON index a8dca6a013b927e6d839f11cdb2871737cc096c1..8e379b5d37d070c5f4de7fe31a110bfe0d10a755 100644 GIT binary patch delta 14 Vcmey*`JZz`A|qqy<|M|s%m6KE1up;q delta 14 Vcmey*`JZz`A|oTi<|M|s%m6EE1lj-q diff --git a/src/decoders/oem/src/message_decoder.cpp b/src/decoders/oem/src/message_decoder.cpp index 4fdd56b7d..5a1836bf7 100644 --- a/src/decoders/oem/src/message_decoder.cpp +++ b/src/decoders/oem/src/message_decoder.cpp @@ -44,7 +44,13 @@ void MessageDecoder::InitOemFieldMaps() // ========================================================= // ASCII Field Mapping // ========================================================= - asciiFieldMap[CalculateBlockCrc32("c")] = SimpleAsciiMapEntry(); + asciiFieldMap[CalculateBlockCrc32("c")] = [](std::vector& vIntermediateFormat_, const BaseField* 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(**ppcToken_), pstMessageDataType_); + }; asciiFieldMap[CalculateBlockCrc32("k")] = SimpleAsciiMapEntry(); asciiFieldMap[CalculateBlockCrc32("lk")] = SimpleAsciiMapEntry();