Skip to content

Commit

Permalink
output_triggers: use output trigger only in newer firmware versions
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
Adrian-Stanea committed Feb 15, 2024
1 parent 2ba3b98 commit da79529
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/m2k_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <digital/m2kdigital_impl.hpp>
#include "m2khardwaretrigger_impl.hpp"
#include "m2khardwaretrigger_v0.24_impl.hpp"
#include "m2khardwaretrigger_v0.32_impl.hpp"
#include "m2kcalibration_impl.hpp"
#include <libm2k/analog/dmm.hpp>
#include "utils/channel.hpp"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit da79529

Please sign in to comment.