From d2bb8b4aad660e837560f25f4b17b5f1d33fa865 Mon Sep 17 00:00:00 2001 From: jianjun wen Date: Tue, 11 Aug 2026 10:52:41 +0530 Subject: [PATCH 1/4] Add concierge.yaml to bifrost GIT_ORIGIN_SPP_REV_ID: 6e4438c322b54c624f7832c85ad01cbb1a779d12 --- score/datarouter/BUILD | 11 +- .../filetransfer_message_trace.h | 6 +- .../doc/design/logging_architecture.md | 2 +- .../datarouter/doc/guideline/configuration.md | 18 +++ .../doc/guideline/dlt_capture_demo.md | 47 +++--- .../datarouter/include/daemon/socketserver.h | 19 ++- score/datarouter/include/dlt/logentry_trace.h | 12 +- .../src/applications/datarouter_app.cpp | 2 +- score/datarouter/src/applications/options.cpp | 144 ++++++++---------- score/datarouter/src/applications/options.h | 20 +++ score/datarouter/src/daemon/socketserver.cpp | 24 ++- score/datarouter/src/persistent_logging/BUILD | 39 ----- .../src/persistent_logging/isysedr_handler.h | 49 ------ .../persistent_logging_stub/BUILD | 32 ---- .../stub_sysedr_factory.cpp | 32 ---- .../stub_sysedr_factory.h | 37 ----- .../stub_sysedr_handler.cpp | 34 ----- .../stub_sysedr_handler.h | 41 ----- .../src/persistent_logging/sysedr_factory.hpp | 57 ------- .../ut_logging/test_log_entry_deserialize.cpp | 4 +- .../test/ut/ut_logging/test_logparser.cpp | 6 +- .../test/ut/ut_logging/test_nonverbosedlt.cpp | 2 +- .../test/ut/ut_logging/test_options.cpp | 88 +++++++++++ .../log/detail/common/log_entry_deserialize.h | 8 +- score/mw/log/legacy_non_verbose_api/tracing.h | 11 +- .../legacy_non_verbose_api/tracing_test.cpp | 6 +- 26 files changed, 283 insertions(+), 468 deletions(-) delete mode 100644 score/datarouter/src/persistent_logging/BUILD delete mode 100644 score/datarouter/src/persistent_logging/isysedr_handler.h delete mode 100644 score/datarouter/src/persistent_logging/persistent_logging_stub/BUILD delete mode 100644 score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.cpp delete mode 100644 score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.h delete mode 100644 score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.cpp delete mode 100644 score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h delete mode 100644 score/datarouter/src/persistent_logging/sysedr_factory.hpp diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index 38ee1e1f..fba584b0 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -384,6 +384,7 @@ cc_library( visibility = ["//score/datarouter/test:__subpackages__"], deps = [ "//score/mw/log", + "@score_baselibs//score/os:getopt", ], ) @@ -563,7 +564,7 @@ cc_library( ], }) + select({ "//score/datarouter/build_configuration_flags:config_persistent_logging": [ - "//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub", + "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", ], "//conditions:default": [ "//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub", @@ -626,7 +627,7 @@ cc_library( ":udp_stream_output", ":unixdomain_server", "//score/datarouter/network:vlan", - "//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub", + "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", "//score/mw/log", "@score_baselibs//score/language/futurecpp", "@score_baselibs//score/mw/log/configuration:nvconfig", @@ -808,7 +809,7 @@ cc_library( "@score_baselibs//score/mw/log/configuration:nvconfigfactory", ] + select({ "//score/datarouter/build_configuration_flags:config_persistent_logging": [ - "//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub", + "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", ], "//conditions:default": [], }), @@ -845,7 +846,7 @@ cc_library( "@score_baselibs//score/mw/log/configuration:nvconfigfactory", ] + select({ "//score/datarouter/build_configuration_flags:config_persistent_logging": [ - "//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub", + "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", ], "//conditions:default": [], }), @@ -1106,7 +1107,7 @@ cc_library( "//score/mw/log", "@score_baselibs//score/mw/log/configuration:nvconfig", "//score/datarouter/dlt_filetransfer_trigger_lib:filetransfer_message_types", - "//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub", + "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", ], ) diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h index d2aa911d..9042a92e 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h +++ b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h @@ -24,15 +24,15 @@ namespace score::logging { -MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, score::platform::DltidT) +SCORE_MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, score::platform::DltidT) // Suppress "AUTOSAR C++14 A18-9-4". The rule states: An argument to std::forward shall not be subsequently used. -// Rationale: STRUCT_TRACEABLE is a macro, std::forward is from the macro definition +// Rationale: SCORE_STRUCT_TRACEABLE is a macro, std::forward is from the macro definition // Suppress "AUTOSAR C++14 M3-2-3". The rule states: "A type, object or function that is used in // multiple translation units shall be declared in one and only one file.". // Rationale: This is a forward declaration that does not vioalate this rule. // coverity[autosar_cpp14_a18_9_4_violation] // coverity[autosar_cpp14_m3_2_3_violation] -STRUCT_TRACEABLE(FileTransferEntry, appid, ctxid, file_name, delete_file) +SCORE_STRUCT_TRACEABLE(FileTransferEntry, appid, ctxid, file_name, delete_file) } // namespace score::logging diff --git a/score/datarouter/doc/design/logging_architecture.md b/score/datarouter/doc/design/logging_architecture.md index ab1755e3..cc4b882b 100644 --- a/score/datarouter/doc/design/logging_architecture.md +++ b/score/datarouter/doc/design/logging_architecture.md @@ -93,7 +93,7 @@ The Serialization/Visitor pattern implements structure serialization using C++ c 1. The compile-time macro: ```c++ -STRUCT_TRACEABLE(S, member1, member2) +SCORE_STRUCT_TRACEABLE(S, member1, member2) ``` generates a `visit(Visitor& v, T& s)` function template that iterates through arguments and their names (`S, "member1", member1, "member2", member2`) with a compile-time `Visitor`. The visitor type serves as a function template argument, enabling `visit(v,s)` usage with different visitor implementations. Each visitor defines a `visit_struct()` entry point function. diff --git a/score/datarouter/doc/guideline/configuration.md b/score/datarouter/doc/guideline/configuration.md index 781ac0e4..48cdb753 100644 --- a/score/datarouter/doc/guideline/configuration.md +++ b/score/datarouter/doc/guideline/configuration.md @@ -91,3 +91,21 @@ The file has multiple sections. - **messageThresholds**: specifies filter thresholds based on AppId and CtxId - **defaultChannel**: if no channelAssignment has been matched, this channel is used - **defaultThresold**: if no messageThreshold matched, this threshold is used to filter the messages + +### Overriding the config file path at runtime + +By default the datarouter reads `log-channels.json` from `./etc/log-channels.json` relative to its working directory. The path can be overridden at startup using the `-c` / `--config` flag: + +```bash +./datarouter --no_adaptive_runtime --config /path/to/log-channels.json +``` + +This is useful for image-level configuration (different deployment images can supply different channel layouts without recompilation) or for manual testing against a local config file without modifying the installed `etc/` tree. + +Similarly, the non-verbose configuration file (`class-id.json`) uses a compiled-in deployment path when no override is given, and can be overridden with `-C` / `--nv-config`: + +```bash +./datarouter --no_adaptive_runtime --nv-config /path/to/class-id.json +``` + +When neither flag is provided the datarouter uses its compiled-in default paths: `./etc/log-channels.json` for the channel configuration and a fixed deployment path for the non-verbose configuration. diff --git a/score/datarouter/doc/guideline/dlt_capture_demo.md b/score/datarouter/doc/guideline/dlt_capture_demo.md index 2cdad181..e7728c1c 100644 --- a/score/datarouter/doc/guideline/dlt_capture_demo.md +++ b/score/datarouter/doc/guideline/dlt_capture_demo.md @@ -10,12 +10,11 @@ This guide configures a minimal setup for capturing DLT logs on a loopback inter - [dlt-viewer](https://github.com/COVESA/dlt-viewer) - GUI-based DLT log viewer - [dlt-receive](https://github.com/COVESA/dlt-daemon/blob/master/doc/dlt-receive.1.md) - Command-line DLT receiver - [Wireshark](https://www.wireshark.org/) - Network protocol analyzer with DLT support - - [Chipmunk](https://github.com/esrlabs/chipmunk) - GUI-based DLT log viewer and analysis tool ### System Requirements - x86 target platform -- Network loopback interface (127.0.0.1) and Docker interface (172.17.0.1) configured and operational as multicast interfaces. +- Network loopback interface (127.0.0.1) configured and operational as a multicast interface. - UDP port 3490 available for DLT traffic ## Datarouter Setup @@ -45,6 +44,19 @@ Execute the datarouter daemon on x86 targets: The `--no_adaptive_runtime` flag bypasses Adaptive runtime requirements for standalone operation. +The following optional flags override the default configuration file paths: + +| Flag | Short | Description | +|---|---|---| +| `--config ` | `-c` | Path to the channel configuration file (`log-channels.json`). Defaults to `./etc/log-channels.json`. | +| `--nv-config ` | `-C` | Path to the non-verbose configuration file (`class-id.json`). Defaults to the compiled-in deployment path when omitted. | + +Example with custom paths: + +```bash +./datarouter --no_adaptive_runtime --config /custom/log-channels.json --nv-config /custom/class-id.json & +``` + ## Demo Application Setup ### Installation Structure @@ -87,15 +99,11 @@ Capture DLT messages on the loopback interface using the command-line tool: ### Option 2: Using DLT Viewer (GUI) -1. Launch [dlt-viewer](https://github.com/COVESA/dlt-viewer). -2. Open **ECU Configuration** and select the **UDP** tab. -3. Configure the connection: - - **Receiving interface**: Select the network interface on which the datarouter is transmitting (for example, `eth0`, `enp0s3`, `wlan0`, or another interface available on your platform). - - **IP Port**: `3490` -4. If multicast is enabled in the datarouter configuration: - - Enable **Multicast on network interface**. - - Set the **Multicast address** to the address configured in `log-channels.json` (for example, `239.255.42.99`). -5. Apply the configuration and start capturing to view real-time DLT log messages. +1. Launch [dlt-viewer](https://github.com/COVESA/dlt-viewer) +2. Configure UDP connection: + - Interface: `127.0.0.1` + - Port: `3490` +3. Start capture to view real-time log messages ### Option 3: Using Wireshark @@ -105,18 +113,6 @@ Capture DLT messages on the loopback interface using the command-line tool: 4. Apply display filter: `udp.port == 3490` 5. Start capture to monitor raw DLT UDP packets -### Option 4: Using Chipmunk (GUI) - -1. Download and install [Chipmunk](https://github.com/esrlabs/chipmunk). -2. Launch Chipmunk and create or open a UDP stream. -3. Configure the connection: - - **Socket Address**: `:3490` (replace `` with the IP address of the network endpoint on which the datarouter is transmitting. - For example, if the datarouter application and client are running on the same machine, use `0.0.0.0:3490`,) -4. If multicast is enabled in the datarouter configuration: - - **Address**: Set the multicast address configured in `log-channels.json` (for example, `239.255.42.99`). -5. Interface Address : Enter the IP address of the network Interface. -5. Start the stream to view incoming DLT log messages. - ## Verification Verify the setup operates correctly by checking: @@ -137,12 +133,11 @@ Verify the setup operates correctly by checking: ### No DLT messages received -- Verify datarouter daemon runs with `--no_adaptive_runtime` flag +- Verify datarouter daemon runs with the `--no_adaptive_runtime` flag +- If using custom config paths, confirm `--config` / `--nv-config` paths are correct - Check UDP port 3490 availability: `netstat -uln | grep 3490` - Confirm loopback interface configuration: `ip addr show lo` - Validate configuration files in `/opt/datarouter/etc/` -- Ensure the datarouter daemon and the DLT client are running before starting the application. - ### Configuration file errors diff --git a/score/datarouter/include/daemon/socketserver.h b/score/datarouter/include/daemon/socketserver.h index cebc079c..48dbb3c3 100644 --- a/score/datarouter/include/daemon/socketserver.h +++ b/score/datarouter/include/daemon/socketserver.h @@ -28,6 +28,7 @@ #include #include #include +#include #include // Forward declaration for testing @@ -68,10 +69,16 @@ class SocketServer bool is_dlt_enabled{false}; }; - static void Run(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime) + // A std::nullopt log_channels_path / nv_config_path keeps the built-in + // default path, so the default behaviour is preserved unless --config / + // --nv-config were provided. + static void Run(const std::atomic_bool& exit_requested, + const bool no_adaptive_runtime, + const std::optional& log_channels_path = std::nullopt, + const std::optional& nv_config_path = std::nullopt) { static SocketServer server; - server.DoWork(exit_requested, no_adaptive_runtime); + server.DoWork(exit_requested, no_adaptive_runtime, log_channels_path, nv_config_path); } // static void run(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime); @@ -81,7 +88,8 @@ class SocketServer std::unique_ptr& persistent_dictionary); static std::unique_ptr CreateDltServer( - const PersistentStorageHandlers& storage_handlers); + const PersistentStorageHandlers& storage_handlers, + const std::optional& log_channels_path = std::nullopt); static std::unique_ptr CreateLogParserFactory( score::logging::dltserver::DltLogServer& dlt_server); @@ -120,7 +128,10 @@ class SocketServer const std::string& appid); private: - void DoWork(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime); + void DoWork(const std::atomic_bool& exit_requested, + const bool no_adaptive_runtime, + const std::optional& log_channels_path, + const std::optional& nv_config_path); }; } // namespace datarouter diff --git a/score/datarouter/include/dlt/logentry_trace.h b/score/datarouter/include/dlt/logentry_trace.h index df031497..5a8bdbf8 100644 --- a/score/datarouter/include/dlt/logentry_trace.h +++ b/score/datarouter/include/dlt/logentry_trace.h @@ -23,13 +23,13 @@ namespace score namespace platform { -// The MEMCPY_SERIALIZABLE macro is part of the Tracing infrastructure and is tested independently. +// The SCORE_MEMCPY_SERIALIZABLE macro is part of the Tracing infrastructure and is tested independently. // This usage is declarative only and does not contain logic specific to this module. // Excluding from coverage to avoid inflating coverage metrics with non-functional declarations. // LCOV_EXCL_START : See above -// MEMCPY_SERIALIZABLE won't cause data loss. +// SCORE_MEMCPY_SERIALIZABLE won't cause data loss. // coverity[autosar_cpp14_a4_7_1_violation] -MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, DltidT) +SCORE_MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, DltidT) // LCOV_EXCL_STOP namespace internal @@ -48,17 +48,17 @@ struct LogEntryFilter uint8_t log_level_threshold = 0U; }; -// The STRUCT_TRACEABLE macro is part of the Tracing infrastructure and is tested independently. +// The SCORE_STRUCT_TRACEABLE macro is part of the Tracing infrastructure and is tested independently. // This usage is declarative only and does not contain logic specific to this module. // Excluding from coverage to avoid inflating coverage metrics with non-functional declarations. // LCOV_EXCL_START : See above // Suppress "AUTOSAR C++14 A18-9-4". The rule states: An argument to std::forward shall not be subsequently used. -// Rationale: STRUCT_TRACEABLE is a macro, std::forward is from the macro definition +// Rationale: SCORE_STRUCT_TRACEABLE is a macro, std::forward is from the macro definition // Suppress "AUTOSAR C++14 M3-2-3" rule finding. This rule states: "A type, object or function that is used in multiple // translation units shall be declared in one and only one file.". // coverity[autosar_cpp14_a18_9_4_violation] // coverity[autosar_cpp14_m3_2_3_violation] -STRUCT_TRACEABLE(LogEntryFilter, app_id, ctx_id, log_level_threshold) +SCORE_STRUCT_TRACEABLE(LogEntryFilter, app_id, ctx_id, log_level_threshold) // LCOV_EXCL_STOP } // namespace internal diff --git a/score/datarouter/src/applications/datarouter_app.cpp b/score/datarouter/src/applications/datarouter_app.cpp index 27b5dd37..a37b9d81 100644 --- a/score/datarouter/src/applications/datarouter_app.cpp +++ b/score/datarouter/src/applications/datarouter_app.cpp @@ -62,7 +62,7 @@ void DatarouterAppRun(const std::atomic_bool& exit_requested) score::mw::log::LogInfo() << "datarouter successfully completed initialization and goes live!"; - SocketServer::Run(exit_requested, opts.NoAdaptiveRuntime()); + SocketServer::Run(exit_requested, opts.NoAdaptiveRuntime(), opts.ConfigPath(), opts.NvConfigPath()); } void DatarouterAppShutdown() diff --git a/score/datarouter/src/applications/options.cpp b/score/datarouter/src/applications/options.cpp index 9c9b319d..4da5ffeb 100644 --- a/score/datarouter/src/applications/options.cpp +++ b/score/datarouter/src/applications/options.cpp @@ -14,11 +14,11 @@ #include "options.h" #include "score/mw/log/logging.h" +#include "score/os/getopt.h" -#include -#include #include #include +#include #include #include @@ -31,28 +31,6 @@ void EmitMessage(const std::string& msg) score::mw::log::LogError() << "Error in command line:" << msg; } -void ReportError(const std::string& text, const char opt_char, const std::string& arg) -{ - std::string msg = text; - - msg += " option \""; - - // If a long option, take it as it is. - // Otherwise use the single option character. - if (arg.rfind("--", 0) == 0) - { - msg += arg; - } - else - { - msg += opt_char; - } - - msg += "\""; - - EmitMessage(msg); -} - void PrintUsage(std::string_view program) { std::cout @@ -62,8 +40,13 @@ void PrintUsage(std::string_view program) " -h, --help Print this message and exit.\n" " -v, --verbose Display plenty of output to stdout.\n" " -n, --no_adaptive_runtime Do not use the Vector stack. Persistentcy features will not be available.\n" - " -V, --version Print the version number of make and exit.\n"; + " -V, --version Print the version number of make and exit.\n" + " -c, --config Path to the channel configuration (log-channels.json). Defaults to the " + "built-in path when omitted.\n" + " -C, --nv-config Path to the non-verbose configuration (class-id.json). Defaults to the " + "built-in path when omitted.\n"; } + } // namespace namespace score @@ -80,74 +63,79 @@ bool Options::Parse(std::int32_t argc, char* const argv[]) { Options& options = Options::Get(); - score::cpp::span args(argv, static_cast::size_type>(argc)); - - for (std::int32_t arg_index = 1; arg_index < argc; ++arg_index) + // Suppress getopt's built-in stderr output; diagnostics are emitted via EmitMessage. + opterr = 0; + + // NOLINTNEXTLINE(modernize-avoid-c-arrays): required by the getopt_long API. + static const std::array<::option, 7> kLongOptions{{ + {"help", no_argument, nullptr, 'h'}, + {"verbose", no_argument, nullptr, 'v'}, + {"no_adaptive_runtime", no_argument, nullptr, 'n'}, + {"version", no_argument, nullptr, 'V'}, + {"config", required_argument, nullptr, 'c'}, + {"nv-config", required_argument, nullptr, 'C'}, + {nullptr, 0, nullptr, 0}, + }}; + + score::os::Getopt& getopt_instance = score::os::Getopt::instance(); + std::int32_t longindex{0}; + std::int32_t opt{}; + + // Leading ':' in optstring causes getopt_long to return ':' (not '?') on missing arguments. + while ((opt = getopt_instance.getopt_long(argc, argv, ":hvnVc:C:", kLongOptions.data(), &longindex)) != -1) { - std::string_view argument_token{score::cpp::at(args, arg_index)}; - - // Long options: --help, --verbose, --no_adaptive_runtime, --version - if (argument_token.size() > 2 && argument_token[0] == '-' && argument_token[1] == '-') + switch (opt) { - std::string_view long_option_name = argument_token.substr(2); - if (long_option_name == "help") - { - PrintUsage(args.front()); + case 'h': + PrintUsage(argv[0]); options.do_nothing_ = true; return true; - } - else if (long_option_name == "verbose") - { + + case 'v': options.verbose_ = true; - } - else if (long_option_name == "no_adaptive_runtime") - { + break; + + case 'n': options.no_adaptive_runtime_ = true; - } - else if (long_option_name == "version") - { + break; + + case 'V': options.print_version_ = true; return true; - } - else + + case 'c': // -c / --config { - ReportError("Unknown", '?', score::cpp::at(args, arg_index)); - return false; + const std::string_view value{optarg}; + if (value.empty()) + { + EmitMessage(R"(Missing value for option "-c/--config")"); + return false; + } + options.config_path_ = std::string{value}; + break; } - } - // Short options: -h, -v, -n, -V - else if (argument_token.size() >= 2 && argument_token[0] == '-') - { - // In some "case" below we are not returning directly to support the grouping of options, for example : -vn - for (size_t short_option_index = 1; short_option_index < argument_token.size(); ++short_option_index) + case 'C': // -C / --nv-config { - char short_option_char = argument_token[short_option_index]; - // using help or version results in exiting the parse function. - switch (short_option_char) + const std::string_view value{optarg}; + if (value.empty()) { - case 'h': - PrintUsage(args.front()); - options.do_nothing_ = true; - return true; - - case 'v': - options.verbose_ = true; - break; - - case 'n': - options.no_adaptive_runtime_ = true; - break; - - case 'V': - options.print_version_ = true; - return true; - - default: - ReportError("Unknown", short_option_char, score::cpp::at(args, arg_index)); - return false; + EmitMessage(R"(Missing value for option "-C/--nv-config")"); + return false; } + options.nv_config_path_ = std::string{value}; + break; } + + case ':': + EmitMessage(std::string{"Missing value for option \""} + + std::string{argv[getopt_instance.getoptind() - 1]} + "\""); + return false; + + default: // '?' + EmitMessage(std::string{"Unknown option \""} + std::string{argv[getopt_instance.getoptind() - 1]} + + "\""); + return false; } } diff --git a/score/datarouter/src/applications/options.h b/score/datarouter/src/applications/options.h index 8b3b3757..85ad5e5f 100644 --- a/score/datarouter/src/applications/options.h +++ b/score/datarouter/src/applications/options.h @@ -15,6 +15,8 @@ #define SCORE_DATAROUTER_SRC_APPLICATIONS_OPTIONS_H #include +#include +#include namespace score { @@ -55,6 +57,22 @@ class Options return no_adaptive_runtime_; } + // Override for the channel configuration file (log-channels.json). Holds a + // value only when --config was provided; std::nullopt keeps the built-in + // default path. + const std::optional& ConfigPath() const + { + return config_path_; + } + + // Override for the non-verbose configuration file (class-id.json). Holds a + // value only when --nv-config was provided; std::nullopt keeps the built-in + // default path. + const std::optional& NvConfigPath() const + { + return nv_config_path_; + } + private: Options(); Options(const Options&) = delete; @@ -66,6 +84,8 @@ class Options bool print_version_; bool verbose_; bool no_adaptive_runtime_; + std::optional config_path_; + std::optional nv_config_path_; }; } // namespace options diff --git a/score/datarouter/src/daemon/socketserver.cpp b/score/datarouter/src/daemon/socketserver.cpp index ddcba930..052d2180 100644 --- a/score/datarouter/src/daemon/socketserver.cpp +++ b/score/datarouter/src/daemon/socketserver.cpp @@ -37,6 +37,7 @@ #include #include #include +#include namespace score { @@ -137,13 +138,17 @@ SocketServer::PersistentStorageHandlers SocketServer::InitializePersistentStorag } std::unique_ptr SocketServer::CreateDltServer( - const PersistentStorageHandlers& storage_handlers) + const PersistentStorageHandlers& storage_handlers, + const std::optional& log_channels_path) { - const auto static_config = ReadStaticDlt(kLogChannelsPath); + // Use the caller-provided path only when --config was given; otherwise keep + // the built-in default so the existing behaviour is unchanged. + const std::string config_path = log_channels_path.value_or(kLogChannelsPath); + const auto static_config = ReadStaticDlt(config_path.c_str()); if (!static_config.has_value()) { score::mw::log::LogError() << static_config.error(); - score::mw::log::LogError() << "Error during parsing file " << std::string_view{kLogChannelsPath} + score::mw::log::LogError() << "Error during parsing file " << std::string_view{config_path} << ", static config is not available, interrupt work"; return nullptr; } @@ -344,7 +349,10 @@ void SocketServer::RunEventLoop(const std::atomic_bool& exit_requested, } } -void SocketServer::DoWork(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime) +void SocketServer::DoWork(const std::atomic_bool& exit_requested, + const bool no_adaptive_runtime, + const std::optional& log_channels_path, + const std::optional& nv_config_path) { SetThreadName(); @@ -355,7 +363,7 @@ void SocketServer::DoWork(const std::atomic_bool& exit_requested, const bool no_ const PersistentStorageHandlers storage_handlers = InitializePersistentStorage(pd); // Create DLT server - auto dlt_server = CreateDltServer(storage_handlers); + auto dlt_server = CreateDltServer(storage_handlers, log_channels_path); if (!dlt_server) { return; @@ -372,8 +380,10 @@ void SocketServer::DoWork(const std::atomic_bool& exit_requested, const bool no_ // Create Unix domain server for config sessions auto unix_domain_server = CreateUnixDomainServer(*dlt_server); - // Load NvConfig - const score::mw::log::NvConfig nv_config = LoadNvConfig(stats_logger); + // Load NvConfig. Use the caller-provided path only when --nv-config was + // given; otherwise fall back to LoadNvConfig's built-in default path. + const score::mw::log::NvConfig nv_config = + nv_config_path.has_value() ? LoadNvConfig(stats_logger, nv_config_path.value()) : LoadNvConfig(stats_logger); // Create message passing factory const auto mp_factory = [&router, &dlt_server, &nv_config]( diff --git a/score/datarouter/src/persistent_logging/BUILD b/score/datarouter/src/persistent_logging/BUILD deleted file mode 100644 index 9fe077c0..00000000 --- a/score/datarouter/src/persistent_logging/BUILD +++ /dev/null @@ -1,39 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* - -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "sysedr_handler_interface", - hdrs = [ - "isysedr_handler.h", - ], - visibility = ["//score/datarouter/src/persistent_logging:__subpackages__"], - deps = [ - "@score_logging//score/datarouter:logparser", - ], -) - -cc_library( - name = "sysedr_factory", - hdrs = [ - "sysedr_factory.hpp", - ], - visibility = [ - "//score/datarouter/src/persistent_logging:__subpackages__", - "//score/datarouter/test:__subpackages__", - ], - deps = [ - ":sysedr_handler_interface", - ], -) diff --git a/score/datarouter/src/persistent_logging/isysedr_handler.h b/score/datarouter/src/persistent_logging/isysedr_handler.h deleted file mode 100644 index b177d4d6..00000000 --- a/score/datarouter/src/persistent_logging/isysedr_handler.h +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#ifndef SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_ISYSEDR_HANDLER_H -#define SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_ISYSEDR_HANDLER_H - -#include "logparser/logparser.h" - -// LCOV_EXCL_START (nothing to test because this is just an interface definition) -namespace score -{ -namespace platform -{ -namespace internal -{ - -class ISysedrHandler : public LogParser::TypeHandler, public LogParser::AnyHandler -{ - public: - ISysedrHandler() = default; - ~ISysedrHandler() = default; - - protected: - // LogParser::TypeHandler - void Handle(TimestampT /* timestamp */, const char* /*data*/, BufsizeT /*size*/) override {}; - // LogParser::AnyHandler - void Handle(const TypeInfo& /*typeInfo*/, - TimestampT /*timestamp*/, - const char* /*data*/, - BufsizeT /*size*/) override {}; -}; - -// LCOV_EXCL_STOP - -} // namespace internal -} // namespace platform -} // namespace score - -#endif // SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_ISYSEDR_HANDLER_H diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/BUILD b/score/datarouter/src/persistent_logging/persistent_logging_stub/BUILD deleted file mode 100644 index fafa2f1a..00000000 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/BUILD +++ /dev/null @@ -1,32 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* - -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "sysedr_stub", - srcs = [ - "stub_sysedr_factory.cpp", - "stub_sysedr_handler.cpp", - ], - hdrs = [ - "stub_sysedr_factory.h", - "stub_sysedr_handler.h", - ], - visibility = ["@score_logging//score/datarouter:__subpackages__"], - deps = [ - "//score/datarouter/src/persistent_logging:sysedr_factory", - "//score/datarouter/src/persistent_logging:sysedr_handler_interface", - "@score_baselibs//score/mw/log", - ], -) diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.cpp b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.cpp deleted file mode 100644 index 6803f8cc..00000000 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#include "score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.h" -#include "score/mw/log/logging.h" - -namespace score -{ -namespace platform -{ -namespace internal -{ - -std::unique_ptr StubSysedrFactory::CreateConcreteSysedrHandler() -{ - score::mw::log::LogError() << "persistent_logging disabled, no persistent logging actions performed"; - return std::make_unique(); -} - -} // namespace internal -} // namespace platform -} // namespace score diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.h b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.h deleted file mode 100644 index 2e927d1b..00000000 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.h +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#ifndef SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_FACTORY_H -#define SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_FACTORY_H - -#include "score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h" -#include "score/datarouter/src/persistent_logging/sysedr_factory.hpp" - -namespace score -{ -namespace platform -{ -namespace internal -{ - -class StubSysedrFactory : public SysedrFactory -{ - public: - std::unique_ptr CreateConcreteSysedrHandler(); -}; - -} // namespace internal -} // namespace platform -} // namespace score - -#endif // SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_FACTORY_H diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.cpp b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.cpp deleted file mode 100644 index 3a6b406b..00000000 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#include "score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h" - -namespace score -{ -namespace platform -{ -namespace internal -{ - -// LCOV_EXCL_START (nothing to test because there is no implementation) -// LogParser::TypeHandler -void StubSysedrHandler::Handle(TimestampT /* timestamp */, const char* data, BufsizeT size) {} - -// LogParser::AnyHandler -void StubSysedrHandler::Handle(const TypeInfo& type_info, TimestampT timestamp, const char* data, BufsizeT size) {} - -// LCOV_EXCL_STOP - -} // namespace internal -} // namespace platform -} // namespace score diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h deleted file mode 100644 index 11128775..00000000 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#ifndef SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H -#define SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H - -#include "score/datarouter/src/persistent_logging/isysedr_handler.h" - -namespace score -{ -namespace platform -{ -namespace internal -{ - -class StubSysedrHandler final : public ISysedrHandler -{ - - private: - // LogParser::TypeHandler - void Handle(TimestampT /* timestamp */, const char* data, BufsizeT size) override; - - // LogParser::AnyHandler - void Handle(const TypeInfo& type_info, TimestampT timestamp, const char* data, BufsizeT size) override; -}; - -} // namespace internal -} // namespace platform -} // namespace score - -#endif // SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H diff --git a/score/datarouter/src/persistent_logging/sysedr_factory.hpp b/score/datarouter/src/persistent_logging/sysedr_factory.hpp deleted file mode 100644 index 40369745..00000000 --- a/score/datarouter/src/persistent_logging/sysedr_factory.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#ifndef SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP -#define SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP - -#include "score/datarouter/src/persistent_logging/isysedr_handler.h" -#include - -namespace score -{ -namespace platform -{ -namespace internal -{ -template -class SysedrFactory -{ - public: - std::unique_ptr CreateSysedrHandler() - { - return static_cast(this)->CreateConcreteSysedrHandler(); - } - - private: - SysedrFactory() = default; - ~SysedrFactory() = default; - SysedrFactory(SysedrFactory&) = delete; - SysedrFactory(SysedrFactory&&) = delete; - SysedrFactory& operator=(SysedrFactory&) = delete; - SysedrFactory& operator=(SysedrFactory&&) = delete; - - /* - Deviation from rule: A11-3-1 - - "Friend declarations shall not be used." - Justification: - - friend class and private constructor used here to prevent wrong inheritance - */ - // coverity[autosar_cpp14_a11_3_1_violation] - friend DerivedSysedrHandler; -}; - -} // namespace internal -} // namespace platform -} // namespace score - -#endif // SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP diff --git a/score/datarouter/test/ut/ut_logging/test_log_entry_deserialize.cpp b/score/datarouter/test/ut/ut_logging/test_log_entry_deserialize.cpp index b9b9ae71..d055bea4 100644 --- a/score/datarouter/test/ut/ut_logging/test_log_entry_deserialize.cpp +++ b/score/datarouter/test/ut/ut_logging/test_log_entry_deserialize.cpp @@ -32,7 +32,7 @@ struct SerializedVectorStd std::uint32_t n; }; -STRUCT_TRACEABLE(SerializedVectorStd, m, payload, n) +SCORE_STRUCT_TRACEABLE(SerializedVectorStd, m, payload, n) struct SerializedVectorDataWrapper { @@ -41,7 +41,7 @@ struct SerializedVectorDataWrapper std::uint32_t n; }; -STRUCT_TRACEABLE(SerializedVectorDataWrapper, m, payload, n) +SCORE_STRUCT_TRACEABLE(SerializedVectorDataWrapper, m, payload, n) namespace test { diff --git a/score/datarouter/test/ut/ut_logging/test_logparser.cpp b/score/datarouter/test/ut/ut_logging/test_logparser.cpp index b2f51966..14dc8cbd 100644 --- a/score/datarouter/test/ut/ut_logging/test_logparser.cpp +++ b/score/datarouter/test/ut/ut_logging/test_logparser.cpp @@ -48,8 +48,8 @@ struct TestFilter int32_t test_field; }; -STRUCT_VISITABLE(TestMessage, test_field) -STRUCT_VISITABLE(TestFilter, test_field) +SCORE_STRUCT_VISITABLE(TestMessage, test_field) +SCORE_STRUCT_VISITABLE(TestFilter, test_field) template std::string MakeTypeParams(DltidT ecu_id, DltidT app_id) @@ -146,7 +146,7 @@ struct SmallTestMessage { uint8_t test_field; }; -STRUCT_VISITABLE(SmallTestMessage, test_field) +SCORE_STRUCT_VISITABLE(SmallTestMessage, test_field) // The purpose of this test is to enhance the line coverage for // parse(TimestampT timestamp, const char* data, BufsizeT size) method. diff --git a/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp b/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp index cbdd9984..15548810 100644 --- a/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp +++ b/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp @@ -32,7 +32,7 @@ struct TestTraceableStruct std::uint32_t i; std::uint32_t j; }; -STRUCT_TRACEABLE(TestTraceableStruct, i, j) +SCORE_STRUCT_TRACEABLE(TestTraceableStruct, i, j) } // namespace test } // namespace datarouter diff --git a/score/datarouter/test/ut/ut_logging/test_options.cpp b/score/datarouter/test/ut/ut_logging/test_options.cpp index fb3651be..18443ddc 100644 --- a/score/datarouter/test/ut/ut_logging/test_options.cpp +++ b/score/datarouter/test/ut/ut_logging/test_options.cpp @@ -240,3 +240,91 @@ TEST_F(OptionsTest, ParseUnknownOptionDoubleQuestionDashDash) bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_FALSE(result); } + +TEST_F(OptionsTest, ParseConfigLongOptionSeparateValue) +{ + // Simulate: ./program --config /path/to/log-channels.json + int argc = 3; + char program_name[] = "myProgram"; + char config_option[] = "--config"; + char config_value[] = "/path/to/log-channels.json"; + char* argv[] = {program_name, config_option, config_value, nullptr}; + + bool result = score::logging::options::Options::Parse(argc, argv); + EXPECT_TRUE(result); + + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_EQ(opts.ConfigPath(), "/path/to/log-channels.json"); +} + +TEST_F(OptionsTest, ParseConfigLongOptionEqualsValue) +{ + // Simulate: ./program --config=/etc/log-channels.json + int argc = 2; + char program_name[] = "myProgram"; + char config_option[] = "--config=/etc/log-channels.json"; + char* argv[] = {program_name, config_option, nullptr}; + + bool result = score::logging::options::Options::Parse(argc, argv); + EXPECT_TRUE(result); + + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_EQ(opts.ConfigPath(), "/etc/log-channels.json"); +} + +TEST_F(OptionsTest, ParseNvConfigLongOptionSeparateValue) +{ + // Simulate: ./program --nv-config /path/to/class-id.json + int argc = 3; + char program_name[] = "myProgram"; + char nv_config_option[] = "--nv-config"; + char nv_config_value[] = "/path/to/class-id.json"; + char* argv[] = {program_name, nv_config_option, nv_config_value, nullptr}; + + bool result = score::logging::options::Options::Parse(argc, argv); + EXPECT_TRUE(result); + + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_EQ(opts.NvConfigPath(), "/path/to/class-id.json"); +} + +TEST_F(OptionsTest, ParseNvConfigLongOptionEqualsValue) +{ + // Simulate: ./program --nv-config=/etc/class-id.json + int argc = 2; + char program_name[] = "myProgram"; + char nv_config_option[] = "--nv-config=/etc/class-id.json"; + char* argv[] = {program_name, nv_config_option, nullptr}; + + bool result = score::logging::options::Options::Parse(argc, argv); + EXPECT_TRUE(result); + + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_EQ(opts.NvConfigPath(), "/etc/class-id.json"); +} + +TEST_F(OptionsTest, ParseConfigLongOptionMissingValue) +{ + // Simulate: ./program --config (no value follows) + int argc = 2; + char program_name[] = "myProgram"; + char config_option[] = "--config"; + char* argv[] = {program_name, config_option, nullptr}; + + // A value-taking option without a value must fail to parse. + bool result = score::logging::options::Options::Parse(argc, argv); + EXPECT_FALSE(result); +} + +TEST_F(OptionsTest, ParseConfigLongOptionEmptyEqualsValue) +{ + // Simulate: ./program --config= (empty value) + int argc = 2; + char program_name[] = "myProgram"; + char config_option[] = "--config="; + char* argv[] = {program_name, config_option, nullptr}; + + // An empty value must fail to parse. + bool result = score::logging::options::Options::Parse(argc, argv); + EXPECT_FALSE(result); +} diff --git a/score/mw/log/detail/common/log_entry_deserialize.h b/score/mw/log/detail/common/log_entry_deserialize.h index b159b4ea..71af36b8 100644 --- a/score/mw/log/detail/common/log_entry_deserialize.h +++ b/score/mw/log/detail/common/log_entry_deserialize.h @@ -60,7 +60,7 @@ Deviation from Rule M11-0-1: Justification: - Maintaining compatibility and avoiding performance overhead outweighs POD Type (class) based design for this particular struct. The Type is simple and does not require invariance (interface OR custom behavior) as per the - design. Moreover the type is used with STRUCT_TRACEABLE for serialization purpose + design. Moreover the type is used with SCORE_STRUCT_TRACEABLE for serialization purpose */ // coverity[autosar_cpp14_a11_0_2_violation] struct LogEntryDeserializationReflection @@ -84,20 +84,20 @@ struct LogEntryDeserializationReflection // NOLINTEND(score-struct-usage-compliance) See above // LCOV_EXCL_START -// STRUCT_TRACEABLE macro tested in score/serialization/serializer_test.cpp +// SCORE_STRUCT_TRACEABLE macro tested in score/serialization/serializer_test.cpp // Not required to test this macro with another structure/data /* Deviation from Rule A0-1-1: - A project shall not contain instances of non-volatile variables being given values that are not subsequently used. Justification: -- we need to use STRUCT_TRACEABLE here and create an instance of LogEntryDeserializationReflection +- we need to use SCORE_STRUCT_TRACEABLE here and create an instance of LogEntryDeserializationReflection - to get the size of LogEntryDeserializationReflection for serialization purpose */ // coverity[autosar_cpp14_a11_0_2_violation] // coverity[autosar_cpp14_a0_1_1_violation] // coverity[autosar_cpp14_a18_9_4_violation] -STRUCT_TRACEABLE(LogEntryDeserializationReflection, app_id, ctx_id, serialized_vector_data, num_of_args, log_level) +SCORE_STRUCT_TRACEABLE(LogEntryDeserializationReflection, app_id, ctx_id, serialized_vector_data, num_of_args, log_level) // LCOV_EXCL_STOP } // namespace log_entry_deserialization diff --git a/score/mw/log/legacy_non_verbose_api/tracing.h b/score/mw/log/legacy_non_verbose_api/tracing.h index c67beb67..8d23b4d8 100644 --- a/score/mw/log/legacy_non_verbose_api/tracing.h +++ b/score/mw/log/legacy_non_verbose_api/tracing.h @@ -473,10 +473,15 @@ inline void TraceWarn(const T& arg) /// \public /// \thread-safe -// Using preprocessor here because we define function macro to use it any where with name STRUCT_TRACEABLE +// Using preprocessor here because we define function macro to use it any where with name SCORE_STRUCT_TRACEABLE // coverity[autosar_cpp14_a16_0_1_violation] -#ifndef STRUCT_TRACEABLE -#define STRUCT_TRACEABLE(...) STRUCT_VISITABLE(__VA_ARGS__) +#ifndef SCORE_STRUCT_TRACEABLE +#define SCORE_STRUCT_TRACEABLE(...) SCORE_STRUCT_VISITABLE(__VA_ARGS__) #endif +/// \public +/// \thread-safe +// Using preprocessor here because we define function macro to use it any where with name SCORE_STRUCT_TRACEABLE +// coverity[autosar_cpp14_a16_0_1_violation] + #endif // SCORE_MW_LOG_LEGACY_NON_VERBOSE_API_TRACING_H diff --git a/score/mw/log/legacy_non_verbose_api/tracing_test.cpp b/score/mw/log/legacy_non_verbose_api/tracing_test.cpp index c9db3c0c..43331fd6 100644 --- a/score/mw/log/legacy_non_verbose_api/tracing_test.cpp +++ b/score/mw/log/legacy_non_verbose_api/tracing_test.cpp @@ -43,7 +43,7 @@ struct DisabledLoggerTestEntry bool dummy; }; -STRUCT_TRACEABLE(DisabledLoggerTestEntry, dummy) +SCORE_STRUCT_TRACEABLE(DisabledLoggerTestEntry, dummy) } // namespace test_data namespace @@ -336,8 +336,8 @@ struct NonVerboseMessage bool bool_value; }; -STRUCT_TRACEABLE(NonVerboseMessage, bool_value) -STRUCT_TRACEABLE(DropCounterTestEntry, test_value) +SCORE_STRUCT_TRACEABLE(NonVerboseMessage, bool_value) +SCORE_STRUCT_TRACEABLE(DropCounterTestEntry, test_value) TEST(TraceFixtureTest, WhenTraceWithLogEnabledAndTraceLevelDoesNotExceed) { From a4007d61a04eeeabf7c825c699a11515401bad03 Mon Sep 17 00:00:00 2001 From: vaishnavi yendole Date: Tue, 4 Aug 2026 15:19:50 +0530 Subject: [PATCH 2/4] Remove persistent logging from PAS logging GIT_ORIGIN_SPP_REV_ID: ad5e2ed2726785488e5ce1878a6ba8daa8fa074e --- score/datarouter/BUILD | 39 +------------------ .../build_configuration_flags/BUILD | 16 -------- .../applications/datarouter_feature_config.h | 15 ------- .../include/daemon/dlt_log_server.h | 11 +----- 4 files changed, 4 insertions(+), 77 deletions(-) diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index fba584b0..8deff4d0 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -46,7 +46,6 @@ cc_library( visibility = [ "//score/datarouter/dlt_filetransfer_trigger_lib:__pkg__", "//score/datarouter/src/file_transfer:__subpackages__", - "//score/datarouter/src/persistent_logging/persistent_logging:__pkg__", "//score/datarouter/test:__subpackages__", ], deps = [ @@ -178,8 +177,6 @@ cc_library( "//score/datarouter/src/dlt/nonverbose_dlt_impl:__pkg__", "//score/datarouter/src/dlt/nonverbose_dlt_stub:__pkg__", "//score/datarouter/src/file_transfer:__subpackages__", - "//score/datarouter/src/persistent_logging:__pkg__", - "//score/datarouter/src/persistent_logging/persistent_logging:__pkg__", "//score/datarouter/test:__subpackages__", ], deps = [ @@ -201,8 +198,6 @@ cc_library( "//score/datarouter/src/dlt/nonverbose_dlt_impl:__pkg__", "//score/datarouter/src/dlt/nonverbose_dlt_stub:__pkg__", "//score/datarouter/src/file_transfer:__subpackages__", - "//score/datarouter/src/persistent_logging:__pkg__", - "//score/datarouter/src/persistent_logging/persistent_logging:__pkg__", ], deps = [ ":datarouter_types", @@ -528,9 +523,6 @@ cc_library( }) + select({ "//score/datarouter/build_configuration_flags:config_file_transfer": ["DLT_FILE_TRANSFER_FEATURE"], "//conditions:default": [], - }) + select({ - "//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"], - "//conditions:default": [], }), strip_include_prefix = "include", visibility = [ @@ -562,13 +554,6 @@ cc_library( "//conditions:default": [ dc_stub_dep, ], - }) + select({ - "//score/datarouter/build_configuration_flags:config_persistent_logging": [ - "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", - ], - "//conditions:default": [ - "//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub", - ], }), ) for name, ara_fact_dep, nv_dep, nv_stub_dep, dc_dep, dc_stub_dep, ft_dep, test_only in [ @@ -627,7 +612,6 @@ cc_library( ":udp_stream_output", ":unixdomain_server", "//score/datarouter/network:vlan", - "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", "//score/mw/log", "@score_baselibs//score/language/futurecpp", "@score_baselibs//score/mw/log/configuration:nvconfig", @@ -791,10 +775,6 @@ cc_library( "//conditions:default": [], }), features = COMPILER_WARNING_FEATURES, - local_defines = select({ - "//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"], - "//conditions:default": [], - }), strip_include_prefix = "include", visibility = [ "//score/datarouter/test:__subpackages__", @@ -807,12 +787,7 @@ cc_library( ":persistentlogconfig", ":socketserver_config_lib", "@score_baselibs//score/mw/log/configuration:nvconfigfactory", - ] + select({ - "//score/datarouter/build_configuration_flags:config_persistent_logging": [ - "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", - ], - "//conditions:default": [], - }), + ], ) cc_library( @@ -831,10 +806,6 @@ cc_library( "//conditions:default": [], }), features = COMPILER_WARNING_FEATURES, - local_defines = select({ - "//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"], - "//conditions:default": [], - }), strip_include_prefix = "include", visibility = ["//score/datarouter/test:__subpackages__"], deps = [ @@ -844,12 +815,7 @@ cc_library( ":persistentlogconfig", ":socketserver_config_lib_testing", "@score_baselibs//score/mw/log/configuration:nvconfigfactory", - ] + select({ - "//score/datarouter/build_configuration_flags:config_persistent_logging": [ - "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", - ], - "//conditions:default": [], - }), + ], ) [ @@ -1107,7 +1073,6 @@ cc_library( "//score/mw/log", "@score_baselibs//score/mw/log/configuration:nvconfig", "//score/datarouter/dlt_filetransfer_trigger_lib:filetransfer_message_types", - "//score/datarouter/src/persistent_logging/persistent_logging:sysedr", ], ) diff --git a/score/datarouter/build_configuration_flags/BUILD b/score/datarouter/build_configuration_flags/BUILD index ef556c25..62df6e74 100644 --- a/score/datarouter/build_configuration_flags/BUILD +++ b/score/datarouter/build_configuration_flags/BUILD @@ -13,22 +13,6 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") -bool_flag( - name = "persistent_logging", - build_setting_default = False, -) - -config_setting( - name = "config_persistent_logging", - flag_values = { - ":persistent_logging": "True", - }, - visibility = [ - "//platform/aas/log_and_trace/datarouterconf:__subpackages__", - "@score_logging//score/datarouter:__subpackages__", - ], -) - bool_flag( name = "persistent_config_feature_enabled", build_setting_default = True, diff --git a/score/datarouter/include/applications/datarouter_feature_config.h b/score/datarouter/include/applications/datarouter_feature_config.h index dc9036d2..4dcc5efe 100644 --- a/score/datarouter/include/applications/datarouter_feature_config.h +++ b/score/datarouter/include/applications/datarouter_feature_config.h @@ -43,27 +43,12 @@ #include "score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_stream_handler_stub.h" #endif -#if defined(PERSISTENT_LOGGING) -#include "score/datarouter/src/persistent_logging/persistent_logging/sysedr_concrete_factory.h" -#else -#include "score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.h" -#endif - namespace score { namespace platform { namespace internal { - -#if defined(PERSISTENT_LOGGING) -using SysedrHandlerType = SysedrHandler; -using SysedrFactoryType = SysedrConcreteFactory; -#else -using SysedrHandlerType = StubSysedrHandler; -using SysedrFactoryType = StubSysedrFactory; -#endif - } // namespace internal namespace datarouter diff --git a/score/datarouter/include/daemon/dlt_log_server.h b/score/datarouter/include/daemon/dlt_log_server.h index 3c86fe1f..ca455434 100644 --- a/score/datarouter/include/daemon/dlt_log_server.h +++ b/score/datarouter/include/daemon/dlt_log_server.h @@ -48,7 +48,6 @@ namespace dltserver { const std::string kLogEntryTypeName{"score::mw::log::detail::LogEntry"}; -const std::string kPersistentRequestTypeName{"score::logging::internal::PersistentLoggingRequestStructure"}; const std::string kFileTransferTypeName{"score::logging::FileTransferEntry"}; class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOutput, DltVerboseHandler::IOutput, @@ -93,8 +92,6 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut parser_(parser ? std::move(parser) : std::make_unique()) { InitLogChannels(); - SysedrFactoryType sysedr_factory; - sysedr_handler_ = sysedr_factory.CreateSysedrHandler(); } virtual ~DltLogServer() = default; @@ -102,14 +99,12 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut // LCOV_EXCL_START std::vector GetGlobalHandlers() { - return {sysedr_handler_.get(), &nvhandler_}; + return {&nvhandler_}; } std::vector GetTypeHandlerBindings() { - return {{kPersistentRequestTypeName, sysedr_handler_.get()}, - {kLogEntryTypeName, &vhandler_}, - {kFileTransferTypeName, &fthandler_}}; + return {{kLogEntryTypeName, &vhandler_}, {kFileTransferTypeName, &fthandler_}}; } // LCOV_EXCL_STOP @@ -313,8 +308,6 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut std::unique_ptr log_sender_; std::unique_ptr parser_; - std::unique_ptr sysedr_handler_; - void SendNonVerbose(const score::mw::log::config::NvMsgDescriptor& desc, uint32_t tmsp, const void* data, From e6808a86fec650e0d611b5c7fb570a74bcd8766e Mon Sep 17 00:00:00 2001 From: rutik akolkar Date: Mon, 10 Aug 2026 11:42:08 +0530 Subject: [PATCH 3/4] mw/log: migrate users of bitmanipulation to score_baselibs. - replace //platform/aas/lib/bitmanipulation with @score_baselibs//score/bitmanipulation and update include paths and namespace from bmw::platform to score::platform GIT_ORIGIN_SPP_REV_ID: 4649fe293ddec3bbc0e6584963d60b798769dc62 --- score/mw/log/detail/common/dlt_format.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/score/mw/log/detail/common/dlt_format.cpp b/score/mw/log/detail/common/dlt_format.cpp index efce0593..105c2484 100644 --- a/score/mw/log/detail/common/dlt_format.cpp +++ b/score/mw/log/detail/common/dlt_format.cpp @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ #include "score/mw/log/detail/common/dlt_format.h" -#include "score/bitmanipulation/bit_manipulation.h" #include "score/mw/log/detail/common/helper_functions.h" +#include "score/bitmanipulation/bit_manipulation.h" #include "score/assert.hpp" #include "score/span.hpp" From 77d0611958cbdb58c531e28a0b9d73502fffc739 Mon Sep 17 00:00:00 2001 From: vaishnavi yendole Date: Tue, 11 Aug 2026 10:52:55 +0530 Subject: [PATCH 4/4] Remove deprecated persistent_logging flag from .bazelrc --- .bazelrc | 1 - .../doc/guideline/dlt_capture_demo.md | 47 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.bazelrc b/.bazelrc index a97c3019..d6e6dbd4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,7 +36,6 @@ build:_common --features=minimal_warnings --features=-strict_warnings --features common --@score_baselibs//score/memory/shared/flags:use_typedshmd=False common --@score_baselibs//score/mw/log/flags:KRemote_Logging=False common --@score_baselibs//score/json:base_library=nlohmann -common --//score/datarouter/build_configuration_flags:persistent_logging=False common --//score/datarouter/build_configuration_flags:persistent_config_feature_enabled=False common --//score/datarouter/build_configuration_flags:enable_dynamic_configuration=False common --//score/datarouter/build_configuration_flags:file_transfer=False diff --git a/score/datarouter/doc/guideline/dlt_capture_demo.md b/score/datarouter/doc/guideline/dlt_capture_demo.md index e7728c1c..2cdad181 100644 --- a/score/datarouter/doc/guideline/dlt_capture_demo.md +++ b/score/datarouter/doc/guideline/dlt_capture_demo.md @@ -10,11 +10,12 @@ This guide configures a minimal setup for capturing DLT logs on a loopback inter - [dlt-viewer](https://github.com/COVESA/dlt-viewer) - GUI-based DLT log viewer - [dlt-receive](https://github.com/COVESA/dlt-daemon/blob/master/doc/dlt-receive.1.md) - Command-line DLT receiver - [Wireshark](https://www.wireshark.org/) - Network protocol analyzer with DLT support + - [Chipmunk](https://github.com/esrlabs/chipmunk) - GUI-based DLT log viewer and analysis tool ### System Requirements - x86 target platform -- Network loopback interface (127.0.0.1) configured and operational as a multicast interface. +- Network loopback interface (127.0.0.1) and Docker interface (172.17.0.1) configured and operational as multicast interfaces. - UDP port 3490 available for DLT traffic ## Datarouter Setup @@ -44,19 +45,6 @@ Execute the datarouter daemon on x86 targets: The `--no_adaptive_runtime` flag bypasses Adaptive runtime requirements for standalone operation. -The following optional flags override the default configuration file paths: - -| Flag | Short | Description | -|---|---|---| -| `--config ` | `-c` | Path to the channel configuration file (`log-channels.json`). Defaults to `./etc/log-channels.json`. | -| `--nv-config ` | `-C` | Path to the non-verbose configuration file (`class-id.json`). Defaults to the compiled-in deployment path when omitted. | - -Example with custom paths: - -```bash -./datarouter --no_adaptive_runtime --config /custom/log-channels.json --nv-config /custom/class-id.json & -``` - ## Demo Application Setup ### Installation Structure @@ -99,11 +87,15 @@ Capture DLT messages on the loopback interface using the command-line tool: ### Option 2: Using DLT Viewer (GUI) -1. Launch [dlt-viewer](https://github.com/COVESA/dlt-viewer) -2. Configure UDP connection: - - Interface: `127.0.0.1` - - Port: `3490` -3. Start capture to view real-time log messages +1. Launch [dlt-viewer](https://github.com/COVESA/dlt-viewer). +2. Open **ECU Configuration** and select the **UDP** tab. +3. Configure the connection: + - **Receiving interface**: Select the network interface on which the datarouter is transmitting (for example, `eth0`, `enp0s3`, `wlan0`, or another interface available on your platform). + - **IP Port**: `3490` +4. If multicast is enabled in the datarouter configuration: + - Enable **Multicast on network interface**. + - Set the **Multicast address** to the address configured in `log-channels.json` (for example, `239.255.42.99`). +5. Apply the configuration and start capturing to view real-time DLT log messages. ### Option 3: Using Wireshark @@ -113,6 +105,18 @@ Capture DLT messages on the loopback interface using the command-line tool: 4. Apply display filter: `udp.port == 3490` 5. Start capture to monitor raw DLT UDP packets +### Option 4: Using Chipmunk (GUI) + +1. Download and install [Chipmunk](https://github.com/esrlabs/chipmunk). +2. Launch Chipmunk and create or open a UDP stream. +3. Configure the connection: + - **Socket Address**: `:3490` (replace `` with the IP address of the network endpoint on which the datarouter is transmitting. + For example, if the datarouter application and client are running on the same machine, use `0.0.0.0:3490`,) +4. If multicast is enabled in the datarouter configuration: + - **Address**: Set the multicast address configured in `log-channels.json` (for example, `239.255.42.99`). +5. Interface Address : Enter the IP address of the network Interface. +5. Start the stream to view incoming DLT log messages. + ## Verification Verify the setup operates correctly by checking: @@ -133,11 +137,12 @@ Verify the setup operates correctly by checking: ### No DLT messages received -- Verify datarouter daemon runs with the `--no_adaptive_runtime` flag -- If using custom config paths, confirm `--config` / `--nv-config` paths are correct +- Verify datarouter daemon runs with `--no_adaptive_runtime` flag - Check UDP port 3490 availability: `netstat -uln | grep 3490` - Confirm loopback interface configuration: `ip addr show lo` - Validate configuration files in `/opt/datarouter/etc/` +- Ensure the datarouter daemon and the DLT client are running before starting the application. + ### Configuration file errors