Skip to content

Commit a50756c

Browse files
committed
ThunderScope: converted to queued command API, refresh reported sample rate when enabling a channel in case we had to lower it server side. Fixes #990.
1 parent 06a24c2 commit a50756c

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

scopehal/ThunderScopeOscilloscope.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ ThunderScopeOscilloscope::ThunderScopeOscilloscope(SCPITransport* transport)
9191
SetChannelVoltageRange(i, 0, 5);
9292
}
9393

94-
//Set initial memory configuration.
95-
SetSampleRate(1000000000L);
96-
SetSampleDepth(10000);
97-
9894
//Set up the data plane socket
9995
auto csock = dynamic_cast<SCPITwinLanTransport*>(m_transport);
10096
if(!csock)
@@ -118,6 +114,10 @@ ThunderScopeOscilloscope::ThunderScopeOscilloscope(SCPITransport* transport)
118114
PushTrigger();
119115
SetTriggerOffset(1000000000); //1us to allow trigphase interpolation
120116

117+
//Set initial memory configuration.
118+
SetSampleRate(1000000000L);
119+
SetSampleDepth(10000);
120+
121121
m_diagnosticValues["Hardware WFM/s"] = &m_diag_hardwareWFMHz;
122122
m_diagnosticValues["Received WFM/s"] = &m_diag_receivedWFMHz;
123123
m_diagnosticValues["Total Waveforms Received"] = &m_diag_totalWFMs;
@@ -233,7 +233,20 @@ string ThunderScopeOscilloscope::GetDriverNameInternal()
233233

234234
void ThunderScopeOscilloscope::FlushConfigCache()
235235
{
236-
lock_guard<recursive_mutex> lock(m_cacheMutex);
236+
//Refresh sample rate from hardware
237+
RefreshSampleRate();
238+
}
239+
240+
void ThunderScopeOscilloscope::RefreshSampleRate()
241+
{
242+
auto reply = m_transport->SendCommandQueuedWithReply("RATE?");
243+
m_srate = stoi(reply);
244+
}
245+
246+
void ThunderScopeOscilloscope::EnableChannel(size_t i)
247+
{
248+
RemoteBridgeOscilloscope::EnableChannel(i);
249+
RefreshSampleRate();
237250
}
238251

239252
double ThunderScopeOscilloscope::GetChannelAttenuation(size_t i)

scopehal/ThunderScopeOscilloscope.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class ThunderScopeOscilloscope : public RemoteBridgeOscilloscope
7272
virtual bool CanEnableChannel(size_t i) override;
7373
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
7474
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override;
75+
virtual void EnableChannel(size_t i) override;
7576

7677
//Triggering
7778
virtual Oscilloscope::TriggerMode PollTrigger() override;
@@ -94,6 +95,7 @@ class ThunderScopeOscilloscope : public RemoteBridgeOscilloscope
9495

9596
protected:
9697
void ResetPerCaptureDiagnostics();
98+
void RefreshSampleRate();
9799

98100
std::string GetChannelColor(size_t i);
99101

0 commit comments

Comments
 (0)