From 3ccc96c6785f88e45bdd81e06e0d73b94070b084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hegyi=20L=C3=A1szl=C3=B3?= Date: Sat, 4 Oct 2025 12:58:54 +0200 Subject: [PATCH] SiglentFunctionGenerator: only send updated frequency when it actually needs to be sent, to prevent crashing the device Also: fix cached frequency type --- scopehal/SiglentFunctionGenerator.cpp | 4 ++++ scopehal/SiglentFunctionGenerator.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scopehal/SiglentFunctionGenerator.cpp b/scopehal/SiglentFunctionGenerator.cpp index 765fd30a..b4c85646 100644 --- a/scopehal/SiglentFunctionGenerator.cpp +++ b/scopehal/SiglentFunctionGenerator.cpp @@ -341,6 +341,10 @@ float SiglentFunctionGenerator::GetFunctionChannelFrequency(int chan) void SiglentFunctionGenerator::SetFunctionChannelFrequency(int chan, float hz) { + if(m_cachedFrequencyValid[chan] && std::abs(m_cachedFrequency[chan] - hz) < 1e-6) + { + return; + } m_transport->SendCommandQueued(m_channels[chan]->GetHwname() + ":BSWV FRQ," + to_string(hz)); m_cachedFrequency[chan] = hz; diff --git a/scopehal/SiglentFunctionGenerator.h b/scopehal/SiglentFunctionGenerator.h index 2a8e3d88..e358fdce 100644 --- a/scopehal/SiglentFunctionGenerator.h +++ b/scopehal/SiglentFunctionGenerator.h @@ -88,7 +88,7 @@ class SiglentFunctionGenerator : public virtual SCPIFunctionGenerator //Config cache bool m_cachedFrequencyValid[2]; - int64_t m_cachedFrequency[2]; + float m_cachedFrequency[2]; bool m_cachedEnableStateValid[2]; bool m_cachedOutputEnable[2]; bool m_cachedAmplitudeValid[2];