From da795290ec42973ef39268e52de19b94bf5e9d2b Mon Sep 17 00:00:00 2001 From: Adrian Stanea Date: Thu, 15 Feb 2024 16:00:10 +0200 Subject: [PATCH] output_triggers: use output trigger only in newer firmware versions - The output trigger feature is only available in fw version >=0.32, using it in older versions will result in an error. Signed-off-by: Adrian Stanea --- src/m2k_impl.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/m2k_impl.cpp b/src/m2k_impl.cpp index 69f04edd..d86ff319 100644 --- a/src/m2k_impl.cpp +++ b/src/m2k_impl.cpp @@ -26,6 +26,7 @@ #include #include "m2khardwaretrigger_impl.hpp" #include "m2khardwaretrigger_v0.24_impl.hpp" +#include "m2khardwaretrigger_v0.32_impl.hpp" #include "m2kcalibration_impl.hpp" #include #include "utils/channel.hpp" @@ -69,12 +70,23 @@ M2kImpl::M2kImpl(std::string uri, iio_context* ctx, std::string name, bool sync) m_instancesPowerSupply.clear(); m_firmware_version = getFirmwareVersion(); + std::cout << "Firmware version: " << m_firmware_version << std::endl; + - int diff = Utils::compareVersions(m_firmware_version, "v0.24"); - if (diff < 0) { //m_firmware_version < 0.24 + int compare_to_24 = Utils::compareVersions(m_firmware_version, "v0.24"); + int compare_to_32 = Utils::compareVersions(m_firmware_version, "v0.32"); + + std::cout << "Compare to 24: " << compare_to_24 << std::endl; + std::cout << "Compare to 32: " << compare_to_32 << std::endl; + if (compare_to_24 < 0) { //m_firmware_version < 0.24 + std::cout << "Old firmware version, using M2kHardwareTriggerImpl\n"; m_trigger = new M2kHardwareTriggerImpl(ctx); - } else { + } else if ( (compare_to_24 >= 0) && (compare_to_32 < 0)) { + std::cout << "BETWEEN firmware version, using M2kHardwareTriggerV024Impl\n"; m_trigger = new M2kHardwareTriggerV024Impl(ctx); + } else { + std::cout << "NEWER firmware version, using M2kHardwareTriggerV032Impl\n"; + m_trigger = new M2kHardwareTriggerV032Impl(ctx); } if (!m_trigger) {