From 67af9f02dad278613d44a125fbc6c860040d78a4 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sat, 1 Nov 2025 01:11:34 -0400 Subject: [PATCH] DAPSpecs: Update parseRequiredParamAsInt to support all param lists --- include/user/deviceAttachmentSpec.h | 15 ++++++++------- smocore/opts.cpp | 2 +- stimBuffApis/livoxGen1/livoxGen1.cpp | 15 +++++++++------ stimBuffApis/xcbWindow/xcbWindow.cpp | 4 ++-- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/include/user/deviceAttachmentSpec.h b/include/user/deviceAttachmentSpec.h index 5fe2918..be6fb8a 100644 --- a/include/user/deviceAttachmentSpec.h +++ b/include/user/deviceAttachmentSpec.h @@ -81,28 +81,29 @@ public: } /** - * @brief Parse a required integer parameter from provider parameters - * @param spec The device attachment specification + * @brief Parse a required integer parameter from a parameter list + * @param params The parameter vector to search in * @param paramName The name of the parameter to parse * @return The parsed integer value * @throws std::runtime_error if parameter is not found or cannot be parsed */ static int parseRequiredParamAsInt( - const DeviceAttachmentSpec& spec, const std::string& paramName + const std::vector>& params, + const std::string& paramName ) { auto it = std::find_if( - spec.providerParams.begin(), - spec.providerParams.end(), + params.begin(), + params.end(), [¶mName](const auto& param) { return param.first == paramName; } ); - if (it == spec.providerParams.end()) + if (it == params.end()) { throw std::runtime_error( - "No " + paramName + " specified in provider params"); + "No " + paramName + " specified in params"); } try { diff --git a/smocore/opts.cpp b/smocore/opts.cpp index f9f3969..b54c14e 100644 --- a/smocore/opts.cpp +++ b/smocore/opts.cpp @@ -121,7 +121,7 @@ std::string OptionParser::stringifyOptions(void) const oss << "Verbose mode is on" << std::endl; } - oss << "DAP Specs: " << dapSpecs << std::endl; + oss << "Cmdline DAP Specs: " << dapSpecs << std::endl; oss << "DAP Spec Files: "; for (const auto& file : dapSpecFiles) { diff --git a/stimBuffApis/livoxGen1/livoxGen1.cpp b/stimBuffApis/livoxGen1/livoxGen1.cpp index 963ab9e..352a62d 100644 --- a/stimBuffApis/livoxGen1/livoxGen1.cpp +++ b/stimBuffApis/livoxGen1/livoxGen1.cpp @@ -554,31 +554,34 @@ extern "C" void livoxGen1_attachDeviceReq( if (param.first == "handshake-timeout-ms") { handshakeTimeoutMs = smo::device::DeviceAttachmentSpec - ::parseRequiredParamAsInt(*desc, "handshake-timeout-ms"); + ::parseRequiredParamAsInt( + desc->providerParams, "handshake-timeout-ms"); } else if (param.first == "retry-delay-ms") { retryDelayMs = smo::device::DeviceAttachmentSpec - ::parseRequiredParamAsInt(*desc, "retry-delay-ms"); + ::parseRequiredParamAsInt( + desc->providerParams, "retry-delay-ms"); } else if (param.first == "smo-subnet-nbits") { smoSubnetNbits = static_cast( smo::device::DeviceAttachmentSpec - ::parseRequiredParamAsInt(*desc, "smo-subnet-nbits")); + ::parseRequiredParamAsInt( + desc->providerParams, "smo-subnet-nbits")); } else if (param.first == "data-port") { dataPort = static_cast( smo::device::DeviceAttachmentSpec - ::parseRequiredParamAsInt(*desc, "data-port")); + ::parseRequiredParamAsInt(desc->providerParams, "data-port")); } else if (param.first == "cmd-port") { cmdPort = static_cast( smo::device::DeviceAttachmentSpec - ::parseRequiredParamAsInt(*desc, "cmd-port")); + ::parseRequiredParamAsInt(desc->providerParams, "cmd-port")); } else if (param.first == "imu-port") { imuPort = static_cast( smo::device::DeviceAttachmentSpec - ::parseRequiredParamAsInt(*desc, "imu-port")); + ::parseRequiredParamAsInt(desc->providerParams, "imu-port")); } else if (param.first == "smo-ip") { if (param.second.empty()) diff --git a/stimBuffApis/xcbWindow/xcbWindow.cpp b/stimBuffApis/xcbWindow/xcbWindow.cpp index 9aa84a6..ff20bc7 100644 --- a/stimBuffApis/xcbWindow/xcbWindow.cpp +++ b/stimBuffApis/xcbWindow/xcbWindow.cpp @@ -71,9 +71,9 @@ AttachedWindow::AttachedWindow( } windowSelector.display = smo::device::DeviceAttachmentSpec - ::parseRequiredParamAsInt(*spec, "display"); + ::parseRequiredParamAsInt(spec->providerParams, "display"); windowSelector.screen = smo::device::DeviceAttachmentSpec - ::parseRequiredParamAsInt(*spec, "screen"); + ::parseRequiredParamAsInt(spec->providerParams, "screen"); parseWindowSelector(*spec);