From 824a415fb4868631f4243ebb12ba494d33ff419b Mon Sep 17 00:00:00 2001 From: Christian Berger Date: Sun, 1 Apr 2018 15:24:26 +0200 Subject: [PATCH] * Update to cluon-complete v0.0.58 Signed-off-by: Christian Berger --- Dockerfile.aarch64 | 2 +- Dockerfile.amd64 | 2 +- Dockerfile.armhf | 2 +- ...-v0.0.56.hpp => cluon-complete-v0.0.58.hpp | 45 ++++++++++++++++--- 4 files changed, 43 insertions(+), 8 deletions(-) rename cluon-complete-v0.0.56.hpp => cluon-complete-v0.0.58.hpp (99%) diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 4c3a892..7990ffa 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -28,7 +28,7 @@ RUN apk update && \ g++ ADD . /opt/sources WORKDIR /opt/sources -RUN ln -sf cluon-complete-v0.0.56.hpp cluon-complete.cpp && \ +RUN ln -sf cluon-complete-v0.0.58.hpp cluon-complete.cpp && \ g++ -std=c++14 -Wall -D HAVE_CLUON_LIVEFEED -pthread -s -static -static-libgcc -static-libstdc++ -o /tmp/cluon-livefeed cluon-complete.cpp RUN [ "cross-build-end" ] diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 index 83336d5..9ea9c85 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile.amd64 @@ -22,7 +22,7 @@ RUN apk update && \ g++ ADD . /opt/sources WORKDIR /opt/sources -RUN ln -sf cluon-complete-v0.0.56.hpp cluon-complete.cpp && \ +RUN ln -sf cluon-complete-v0.0.58.hpp cluon-complete.cpp && \ g++ -std=c++14 -Wall -D HAVE_CLUON_LIVEFEED -pthread -s -static -static-libgcc -static-libstdc++ -o /tmp/cluon-livefeed cluon-complete.cpp diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 796572f..dc405ee 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -28,7 +28,7 @@ RUN apk update && \ g++ ADD . /opt/sources WORKDIR /opt/sources -RUN ln -sf cluon-complete-v0.0.56.hpp cluon-complete.cpp && \ +RUN ln -sf cluon-complete-v0.0.58.hpp cluon-complete.cpp && \ g++ -std=c++14 -Wall -D HAVE_CLUON_LIVEFEED -pthread -s -static -static-libgcc -static-libstdc++ -o /tmp/cluon-livefeed cluon-complete.cpp RUN [ "cross-build-end" ] diff --git a/cluon-complete-v0.0.56.hpp b/cluon-complete-v0.0.58.hpp similarity index 99% rename from cluon-complete-v0.0.56.hpp rename to cluon-complete-v0.0.58.hpp index 03a3499..0732af3 100644 --- a/cluon-complete-v0.0.56.hpp +++ b/cluon-complete-v0.0.58.hpp @@ -1,6 +1,6 @@ // This is an auto-generated header-only single-file distribution of libcluon. -// Date: Sat, 31 Mar 2018 22:46:13 +0200 -// Version: 0.0.56 +// Date: Sun, 01 Apr 2018 15:22:27 +0200 +// Version: 0.0.58 // // // Implementation of N4562 std::experimental::any (merged into C++17) for C++11 compilers. @@ -13177,9 +13177,12 @@ int main(int argc, char **argv) { */ //#include "cluon/cluon.hpp" +//#include "cluon/MetaMessage.hpp" +//#include "cluon/MessageParser.hpp" //#include "cluon/OD4Session.hpp" #include +#include #include #include #include @@ -13195,6 +13198,10 @@ enum Color { DEFAULT = 39, }; +void clearScreen(); +void writeText(Color c, uint8_t y, uint8_t x, const std::string &text); +std::string formatTimeStamp(const cluon::data::TimeStamp &ts); + void clearScreen() { std::cout << "\033[2J" << std::endl; } @@ -13218,10 +13225,31 @@ int main(int argc, char **argv) { auto commandlineArguments = cluon::getCommandlineArguments(argc, argv); if (0 == commandlineArguments.count("cid")) { std::cerr << PROGRAM - << " displays any Envelopes received from an OpenDaVINCI v4 session to stdout." << std::endl; - std::cerr << "Usage: " << PROGRAM << " --cid=" << std::endl; + << " displays any Envelopes received from an OpenDaVINCI v4 session to stdout with optional data type resolving using a .odvd message specification." << std::endl; + std::cerr << "Usage: " << PROGRAM << " [--odvd=] --cid=" << std::endl; std::cerr << "Examples: " << PROGRAM << " --cid=111" << std::endl; + std::cerr << " " << PROGRAM << " --odvd=MyMessages.odvd --cid=111" << std::endl; } else { + std::map scopeOfMetaMessages{}; + + // Try parsing a supplied .odvd file to resolve numerical data types to human readable message names. + { + std::string odvdFile{commandlineArguments["odvd"]}; + if (!odvdFile.empty()) { + std::fstream fin{odvdFile, std::ios::in}; + if (fin.good()) { + const std::string s{static_cast(std::stringstream() << fin.rdbuf()).str()}; // NOLINT + + cluon::MessageParser mp; + auto parsingResult = mp.parse(s); + if (cluon::MessageParser::MessageParserErrorCodes::NO_ERROR == parsingResult.second) { + for (const auto &mm : parsingResult.first) { scopeOfMetaMessages[mm.messageIdentifier()] = mm; } + std::clog << "Parsed " << parsingResult.first.size() << " message(s)." << std::endl; + } + } + } + } + std::mutex mapOfLastEnvelopesMutex; std::map > mapOfLastEnvelopes; @@ -13245,7 +13273,14 @@ int main(int argc, char **argv) { auto env = ee.second; std::stringstream sstr; - sstr << "Envelope: " << std::setfill(' ') << std::setw(5) << env.dataType() << std::setw(0) << "/" << env.senderStamp() << "; " << "sent: " << formatTimeStamp(env.sent()) << "; sample: " << formatTimeStamp(env.sampleTimeStamp()) << std::endl; + sstr << "Envelope: " << std::setfill(' ') << std::setw(5) << env.dataType() << std::setw(0) << "/" << env.senderStamp() << "; " << "sent: " << formatTimeStamp(env.sent()) << "; sample: " << formatTimeStamp(env.sampleTimeStamp()); + if (scopeOfMetaMessages.count(env.dataType()) > 0) { + sstr << "; " << scopeOfMetaMessages[env.dataType()].messageName(); + } + else { + sstr << "; unknown data type"; + } + sstr << std::endl; const auto AGE{LAST_TIME_POINT - (env.received().seconds() * 1000 * 1000 + env.received().microseconds())};