From cfc8b43dec7318919ca716a4014ee9525fbbea11 Mon Sep 17 00:00:00 2001 From: jwillmartin Date: Mon, 29 Apr 2024 16:34:34 -0400 Subject: [PATCH] modified: src/v2i-hub/MapPlugin/src/MapPlugin.cpp modified: src/v2i-hub/MapPlugin/src/MapPlugin.h --- src/v2i-hub/MapPlugin/src/MapPlugin.cpp | 19 ++++++++++++------- src/v2i-hub/MapPlugin/src/MapPlugin.h | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/v2i-hub/MapPlugin/src/MapPlugin.cpp b/src/v2i-hub/MapPlugin/src/MapPlugin.cpp index 9fd815db7..ebd378a6b 100644 --- a/src/v2i-hub/MapPlugin/src/MapPlugin.cpp +++ b/src/v2i-hub/MapPlugin/src/MapPlugin.cpp @@ -207,6 +207,17 @@ int MapPlugin::Main() { return (EXIT_SUCCESS); } +string MapPlugin::removeMessageFrame(string &fileContent) { + // Check for and remove MessageFrame + if (fileContent.size() >= 4 && fileContent.substr(0, 4) == "0012") { + size_t pos = fileContent.find("38"); + PLOG(logDEBUG) << "Beginning of MapData found at: " << pos; + fileContent.erase(0, pos); + PLOG(logDEBUG) << "Payload without MessageFrame: " << fileContent; + } + return fileContent; +} + bool MapPlugin::LoadMapFiles() { if (_mapFiles.empty()) @@ -255,13 +266,7 @@ bool MapPlugin::LoadMapFiles() // Remove any newline characters fileContent.erase(remove(fileContent.begin(), fileContent.end(), '\n'), fileContent.end()); - // Check for and remove MessageFrame - if (fileContent.size() >= 4 && fileContent.substr(0, 4) == "0012") { - size_t pos = fileContent.find("38"); - PLOG(logDEBUG) << "Beginning of MapData found at: " << pos; - fileContent.erase(0, pos); - PLOG(logDEBUG) << "Payload without MessageFrame: " << fileContent; - } + fileContent = removeMessageFrame(fileContent); std::istringstream streamableContent(fileContent); streamableContent >> bytes; diff --git a/src/v2i-hub/MapPlugin/src/MapPlugin.h b/src/v2i-hub/MapPlugin/src/MapPlugin.h index f7419f417..ef129e276 100644 --- a/src/v2i-hub/MapPlugin/src/MapPlugin.h +++ b/src/v2i-hub/MapPlugin/src/MapPlugin.h @@ -97,6 +97,8 @@ class MapPlugin: public PluginClientClockAware { bool LoadMapFiles(); void DebugPrintMapFiles(); + string removeMessageFrame(string &fileContent); + }; } // namespace MapPlugin