ngscopeclient 0.1-dev+51fbda87c
DSLabsOscilloscope.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
36#ifndef DSLabsOscilloscope_h
37#define DSLabsOscilloscope_h
38
39#include "RemoteBridgeOscilloscope.h"
40#include "../xptools/HzClock.h"
41
47{
48public:
50 virtual ~DSLabsOscilloscope();
51
52 //not copyable or assignable
53 DSLabsOscilloscope(const DSLabsOscilloscope& rhs) =delete;
54 DSLabsOscilloscope& operator=(const DSLabsOscilloscope& rhs) =delete;
55
56public:
57
58 //Device information
59 virtual unsigned int GetInstrumentTypes() const override;
60 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
61 virtual void FlushConfigCache() override;
62
63 //Channel configuration
64 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) override;
65 virtual double GetChannelAttenuation(size_t i) override;
66 virtual void SetChannelAttenuation(size_t i, double atten) override;
67 virtual unsigned int GetChannelBandwidthLimit(size_t i) override;
68 virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override;
69 virtual OscilloscopeChannel* GetExternalTrigger() override;
70 virtual bool CanEnableChannel(size_t i) override;
71
72 //Triggering
73 virtual Oscilloscope::TriggerMode PollTrigger() override;
74 virtual bool AcquireData() override;
75
76 // Captures
77 virtual void Start() override;
78 virtual void StartSingleTrigger() override;
79 virtual void ForceTrigger() override;
80
81 //Timebase
82 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() override;
83 virtual std::vector<uint64_t> GetSampleRatesInterleaved() override;
84 virtual std::set<InterleaveConflict> GetInterleaveConflicts() override;
85 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() override;
86 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() override;
87 virtual bool IsInterleaving() override;
88 virtual bool SetInterleaving(bool combine) override;
89
90 //ADC configuration
91 virtual std::vector<AnalogBank> GetAnalogBanks() override;
92 virtual AnalogBank GetAnalogBank(size_t channel) override;
93 virtual bool IsADCModeConfigurable() override;
94 virtual std::vector<std::string> GetADCModeNames(size_t channel) override;
95 virtual size_t GetADCMode(size_t channel) override;
96 virtual void SetADCMode(size_t channel, size_t mode) override;
97
99 // Logic analyzer configuration
100
101 virtual std::vector<DigitalBank> GetDigitalBanks() override;
102 virtual DigitalBank GetDigitalBank(size_t channel) override;
103 virtual bool IsDigitalHysteresisConfigurable() override;
104 virtual bool IsDigitalThresholdConfigurable() override;
105 virtual float GetDigitalHysteresis(size_t channel) override;
106 virtual float GetDigitalThreshold(size_t channel) override;
107 virtual void SetDigitalHysteresis(size_t channel, float level) override;
108 virtual void SetDigitalThreshold(size_t channel, float level) override;
109
110 enum Series
111 {
112 DSCOPE_U3P100,
113 DSLOGIC_U3PRO16,
114
115 SERIES_UNKNOWN //unknown or invalid model name
116 };
117
118protected:
119 void IdentifyHardware();
120 void ResetPerCaptureDiagnostics();
121
122 std::string GetChannelColor(size_t i);
123
124 size_t m_analogChannelCount;
125 size_t m_digitalChannelBase;
126 size_t m_digitalChannelCount;
127
128 //Most DSLabs API calls are write only, so we have to maintain all state clientside.
129 //This isn't strictly a cache anymore since it's never flushed!
130 std::map<size_t, double> m_channelAttenuations;
131
132 // Only configurable for the entire device
133 float m_digitalThreshold;
134
135 void SendDataSocket(size_t n, const uint8_t* p);
136 bool ReadDataSocket(size_t n, uint8_t* p);
137
138 Series m_series;
139
140 FilterParameter m_diag_hardwareWFMHz;
141 FilterParameter m_diag_receivedWFMHz;
142 FilterParameter m_diag_totalWFMs;
143 FilterParameter m_diag_droppedWFMs;
144 FilterParameter m_diag_droppedPercent;
145 HzClock m_receiveClock;
146
147public:
148
149 static std::string GetDriverNameInternal();
150 OSCILLOSCOPE_INITPROC(DSLabsOscilloscope);
151};
152
153#endif
DSLabsOscilloscope - driver for talking to the scopehal-dslabs-bridge daemons.
Definition: DSLabsOscilloscope.h:47
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition: DSLabsOscilloscope.cpp:644
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition: DSLabsOscilloscope.cpp:603
virtual void SetDigitalThreshold(size_t channel, float level) override
Gets the threshold for a digital input.
Definition: DSLabsOscilloscope.cpp:741
virtual std::vector< DigitalBank > GetDigitalBanks() override
Gets the digital channel banks for this instrument.
Definition: DSLabsOscilloscope.cpp:703
virtual DigitalBank GetDigitalBank(size_t channel) override
Gets the bank containing a given channel.
Definition: DSLabsOscilloscope.cpp:709
virtual bool IsDigitalThresholdConfigurable() override
Checks if digital input threshold is configurable or fixed.
Definition: DSLabsOscilloscope.cpp:720
virtual bool IsADCModeConfigurable() override
Returns true if the ADC is configurable, false if it can only run in one mode.
Definition: DSLabsOscilloscope.cpp:677
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition: DSLabsOscilloscope.cpp:585
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition: DSLabsOscilloscope.cpp:264
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition: DSLabsOscilloscope.cpp:291
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition: DSLabsOscilloscope.cpp:270
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition: DSLabsOscilloscope.cpp:297
virtual bool AcquireData() override
Pull data from the instrument.
Definition: DSLabsOscilloscope.cpp:304
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition: DSLabsOscilloscope.cpp:656
virtual void SetADCMode(size_t channel, size_t mode) override
Sets the ADC mode for a channel.
Definition: DSLabsOscilloscope.cpp:695
virtual bool CanEnableChannel(size_t i) override
Determines if a channel can be enabled.
Definition: DSLabsOscilloscope.cpp:757
virtual size_t GetADCMode(size_t channel) override
Gets the ADC mode for a channel.
Definition: DSLabsOscilloscope.cpp:690
virtual bool IsDigitalHysteresisConfigurable() override
Checks if digital input hysteresis is configurable or fixed.
Definition: DSLabsOscilloscope.cpp:715
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition: DSLabsOscilloscope.cpp:287
virtual std::vector< AnalogBank > GetAnalogBanks() override
Gets the analog banks for this instrument.
Definition: DSLabsOscilloscope.cpp:664
virtual AnalogBank GetAnalogBank(size_t channel) override
Gets the bank containing a given channel.
Definition: DSLabsOscilloscope.cpp:671
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition: DSLabsOscilloscope.cpp:536
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition: DSLabsOscilloscope.cpp:542
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: DSLabsOscilloscope.cpp:241
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition: DSLabsOscilloscope.cpp:637
std::string GetChannelColor(size_t i)
Get a channel color based on DreamSource's standard color sequence.
Definition: DSLabsOscilloscope.cpp:171
virtual void SetDigitalHysteresis(size_t channel, float level) override
Sets the hysteresis for a digital input.
Definition: DSLabsOscilloscope.cpp:736
virtual void FlushConfigCache() override
Instruments are allowed to cache configuration settings to reduce round trip queries to the device.
Definition: DSLabsOscilloscope.cpp:259
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition: DSLabsOscilloscope.cpp:650
virtual float GetDigitalHysteresis(size_t channel) override
Gets the hysteresis for a digital input.
Definition: DSLabsOscilloscope.cpp:725
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition: DSLabsOscilloscope.cpp:282
virtual float GetDigitalThreshold(size_t channel) override
Gets the threshold for a digital input.
Definition: DSLabsOscilloscope.cpp:730
virtual std::vector< std::string > GetADCModeNames(size_t channel) override
Gets the names of the ADC modes for the bank a given channel is located in.
Definition: DSLabsOscilloscope.cpp:682
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition: DSLabsOscilloscope.cpp:548
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition: DSLabsOscilloscope.cpp:554
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition: DSLabsOscilloscope.cpp:246
DSLabsOscilloscope(SCPITransport *transport)
Initialize the driver.
Definition: DSLabsOscilloscope.cpp:60
A parameter to a filter.
Definition: FilterParameter.h:86
Clock that measures rate at which it is called; windowed average.
Definition: HzClock.h:52
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
TriggerMode
Definition: Oscilloscope.h:411
An oscilloscope connected over a SDK-to-SCPI bridge that follows our pattern (i.e....
Definition: RemoteBridgeOscilloscope.h:40
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47