Commit e6297cf5fdb8cb298359bc77ba0363d8f93a3f96

Authored by David Graeff
Committed by David Gräff
1 parent 997a01ec

Make software triggering and fixed sample rates feel less hackish

* Add new feature flag "isFixedSamplerateDevice" and a new "fixedSampleRates"
  vector for fixed sample rate devices.
* Add "specialTriggerChannels" to the device specifications and remove it from
  hantekdsocontrol.
* Correct constness mistakes
* Convert BulkCode to enum class. All (uint8_t) conversions need to disappear
  with a second refactoring round, when the command and commandPending field
  will be redone.

Bigger picture:
 - The hantekdsocontrol class should not differentiate on specific model commands.
 - Get rid of the switch in HantekDsoControl::setTriggerSource
 - Unite HantekDsoControl::"command" and "commandPending" by adding a
   pending flag to the new BulkCommand class.
 - Unite HantekDsoControl::"control" and "controlPending" by adding a
   pending flag to the new ControlCommand class.
 - Get rid of HantekDsoControl::"controlCode"
docs/adddevice.md
@@ -53,12 +53,12 @@ The actual commands that are send, need to be defined as well, for instance: @@ -53,12 +53,12 @@ The actual commands that are send, need to be defined as well, for instance:
53 ``` c++ 53 ``` c++
54 specification.command.control.setOffset = CONTROL_SETOFFSET; 54 specification.command.control.setOffset = CONTROL_SETOFFSET;
55 specification.command.control.setRelays = CONTROL_SETRELAYS; 55 specification.command.control.setRelays = CONTROL_SETRELAYS;
56 - specification.command.bulk.setGain = BULK_SETGAIN;  
57 - specification.command.bulk.setRecordLength = BULK_SETTRIGGERANDSAMPLERATE;  
58 - specification.command.bulk.setChannels = BULK_SETTRIGGERANDSAMPLERATE;  
59 - specification.command.bulk.setSamplerate = BULK_SETTRIGGERANDSAMPLERATE;  
60 - specification.command.bulk.setTrigger = BULK_SETTRIGGERANDSAMPLERATE;  
61 - specification.command.bulk.setPretrigger = BULK_SETTRIGGERANDSAMPLERATE; 56 + specification.command.bulk.setGain = BulkCode::SETGAIN;
  57 + specification.command.bulk.setRecordLength = BulkCode::SETTRIGGERANDSAMPLERATE;
  58 + specification.command.bulk.setChannels = BulkCode::SETTRIGGERANDSAMPLERATE;
  59 + specification.command.bulk.setSamplerate = BulkCode::SETTRIGGERANDSAMPLERATE;
  60 + specification.command.bulk.setTrigger = BulkCode::SETTRIGGERANDSAMPLERATE;
  61 + specification.command.bulk.setPretrigger = BulkCode::SETTRIGGERANDSAMPLERATE;
62 ``` 62 ```
63 63
64 64
openhantek/src/docks/TriggerDock.cpp
@@ -23,14 +23,15 @@ @@ -23,14 +23,15 @@
23 /// \param specialTriggers The names of the special trigger sources. 23 /// \param specialTriggers The names of the special trigger sources.
24 /// \param parent The parent widget. 24 /// \param parent The parent widget.
25 /// \param flags Flags for the window manager. 25 /// \param flags Flags for the window manager.
26 -TriggerDock::TriggerDock(DsoSettings *settings, const QStringList *specialTriggers, QWidget *parent, 26 +TriggerDock::TriggerDock(DsoSettings *settings, const std::vector<std::string> &specialTriggers, QWidget *parent,
27 Qt::WindowFlags flags) 27 Qt::WindowFlags flags)
28 : QDockWidget(tr("Trigger"), parent, flags), settings(settings) { 28 : QDockWidget(tr("Trigger"), parent, flags), settings(settings) {
29 29
30 // Initialize lists for comboboxes 30 // Initialize lists for comboboxes
31 for (unsigned int channel = 0; channel < settings->scope.physicalChannels; ++channel) 31 for (unsigned int channel = 0; channel < settings->scope.physicalChannels; ++channel)
32 this->sourceStandardStrings << tr("CH%1").arg(channel + 1); 32 this->sourceStandardStrings << tr("CH%1").arg(channel + 1);
33 - this->sourceSpecialStrings << *specialTriggers; 33 + for(const std::string& name: specialTriggers)
  34 + this->sourceSpecialStrings.append(QString::fromStdString(name));
34 35
35 // Initialize elements 36 // Initialize elements
36 this->modeLabel = new QLabel(tr("Mode")); 37 this->modeLabel = new QLabel(tr("Mode"));
openhantek/src/docks/TriggerDock.h
@@ -19,7 +19,7 @@ class TriggerDock : public QDockWidget { @@ -19,7 +19,7 @@ class TriggerDock : public QDockWidget {
19 Q_OBJECT 19 Q_OBJECT
20 20
21 public: 21 public:
22 - TriggerDock(DsoSettings *settings, const QStringList *specialTriggers, QWidget *parent, Qt::WindowFlags flags = 0); 22 + TriggerDock(DsoSettings *settings, const std::vector<std::string>& specialTriggers, QWidget *parent, Qt::WindowFlags flags = 0);
23 23
24 int setMode(Dso::TriggerMode mode); 24 int setMode(Dso::TriggerMode mode);
25 int setSource(bool special, unsigned int id); 25 int setSource(bool special, unsigned int id);
openhantek/src/hantekdso/controlindexes.h
@@ -8,15 +8,12 @@ namespace Hantek { @@ -8,15 +8,12 @@ namespace Hantek {
8 /// \enum ControlIndex 8 /// \enum ControlIndex
9 /// \brief The array indices for the waiting control commands. 9 /// \brief The array indices for the waiting control commands.
10 enum ControlIndex { 10 enum ControlIndex {
11 - // CONTROLINDEX_VALUE,  
12 - // CONTROLINDEX_GETSPEED,  
13 - // CONTROLINDEX_BEGINCOMMAND,  
14 CONTROLINDEX_SETOFFSET, 11 CONTROLINDEX_SETOFFSET,
15 CONTROLINDEX_SETRELAYS, 12 CONTROLINDEX_SETRELAYS,
16 CONTROLINDEX_SETVOLTDIV_CH1, 13 CONTROLINDEX_SETVOLTDIV_CH1,
17 CONTROLINDEX_SETVOLTDIV_CH2, 14 CONTROLINDEX_SETVOLTDIV_CH2,
18 - CONTROLINDEX_SETTIMEDIV,  
19 - CONTROLINDEX_ACQUIIRE_HARD_DATA, 15 + CONTROLINDEX_SETTIMEDIV, ///< For 6022BL/BE
  16 + CONTROLINDEX_ACQUIIRE_HARD_DATA, ///< For 6022BL/BE
20 CONTROLINDEX_COUNT 17 CONTROLINDEX_COUNT
21 }; 18 };
22 19
openhantek/src/hantekdso/controlsettings.h
@@ -58,6 +58,8 @@ struct ControlSettings { @@ -58,6 +58,8 @@ struct ControlSettings {
58 ControlSettingsTrigger trigger; ///< The trigger settings 58 ControlSettingsTrigger trigger; ///< The trigger settings
59 unsigned recordLengthId = 1; ///< The id in the record length array 59 unsigned recordLengthId = 1; ///< The id in the record length array
60 unsigned usedChannels = 0; ///< Number of activated channels 60 unsigned usedChannels = 0; ///< Number of activated channels
  61 + // Software trigger, margin
  62 + const unsigned swtriggerSampleMargin = 2000;
61 }; 63 };
62 64
63 } 65 }
openhantek/src/hantekdso/controlspecification.h
@@ -10,6 +10,9 @@ @@ -10,6 +10,9 @@
10 10
11 namespace Hantek { 11 namespace Hantek {
12 12
  13 +typedef unsigned RecordLengthID;
  14 +typedef unsigned ChannelID;
  15 +
13 ////////////////////////////////////////////////////////////////////////////// 16 //////////////////////////////////////////////////////////////////////////////
14 /// \struct ControlSpecificationCommandsBulk hantek/control.h 17 /// \struct ControlSpecificationCommandsBulk hantek/control.h
15 /// \brief Stores the bulk command codes used for this device. 18 /// \brief Stores the bulk command codes used for this device.
@@ -29,7 +32,7 @@ struct ControlSpecificationCommandsBulk { @@ -29,7 +32,7 @@ struct ControlSpecificationCommandsBulk {
29 struct ControlSpecificationCommandsControl { 32 struct ControlSpecificationCommandsControl {
30 ControlCode setOffset = (ControlCode)-1; ///< Command for setting offset calibration data 33 ControlCode setOffset = (ControlCode)-1; ///< Command for setting offset calibration data
31 ControlCode setRelays = (ControlCode)-1; ///< Command for setting gain relays (Usually in 34 ControlCode setRelays = (ControlCode)-1; ///< Command for setting gain relays (Usually in
32 - /// combination with BULK_SETGAIN) 35 + /// combination with BulkCode::SETGAIN)
33 }; 36 };
34 37
35 ////////////////////////////////////////////////////////////////////////////// 38 //////////////////////////////////////////////////////////////////////////////
@@ -67,6 +70,23 @@ struct ControlSpecificationSamplerate { @@ -67,6 +70,23 @@ struct ControlSpecificationSamplerate {
67 ControlSamplerateLimits multi = {100e6, 100e6, 0, std::vector<unsigned>()}; ///< The limits for multi channel mode 70 ControlSamplerateLimits multi = {100e6, 100e6, 0, std::vector<unsigned>()}; ///< The limits for multi channel mode
68 }; 71 };
69 72
  73 +struct ControlSpecificationGainLevel {
  74 + /// The index of the selected gain on the hardware
  75 + unsigned char gainIndex;
  76 + /// Available voltage steps in V/screenheight
  77 + double gainSteps;
  78 +};
  79 +
  80 +struct FixedSampleRate {
  81 + unsigned char id;
  82 + double samplerate;
  83 +};
  84 +
  85 +struct SpecialTriggerChannel {
  86 + std::string name;
  87 + int hardwareID;
  88 +};
  89 +
70 ////////////////////////////////////////////////////////////////////////////// 90 //////////////////////////////////////////////////////////////////////////////
71 /// \struct ControlSpecification hantek/control.h 91 /// \struct ControlSpecification hantek/control.h
72 /// \brief Stores the specifications of the currently connected device. 92 /// \brief Stores the specifications of the currently connected device.
@@ -76,22 +96,24 @@ struct ControlSpecification { @@ -76,22 +96,24 @@ struct ControlSpecification {
76 96
77 // Limits 97 // Limits
78 ControlSpecificationSamplerate samplerate; ///< The samplerate specifications 98 ControlSpecificationSamplerate samplerate; ///< The samplerate specifications
79 - std::vector<unsigned int> bufferDividers; ///< Samplerate dividers for record lengths  
80 - std::vector<double> gainSteps; ///< Available voltage steps in V/screenheight 99 + std::vector<RecordLengthID> bufferDividers; ///< Samplerate dividers for record lengths
81 unsigned char sampleSize; ///< Number of bits per sample 100 unsigned char sampleSize; ///< Number of bits per sample
82 101
83 // Calibration 102 // Calibration
84 /// The sample values at the top of the screen 103 /// The sample values at the top of the screen
85 std::vector<unsigned short> voltageLimit[HANTEK_CHANNELS]; 104 std::vector<unsigned short> voltageLimit[HANTEK_CHANNELS];
86 - /// The index of the selected gain on the hardware  
87 - std::vector<unsigned char> gainIndex;  
88 - std::vector<unsigned char> gainDiv;  
89 - std::vector<double> sampleSteps; ///< Available samplerate steps in s  
90 - std::vector<unsigned char> sampleDiv;  
91 -  
92 /// Calibration data for the channel offsets 105 /// Calibration data for the channel offsets
93 OffsetsPerGainStep offsetLimit[HANTEK_CHANNELS]; 106 OffsetsPerGainStep offsetLimit[HANTEK_CHANNELS];
94 107
  108 + /// Gain levels
  109 + std::vector<ControlSpecificationGainLevel> gain;
  110 +
  111 + /// For devices that support only fixed sample rates (isFixedSamplerateDevice=true)
  112 + std::vector<FixedSampleRate> fixedSampleRates;
  113 +
  114 + std::vector<SpecialTriggerChannel> specialTriggerChannels;
  115 +
  116 + bool isFixedSamplerateDevice = false;
95 bool isSoftwareTriggerDevice = false; 117 bool isSoftwareTriggerDevice = false;
96 bool useControlNoBulk = false; 118 bool useControlNoBulk = false;
97 bool supportsCaptureState = true; 119 bool supportsCaptureState = true;
openhantek/src/hantekdso/hantekdsocontrol.cpp
@@ -32,10 +32,10 @@ void HantekDsoControl::startSampling() { @@ -32,10 +32,10 @@ void HantekDsoControl::startSampling() {
32 if (!isRollMode()) emit recordTimeChanged((double)getRecordLength() / controlsettings.samplerate.current); 32 if (!isRollMode()) emit recordTimeChanged((double)getRecordLength() / controlsettings.samplerate.current);
33 emit samplerateChanged(controlsettings.samplerate.current); 33 emit samplerateChanged(controlsettings.samplerate.current);
34 34
35 - if (specification.isSoftwareTriggerDevice) { 35 + if (specification.isFixedSamplerateDevice) {
36 // Convert to GUI presentable values (1e5 -> 1.0, 48e6 -> 480.0 etc) 36 // Convert to GUI presentable values (1e5 -> 1.0, 48e6 -> 480.0 etc)
37 QList<double> sampleSteps; 37 QList<double> sampleSteps;
38 - for (double v : specification.sampleSteps) { sampleSteps << v / 1e5; } 38 + for (auto& v : specification.fixedSampleRates) { sampleSteps << v.samplerate / 1e5; }
39 emit samplerateSet(1, sampleSteps); 39 emit samplerateSet(1, sampleSteps);
40 } 40 }
41 41
@@ -48,7 +48,14 @@ void HantekDsoControl::stopSampling() { @@ -48,7 +48,14 @@ void HantekDsoControl::stopSampling() {
48 emit samplingStopped(); 48 emit samplingStopped();
49 } 49 }
50 50
51 -const QStringList *HantekDsoControl::getSpecialTriggerSources() { return &(specialTriggerSources); } 51 +const std::vector<std::string> HantekDsoControl::getSpecialTriggerSources()
  52 +{
  53 + std::vector<std::string> sources;
  54 + for (auto& v: specification.specialTriggerChannels) {
  55 + sources.push_back(v.name);
  56 + }
  57 + return sources;
  58 +}
52 59
53 USBDevice *HantekDsoControl::getDevice() { return device; } 60 USBDevice *HantekDsoControl::getDevice() { return device; }
54 61
@@ -65,12 +72,12 @@ HantekDsoControl::HantekDsoControl(USBDevice *device) : device(device), @@ -65,12 +72,12 @@ HantekDsoControl::HantekDsoControl(USBDevice *device) : device(device),
65 this->controlCode[CONTROLINDEX_SETRELAYS] = CONTROL_SETRELAYS; 72 this->controlCode[CONTROLINDEX_SETRELAYS] = CONTROL_SETRELAYS;
66 73
67 // Instantiate the commands needed for all models 74 // Instantiate the commands needed for all models
68 - command[BULK_FORCETRIGGER] = new BulkForceTrigger();  
69 - command[BULK_STARTSAMPLING] = new BulkCaptureStart();  
70 - command[BULK_ENABLETRIGGER] = new BulkTriggerEnabled();  
71 - command[BULK_GETDATA] = new BulkGetData();  
72 - command[BULK_GETCAPTURESTATE] = new BulkGetCaptureState();  
73 - command[BULK_SETGAIN] = new BulkSetGain(); 75 + command[(uint8_t)BulkCode::FORCETRIGGER] = new BulkForceTrigger();
  76 + command[(uint8_t)BulkCode::STARTSAMPLING] = new BulkCaptureStart();
  77 + command[(uint8_t)BulkCode::ENABLETRIGGER] = new BulkTriggerEnabled();
  78 + command[(uint8_t)BulkCode::GETDATA] = new BulkGetData();
  79 + command[(uint8_t)BulkCode::GETCAPTURESTATE] = new BulkGetCaptureState();
  80 + command[(uint8_t)BulkCode::SETGAIN] = new BulkSetGain();
74 81
75 if (specification.useControlNoBulk) 82 if (specification.useControlNoBulk)
76 device->setEnableBulkTransfer(false); 83 device->setEnableBulkTransfer(false);
@@ -82,7 +89,7 @@ HantekDsoControl::HantekDsoControl(USBDevice *device) : device(device), @@ -82,7 +89,7 @@ HantekDsoControl::HantekDsoControl(USBDevice *device) : device(device),
82 } 89 }
83 90
84 HantekDsoControl::~HantekDsoControl() { 91 HantekDsoControl::~HantekDsoControl() {
85 - for (int cIndex = 0; cIndex < BULK_COUNT; ++cIndex) { delete command[cIndex]; } 92 + for (int cIndex = 0; cIndex < (uint8_t)BulkCode::COUNT; ++cIndex) { delete command[cIndex]; }
86 for (int cIndex = 0; cIndex < CONTROLINDEX_COUNT; ++cIndex) { delete control[cIndex]; } 93 for (int cIndex = 0; cIndex < CONTROLINDEX_COUNT; ++cIndex) { delete control[cIndex]; }
87 } 94 }
88 95
@@ -157,7 +164,7 @@ std::pair&lt;int, unsigned&gt; HantekDsoControl::getCaptureState() const { @@ -157,7 +164,7 @@ std::pair&lt;int, unsigned&gt; HantekDsoControl::getCaptureState() const {
157 164
158 if (!specification.supportsCaptureState) return std::make_pair(CAPTURE_READY, 0); 165 if (!specification.supportsCaptureState) return std::make_pair(CAPTURE_READY, 0);
159 166
160 - errorCode = device->bulkCommand(command[BULK_GETCAPTURESTATE], 1); 167 + errorCode = device->bulkCommand(command[(uint8_t)BulkCode::GETCAPTURESTATE], 1);
161 if (errorCode < 0) { 168 if (errorCode < 0) {
162 qWarning() << "Getting capture state failed: " << libUsbErrorString(errorCode); 169 qWarning() << "Getting capture state failed: " << libUsbErrorString(errorCode);
163 return std::make_pair(CAPTURE_ERROR, 0); 170 return std::make_pair(CAPTURE_ERROR, 0);
@@ -176,7 +183,7 @@ std::pair&lt;int, unsigned&gt; HantekDsoControl::getCaptureState() const { @@ -176,7 +183,7 @@ std::pair&lt;int, unsigned&gt; HantekDsoControl::getCaptureState() const {
176 std::vector<unsigned char> HantekDsoControl::getSamples(unsigned &previousSampleCount) const { 183 std::vector<unsigned char> HantekDsoControl::getSamples(unsigned &previousSampleCount) const {
177 if (!specification.useControlNoBulk) { 184 if (!specification.useControlNoBulk) {
178 // Request data 185 // Request data
179 - int errorCode = device->bulkCommand(command[BULK_GETDATA], 1); 186 + int errorCode = device->bulkCommand(command[(uint8_t)BulkCode::GETDATA], 1);
180 if (errorCode < 0) { 187 if (errorCode < 0) {
181 qWarning() << "Getting sample data failed: " << libUsbErrorString(errorCode); 188 qWarning() << "Getting sample data failed: " << libUsbErrorString(errorCode);
182 emit communicationError(); 189 emit communicationError();
@@ -242,7 +249,7 @@ void HantekDsoControl::convertRawDataToSamples(const std::vector&lt;unsigned char&gt; @@ -242,7 +249,7 @@ void HantekDsoControl::convertRawDataToSamples(const std::vector&lt;unsigned char&gt;
242 const unsigned gainID = controlsettings.voltage[channel].gain; 249 const unsigned gainID = controlsettings.voltage[channel].gain;
243 const unsigned short limit = specification.voltageLimit[channel][gainID]; 250 const unsigned short limit = specification.voltageLimit[channel][gainID];
244 const double offset = controlsettings.voltage[channel].offsetReal; 251 const double offset = controlsettings.voltage[channel].offsetReal;
245 - const double gainStep = specification.gainSteps[gainID]; 252 + const double gainStep = specification.gain[gainID].gainSteps;
246 253
247 // Convert data from the oscilloscope and write it into the sample buffer 254 // Convert data from the oscilloscope and write it into the sample buffer
248 unsigned bufferPosition = controlsettings.trigger.point * 2; 255 unsigned bufferPosition = controlsettings.trigger.point * 2;
@@ -275,7 +282,7 @@ void HantekDsoControl::convertRawDataToSamples(const std::vector&lt;unsigned char&gt; @@ -275,7 +282,7 @@ void HantekDsoControl::convertRawDataToSamples(const std::vector&lt;unsigned char&gt;
275 const unsigned gainID = controlsettings.voltage[channel].gain; 282 const unsigned gainID = controlsettings.voltage[channel].gain;
276 const unsigned short limit = specification.voltageLimit[channel][gainID]; 283 const unsigned short limit = specification.voltageLimit[channel][gainID];
277 const double offset = controlsettings.voltage[channel].offsetReal; 284 const double offset = controlsettings.voltage[channel].offsetReal;
278 - const double gainStep = specification.gainSteps[gainID]; 285 + const double gainStep = specification.gain[gainID].gainSteps;
279 286
280 // Convert data from the oscilloscope and write it into the sample buffer 287 // Convert data from the oscilloscope and write it into the sample buffer
281 unsigned bufferPosition = controlsettings.trigger.point * 2; 288 unsigned bufferPosition = controlsettings.trigger.point * 2;
@@ -344,7 +351,7 @@ double HantekDsoControl::getBestSamplerate(double samplerate, bool fastRate, boo @@ -344,7 +351,7 @@ double HantekDsoControl::getBestSamplerate(double samplerate, bool fastRate, boo
344 bestSamplerate = limits->max / specification.bufferDividers[controlsettings.recordLengthId]; 351 bestSamplerate = limits->max / specification.bufferDividers[controlsettings.recordLengthId];
345 } else { 352 } else {
346 switch (specification.command.bulk.setSamplerate) { 353 switch (specification.command.bulk.setSamplerate) {
347 - case BULK_SETTRIGGERANDSAMPLERATE: 354 + case BulkCode::SETTRIGGERANDSAMPLERATE:
348 // DSO-2090 supports the downsampling factors 1, 2, 4 and 5 using 355 // DSO-2090 supports the downsampling factors 1, 2, 4 and 5 using
349 // valueFast or all even values above using valueSlow 356 // valueFast or all even values above using valueSlow
350 if ((maximum && bestDownsampler <= 5.0) || (!maximum && bestDownsampler < 6.0)) { 357 if ((maximum && bestDownsampler <= 5.0) || (!maximum && bestDownsampler < 6.0)) {
@@ -372,7 +379,7 @@ double HantekDsoControl::getBestSamplerate(double samplerate, bool fastRate, boo @@ -372,7 +379,7 @@ double HantekDsoControl::getBestSamplerate(double samplerate, bool fastRate, boo
372 } 379 }
373 break; 380 break;
374 381
375 - case BULK_CSETTRIGGERORSAMPLERATE: 382 + case BulkCode::CSETTRIGGERORSAMPLERATE:
376 // DSO-5200 may not supports all downsampling factors, requires testing 383 // DSO-5200 may not supports all downsampling factors, requires testing
377 if (maximum) { 384 if (maximum) {
378 bestDownsampler = ceil(bestDownsampler); // Round up to next integer value 385 bestDownsampler = ceil(bestDownsampler); // Round up to next integer value
@@ -381,7 +388,7 @@ double HantekDsoControl::getBestSamplerate(double samplerate, bool fastRate, boo @@ -381,7 +388,7 @@ double HantekDsoControl::getBestSamplerate(double samplerate, bool fastRate, boo
381 } 388 }
382 break; 389 break;
383 390
384 - case BULK_ESETTRIGGERORSAMPLERATE: 391 + case BulkCode::ESETTRIGGERORSAMPLERATE:
385 // DSO-2250 doesn't have a fast value, so it supports all downsampling 392 // DSO-2250 doesn't have a fast value, so it supports all downsampling
386 // factors 393 // factors
387 if (maximum) { 394 if (maximum) {
@@ -421,30 +428,30 @@ unsigned HantekDsoControl::updateRecordLength(unsigned index) { @@ -421,30 +428,30 @@ unsigned HantekDsoControl::updateRecordLength(unsigned index) {
421 if (index >= (unsigned)controlsettings.samplerate.limits->recordLengths.size()) return 0; 428 if (index >= (unsigned)controlsettings.samplerate.limits->recordLengths.size()) return 0;
422 429
423 switch (specification.command.bulk.setRecordLength) { 430 switch (specification.command.bulk.setRecordLength) {
424 - case BULK_SETTRIGGERANDSAMPLERATE: 431 + case BulkCode::SETTRIGGERANDSAMPLERATE:
425 // SetTriggerAndSamplerate bulk command for record length 432 // SetTriggerAndSamplerate bulk command for record length
426 - static_cast<BulkSetTriggerAndSamplerate *>(command[BULK_SETTRIGGERANDSAMPLERATE])->setRecordLength(index);  
427 - commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 433 + static_cast<BulkSetTriggerAndSamplerate *>(command[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE])->setRecordLength(index);
  434 + commandPending[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = true;
428 435
429 break; 436 break;
430 437
431 - case BULK_DSETBUFFER:  
432 - if (specification.command.bulk.setPretrigger == BULK_FSETBUFFER) { 438 + case BulkCode::DSETBUFFER:
  439 + if (specification.command.bulk.setPretrigger == BulkCode::FSETBUFFER) {
433 // Pointers to needed commands 440 // Pointers to needed commands
434 BulkSetRecordLength2250 *commandSetRecordLength2250 = 441 BulkSetRecordLength2250 *commandSetRecordLength2250 =
435 - static_cast<BulkSetRecordLength2250 *>(command[BULK_DSETBUFFER]); 442 + static_cast<BulkSetRecordLength2250 *>(command[(uint8_t)BulkCode::DSETBUFFER]);
436 443
437 commandSetRecordLength2250->setRecordLength(index); 444 commandSetRecordLength2250->setRecordLength(index);
438 } else { 445 } else {
439 // SetBuffer5200 bulk command for record length 446 // SetBuffer5200 bulk command for record length
440 - BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(command[BULK_DSETBUFFER]); 447 + BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(command[(uint8_t)BulkCode::DSETBUFFER]);
441 448
442 commandSetBuffer5200->setUsedPre(DTriggerPositionUsed::DTRIGGERPOSITION_ON); 449 commandSetBuffer5200->setUsedPre(DTriggerPositionUsed::DTRIGGERPOSITION_ON);
443 commandSetBuffer5200->setUsedPost(DTriggerPositionUsed::DTRIGGERPOSITION_ON); 450 commandSetBuffer5200->setUsedPost(DTriggerPositionUsed::DTRIGGERPOSITION_ON);
444 commandSetBuffer5200->setRecordLength(index); 451 commandSetBuffer5200->setRecordLength(index);
445 } 452 }
446 453
447 - commandPending[BULK_DSETBUFFER] = true; 454 + commandPending[(uint8_t)BulkCode::DSETBUFFER] = true;
448 455
449 break; 456 break;
450 457
@@ -475,7 +482,7 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate) @@ -475,7 +482,7 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate)
475 482
476 // Set the calculated samplerate 483 // Set the calculated samplerate
477 switch (specification.command.bulk.setSamplerate) { 484 switch (specification.command.bulk.setSamplerate) {
478 - case BULK_SETTRIGGERANDSAMPLERATE: { 485 + case BulkCode::SETTRIGGERANDSAMPLERATE: {
479 short int downsamplerValue = 0; 486 short int downsamplerValue = 0;
480 unsigned char samplerateId = 0; 487 unsigned char samplerateId = 0;
481 bool downsampling = false; 488 bool downsampling = false;
@@ -501,7 +508,7 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate) @@ -501,7 +508,7 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate)
501 508
502 // Pointers to needed commands 509 // Pointers to needed commands
503 BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = 510 BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate =
504 - static_cast<BulkSetTriggerAndSamplerate *>(command[BULK_SETTRIGGERANDSAMPLERATE]); 511 + static_cast<BulkSetTriggerAndSamplerate *>(command[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE]);
505 512
506 // Store if samplerate ID or downsampling factor is used 513 // Store if samplerate ID or downsampling factor is used
507 commandSetTriggerAndSamplerate->setDownsamplingMode(downsampling); 514 commandSetTriggerAndSamplerate->setDownsamplingMode(downsampling);
@@ -512,11 +519,11 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate) @@ -512,11 +519,11 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate)
512 // Set fast rate when used 519 // Set fast rate when used
513 commandSetTriggerAndSamplerate->setFastRate(false /*fastRate*/); 520 commandSetTriggerAndSamplerate->setFastRate(false /*fastRate*/);
514 521
515 - commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 522 + commandPending[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = true;
516 523
517 break; 524 break;
518 } 525 }
519 - case BULK_CSETTRIGGERORSAMPLERATE: { 526 + case BulkCode::CSETTRIGGERORSAMPLERATE: {
520 // Split the resulting divider into the values understood by the device 527 // Split the resulting divider into the values understood by the device
521 // The fast value is kept at 4 (or 3) for slow sample rates 528 // The fast value is kept at 4 (or 3) for slow sample rates
522 long int valueSlow = qMax(((long int)downsampler - 3) / 2, (long int)0); 529 long int valueSlow = qMax(((long int)downsampler - 3) / 2, (long int)0);
@@ -524,9 +531,9 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate) @@ -524,9 +531,9 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate)
524 531
525 // Pointers to needed commands 532 // Pointers to needed commands
526 BulkSetSamplerate5200 *commandSetSamplerate5200 = 533 BulkSetSamplerate5200 *commandSetSamplerate5200 =
527 - static_cast<BulkSetSamplerate5200 *>(command[BULK_CSETTRIGGERORSAMPLERATE]); 534 + static_cast<BulkSetSamplerate5200 *>(command[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE]);
528 BulkSetTrigger5200 *commandSetTrigger5200 = 535 BulkSetTrigger5200 *commandSetTrigger5200 =
529 - static_cast<BulkSetTrigger5200 *>(command[BULK_ESETTRIGGERORSAMPLERATE]); 536 + static_cast<BulkSetTrigger5200 *>(command[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE]);
530 537
531 // Store samplerate fast value 538 // Store samplerate fast value
532 commandSetSamplerate5200->setSamplerateFast(4 - valueFast); 539 commandSetSamplerate5200->setSamplerateFast(4 - valueFast);
@@ -535,15 +542,15 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate) @@ -535,15 +542,15 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate)
535 // Set fast rate when used 542 // Set fast rate when used
536 commandSetTrigger5200->setFastRate(fastRate); 543 commandSetTrigger5200->setFastRate(fastRate);
537 544
538 - commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true;  
539 - commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; 545 + commandPending[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE] = true;
  546 + commandPending[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = true;
540 547
541 break; 548 break;
542 } 549 }
543 - case BULK_ESETTRIGGERORSAMPLERATE: { 550 + case BulkCode::ESETTRIGGERORSAMPLERATE: {
544 // Pointers to needed commands 551 // Pointers to needed commands
545 BulkSetSamplerate2250 *commandSetSamplerate2250 = 552 BulkSetSamplerate2250 *commandSetSamplerate2250 =
546 - static_cast<BulkSetSamplerate2250 *>(command[BULK_ESETTRIGGERORSAMPLERATE]); 553 + static_cast<BulkSetSamplerate2250 *>(command[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE]);
547 554
548 bool downsampling = downsampler >= 1; 555 bool downsampling = downsampler >= 1;
549 // Store downsampler state value 556 // Store downsampler state value
@@ -553,7 +560,7 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate) @@ -553,7 +560,7 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate)
553 // Set fast rate when used 560 // Set fast rate when used
554 commandSetSamplerate2250->setFastRate(fastRate); 561 commandSetSamplerate2250->setFastRate(fastRate);
555 562
556 - commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; 563 + commandPending[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = true;
557 564
558 break; 565 break;
559 } 566 }
@@ -655,19 +662,17 @@ Dso::ErrorCode HantekDsoControl::setSamplerate(double samplerate) { @@ -655,19 +662,17 @@ Dso::ErrorCode HantekDsoControl::setSamplerate(double samplerate) {
655 } 662 }
656 } else { 663 } else {
657 unsigned sampleId; 664 unsigned sampleId;
658 - for (sampleId = 0; sampleId < specification.sampleSteps.size() - 1; ++sampleId)  
659 - if (specification.sampleSteps[sampleId] == samplerate) break; 665 + for (sampleId = 0; sampleId < specification.fixedSampleRates.size() - 1; ++sampleId)
  666 + if (specification.fixedSampleRates[sampleId].samplerate == samplerate) break;
660 this->controlCode[CONTROLINDEX_SETTIMEDIV] = CONTROL_SETTIMEDIV; 667 this->controlCode[CONTROLINDEX_SETTIMEDIV] = CONTROL_SETTIMEDIV;
661 static_cast<ControlSetTimeDIV *>(this->control[CONTROLINDEX_SETTIMEDIV]) 668 static_cast<ControlSetTimeDIV *>(this->control[CONTROLINDEX_SETTIMEDIV])
662 - ->setDiv(specification.sampleDiv[sampleId]); 669 + ->setDiv(specification.fixedSampleRates[sampleId].id);
663 this->controlPending[CONTROLINDEX_SETTIMEDIV] = true; 670 this->controlPending[CONTROLINDEX_SETTIMEDIV] = true;
664 controlsettings.samplerate.current = samplerate; 671 controlsettings.samplerate.current = samplerate;
665 672
666 - // Provide margin for SW trigger  
667 - unsigned sampleMargin = 2000;  
668 // Check for Roll mode 673 // Check for Roll mode
669 if (!isRollMode()) 674 if (!isRollMode())
670 - emit recordTimeChanged((double)(getRecordLength() - sampleMargin) / controlsettings.samplerate.current); 675 + emit recordTimeChanged((double)(getRecordLength() - controlsettings.swtriggerSampleMargin) / controlsettings.samplerate.current);
671 emit samplerateChanged(controlsettings.samplerate.current); 676 emit samplerateChanged(controlsettings.samplerate.current);
672 677
673 return Dso::ErrorCode::NONE; 678 return Dso::ErrorCode::NONE;
@@ -688,7 +693,7 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) { @@ -688,7 +693,7 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) {
688 controlsettings.samplerate.target.samplerateSet = false; 693 controlsettings.samplerate.target.samplerateSet = false;
689 } 694 }
690 695
691 - if (!specification.isSoftwareTriggerDevice) { 696 + if (!specification.isFixedSamplerateDevice) {
692 // Calculate the maximum samplerate that would still provide the requested 697 // Calculate the maximum samplerate that would still provide the requested
693 // duration 698 // duration
694 double maxSamplerate = 699 double maxSamplerate =
@@ -714,21 +719,18 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) { @@ -714,21 +719,18 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) {
714 // supported 719 // supported
715 // Find highest samplerate using less than 10240 samples to obtain our 720 // Find highest samplerate using less than 10240 samples to obtain our
716 // duration. 721 // duration.
717 - // Better add some margin for our SW trigger  
718 - unsigned sampleMargin = 2000;  
719 unsigned sampleCount = 10240; 722 unsigned sampleCount = 10240;
720 - unsigned bestId = 0;  
721 unsigned sampleId; 723 unsigned sampleId;
722 - for (sampleId = 0; sampleId < specification.sampleSteps.size(); ++sampleId) {  
723 - if (specification.sampleSteps[sampleId] * duration < (sampleCount - sampleMargin)) bestId = sampleId; 724 + for (sampleId = 0; sampleId < specification.fixedSampleRates.size(); ++sampleId) {
  725 + if (specification.fixedSampleRates[sampleId].samplerate * duration <
  726 + (sampleCount - controlsettings.swtriggerSampleMargin))break;
724 } 727 }
725 - sampleId = bestId;  
726 // Usable sample value 728 // Usable sample value
727 this->controlCode[CONTROLINDEX_SETTIMEDIV] = CONTROL_SETTIMEDIV; 729 this->controlCode[CONTROLINDEX_SETTIMEDIV] = CONTROL_SETTIMEDIV;
728 static_cast<ControlSetTimeDIV *>(this->control[CONTROLINDEX_SETTIMEDIV]) 730 static_cast<ControlSetTimeDIV *>(this->control[CONTROLINDEX_SETTIMEDIV])
729 - ->setDiv(specification.sampleDiv[sampleId]); 731 + ->setDiv(specification.fixedSampleRates[sampleId].id);
730 this->controlPending[CONTROLINDEX_SETTIMEDIV] = true; 732 this->controlPending[CONTROLINDEX_SETTIMEDIV] = true;
731 - controlsettings.samplerate.current = specification.sampleSteps[sampleId]; 733 + controlsettings.samplerate.current = specification.fixedSampleRates[sampleId].samplerate;
732 734
733 emit samplerateChanged(controlsettings.samplerate.current); 735 emit samplerateChanged(controlsettings.samplerate.current);
734 return Dso::ErrorCode::NONE; 736 return Dso::ErrorCode::NONE;
@@ -759,7 +761,7 @@ Dso::ErrorCode HantekDsoControl::setChannelUsed(unsigned channel, bool used) { @@ -759,7 +761,7 @@ Dso::ErrorCode HantekDsoControl::setChannelUsed(unsigned channel, bool used) {
759 usedChannels = UsedChannels::USED_CH1CH2; 761 usedChannels = UsedChannels::USED_CH1CH2;
760 } else { 762 } else {
761 // DSO-2250 uses a different value for channel 2 763 // DSO-2250 uses a different value for channel 2
762 - if (specification.command.bulk.setChannels == BULK_BSETCHANNELS) 764 + if (specification.command.bulk.setChannels == BulkCode::BSETCHANNELS)
763 usedChannels = UsedChannels::BUSED_CH2; 765 usedChannels = UsedChannels::BUSED_CH2;
764 else 766 else
765 usedChannels = UsedChannels::USED_CH2; 767 usedChannels = UsedChannels::USED_CH2;
@@ -767,24 +769,24 @@ Dso::ErrorCode HantekDsoControl::setChannelUsed(unsigned channel, bool used) { @@ -767,24 +769,24 @@ Dso::ErrorCode HantekDsoControl::setChannelUsed(unsigned channel, bool used) {
767 } 769 }
768 770
769 switch (specification.command.bulk.setChannels) { 771 switch (specification.command.bulk.setChannels) {
770 - case BULK_SETTRIGGERANDSAMPLERATE: { 772 + case BulkCode::SETTRIGGERANDSAMPLERATE: {
771 // SetTriggerAndSamplerate bulk command for trigger source 773 // SetTriggerAndSamplerate bulk command for trigger source
772 - static_cast<BulkSetTriggerAndSamplerate *>(command[BULK_SETTRIGGERANDSAMPLERATE]) 774 + static_cast<BulkSetTriggerAndSamplerate *>(command[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE])
773 ->setUsedChannels((uint8_t)usedChannels); 775 ->setUsedChannels((uint8_t)usedChannels);
774 - commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 776 + commandPending[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = true;
775 break; 777 break;
776 } 778 }
777 - case BULK_BSETCHANNELS: { 779 + case BulkCode::BSETCHANNELS: {
778 // SetChannels2250 bulk command for active channels 780 // SetChannels2250 bulk command for active channels
779 - static_cast<BulkSetChannels2250 *>(command[BULK_BSETCHANNELS])->setUsedChannels((uint8_t)usedChannels);  
780 - commandPending[BULK_BSETCHANNELS] = true; 781 + static_cast<BulkSetChannels2250 *>(command[(uint8_t)BulkCode::BSETCHANNELS])->setUsedChannels((uint8_t)usedChannels);
  782 + commandPending[(uint8_t)BulkCode::BSETCHANNELS] = true;
781 783
782 break; 784 break;
783 } 785 }
784 - case BULK_ESETTRIGGERORSAMPLERATE: { 786 + case BulkCode::ESETTRIGGERORSAMPLERATE: {
785 // SetTrigger5200s bulk command for trigger source 787 // SetTrigger5200s bulk command for trigger source
786 - static_cast<BulkSetTrigger5200 *>(command[BULK_ESETTRIGGERORSAMPLERATE])->setUsedChannels((uint8_t)usedChannels);  
787 - commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; 788 + static_cast<BulkSetTrigger5200 *>(command[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE])->setUsedChannels((uint8_t)usedChannels);
  789 + commandPending[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = true;
788 break; 790 break;
789 } 791 }
790 default: 792 default:
@@ -830,34 +832,34 @@ Dso::ErrorCode HantekDsoControl::setGain(unsigned channel, double gain) { @@ -830,34 +832,34 @@ Dso::ErrorCode HantekDsoControl::setGain(unsigned channel, double gain) {
830 if (channel >= HANTEK_CHANNELS) return Dso::ErrorCode::PARAMETER; 832 if (channel >= HANTEK_CHANNELS) return Dso::ErrorCode::PARAMETER;
831 833
832 // Find lowest gain voltage thats at least as high as the requested 834 // Find lowest gain voltage thats at least as high as the requested
833 - unsigned gainId;  
834 - for (gainId = 0; gainId < specification.gainSteps.size() - 1; ++gainId)  
835 - if (specification.gainSteps[gainId] >= gain) break; 835 + unsigned gainID;
  836 + for (gainID = 0; gainID < specification.gain.size() - 1; ++gainID)
  837 + if (specification.gain[gainID].gainSteps >= gain) break;
836 838
837 if (specification.useControlNoBulk) { 839 if (specification.useControlNoBulk) {
838 if (channel == 0) { 840 if (channel == 0) {
839 static_cast<ControlSetVoltDIV_CH1 *>(this->control[CONTROLINDEX_SETVOLTDIV_CH1]) 841 static_cast<ControlSetVoltDIV_CH1 *>(this->control[CONTROLINDEX_SETVOLTDIV_CH1])
840 - ->setDiv(specification.gainDiv[gainId]); 842 + ->setDiv(specification.gain[gainID].gainIndex);
841 this->controlPending[CONTROLINDEX_SETVOLTDIV_CH1] = true; 843 this->controlPending[CONTROLINDEX_SETVOLTDIV_CH1] = true;
842 } else if (channel == 1) { 844 } else if (channel == 1) {
843 static_cast<ControlSetVoltDIV_CH2 *>(this->control[CONTROLINDEX_SETVOLTDIV_CH2]) 845 static_cast<ControlSetVoltDIV_CH2 *>(this->control[CONTROLINDEX_SETVOLTDIV_CH2])
844 - ->setDiv(specification.gainDiv[gainId]); 846 + ->setDiv(specification.gain[gainID].gainIndex);
845 this->controlPending[CONTROLINDEX_SETVOLTDIV_CH2] = true; 847 this->controlPending[CONTROLINDEX_SETVOLTDIV_CH2] = true;
846 } else 848 } else
847 qDebug("%s: Unsuported channel: %i\n", __func__, channel); 849 qDebug("%s: Unsuported channel: %i\n", __func__, channel);
848 } else { 850 } else {
849 // SetGain bulk command for gain 851 // SetGain bulk command for gain
850 - static_cast<BulkSetGain *>(command[BULK_SETGAIN])->setGain(channel, specification.gainIndex[gainId]);  
851 - commandPending[BULK_SETGAIN] = true; 852 + static_cast<BulkSetGain *>(command[(uint8_t)BulkCode::SETGAIN])->setGain(channel, specification.gain[gainID].gainIndex);
  853 + commandPending[(uint8_t)BulkCode::SETGAIN] = true;
852 854
853 // SetRelays control command for gain relays 855 // SetRelays control command for gain relays
854 ControlSetRelays *controlSetRelays = static_cast<ControlSetRelays *>(this->control[CONTROLINDEX_SETRELAYS]); 856 ControlSetRelays *controlSetRelays = static_cast<ControlSetRelays *>(this->control[CONTROLINDEX_SETRELAYS]);
855 - controlSetRelays->setBelow1V(channel, gainId < 3);  
856 - controlSetRelays->setBelow100mV(channel, gainId < 6); 857 + controlSetRelays->setBelow1V(channel, gainID < 3);
  858 + controlSetRelays->setBelow100mV(channel, gainID < 6);
857 this->controlPending[CONTROLINDEX_SETRELAYS] = true; 859 this->controlPending[CONTROLINDEX_SETRELAYS] = true;
858 } 860 }
859 861
860 - controlsettings.voltage[channel].gain = gainId; 862 + controlsettings.voltage[channel].gain = gainID;
861 863
862 this->setOffset(channel, controlsettings.voltage[channel].offset); 864 this->setOffset(channel, controlsettings.voltage[channel].offset);
863 865
@@ -913,30 +915,36 @@ Dso::ErrorCode HantekDsoControl::setTriggerMode(Dso::TriggerMode mode) { @@ -913,30 +915,36 @@ Dso::ErrorCode HantekDsoControl::setTriggerMode(Dso::TriggerMode mode) {
913 /// \return See ::Dso::ErrorCode. 915 /// \return See ::Dso::ErrorCode.
914 Dso::ErrorCode HantekDsoControl::setTriggerSource(bool special, unsigned id) { 916 Dso::ErrorCode HantekDsoControl::setTriggerSource(bool special, unsigned id) {
915 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 917 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
  918 + if (specification.isSoftwareTriggerDevice) return Dso::ErrorCode::UNSUPPORTED;
916 919
917 - if ((!special && id >= HANTEK_CHANNELS) || (special && id >= HANTEK_SPECIAL_CHANNELS)) 920 + if (!special && id >= HANTEK_CHANNELS)
918 return Dso::ErrorCode::PARAMETER; 921 return Dso::ErrorCode::PARAMETER;
919 922
  923 + if (special && id >= specification.specialTriggerChannels.size())
  924 + return Dso::ErrorCode::PARAMETER;
  925 +
  926 + int hardwareID = special ? specification.specialTriggerChannels[id].hardwareID:(int)id;
  927 +
920 switch (specification.command.bulk.setTrigger) { 928 switch (specification.command.bulk.setTrigger) {
921 - case BULK_SETTRIGGERANDSAMPLERATE: 929 + case BulkCode::SETTRIGGERANDSAMPLERATE:
922 // SetTriggerAndSamplerate bulk command for trigger source 930 // SetTriggerAndSamplerate bulk command for trigger source
923 - static_cast<BulkSetTriggerAndSamplerate *>(command[BULK_SETTRIGGERANDSAMPLERATE])  
924 - ->setTriggerSource(special ? 3 + id : 1 - id);  
925 - commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 931 + static_cast<BulkSetTriggerAndSamplerate *>(command[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE])
  932 + ->setTriggerSource(1 - hardwareID);
  933 + commandPending[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = true;
926 break; 934 break;
927 935
928 - case BULK_CSETTRIGGERORSAMPLERATE: 936 + case BulkCode::CSETTRIGGERORSAMPLERATE:
929 // SetTrigger2250 bulk command for trigger source 937 // SetTrigger2250 bulk command for trigger source
930 - static_cast<BulkSetTrigger2250 *>(command[BULK_CSETTRIGGERORSAMPLERATE])  
931 - ->setTriggerSource(special ? 0 : 2 + id);  
932 - commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; 938 + static_cast<BulkSetTrigger2250 *>(command[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE])
  939 + ->setTriggerSource(2 + hardwareID);
  940 + commandPending[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE] = true;
933 break; 941 break;
934 942
935 - case BULK_ESETTRIGGERORSAMPLERATE: 943 + case BulkCode::ESETTRIGGERORSAMPLERATE:
936 // SetTrigger5200 bulk command for trigger source 944 // SetTrigger5200 bulk command for trigger source
937 - static_cast<BulkSetTrigger5200 *>(command[BULK_ESETTRIGGERORSAMPLERATE])  
938 - ->setTriggerSource(special ? 3 + id : 1 - id);  
939 - commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; 945 + static_cast<BulkSetTrigger5200 *>(command[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE])
  946 + ->setTriggerSource(1 - hardwareID);
  947 + commandPending[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = true;
940 break; 948 break;
941 949
942 default: 950 default:
@@ -986,8 +994,9 @@ Dso::ErrorCode HantekDsoControl::setTriggerLevel(unsigned channel, double level) @@ -986,8 +994,9 @@ Dso::ErrorCode HantekDsoControl::setTriggerLevel(unsigned channel, double level)
986 } 994 }
987 995
988 // Never get out of the limits 996 // Never get out of the limits
  997 + const unsigned gainID = controlsettings.voltage[channel].gain;
989 const double offsetReal = controlsettings.voltage[channel].offsetReal; 998 const double offsetReal = controlsettings.voltage[channel].offsetReal;
990 - const double gainStep = specification.gainSteps[controlsettings.voltage[channel].gain]; 999 + const double gainStep = specification.gain[gainID].gainSteps;
991 unsigned short levelValue = qBound( 1000 unsigned short levelValue = qBound(
992 minimum, (unsigned short)(((offsetReal + level / gainStep) * (maximum - minimum) + 0.5) + minimum), maximum); 1001 minimum, (unsigned short)(((offsetReal + level / gainStep) * (maximum - minimum) + 0.5) + minimum), maximum);
993 1002
@@ -1013,22 +1022,22 @@ Dso::ErrorCode HantekDsoControl::setTriggerSlope(Dso::Slope slope) { @@ -1013,22 +1022,22 @@ Dso::ErrorCode HantekDsoControl::setTriggerSlope(Dso::Slope slope) {
1013 if (slope >= Dso::SLOPE_COUNT) return Dso::ErrorCode::PARAMETER; 1022 if (slope >= Dso::SLOPE_COUNT) return Dso::ErrorCode::PARAMETER;
1014 1023
1015 switch (specification.command.bulk.setTrigger) { 1024 switch (specification.command.bulk.setTrigger) {
1016 - case BULK_SETTRIGGERANDSAMPLERATE: { 1025 + case BulkCode::SETTRIGGERANDSAMPLERATE: {
1017 // SetTriggerAndSamplerate bulk command for trigger slope 1026 // SetTriggerAndSamplerate bulk command for trigger slope
1018 - static_cast<BulkSetTriggerAndSamplerate *>(command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSlope(slope);  
1019 - commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 1027 + static_cast<BulkSetTriggerAndSamplerate *>(command[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE])->setTriggerSlope(slope);
  1028 + commandPending[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = true;
1020 break; 1029 break;
1021 } 1030 }
1022 - case BULK_CSETTRIGGERORSAMPLERATE: { 1031 + case BulkCode::CSETTRIGGERORSAMPLERATE: {
1023 // SetTrigger2250 bulk command for trigger slope 1032 // SetTrigger2250 bulk command for trigger slope
1024 - static_cast<BulkSetTrigger2250 *>(command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSlope(slope);  
1025 - commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; 1033 + static_cast<BulkSetTrigger2250 *>(command[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE])->setTriggerSlope(slope);
  1034 + commandPending[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE] = true;
1026 break; 1035 break;
1027 } 1036 }
1028 - case BULK_ESETTRIGGERORSAMPLERATE: { 1037 + case BulkCode::ESETTRIGGERORSAMPLERATE: {
1029 // SetTrigger5200 bulk command for trigger slope 1038 // SetTrigger5200 bulk command for trigger slope
1030 - static_cast<BulkSetTrigger5200 *>(command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSlope(slope);  
1031 - commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; 1039 + static_cast<BulkSetTrigger5200 *>(command[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE])->setTriggerSlope(slope);
  1040 + commandPending[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = true;
1032 break; 1041 break;
1033 } 1042 }
1034 default: 1043 default:
@@ -1039,7 +1048,7 @@ Dso::ErrorCode HantekDsoControl::setTriggerSlope(Dso::Slope slope) { @@ -1039,7 +1048,7 @@ Dso::ErrorCode HantekDsoControl::setTriggerSlope(Dso::Slope slope) {
1039 return Dso::ErrorCode::NONE; 1048 return Dso::ErrorCode::NONE;
1040 } 1049 }
1041 1050
1042 -void HantekDsoControl::forceTrigger() { commandPending[BULK_FORCETRIGGER] = true; } 1051 +void HantekDsoControl::forceTrigger() { commandPending[(uint8_t)BulkCode::FORCETRIGGER] = true; }
1043 1052
1044 /// \brief Set the trigger position. 1053 /// \brief Set the trigger position.
1045 /// \param position The new trigger position (in s). 1054 /// \param position The new trigger position (in s).
@@ -1054,39 +1063,39 @@ Dso::ErrorCode HantekDsoControl::setPretriggerPosition(double position) { @@ -1054,39 +1063,39 @@ Dso::ErrorCode HantekDsoControl::setPretriggerPosition(double position) {
1054 if (controlsettings.samplerate.limits == &specification.samplerate.multi) positionSamples /= HANTEK_CHANNELS; 1063 if (controlsettings.samplerate.limits == &specification.samplerate.multi) positionSamples /= HANTEK_CHANNELS;
1055 1064
1056 switch (specification.command.bulk.setPretrigger) { 1065 switch (specification.command.bulk.setPretrigger) {
1057 - case BULK_SETTRIGGERANDSAMPLERATE: { 1066 + case BulkCode::SETTRIGGERANDSAMPLERATE: {
1058 // Calculate the position value (Start point depending on record length) 1067 // Calculate the position value (Start point depending on record length)
1059 unsigned position = isRollMode() ? 0x1 : 0x7ffff - recordLength + (unsigned)positionSamples; 1068 unsigned position = isRollMode() ? 0x1 : 0x7ffff - recordLength + (unsigned)positionSamples;
1060 1069
1061 // SetTriggerAndSamplerate bulk command for trigger position 1070 // SetTriggerAndSamplerate bulk command for trigger position
1062 - static_cast<BulkSetTriggerAndSamplerate *>(command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position);  
1063 - commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 1071 + static_cast<BulkSetTriggerAndSamplerate *>(command[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position);
  1072 + commandPending[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = true;
1064 1073
1065 break; 1074 break;
1066 } 1075 }
1067 - case BULK_FSETBUFFER: { 1076 + case BulkCode::FSETBUFFER: {
1068 // Calculate the position values (Inverse, maximum is 0x7ffff) 1077 // Calculate the position values (Inverse, maximum is 0x7ffff)
1069 unsigned positionPre = 0x7ffff - recordLength + (unsigned)positionSamples; 1078 unsigned positionPre = 0x7ffff - recordLength + (unsigned)positionSamples;
1070 unsigned positionPost = 0x7ffff - (unsigned)positionSamples; 1079 unsigned positionPost = 0x7ffff - (unsigned)positionSamples;
1071 1080
1072 // SetBuffer2250 bulk command for trigger position 1081 // SetBuffer2250 bulk command for trigger position
1073 - BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(command[BULK_FSETBUFFER]); 1082 + BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(command[(uint8_t)BulkCode::FSETBUFFER]);
1074 commandSetBuffer2250->setTriggerPositionPre(positionPre); 1083 commandSetBuffer2250->setTriggerPositionPre(positionPre);
1075 commandSetBuffer2250->setTriggerPositionPost(positionPost); 1084 commandSetBuffer2250->setTriggerPositionPost(positionPost);
1076 - commandPending[BULK_FSETBUFFER] = true; 1085 + commandPending[(uint8_t)BulkCode::FSETBUFFER] = true;
1077 1086
1078 break; 1087 break;
1079 } 1088 }
1080 - case BULK_ESETTRIGGERORSAMPLERATE: { 1089 + case BulkCode::ESETTRIGGERORSAMPLERATE: {
1081 // Calculate the position values (Inverse, maximum is 0xffff) 1090 // Calculate the position values (Inverse, maximum is 0xffff)
1082 unsigned positionPre = 0xffff - recordLength + (unsigned)positionSamples; 1091 unsigned positionPre = 0xffff - recordLength + (unsigned)positionSamples;
1083 unsigned positionPost = 0xffff - (unsigned)positionSamples; 1092 unsigned positionPost = 0xffff - (unsigned)positionSamples;
1084 1093
1085 // SetBuffer5200 bulk command for trigger position 1094 // SetBuffer5200 bulk command for trigger position
1086 - BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(command[BULK_DSETBUFFER]); 1095 + BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(command[(uint8_t)BulkCode::DSETBUFFER]);
1087 commandSetBuffer5200->setTriggerPositionPre((unsigned short)positionPre); 1096 commandSetBuffer5200->setTriggerPositionPre((unsigned short)positionPre);
1088 commandSetBuffer5200->setTriggerPositionPost((unsigned short)positionPost); 1097 commandSetBuffer5200->setTriggerPositionPost((unsigned short)positionPost);
1089 - commandPending[BULK_DSETBUFFER] = true; 1098 + commandPending[(uint8_t)BulkCode::DSETBUFFER] = true;
1090 1099
1091 break; 1100 break;
1092 } 1101 }
@@ -1115,7 +1124,7 @@ Dso::ErrorCode HantekDsoControl::stringCommand(const QString &amp;commandString) { @@ -1115,7 +1124,7 @@ Dso::ErrorCode HantekDsoControl::stringCommand(const QString &amp;commandString) {
1115 1124
1116 // Read command code (First byte) 1125 // Read command code (First byte)
1117 hexParse(commandParts[2], &commandCode, 1); 1126 hexParse(commandParts[2], &commandCode, 1);
1118 - if (commandCode > BULK_COUNT) return Dso::ErrorCode::UNSUPPORTED; 1127 + if (commandCode > (uint8_t)BulkCode::COUNT) return Dso::ErrorCode::UNSUPPORTED;
1119 1128
1120 // Update bulk command and mark as pending 1129 // Update bulk command and mark as pending
1121 hexParse(data, command[commandCode]->data(), command[commandCode]->getSize()); 1130 hexParse(data, command[commandCode]->data(), command[commandCode]->getSize());
@@ -1146,7 +1155,7 @@ void HantekDsoControl::run() { @@ -1146,7 +1155,7 @@ void HantekDsoControl::run() {
1146 int errorCode = 0; 1155 int errorCode = 0;
1147 1156
1148 // Send all pending bulk commands 1157 // Send all pending bulk commands
1149 - for (int cIndex = 0; cIndex < BULK_COUNT; ++cIndex) { 1158 + for (int cIndex = 0; cIndex < (uint8_t)BulkCode::COUNT; ++cIndex) {
1150 if (!commandPending[cIndex]) continue; 1159 if (!commandPending[cIndex]) continue;
1151 1160
1152 timestampDebug( 1161 timestampDebug(
@@ -1200,7 +1209,7 @@ void HantekDsoControl::run() { @@ -1200,7 +1209,7 @@ void HantekDsoControl::run() {
1200 // Sampling hasn't started, update the expected sample count 1209 // Sampling hasn't started, update the expected sample count
1201 this->previousSampleCount = this->getSampleCount(); 1210 this->previousSampleCount = this->getSampleCount();
1202 1211
1203 - errorCode = device->bulkCommand(command[BULK_STARTSAMPLING]); 1212 + errorCode = device->bulkCommand(command[(uint8_t)BulkCode::STARTSAMPLING]);
1204 if (errorCode < 0) { 1213 if (errorCode < 0) {
1205 if (errorCode == LIBUSB_ERROR_NO_DEVICE) { 1214 if (errorCode == LIBUSB_ERROR_NO_DEVICE) {
1206 emit communicationError(); 1215 emit communicationError();
@@ -1216,7 +1225,7 @@ void HantekDsoControl::run() { @@ -1216,7 +1225,7 @@ void HantekDsoControl::run() {
1216 break; 1225 break;
1217 1226
1218 case RollState::ENABLETRIGGER: 1227 case RollState::ENABLETRIGGER:
1219 - errorCode = device->bulkCommand(command[BULK_ENABLETRIGGER]); 1228 + errorCode = device->bulkCommand(command[(uint8_t)BulkCode::ENABLETRIGGER]);
1220 if (errorCode < 0) { 1229 if (errorCode < 0) {
1221 if (errorCode == LIBUSB_ERROR_NO_DEVICE) { 1230 if (errorCode == LIBUSB_ERROR_NO_DEVICE) {
1222 emit communicationError(); 1231 emit communicationError();
@@ -1230,7 +1239,7 @@ void HantekDsoControl::run() { @@ -1230,7 +1239,7 @@ void HantekDsoControl::run() {
1230 break; 1239 break;
1231 1240
1232 case RollState::FORCETRIGGER: 1241 case RollState::FORCETRIGGER:
1233 - errorCode = device->bulkCommand(command[BULK_FORCETRIGGER]); 1242 + errorCode = device->bulkCommand(command[(uint8_t)BulkCode::FORCETRIGGER]);
1234 if (errorCode < 0) { 1243 if (errorCode < 0) {
1235 if (errorCode == LIBUSB_ERROR_NO_DEVICE) { 1244 if (errorCode == LIBUSB_ERROR_NO_DEVICE) {
1236 emit communicationError(); 1245 emit communicationError();
@@ -1310,7 +1319,7 @@ void HantekDsoControl::run() { @@ -1310,7 +1319,7 @@ void HantekDsoControl::run() {
1310 if (this->cycleCounter == this->startCycle && !isRollMode()) { 1319 if (this->cycleCounter == this->startCycle && !isRollMode()) {
1311 // Buffer refilled completely since start of sampling, enable the 1320 // Buffer refilled completely since start of sampling, enable the
1312 // trigger now 1321 // trigger now
1313 - errorCode = device->bulkCommand(command[BULK_ENABLETRIGGER]); 1322 + errorCode = device->bulkCommand(command[(uint8_t)BulkCode::ENABLETRIGGER]);
1314 if (errorCode < 0) { 1323 if (errorCode < 0) {
1315 if (errorCode == LIBUSB_ERROR_NO_DEVICE) { 1324 if (errorCode == LIBUSB_ERROR_NO_DEVICE) {
1316 emit communicationError(); 1325 emit communicationError();
@@ -1323,7 +1332,7 @@ void HantekDsoControl::run() { @@ -1323,7 +1332,7 @@ void HantekDsoControl::run() {
1323 } else if (this->cycleCounter >= 8 + this->startCycle && 1332 } else if (this->cycleCounter >= 8 + this->startCycle &&
1324 controlsettings.trigger.mode == Dso::TRIGGERMODE_AUTO) { 1333 controlsettings.trigger.mode == Dso::TRIGGERMODE_AUTO) {
1325 // Force triggering 1334 // Force triggering
1326 - errorCode = device->bulkCommand(command[BULK_FORCETRIGGER]); 1335 + errorCode = device->bulkCommand(command[(uint8_t)BulkCode::FORCETRIGGER]);
1327 if (errorCode < 0) { 1336 if (errorCode < 0) {
1328 if (errorCode == LIBUSB_ERROR_NO_DEVICE) { 1337 if (errorCode == LIBUSB_ERROR_NO_DEVICE) {
1329 emit communicationError(); 1338 emit communicationError();
@@ -1339,7 +1348,7 @@ void HantekDsoControl::run() { @@ -1339,7 +1348,7 @@ void HantekDsoControl::run() {
1339 } 1348 }
1340 1349
1341 // Start capturing 1350 // Start capturing
1342 - errorCode = device->bulkCommand(command[BULK_STARTSAMPLING]); 1351 + errorCode = device->bulkCommand(command[(uint8_t)BulkCode::STARTSAMPLING]);
1343 if (errorCode < 0) { 1352 if (errorCode < 0) {
1344 if (errorCode == LIBUSB_ERROR_NO_DEVICE) { 1353 if (errorCode == LIBUSB_ERROR_NO_DEVICE) {
1345 emit communicationError(); 1354 emit communicationError();
openhantek/src/hantekdso/hantekdsocontrol.h
@@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
8 #include "controlspecification.h" 8 #include "controlspecification.h"
9 #include "controlsettings.h" 9 #include "controlsettings.h"
10 #include "controlindexes.h" 10 #include "controlindexes.h"
11 -#include "utils/dataarray.h"  
12 #include "utils/printutils.h" 11 #include "utils/printutils.h"
13 12
14 #include <vector> 13 #include <vector>
@@ -19,6 +18,10 @@ @@ -19,6 +18,10 @@
19 #include <QTimer> 18 #include <QTimer>
20 19
21 class USBDevice; 20 class USBDevice;
  21 +namespace Hantek {
  22 +class BulkCommand;
  23 +class ControlCommand;
  24 +}
22 25
23 /// \brief The DsoControl abstraction layer for %Hantek USB DSOs. 26 /// \brief The DsoControl abstraction layer for %Hantek USB DSOs.
24 /// TODO Please anyone, refactor this class into smaller pieces (Separation of Concerns!). 27 /// TODO Please anyone, refactor this class into smaller pieces (Separation of Concerns!).
@@ -62,7 +65,7 @@ class HantekDsoControl : public QObject { @@ -62,7 +65,7 @@ class HantekDsoControl : public QObject {
62 double getMaxSamplerate(); 65 double getMaxSamplerate();
63 66
64 /// \brief Get a list of the names of the special trigger sources. 67 /// \brief Get a list of the names of the special trigger sources.
65 - const QStringList *getSpecialTriggerSources(); 68 + const std::vector<std::string> getSpecialTriggerSources();
66 69
67 /// Return the associated usb device. 70 /// Return the associated usb device.
68 USBDevice *getDevice(); 71 USBDevice *getDevice();
@@ -144,11 +147,11 @@ class HantekDsoControl : public QObject { @@ -144,11 +147,11 @@ class HantekDsoControl : public QObject {
144 147
145 public: // TODO redo command queues 148 public: // TODO redo command queues
146 /// Pointers to bulk commands, ready to be transmitted 149 /// Pointers to bulk commands, ready to be transmitted
147 - DataArray<unsigned char> *command[Hantek::BULK_COUNT] = {0}; 150 + Hantek::BulkCommand *command[(uint8_t)Hantek::BulkCode::COUNT] = {0};
148 /// true, when the command should be executed 151 /// true, when the command should be executed
149 - bool commandPending[Hantek::BULK_COUNT] = {false}; 152 + bool commandPending[(uint8_t)Hantek::BulkCode::COUNT] = {false};
150 ///< Pointers to control commands 153 ///< Pointers to control commands
151 - DataArray<unsigned char> *control[Hantek::CONTROLINDEX_COUNT] = {0}; 154 + Hantek::ControlCommand *control[Hantek::CONTROLINDEX_COUNT] = {0};
152 ///< Request codes for control commands 155 ///< Request codes for control commands
153 unsigned char controlCode[Hantek::CONTROLINDEX_COUNT]; 156 unsigned char controlCode[Hantek::CONTROLINDEX_COUNT];
154 ///< true, when the control command should be executed 157 ///< true, when the control command should be executed
@@ -158,8 +161,6 @@ class HantekDsoControl : public QObject { @@ -158,8 +161,6 @@ class HantekDsoControl : public QObject {
158 USBDevice *device; ///< The USB device for the oscilloscope 161 USBDevice *device; ///< The USB device for the oscilloscope
159 bool sampling = false; ///< true, if the oscilloscope is taking samples 162 bool sampling = false; ///< true, if the oscilloscope is taking samples
160 163
161 - QStringList specialTriggerSources = {tr("EXT"), tr("EXT/10")}; ///< Names of the special trigger sources  
162 -  
163 // Device setup 164 // Device setup
164 Hantek::ControlSpecification specification; ///< The specifications of the device 165 Hantek::ControlSpecification specification; ///< The specifications of the device
165 Hantek::ControlSettings controlsettings; ///< The current settings of the device 166 Hantek::ControlSettings controlsettings; ///< The current settings of the device
openhantek/src/hantekdso/models/modelDSO2090.cpp
@@ -7,12 +7,12 @@ using namespace Hantek; @@ -7,12 +7,12 @@ using namespace Hantek;
7 ModelDSO2090::ModelDSO2090() : DSOModel(ID, 0x04b5, 0x2090, 0x04b4, 0x2090, "dso2090x86", "DSO-2090", Hantek::ControlSpecification()) { 7 ModelDSO2090::ModelDSO2090() : DSOModel(ID, 0x04b5, 0x2090, 0x04b4, 0x2090, "dso2090x86", "DSO-2090", Hantek::ControlSpecification()) {
8 specification.command.control.setOffset = CONTROL_SETOFFSET; 8 specification.command.control.setOffset = CONTROL_SETOFFSET;
9 specification.command.control.setRelays = CONTROL_SETRELAYS; 9 specification.command.control.setRelays = CONTROL_SETRELAYS;
10 - specification.command.bulk.setGain = BULK_SETGAIN;  
11 - specification.command.bulk.setRecordLength = BULK_SETTRIGGERANDSAMPLERATE;  
12 - specification.command.bulk.setChannels = BULK_SETTRIGGERANDSAMPLERATE;  
13 - specification.command.bulk.setSamplerate = BULK_SETTRIGGERANDSAMPLERATE;  
14 - specification.command.bulk.setTrigger = BULK_SETTRIGGERANDSAMPLERATE;  
15 - specification.command.bulk.setPretrigger = BULK_SETTRIGGERANDSAMPLERATE; 10 + specification.command.bulk.setGain = BulkCode::SETGAIN;
  11 + specification.command.bulk.setRecordLength = BulkCode::SETTRIGGERANDSAMPLERATE;
  12 + specification.command.bulk.setChannels = BulkCode::SETTRIGGERANDSAMPLERATE;
  13 + specification.command.bulk.setSamplerate = BulkCode::SETTRIGGERANDSAMPLERATE;
  14 + specification.command.bulk.setTrigger = BulkCode::SETTRIGGERANDSAMPLERATE;
  15 + specification.command.bulk.setPretrigger = BulkCode::SETTRIGGERANDSAMPLERATE;
16 16
17 specification.samplerate.single.base = 50e6; 17 specification.samplerate.single.base = 50e6;
18 specification.samplerate.single.max = 50e6; 18 specification.samplerate.single.max = 50e6;
@@ -23,16 +23,17 @@ ModelDSO2090::ModelDSO2090() : DSOModel(ID, 0x04b5, 0x2090, 0x04b4, 0x2090, &quot;dso @@ -23,16 +23,17 @@ ModelDSO2090::ModelDSO2090() : DSOModel(ID, 0x04b5, 0x2090, 0x04b4, 0x2090, &quot;dso
23 specification.samplerate.multi.maxDownsampler = 131072; 23 specification.samplerate.multi.maxDownsampler = 131072;
24 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480, 65536}; 24 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480, 65536};
25 specification.bufferDividers = { 1000 , 1 , 1 }; 25 specification.bufferDividers = { 1000 , 1 , 1 };
26 - specification.gainSteps = { 0.08 , 0.16 , 0.40 , 0.80 , 1.60 , 4.00 , 8.0 , 16.0 , 40.0 };  
27 specification.voltageLimit[0] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 }; 26 specification.voltageLimit[0] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 };
28 specification.voltageLimit[1] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 }; 27 specification.voltageLimit[1] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 };
29 - specification.gainIndex = { 0 , 1 , 2 , 0 , 1 , 2 , 0 , 1 , 2 }; 28 + specification.gain = { {0,0.08} , {1,0.16} , {2,0.40} , {0,0.80} ,
  29 + {1,1.60} , {2,4.00} , {0,8.00} , {1,16.00} , {2,40.00} };
30 specification.sampleSize = 8; 30 specification.sampleSize = 8;
  31 + specification.specialTriggerChannels = {{"EXT", -2}, {"EXT/10", -3}};
31 } 32 }
32 33
33 void ModelDSO2090::applyRequirements(HantekDsoControl *dsoControl) const { 34 void ModelDSO2090::applyRequirements(HantekDsoControl *dsoControl) const {
34 - dsoControl->command[BULK_SETTRIGGERANDSAMPLERATE] = new BulkSetTriggerAndSamplerate();  
35 - dsoControl->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 35 + dsoControl->command[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = new BulkSetTriggerAndSamplerate();
  36 + dsoControl->commandPending[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = true;
36 37
37 dsoControl->controlPending[CONTROLINDEX_SETOFFSET] = true; 38 dsoControl->controlPending[CONTROLINDEX_SETOFFSET] = true;
38 dsoControl->controlPending[CONTROLINDEX_SETRELAYS] = true; 39 dsoControl->controlPending[CONTROLINDEX_SETRELAYS] = true;
openhantek/src/hantekdso/models/modelDSO2150.cpp
@@ -7,12 +7,12 @@ using namespace Hantek; @@ -7,12 +7,12 @@ using namespace Hantek;
7 ModelDSO2150::ModelDSO2150() : DSOModel(ID, 0x04b5, 0x2150, 0x04b4, 0x2150, "dso2150x86", "DSO-2150", Hantek::ControlSpecification()) { 7 ModelDSO2150::ModelDSO2150() : DSOModel(ID, 0x04b5, 0x2150, 0x04b4, 0x2150, "dso2150x86", "DSO-2150", Hantek::ControlSpecification()) {
8 specification.command.control.setOffset = CONTROL_SETOFFSET; 8 specification.command.control.setOffset = CONTROL_SETOFFSET;
9 specification.command.control.setRelays = CONTROL_SETRELAYS; 9 specification.command.control.setRelays = CONTROL_SETRELAYS;
10 - specification.command.bulk.setGain = BULK_SETGAIN;  
11 - specification.command.bulk.setRecordLength = BULK_SETTRIGGERANDSAMPLERATE;  
12 - specification.command.bulk.setChannels = BULK_SETTRIGGERANDSAMPLERATE;  
13 - specification.command.bulk.setSamplerate = BULK_SETTRIGGERANDSAMPLERATE;  
14 - specification.command.bulk.setTrigger = BULK_SETTRIGGERANDSAMPLERATE;  
15 - specification.command.bulk.setPretrigger = BULK_SETTRIGGERANDSAMPLERATE; 10 + specification.command.bulk.setGain = BulkCode::SETGAIN;
  11 + specification.command.bulk.setRecordLength = BulkCode::SETTRIGGERANDSAMPLERATE;
  12 + specification.command.bulk.setChannels = BulkCode::SETTRIGGERANDSAMPLERATE;
  13 + specification.command.bulk.setSamplerate = BulkCode::SETTRIGGERANDSAMPLERATE;
  14 + specification.command.bulk.setTrigger = BulkCode::SETTRIGGERANDSAMPLERATE;
  15 + specification.command.bulk.setPretrigger = BulkCode::SETTRIGGERANDSAMPLERATE;
16 16
17 specification.samplerate.single.base = 50e6; 17 specification.samplerate.single.base = 50e6;
18 specification.samplerate.single.max = 75e6; 18 specification.samplerate.single.max = 75e6;
@@ -23,16 +23,17 @@ ModelDSO2150::ModelDSO2150() : DSOModel(ID, 0x04b5, 0x2150, 0x04b4, 0x2150, &quot;dso @@ -23,16 +23,17 @@ ModelDSO2150::ModelDSO2150() : DSOModel(ID, 0x04b5, 0x2150, 0x04b4, 0x2150, &quot;dso
23 specification.samplerate.multi.maxDownsampler = 131072; 23 specification.samplerate.multi.maxDownsampler = 131072;
24 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480, 65536}; 24 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480, 65536};
25 specification.bufferDividers = { 1000 , 1 , 1 }; 25 specification.bufferDividers = { 1000 , 1 , 1 };
26 - specification.gainSteps = { 0.08 , 0.16 , 0.40 , 0.80 , 1.60 , 4.00 , 8.0 , 16.0 , 40.0 };  
27 specification.voltageLimit[0] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 }; 26 specification.voltageLimit[0] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 };
28 specification.voltageLimit[1] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 }; 27 specification.voltageLimit[1] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 };
29 - specification.gainIndex = { 0 , 1 , 2 , 0 , 1 , 2 , 0 , 1 , 2 }; 28 + specification.gain = { {0,0.08} , {1,0.16} , {2,0.40} , {0,0.80} ,
  29 + {1,1.60} , {2,4.00} , {0,8.00} , {1,16.00} , {2,40.00} };
30 specification.sampleSize = 8; 30 specification.sampleSize = 8;
  31 + specification.specialTriggerChannels = {{"EXT", -2}, {"EXT/10", -3}};
31 } 32 }
32 33
33 void ModelDSO2150::applyRequirements(HantekDsoControl *dsoControl) const { 34 void ModelDSO2150::applyRequirements(HantekDsoControl *dsoControl) const {
34 - dsoControl->command[BULK_SETTRIGGERANDSAMPLERATE] = new BulkSetTriggerAndSamplerate();  
35 - dsoControl->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 35 + dsoControl->command[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = new BulkSetTriggerAndSamplerate();
  36 + dsoControl->commandPending[(uint8_t)BulkCode::SETTRIGGERANDSAMPLERATE] = true;
36 dsoControl->controlPending[CONTROLINDEX_SETOFFSET] = true; 37 dsoControl->controlPending[CONTROLINDEX_SETOFFSET] = true;
37 dsoControl->controlPending[CONTROLINDEX_SETRELAYS] = true; 38 dsoControl->controlPending[CONTROLINDEX_SETRELAYS] = true;
38 } 39 }
openhantek/src/hantekdso/models/modelDSO2250.cpp
@@ -7,12 +7,12 @@ using namespace Hantek; @@ -7,12 +7,12 @@ using namespace Hantek;
7 ModelDSO2250::ModelDSO2250() : DSOModel(ID, 0x04b5, 0x2250, 0x04b4, 0x2250, "dso2250x86", "DSO-2250", Hantek::ControlSpecification()) { 7 ModelDSO2250::ModelDSO2250() : DSOModel(ID, 0x04b5, 0x2250, 0x04b4, 0x2250, "dso2250x86", "DSO-2250", Hantek::ControlSpecification()) {
8 specification.command.control.setOffset = CONTROL_SETOFFSET; 8 specification.command.control.setOffset = CONTROL_SETOFFSET;
9 specification.command.control.setRelays = CONTROL_SETRELAYS; 9 specification.command.control.setRelays = CONTROL_SETRELAYS;
10 - specification.command.bulk.setGain = BULK_SETGAIN;  
11 - specification.command.bulk.setRecordLength = BULK_DSETBUFFER;  
12 - specification.command.bulk.setChannels = BULK_BSETCHANNELS;  
13 - specification.command.bulk.setSamplerate = BULK_ESETTRIGGERORSAMPLERATE;  
14 - specification.command.bulk.setTrigger = BULK_CSETTRIGGERORSAMPLERATE;  
15 - specification.command.bulk.setPretrigger = BULK_FSETBUFFER; 10 + specification.command.bulk.setGain = BulkCode::SETGAIN;
  11 + specification.command.bulk.setRecordLength = BulkCode::DSETBUFFER;
  12 + specification.command.bulk.setChannels = BulkCode::BSETCHANNELS;
  13 + specification.command.bulk.setSamplerate = BulkCode::ESETTRIGGERORSAMPLERATE;
  14 + specification.command.bulk.setTrigger = BulkCode::CSETTRIGGERORSAMPLERATE;
  15 + specification.command.bulk.setPretrigger = BulkCode::FSETBUFFER;
16 16
17 specification.samplerate.single.base = 100e6; 17 specification.samplerate.single.base = 100e6;
18 specification.samplerate.single.max = 100e6; 18 specification.samplerate.single.max = 100e6;
@@ -23,25 +23,26 @@ ModelDSO2250::ModelDSO2250() : DSOModel(ID, 0x04b5, 0x2250, 0x04b4, 0x2250, &quot;dso @@ -23,25 +23,26 @@ ModelDSO2250::ModelDSO2250() : DSOModel(ID, 0x04b5, 0x2250, 0x04b4, 0x2250, &quot;dso
23 specification.samplerate.multi.maxDownsampler = 65536; 23 specification.samplerate.multi.maxDownsampler = 65536;
24 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480, 1048576}; 24 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480, 1048576};
25 specification.bufferDividers = { 1000 , 1 , 1 }; 25 specification.bufferDividers = { 1000 , 1 , 1 };
26 - specification.gainSteps = { 0.08 , 0.16 , 0.40 , 0.80 , 1.60 , 4.00 , 8.0 , 16.0 , 40.0 };  
27 specification.voltageLimit[0] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 }; 26 specification.voltageLimit[0] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 };
28 specification.voltageLimit[1] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 }; 27 specification.voltageLimit[1] = { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 };
29 - specification.gainIndex = { 0 , 2 , 3 , 0 , 2 , 3 , 0 , 2 , 3 }; 28 + specification.gain = { {0,0.08} , {2,0.16} , {3,0.40} , {0,0.80} ,
  29 + {2,1.60} , {3,4.00} , {0,8.00} , {2,16.00} , {3,40.00} };
30 specification.sampleSize = 8; 30 specification.sampleSize = 8;
  31 + specification.specialTriggerChannels = {{"EXT", -2}};
31 } 32 }
32 33
33 void ModelDSO2250::applyRequirements(HantekDsoControl *dsoControl) const { 34 void ModelDSO2250::applyRequirements(HantekDsoControl *dsoControl) const {
34 // Instantiate additional commands for the DSO-2250 35 // Instantiate additional commands for the DSO-2250
35 - dsoControl->command[BULK_BSETCHANNELS] = new BulkSetChannels2250();  
36 - dsoControl->command[BULK_CSETTRIGGERORSAMPLERATE] = new BulkSetTrigger2250();  
37 - dsoControl->command[BULK_DSETBUFFER] = new BulkSetRecordLength2250();  
38 - dsoControl->command[BULK_ESETTRIGGERORSAMPLERATE] = new BulkSetSamplerate2250();  
39 - dsoControl->command[BULK_FSETBUFFER] = new BulkSetBuffer2250();  
40 - dsoControl->commandPending[BULK_BSETCHANNELS] = true;  
41 - dsoControl->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true;  
42 - dsoControl->commandPending[BULK_DSETBUFFER] = true;  
43 - dsoControl->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true;  
44 - dsoControl->commandPending[BULK_FSETBUFFER] = true; 36 + dsoControl->command[(uint8_t)BulkCode::BSETCHANNELS] = new BulkSetChannels2250();
  37 + dsoControl->command[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE] = new BulkSetTrigger2250();
  38 + dsoControl->command[(uint8_t)BulkCode::DSETBUFFER] = new BulkSetRecordLength2250();
  39 + dsoControl->command[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = new BulkSetSamplerate2250();
  40 + dsoControl->command[(uint8_t)BulkCode::FSETBUFFER] = new BulkSetBuffer2250();
  41 + dsoControl->commandPending[(uint8_t)BulkCode::BSETCHANNELS] = true;
  42 + dsoControl->commandPending[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE] = true;
  43 + dsoControl->commandPending[(uint8_t)BulkCode::DSETBUFFER] = true;
  44 + dsoControl->commandPending[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = true;
  45 + dsoControl->commandPending[(uint8_t)BulkCode::FSETBUFFER] = true;
45 46
46 dsoControl->controlPending[CONTROLINDEX_SETOFFSET] = true; 47 dsoControl->controlPending[CONTROLINDEX_SETOFFSET] = true;
47 dsoControl->controlPending[CONTROLINDEX_SETRELAYS] = true; 48 dsoControl->controlPending[CONTROLINDEX_SETRELAYS] = true;
openhantek/src/hantekdso/models/modelDSO5200.cpp
@@ -7,12 +7,12 @@ using namespace Hantek; @@ -7,12 +7,12 @@ using namespace Hantek;
7 ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, "dso5200x86", "DSO-5200", Hantek::ControlSpecification()) { 7 ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, "dso5200x86", "DSO-5200", Hantek::ControlSpecification()) {
8 specification.command.control.setOffset = CONTROL_SETOFFSET; 8 specification.command.control.setOffset = CONTROL_SETOFFSET;
9 specification.command.control.setRelays = CONTROL_SETRELAYS; 9 specification.command.control.setRelays = CONTROL_SETRELAYS;
10 - specification.command.bulk.setGain = BULK_SETGAIN;  
11 - specification.command.bulk.setRecordLength = BULK_DSETBUFFER;  
12 - specification.command.bulk.setChannels = BULK_ESETTRIGGERORSAMPLERATE;  
13 - specification.command.bulk.setSamplerate = BULK_CSETTRIGGERORSAMPLERATE;  
14 - specification.command.bulk.setTrigger = BULK_ESETTRIGGERORSAMPLERATE;  
15 - specification.command.bulk.setPretrigger = BULK_ESETTRIGGERORSAMPLERATE; 10 + specification.command.bulk.setGain = BulkCode::SETGAIN;
  11 + specification.command.bulk.setRecordLength = BulkCode::DSETBUFFER;
  12 + specification.command.bulk.setChannels = BulkCode::ESETTRIGGERORSAMPLERATE;
  13 + specification.command.bulk.setSamplerate = BulkCode::CSETTRIGGERORSAMPLERATE;
  14 + specification.command.bulk.setTrigger = BulkCode::ESETTRIGGERORSAMPLERATE;
  15 + specification.command.bulk.setPretrigger = BulkCode::ESETTRIGGERORSAMPLERATE;
16 // specification.command.values.voltageLimits = VALUE_ETSCORRECTION; 16 // specification.command.values.voltageLimits = VALUE_ETSCORRECTION;
17 17
18 specification.samplerate.single.base = 100e6; 18 specification.samplerate.single.base = 100e6;
@@ -24,22 +24,23 @@ ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, &quot;dso @@ -24,22 +24,23 @@ ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, &quot;dso
24 specification.samplerate.multi.maxDownsampler = 131072; 24 specification.samplerate.multi.maxDownsampler = 131072;
25 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480, 28672}; 25 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480, 28672};
26 specification.bufferDividers = { 1000 , 1 , 1 }; 26 specification.bufferDividers = { 1000 , 1 , 1 };
27 - specification.gainSteps = { 0.16 , 0.40 , 0.80 , 1.60 , 4.00 , 8.0 , 16.0 , 40.0 , 80.0 };  
28 /// \todo Use calibration data to get the DSO-5200(A) sample ranges 27 /// \todo Use calibration data to get the DSO-5200(A) sample ranges
29 specification.voltageLimit[0] = { 368 , 454 , 908 , 368 , 454 , 908 , 368 , 454 , 908 }; 28 specification.voltageLimit[0] = { 368 , 454 , 908 , 368 , 454 , 908 , 368 , 454 , 908 };
30 specification.voltageLimit[1] = { 368 , 454 , 908 , 368 , 454 , 908 , 368 , 454 , 908 }; 29 specification.voltageLimit[1] = { 368 , 454 , 908 , 368 , 454 , 908 , 368 , 454 , 908 };
31 - specification.gainIndex = { 1 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 0 }; 30 + specification.gain = { {1,0.16} , {0,0.40} , {0,0.80} , {1,1.60} ,
  31 + {0,4.00} , {0,8.00} , {1,16.0} , {0,40.0} , {0,80.0} };
32 specification.sampleSize = 10; 32 specification.sampleSize = 10;
  33 + specification.specialTriggerChannels = {{"EXT", -2}, {"EXT/10", -3}}; // 3, 4
33 } 34 }
34 35
35 void ModelDSO5200::applyRequirements(HantekDsoControl *dsoControl) const { 36 void ModelDSO5200::applyRequirements(HantekDsoControl *dsoControl) const {
36 // Instantiate additional commands for the DSO-5200 37 // Instantiate additional commands for the DSO-5200
37 - dsoControl->command[BULK_CSETTRIGGERORSAMPLERATE] = new BulkSetSamplerate5200();  
38 - dsoControl->command[BULK_DSETBUFFER] = new BulkSetBuffer5200();  
39 - dsoControl->command[BULK_ESETTRIGGERORSAMPLERATE] = new BulkSetTrigger5200();  
40 - dsoControl->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true;  
41 - dsoControl->commandPending[BULK_DSETBUFFER] = true;  
42 - dsoControl->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; 38 + dsoControl->command[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE] = new BulkSetSamplerate5200();
  39 + dsoControl->command[(uint8_t)BulkCode::DSETBUFFER] = new BulkSetBuffer5200();
  40 + dsoControl->command[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = new BulkSetTrigger5200();
  41 + dsoControl->commandPending[(uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE] = true;
  42 + dsoControl->commandPending[(uint8_t)BulkCode::DSETBUFFER] = true;
  43 + dsoControl->commandPending[(uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE] = true;
43 44
44 dsoControl->controlPending[CONTROLINDEX_SETOFFSET] = true; 45 dsoControl->controlPending[CONTROLINDEX_SETOFFSET] = true;
45 dsoControl->controlPending[CONTROLINDEX_SETRELAYS] = true; 46 dsoControl->controlPending[CONTROLINDEX_SETRELAYS] = true;
openhantek/src/hantekdso/models/modelDSO6022.cpp
@@ -10,6 +10,7 @@ ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022, @@ -10,6 +10,7 @@ ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022,
10 // 6022BE do not support any bulk commands 10 // 6022BE do not support any bulk commands
11 specification.useControlNoBulk = true; 11 specification.useControlNoBulk = true;
12 specification.isSoftwareTriggerDevice = true; 12 specification.isSoftwareTriggerDevice = true;
  13 + specification.isFixedSamplerateDevice = true;
13 specification.supportsCaptureState = false; 14 specification.supportsCaptureState = false;
14 specification.supportsOffset = false; 15 specification.supportsOffset = false;
15 specification.supportsCouplingRelays = false; 16 specification.supportsCouplingRelays = false;
@@ -23,14 +24,14 @@ ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022, @@ -23,14 +24,14 @@ ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022,
23 specification.samplerate.multi.maxDownsampler = 10; 24 specification.samplerate.multi.maxDownsampler = 10;
24 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480}; 25 specification.samplerate.multi.recordLengths = {UINT_MAX, 20480};
25 specification.bufferDividers = { 1000 , 1 , 1 }; 26 specification.bufferDividers = { 1000 , 1 , 1 };
26 - specification.gainSteps = { 0.08 , 0.16 , 0.40 , 0.80 , 1.60 , 4.00 , 8.0 , 16.0 , 40.0 };  
27 // This data was based on testing and depends on Divider. 27 // This data was based on testing and depends on Divider.
28 specification.voltageLimit[0] = { 25 , 51 , 103 , 206 , 412 , 196 , 392 , 784 , 1000 }; 28 specification.voltageLimit[0] = { 25 , 51 , 103 , 206 , 412 , 196 , 392 , 784 , 1000 };
29 specification.voltageLimit[1] = { 25 , 51 , 103 , 206 , 412 , 196 , 392 , 784 , 1000 }; 29 specification.voltageLimit[1] = { 25 , 51 , 103 , 206 , 412 , 196 , 392 , 784 , 1000 };
30 // Divider. Tested and calculated results are different! 30 // Divider. Tested and calculated results are different!
31 - specification.gainDiv = { 10 , 10 , 10 , 10 , 10 , 2 , 2 , 2 , 1 };  
32 - specification.sampleSteps = { 1e5 , 2e5 , 5e5 , 1e6 , 2e6 , 4e6 , 8e6 , 16e6 , 24e6 , 48e6 };  
33 - specification.sampleDiv = { 10 , 20 , 50 , 1 , 2 , 4 , 8 , 16 , 24 , 48 }; 31 + specification.gain = { {10,0.08} , {10,0.16} , {10,0.40} , {10,0.80} ,
  32 + {10,1.60} , {2,4.00} , {2,8.00} , {2,16.00} , {1,40.00} };
  33 + specification.fixedSampleRates = { {10,1e5} , {20,2e5} , {50,5e5} , {1,1e6} , {2,2e6} , {4,4e6} , {8,8e6} ,
  34 + {16,16e6} , {24,24e6} , {48,48e6} };
34 specification.sampleSize = 8; 35 specification.sampleSize = 8;
35 } 36 }
36 37
openhantek/src/hantekprotocol/bulkStructs.cpp
@@ -9,13 +9,13 @@ namespace Hantek { @@ -9,13 +9,13 @@ namespace Hantek {
9 ////////////////////////////////////////////////////////////////////////////// 9 //////////////////////////////////////////////////////////////////////////////
10 // class BulkSetFilter 10 // class BulkSetFilter
11 /// \brief Sets the data array to the default values. 11 /// \brief Sets the data array to the default values.
12 -BulkSetFilter::BulkSetFilter() : DataArray<uint8_t>(8) { this->init(); } 12 +BulkSetFilter::BulkSetFilter() : BulkCommand(8) { this->init(); }
13 13
14 /// \brief Sets the FilterByte to the given value. 14 /// \brief Sets the FilterByte to the given value.
15 /// \param channel1 true if channel 1 is filtered. 15 /// \param channel1 true if channel 1 is filtered.
16 /// \param channel2 true if channel 2 is filtered. 16 /// \param channel2 true if channel 2 is filtered.
17 /// \param trigger true if trigger is filtered. 17 /// \param trigger true if trigger is filtered.
18 -BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : DataArray<uint8_t>(8) { 18 +BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : BulkCommand(8) {
19 this->init(); 19 this->init();
20 20
21 this->setChannel(0, channel1); 21 this->setChannel(0, channel1);
@@ -59,14 +59,14 @@ void BulkSetFilter::setTrigger(bool filtered) { @@ -59,14 +59,14 @@ void BulkSetFilter::setTrigger(bool filtered) {
59 59
60 /// \brief Initialize the array to the needed values. 60 /// \brief Initialize the array to the needed values.
61 void BulkSetFilter::init() { 61 void BulkSetFilter::init() {
62 - this->array[0] = BULK_SETFILTER; 62 + this->array[0] =(uint8_t) BulkCode::SETFILTER;
63 this->array[1] = 0x0f; 63 this->array[1] = 0x0f;
64 } 64 }
65 65
66 ////////////////////////////////////////////////////////////////////////////// 66 //////////////////////////////////////////////////////////////////////////////
67 // class BulkSetTriggerAndSamplerate 67 // class BulkSetTriggerAndSamplerate
68 /// \brief Sets the data array to the default values. 68 /// \brief Sets the data array to the default values.
69 -BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : DataArray<uint8_t>(12) { this->init(); } 69 +BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : BulkCommand(12) { this->init(); }
70 70
71 /// \brief Sets the data bytes to the specified values. 71 /// \brief Sets the data bytes to the specified values.
72 /// \param downsampler The Downsampler value. 72 /// \param downsampler The Downsampler value.
@@ -82,7 +82,7 @@ BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate(uint16_t downsampler, u @@ -82,7 +82,7 @@ BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate(uint16_t downsampler, u
82 uint8_t triggerSource, uint8_t recordLength, 82 uint8_t triggerSource, uint8_t recordLength,
83 uint8_t samplerateId, bool downsamplingMode, 83 uint8_t samplerateId, bool downsamplingMode,
84 uint8_t usedChannels, bool fastRate, uint8_t triggerSlope) 84 uint8_t usedChannels, bool fastRate, uint8_t triggerSlope)
85 - : DataArray<uint8_t>(12) { 85 + : BulkCommand(12) {
86 this->init(); 86 this->init();
87 87
88 this->setTriggerSource(triggerSource); 88 this->setTriggerSource(triggerSource);
@@ -196,37 +196,37 @@ void BulkSetTriggerAndSamplerate::setTriggerPosition(uint32_t position) { @@ -196,37 +196,37 @@ void BulkSetTriggerAndSamplerate::setTriggerPosition(uint32_t position) {
196 } 196 }
197 197
198 /// \brief Initialize the array to the needed values. 198 /// \brief Initialize the array to the needed values.
199 -void BulkSetTriggerAndSamplerate::init() { this->array[0] = BULK_SETTRIGGERANDSAMPLERATE; } 199 +void BulkSetTriggerAndSamplerate::init() { this->array[0] = (uint8_t) BulkCode::SETTRIGGERANDSAMPLERATE; }
200 200
201 ////////////////////////////////////////////////////////////////////////////// 201 //////////////////////////////////////////////////////////////////////////////
202 // class BulkForceTrigger 202 // class BulkForceTrigger
203 /// \brief Sets the data array to needed values. 203 /// \brief Sets the data array to needed values.
204 -BulkForceTrigger::BulkForceTrigger() : DataArray<uint8_t>(2) { this->array[0] = BULK_FORCETRIGGER; } 204 +BulkForceTrigger::BulkForceTrigger() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::FORCETRIGGER; }
205 205
206 ////////////////////////////////////////////////////////////////////////////// 206 //////////////////////////////////////////////////////////////////////////////
207 // class BulkCaptureStart 207 // class BulkCaptureStart
208 /// \brief Sets the data array to needed values. 208 /// \brief Sets the data array to needed values.
209 -BulkCaptureStart::BulkCaptureStart() : DataArray<uint8_t>(2) { this->array[0] = BULK_STARTSAMPLING; } 209 +BulkCaptureStart::BulkCaptureStart() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::STARTSAMPLING; }
210 210
211 ////////////////////////////////////////////////////////////////////////////// 211 //////////////////////////////////////////////////////////////////////////////
212 // class BulkTriggerEnabled 212 // class BulkTriggerEnabled
213 /// \brief Sets the data array to needed values. 213 /// \brief Sets the data array to needed values.
214 -BulkTriggerEnabled::BulkTriggerEnabled() : DataArray<uint8_t>(2) { this->array[0] = BULK_ENABLETRIGGER; } 214 +BulkTriggerEnabled::BulkTriggerEnabled() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::ENABLETRIGGER; }
215 215
216 ////////////////////////////////////////////////////////////////////////////// 216 //////////////////////////////////////////////////////////////////////////////
217 // class BulkGetData 217 // class BulkGetData
218 /// \brief Sets the data array to needed values. 218 /// \brief Sets the data array to needed values.
219 -BulkGetData::BulkGetData() : DataArray<uint8_t>(2) { this->array[0] = BULK_GETDATA; } 219 +BulkGetData::BulkGetData() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::GETDATA; }
220 220
221 ////////////////////////////////////////////////////////////////////////////// 221 //////////////////////////////////////////////////////////////////////////////
222 // class BulkGetCaptureState 222 // class BulkGetCaptureState
223 /// \brief Sets the data array to needed values. 223 /// \brief Sets the data array to needed values.
224 -BulkGetCaptureState::BulkGetCaptureState() : DataArray<uint8_t>(2) { this->array[0] = BULK_GETCAPTURESTATE; } 224 +BulkGetCaptureState::BulkGetCaptureState() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::GETCAPTURESTATE; }
225 225
226 ////////////////////////////////////////////////////////////////////////////// 226 //////////////////////////////////////////////////////////////////////////////
227 // class BulkResponseGetCaptureState 227 // class BulkResponseGetCaptureState
228 /// \brief Initializes the array. 228 /// \brief Initializes the array.
229 -BulkResponseGetCaptureState::BulkResponseGetCaptureState() : DataArray<uint8_t>(512) {} 229 +BulkResponseGetCaptureState::BulkResponseGetCaptureState() : BulkCommand(512) {}
230 230
231 /// \brief Gets the capture state. 231 /// \brief Gets the capture state.
232 /// \return The CaptureState of the oscilloscope. 232 /// \return The CaptureState of the oscilloscope.
@@ -241,12 +241,12 @@ unsigned int BulkResponseGetCaptureState::getTriggerPoint() { @@ -241,12 +241,12 @@ unsigned int BulkResponseGetCaptureState::getTriggerPoint() {
241 ////////////////////////////////////////////////////////////////////////////// 241 //////////////////////////////////////////////////////////////////////////////
242 // class BulkSetGain 242 // class BulkSetGain
243 /// \brief Sets the data array to needed values. 243 /// \brief Sets the data array to needed values.
244 -BulkSetGain::BulkSetGain() : DataArray<uint8_t>(8) { this->init(); } 244 +BulkSetGain::BulkSetGain() : BulkCommand(8) { this->init(); }
245 245
246 /// \brief Sets the gain to the given values. 246 /// \brief Sets the gain to the given values.
247 /// \param channel1 The gain value for channel 1. 247 /// \param channel1 The gain value for channel 1.
248 /// \param channel2 The gain value for channel 2. 248 /// \param channel2 The gain value for channel 2.
249 -BulkSetGain::BulkSetGain(uint8_t channel1, uint8_t channel2) : DataArray<uint8_t>(8) { 249 +BulkSetGain::BulkSetGain(uint8_t channel1, uint8_t channel2) : BulkCommand(8) {
250 this->init(); 250 this->init();
251 251
252 this->setGain(0, channel1); 252 this->setGain(0, channel1);
@@ -276,16 +276,16 @@ void BulkSetGain::setGain(unsigned int channel, uint8_t value) { @@ -276,16 +276,16 @@ void BulkSetGain::setGain(unsigned int channel, uint8_t value) {
276 } 276 }
277 277
278 /// \brief Initialize the array to the needed values. 278 /// \brief Initialize the array to the needed values.
279 -void BulkSetGain::init() { this->array[0] = BULK_SETGAIN; } 279 +void BulkSetGain::init() { this->array[0] = (uint8_t)BulkCode::SETGAIN; }
280 280
281 ////////////////////////////////////////////////////////////////////////////// 281 //////////////////////////////////////////////////////////////////////////////
282 // class BulkSetLogicalData 282 // class BulkSetLogicalData
283 /// \brief Sets the data array to needed values. 283 /// \brief Sets the data array to needed values.
284 -BulkSetLogicalData::BulkSetLogicalData() : DataArray<uint8_t>(8) { this->init(); } 284 +BulkSetLogicalData::BulkSetLogicalData() : BulkCommand(8) { this->init(); }
285 285
286 /// \brief Sets the data to the given value. 286 /// \brief Sets the data to the given value.
287 /// \param data The data byte. 287 /// \param data The data byte.
288 -BulkSetLogicalData::BulkSetLogicalData(uint8_t data) : DataArray<uint8_t>(8) { 288 +BulkSetLogicalData::BulkSetLogicalData(uint8_t data) : BulkCommand(8) {
289 this->init(); 289 this->init();
290 290
291 this->setData(data); 291 this->setData(data);
@@ -300,21 +300,21 @@ uint8_t BulkSetLogicalData::getData() { return this-&gt;array[2]; } @@ -300,21 +300,21 @@ uint8_t BulkSetLogicalData::getData() { return this-&gt;array[2]; }
300 void BulkSetLogicalData::setData(uint8_t data) { this->array[2] = data; } 300 void BulkSetLogicalData::setData(uint8_t data) { this->array[2] = data; }
301 301
302 /// \brief Initialize the array to the needed values. 302 /// \brief Initialize the array to the needed values.
303 -void BulkSetLogicalData::init() { this->array[0] = BULK_SETLOGICALDATA; } 303 +void BulkSetLogicalData::init() { this->array[0] = (uint8_t)BulkCode::SETLOGICALDATA; }
304 304
305 ////////////////////////////////////////////////////////////////////////////// 305 //////////////////////////////////////////////////////////////////////////////
306 // class BulkGetLogicalData 306 // class BulkGetLogicalData
307 /// \brief Sets the data array to needed values. 307 /// \brief Sets the data array to needed values.
308 -BulkGetLogicalData::BulkGetLogicalData() : DataArray<uint8_t>(2) { this->array[0] = BULK_GETLOGICALDATA; } 308 +BulkGetLogicalData::BulkGetLogicalData() : BulkCommand(2) { this->array[0] = (uint8_t)BulkCode::GETLOGICALDATA; }
309 309
310 ////////////////////////////////////////////////////////////////////////////// 310 //////////////////////////////////////////////////////////////////////////////
311 // class BulkSetFilter2250 311 // class BulkSetFilter2250
312 /// \brief Sets the data array to needed values. 312 /// \brief Sets the data array to needed values.
313 -BulkSetChannels2250::BulkSetChannels2250() : DataArray<uint8_t>(4) { this->init(); } 313 +BulkSetChannels2250::BulkSetChannels2250() : BulkCommand(4) { this->init(); }
314 314
315 /// \brief Sets the used channels. 315 /// \brief Sets the used channels.
316 /// \param usedChannels The UsedChannels value. 316 /// \param usedChannels The UsedChannels value.
317 -BulkSetChannels2250::BulkSetChannels2250(uint8_t usedChannels) : DataArray<uint8_t>(4) { 317 +BulkSetChannels2250::BulkSetChannels2250(uint8_t usedChannels) : BulkCommand(4) {
318 this->init(); 318 this->init();
319 319
320 this->setUsedChannels(usedChannels); 320 this->setUsedChannels(usedChannels);
@@ -329,17 +329,17 @@ uint8_t BulkSetChannels2250::getUsedChannels() { return this-&gt;array[2]; } @@ -329,17 +329,17 @@ uint8_t BulkSetChannels2250::getUsedChannels() { return this-&gt;array[2]; }
329 void BulkSetChannels2250::setUsedChannels(uint8_t value) { this->array[2] = value; } 329 void BulkSetChannels2250::setUsedChannels(uint8_t value) { this->array[2] = value; }
330 330
331 /// \brief Initialize the array to the needed values. 331 /// \brief Initialize the array to the needed values.
332 -void BulkSetChannels2250::init() { this->array[0] = BULK_BSETCHANNELS; } 332 +void BulkSetChannels2250::init() { this->array[0] = (uint8_t)BulkCode::BSETCHANNELS; }
333 333
334 ////////////////////////////////////////////////////////////////////////////// 334 //////////////////////////////////////////////////////////////////////////////
335 // class BulkSetTrigger2250 335 // class BulkSetTrigger2250
336 /// \brief Sets the data array to needed values. 336 /// \brief Sets the data array to needed values.
337 -BulkSetTrigger2250::BulkSetTrigger2250() : DataArray<uint8_t>(8) { this->init(); } 337 +BulkSetTrigger2250::BulkSetTrigger2250() : BulkCommand(8) { this->init(); }
338 338
339 /// \brief Sets the used channels. 339 /// \brief Sets the used channels.
340 /// \param triggerSource The trigger source id (CTriggerBits). 340 /// \param triggerSource The trigger source id (CTriggerBits).
341 /// \param triggerSlope The triggerSlope value (CTriggerBits). 341 /// \param triggerSlope The triggerSlope value (CTriggerBits).
342 -BulkSetTrigger2250::BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope) : DataArray<uint8_t>(8) { 342 +BulkSetTrigger2250::BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope) : BulkCommand(8) {
343 this->init(); 343 this->init();
344 344
345 this->setTriggerSource(triggerSource); 345 this->setTriggerSource(triggerSource);
@@ -363,17 +363,17 @@ uint8_t BulkSetTrigger2250::getTriggerSlope() { return ((CTriggerBits *)&amp;(this-&gt; @@ -363,17 +363,17 @@ uint8_t BulkSetTrigger2250::getTriggerSlope() { return ((CTriggerBits *)&amp;(this-&gt;
363 void BulkSetTrigger2250::setTriggerSlope(uint8_t slope) { ((CTriggerBits *)&(this->array[2]))->triggerSlope = slope; } 363 void BulkSetTrigger2250::setTriggerSlope(uint8_t slope) { ((CTriggerBits *)&(this->array[2]))->triggerSlope = slope; }
364 364
365 /// \brief Initialize the array to the needed values. 365 /// \brief Initialize the array to the needed values.
366 -void BulkSetTrigger2250::init() { this->array[0] = BULK_CSETTRIGGERORSAMPLERATE; } 366 +void BulkSetTrigger2250::init() { this->array[0] = (uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE; }
367 367
368 ////////////////////////////////////////////////////////////////////////////// 368 //////////////////////////////////////////////////////////////////////////////
369 // class BulkSetSamplerate5200 369 // class BulkSetSamplerate5200
370 /// \brief Sets the data array to the default values. 370 /// \brief Sets the data array to the default values.
371 -BulkSetSamplerate5200::BulkSetSamplerate5200() : DataArray<uint8_t>(6) { this->init(); } 371 +BulkSetSamplerate5200::BulkSetSamplerate5200() : BulkCommand(6) { this->init(); }
372 372
373 /// \brief Sets the data bytes to the specified values. 373 /// \brief Sets the data bytes to the specified values.
374 /// \param samplerateSlow The SamplerateSlow value. 374 /// \param samplerateSlow The SamplerateSlow value.
375 /// \param samplerateFast The SamplerateFast value. 375 /// \param samplerateFast The SamplerateFast value.
376 -BulkSetSamplerate5200::BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast) : DataArray<uint8_t>(6) { 376 +BulkSetSamplerate5200::BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast) : BulkCommand(6) {
377 this->init(); 377 this->init();
378 378
379 this->setSamplerateFast(samplerateFast); 379 this->setSamplerateFast(samplerateFast);
@@ -402,16 +402,16 @@ void BulkSetSamplerate5200::setSamplerateSlow(uint16_t samplerate) { @@ -402,16 +402,16 @@ void BulkSetSamplerate5200::setSamplerateSlow(uint16_t samplerate) {
402 } 402 }
403 403
404 /// \brief Initialize the array to the needed values. 404 /// \brief Initialize the array to the needed values.
405 -void BulkSetSamplerate5200::init() { this->array[0] = BULK_CSETTRIGGERORSAMPLERATE; } 405 +void BulkSetSamplerate5200::init() { this->array[0] = (uint8_t)BulkCode::CSETTRIGGERORSAMPLERATE; }
406 406
407 ////////////////////////////////////////////////////////////////////////////// 407 //////////////////////////////////////////////////////////////////////////////
408 // class BulkSetBuffer2250 408 // class BulkSetBuffer2250
409 /// \brief Sets the data array to the default values. 409 /// \brief Sets the data array to the default values.
410 -BulkSetRecordLength2250::BulkSetRecordLength2250() : DataArray<uint8_t>(4) { this->init(); } 410 +BulkSetRecordLength2250::BulkSetRecordLength2250() : BulkCommand(4) { this->init(); }
411 411
412 /// \brief Sets the data bytes to the specified values. 412 /// \brief Sets the data bytes to the specified values.
413 /// \param recordLength The ::RecordLengthId value. 413 /// \param recordLength The ::RecordLengthId value.
414 -BulkSetRecordLength2250::BulkSetRecordLength2250(uint8_t recordLength) : DataArray<uint8_t>(4) { 414 +BulkSetRecordLength2250::BulkSetRecordLength2250(uint8_t recordLength) : BulkCommand(4) {
415 this->init(); 415 this->init();
416 416
417 this->setRecordLength(recordLength); 417 this->setRecordLength(recordLength);
@@ -426,12 +426,12 @@ uint8_t BulkSetRecordLength2250::getRecordLength() { return this-&gt;array[2]; } @@ -426,12 +426,12 @@ uint8_t BulkSetRecordLength2250::getRecordLength() { return this-&gt;array[2]; }
426 void BulkSetRecordLength2250::setRecordLength(uint8_t value) { this->array[2] = value; } 426 void BulkSetRecordLength2250::setRecordLength(uint8_t value) { this->array[2] = value; }
427 427
428 /// \brief Initialize the array to the needed values. 428 /// \brief Initialize the array to the needed values.
429 -void BulkSetRecordLength2250::init() { this->array[0] = BULK_DSETBUFFER; } 429 +void BulkSetRecordLength2250::init() { this->array[0] = (uint8_t)BulkCode::DSETBUFFER; }
430 430
431 ////////////////////////////////////////////////////////////////////////////// 431 //////////////////////////////////////////////////////////////////////////////
432 // class BulkSetBuffer5200 432 // class BulkSetBuffer5200
433 /// \brief Sets the data array to the default values. 433 /// \brief Sets the data array to the default values.
434 -BulkSetBuffer5200::BulkSetBuffer5200() : DataArray<uint8_t>(10) { this->init(); } 434 +BulkSetBuffer5200::BulkSetBuffer5200() : BulkCommand(10) { this->init(); }
435 435
436 /// \brief Sets the data bytes to the specified values. 436 /// \brief Sets the data bytes to the specified values.
437 /// \param triggerPositionPre The TriggerPositionPre value. 437 /// \param triggerPositionPre The TriggerPositionPre value.
@@ -441,7 +441,7 @@ BulkSetBuffer5200::BulkSetBuffer5200() : DataArray&lt;uint8_t&gt;(10) { this-&gt;init(); @@ -441,7 +441,7 @@ BulkSetBuffer5200::BulkSetBuffer5200() : DataArray&lt;uint8_t&gt;(10) { this-&gt;init();
441 /// \param recordLength The ::RecordLengthId value. 441 /// \param recordLength The ::RecordLengthId value.
442 BulkSetBuffer5200::BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, DTriggerPositionUsed usedPre, 442 BulkSetBuffer5200::BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, DTriggerPositionUsed usedPre,
443 DTriggerPositionUsed usedPost, uint8_t recordLength) 443 DTriggerPositionUsed usedPost, uint8_t recordLength)
444 - : DataArray<uint8_t>(10) { 444 + : BulkCommand(10) {
445 this->init(); 445 this->init();
446 446
447 this->setTriggerPositionPre(triggerPositionPre); 447 this->setTriggerPositionPre(triggerPositionPre);
@@ -503,7 +503,7 @@ void BulkSetBuffer5200::setRecordLength(uint8_t value) { ((DBufferBits *)&amp;(this- @@ -503,7 +503,7 @@ void BulkSetBuffer5200::setRecordLength(uint8_t value) { ((DBufferBits *)&amp;(this-
503 503
504 /// \brief Initialize the array to the needed values. 504 /// \brief Initialize the array to the needed values.
505 void BulkSetBuffer5200::init() { 505 void BulkSetBuffer5200::init() {
506 - this->array[0] = BULK_DSETBUFFER; 506 + this->array[0] = (uint8_t)BulkCode::DSETBUFFER;
507 this->array[5] = 0xff; 507 this->array[5] = 0xff;
508 this->array[9] = 0xff; 508 this->array[9] = 0xff;
509 } 509 }
@@ -511,14 +511,14 @@ void BulkSetBuffer5200::init() { @@ -511,14 +511,14 @@ void BulkSetBuffer5200::init() {
511 ////////////////////////////////////////////////////////////////////////////// 511 //////////////////////////////////////////////////////////////////////////////
512 // class BulkSetSamplerate2250 512 // class BulkSetSamplerate2250
513 /// \brief Sets the data array to the default values. 513 /// \brief Sets the data array to the default values.
514 -BulkSetSamplerate2250::BulkSetSamplerate2250() : DataArray<uint8_t>(8) { this->init(); } 514 +BulkSetSamplerate2250::BulkSetSamplerate2250() : BulkCommand(8) { this->init(); }
515 515
516 /// \brief Sets the data bytes to the specified values. 516 /// \brief Sets the data bytes to the specified values.
517 /// \param fastRate The fastRate state (ESamplerateBits). 517 /// \param fastRate The fastRate state (ESamplerateBits).
518 /// \param downsampling The downsampling state (ESamplerateBits). 518 /// \param downsampling The downsampling state (ESamplerateBits).
519 /// \param samplerate The Samplerate value. 519 /// \param samplerate The Samplerate value.
520 BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, uint16_t samplerate) 520 BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, uint16_t samplerate)
521 - : DataArray<uint8_t>(8) { 521 + : BulkCommand(8) {
522 this->init(); 522 this->init();
523 523
524 this->setFastRate(fastRate); 524 this->setFastRate(fastRate);
@@ -558,12 +558,12 @@ void BulkSetSamplerate2250::setSamplerate(uint16_t samplerate) { @@ -558,12 +558,12 @@ void BulkSetSamplerate2250::setSamplerate(uint16_t samplerate) {
558 } 558 }
559 559
560 /// \brief Initialize the array to the needed values. 560 /// \brief Initialize the array to the needed values.
561 -void BulkSetSamplerate2250::init() { this->array[0] = BULK_ESETTRIGGERORSAMPLERATE; } 561 +void BulkSetSamplerate2250::init() { this->array[0] = (uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE; }
562 562
563 ////////////////////////////////////////////////////////////////////////////// 563 //////////////////////////////////////////////////////////////////////////////
564 // class BulkSetTrigger5200 564 // class BulkSetTrigger5200
565 /// \brief Sets the data array to the default values. 565 /// \brief Sets the data array to the default values.
566 -BulkSetTrigger5200::BulkSetTrigger5200() : DataArray<uint8_t>(8) { this->init(); } 566 +BulkSetTrigger5200::BulkSetTrigger5200() : BulkCommand(8) { this->init(); }
567 567
568 /// \brief Sets the data bytes to the specified values. 568 /// \brief Sets the data bytes to the specified values.
569 /// \param triggerSource The trigger source id. 569 /// \param triggerSource The trigger source id.
@@ -573,7 +573,7 @@ BulkSetTrigger5200::BulkSetTrigger5200() : DataArray&lt;uint8_t&gt;(8) { this-&gt;init(); @@ -573,7 +573,7 @@ BulkSetTrigger5200::BulkSetTrigger5200() : DataArray&lt;uint8_t&gt;(8) { this-&gt;init();
573 /// \param triggerPulse The triggerPulse value. 573 /// \param triggerPulse The triggerPulse value.
574 BulkSetTrigger5200::BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate, uint8_t triggerSlope, 574 BulkSetTrigger5200::BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate, uint8_t triggerSlope,
575 uint8_t triggerPulse) 575 uint8_t triggerPulse)
576 - : DataArray<uint8_t>(8) { 576 + : BulkCommand(8) {
577 this->init(); 577 this->init();
578 578
579 this->setTriggerSource(triggerSource); 579 this->setTriggerSource(triggerSource);
@@ -625,21 +625,21 @@ void BulkSetTrigger5200::setTriggerPulse(bool pulse) { ((ETsrBits *)&amp;(this-&gt;arra @@ -625,21 +625,21 @@ void BulkSetTrigger5200::setTriggerPulse(bool pulse) { ((ETsrBits *)&amp;(this-&gt;arra
625 625
626 /// \brief Initialize the array to the needed values. 626 /// \brief Initialize the array to the needed values.
627 void BulkSetTrigger5200::init() { 627 void BulkSetTrigger5200::init() {
628 - this->array[0] = BULK_ESETTRIGGERORSAMPLERATE; 628 + this->array[0] = (uint8_t)BulkCode::ESETTRIGGERORSAMPLERATE;
629 this->array[4] = 0x02; 629 this->array[4] = 0x02;
630 } 630 }
631 631
632 ////////////////////////////////////////////////////////////////////////////// 632 //////////////////////////////////////////////////////////////////////////////
633 /// \class BulkSetBuffer2250 hantek/types.h 633 /// \class BulkSetBuffer2250 hantek/types.h
634 -/// \brief The DSO-2250 BULK_FSETBUFFER builder. 634 +/// \brief The DSO-2250 BulkCode::FSETBUFFER builder.
635 /// \brief Sets the data array to the default values. 635 /// \brief Sets the data array to the default values.
636 -BulkSetBuffer2250::BulkSetBuffer2250() : DataArray<uint8_t>(10) { this->init(); } 636 +BulkSetBuffer2250::BulkSetBuffer2250() : BulkCommand(10) { this->init(); }
637 637
638 /// \brief Sets the data bytes to the specified values. 638 /// \brief Sets the data bytes to the specified values.
639 /// \param triggerPositionPre The TriggerPositionPre value. 639 /// \param triggerPositionPre The TriggerPositionPre value.
640 /// \param triggerPositionPost The TriggerPositionPost value. 640 /// \param triggerPositionPost The TriggerPositionPost value.
641 BulkSetBuffer2250::BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost) 641 BulkSetBuffer2250::BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost)
642 - : DataArray<uint8_t>(12) { 642 + : BulkCommand(12) {
643 this->init(); 643 this->init();
644 644
645 this->setTriggerPositionPre(triggerPositionPre); 645 this->setTriggerPositionPre(triggerPositionPre);
@@ -675,5 +675,5 @@ void BulkSetBuffer2250::setTriggerPositionPre(uint32_t position) { @@ -675,5 +675,5 @@ void BulkSetBuffer2250::setTriggerPositionPre(uint32_t position) {
675 } 675 }
676 676
677 /// \brief Initialize the array to the needed values. 677 /// \brief Initialize the array to the needed values.
678 -void BulkSetBuffer2250::init() { this->array[0] = BULK_FSETBUFFER; } 678 +void BulkSetBuffer2250::init() { this->array[0] = (uint8_t)BulkCode::FSETBUFFER; }
679 } 679 }
openhantek/src/hantekprotocol/bulkStructs.h
@@ -13,10 +13,15 @@ @@ -13,10 +13,15 @@
13 13
14 namespace Hantek { 14 namespace Hantek {
15 15
  16 +class BulkCommand : public DataArray<uint8_t> {
  17 +protected:
  18 + BulkCommand(unsigned size): DataArray<uint8_t>(size) {}
  19 +};
  20 +
16 ////////////////////////////////////////////////////////////////////////////// 21 //////////////////////////////////////////////////////////////////////////////
17 /// \class BulkSetFilter hantek/types.h 22 /// \class BulkSetFilter hantek/types.h
18 -/// \brief The BULK_SETFILTER builder.  
19 -class BulkSetFilter : public DataArray<uint8_t> { 23 +/// \brief The BULK::SETFILTER builder.
  24 +class BulkSetFilter : public BulkCommand {
20 public: 25 public:
21 BulkSetFilter(); 26 BulkSetFilter();
22 BulkSetFilter(bool channel1, bool channel2, bool trigger); 27 BulkSetFilter(bool channel1, bool channel2, bool trigger);
@@ -32,8 +37,8 @@ class BulkSetFilter : public DataArray&lt;uint8_t&gt; { @@ -32,8 +37,8 @@ class BulkSetFilter : public DataArray&lt;uint8_t&gt; {
32 37
33 ////////////////////////////////////////////////////////////////////////////// 38 //////////////////////////////////////////////////////////////////////////////
34 /// \class BulkSetTriggerAndSamplerate hantek/types.h 39 /// \class BulkSetTriggerAndSamplerate hantek/types.h
35 -/// \brief The BULK_SETTRIGGERANDSAMPLERATE builder.  
36 -class BulkSetTriggerAndSamplerate : public DataArray<uint8_t> { 40 +/// \brief The BulkCode::SETTRIGGERANDSAMPLERATE builder.
  41 +class BulkSetTriggerAndSamplerate : public BulkCommand {
37 public: 42 public:
38 BulkSetTriggerAndSamplerate(); 43 BulkSetTriggerAndSamplerate();
39 BulkSetTriggerAndSamplerate(uint16_t downsampler, uint32_t triggerPosition, uint8_t triggerSource = 0, 44 BulkSetTriggerAndSamplerate(uint16_t downsampler, uint32_t triggerPosition, uint8_t triggerSource = 0,
@@ -65,8 +70,8 @@ class BulkSetTriggerAndSamplerate : public DataArray&lt;uint8_t&gt; { @@ -65,8 +70,8 @@ class BulkSetTriggerAndSamplerate : public DataArray&lt;uint8_t&gt; {
65 70
66 ////////////////////////////////////////////////////////////////////////////// 71 //////////////////////////////////////////////////////////////////////////////
67 /// \class BulkForceTrigger hantek/types.h 72 /// \class BulkForceTrigger hantek/types.h
68 -/// \brief The BULK_FORCETRIGGER builder.  
69 -class BulkForceTrigger : public DataArray<uint8_t> { 73 +/// \brief The BulkCode::FORCETRIGGER builder.
  74 +class BulkForceTrigger : public BulkCommand {
70 public: 75 public:
71 BulkForceTrigger(); 76 BulkForceTrigger();
72 }; 77 };
@@ -74,7 +79,7 @@ class BulkForceTrigger : public DataArray&lt;uint8_t&gt; { @@ -74,7 +79,7 @@ class BulkForceTrigger : public DataArray&lt;uint8_t&gt; {
74 ////////////////////////////////////////////////////////////////////////////// 79 //////////////////////////////////////////////////////////////////////////////
75 /// \class BulkCaptureStart hantek/types.h 80 /// \class BulkCaptureStart hantek/types.h
76 /// \brief The BULK_CAPTURESTART builder. 81 /// \brief The BULK_CAPTURESTART builder.
77 -class BulkCaptureStart : public DataArray<uint8_t> { 82 +class BulkCaptureStart : public BulkCommand {
78 public: 83 public:
79 BulkCaptureStart(); 84 BulkCaptureStart();
80 }; 85 };
@@ -82,31 +87,31 @@ class BulkCaptureStart : public DataArray&lt;uint8_t&gt; { @@ -82,31 +87,31 @@ class BulkCaptureStart : public DataArray&lt;uint8_t&gt; {
82 ////////////////////////////////////////////////////////////////////////////// 87 //////////////////////////////////////////////////////////////////////////////
83 /// \class BulkTriggerEnabled hantek/types.h 88 /// \class BulkTriggerEnabled hantek/types.h
84 /// \brief The BULK_TRIGGERENABLED builder. 89 /// \brief The BULK_TRIGGERENABLED builder.
85 -class BulkTriggerEnabled : public DataArray<uint8_t> { 90 +class BulkTriggerEnabled : public BulkCommand {
86 public: 91 public:
87 BulkTriggerEnabled(); 92 BulkTriggerEnabled();
88 }; 93 };
89 94
90 ////////////////////////////////////////////////////////////////////////////// 95 //////////////////////////////////////////////////////////////////////////////
91 /// \class BulkGetData hantek/types.h 96 /// \class BulkGetData hantek/types.h
92 -/// \brief The BULK_GETDATA builder.  
93 -class BulkGetData : public DataArray<uint8_t> { 97 +/// \brief The BulkCode::GETDATA builder.
  98 +class BulkGetData : public BulkCommand {
94 public: 99 public:
95 BulkGetData(); 100 BulkGetData();
96 }; 101 };
97 102
98 ////////////////////////////////////////////////////////////////////////////// 103 //////////////////////////////////////////////////////////////////////////////
99 /// \class BulkGetCaptureState hantek/types.h 104 /// \class BulkGetCaptureState hantek/types.h
100 -/// \brief The BULK_GETCAPTURESTATE builder.  
101 -class BulkGetCaptureState : public DataArray<uint8_t> { 105 +/// \brief The BulkCode::GETCAPTURESTATE builder.
  106 +class BulkGetCaptureState : public BulkCommand {
102 public: 107 public:
103 BulkGetCaptureState(); 108 BulkGetCaptureState();
104 }; 109 };
105 110
106 ////////////////////////////////////////////////////////////////////////////// 111 //////////////////////////////////////////////////////////////////////////////
107 /// \class BulkResponseGetCaptureState hantek/types.h 112 /// \class BulkResponseGetCaptureState hantek/types.h
108 -/// \brief The parser for the BULK_GETCAPTURESTATE response.  
109 -class BulkResponseGetCaptureState : public DataArray<uint8_t> { 113 +/// \brief The parser for the BulkCode::GETCAPTURESTATE response.
  114 +class BulkResponseGetCaptureState : public BulkCommand {
110 public: 115 public:
111 BulkResponseGetCaptureState(); 116 BulkResponseGetCaptureState();
112 117
@@ -116,8 +121,8 @@ class BulkResponseGetCaptureState : public DataArray&lt;uint8_t&gt; { @@ -116,8 +121,8 @@ class BulkResponseGetCaptureState : public DataArray&lt;uint8_t&gt; {
116 121
117 ////////////////////////////////////////////////////////////////////////////// 122 //////////////////////////////////////////////////////////////////////////////
118 /// \class BulkSetGain hantek/types.h 123 /// \class BulkSetGain hantek/types.h
119 -/// \brief The BULK_SETGAIN builder.  
120 -class BulkSetGain : public DataArray<uint8_t> { 124 +/// \brief The BulkCode::SETGAIN builder.
  125 +class BulkSetGain : public BulkCommand {
121 public: 126 public:
122 BulkSetGain(); 127 BulkSetGain();
123 BulkSetGain(uint8_t channel1, uint8_t channel2); 128 BulkSetGain(uint8_t channel1, uint8_t channel2);
@@ -131,8 +136,8 @@ class BulkSetGain : public DataArray&lt;uint8_t&gt; { @@ -131,8 +136,8 @@ class BulkSetGain : public DataArray&lt;uint8_t&gt; {
131 136
132 ////////////////////////////////////////////////////////////////////////////// 137 //////////////////////////////////////////////////////////////////////////////
133 /// \class BulkSetLogicalData hantek/types.h 138 /// \class BulkSetLogicalData hantek/types.h
134 -/// \brief The BULK_SETLOGICALDATA builder.  
135 -class BulkSetLogicalData : public DataArray<uint8_t> { 139 +/// \brief The BulkCode::SETLOGICALDATA builder.
  140 +class BulkSetLogicalData : public BulkCommand {
136 public: 141 public:
137 BulkSetLogicalData(); 142 BulkSetLogicalData();
138 BulkSetLogicalData(uint8_t data); 143 BulkSetLogicalData(uint8_t data);
@@ -146,8 +151,8 @@ class BulkSetLogicalData : public DataArray&lt;uint8_t&gt; { @@ -146,8 +151,8 @@ class BulkSetLogicalData : public DataArray&lt;uint8_t&gt; {
146 151
147 ////////////////////////////////////////////////////////////////////////////// 152 //////////////////////////////////////////////////////////////////////////////
148 /// \class BulkGetLogicalData hantek/types.h 153 /// \class BulkGetLogicalData hantek/types.h
149 -/// \brief The BULK_GETLOGICALDATA builder.  
150 -class BulkGetLogicalData : public DataArray<uint8_t> { 154 +/// \brief The BulkCode::GETLOGICALDATA builder.
  155 +class BulkGetLogicalData : public BulkCommand {
151 public: 156 public:
152 BulkGetLogicalData(); 157 BulkGetLogicalData();
153 }; 158 };
@@ -155,7 +160,7 @@ class BulkGetLogicalData : public DataArray&lt;uint8_t&gt; { @@ -155,7 +160,7 @@ class BulkGetLogicalData : public DataArray&lt;uint8_t&gt; {
155 ////////////////////////////////////////////////////////////////////////////// 160 //////////////////////////////////////////////////////////////////////////////
156 /// \class BulkSetChannels2250 hantek/types.h 161 /// \class BulkSetChannels2250 hantek/types.h
157 /// \brief The DSO-2250 BULK_BSETFILTER builder. 162 /// \brief The DSO-2250 BULK_BSETFILTER builder.
158 -class BulkSetChannels2250 : public DataArray<uint8_t> { 163 +class BulkSetChannels2250 : public BulkCommand {
159 public: 164 public:
160 BulkSetChannels2250(); 165 BulkSetChannels2250();
161 BulkSetChannels2250(uint8_t usedChannels); 166 BulkSetChannels2250(uint8_t usedChannels);
@@ -169,8 +174,8 @@ class BulkSetChannels2250 : public DataArray&lt;uint8_t&gt; { @@ -169,8 +174,8 @@ class BulkSetChannels2250 : public DataArray&lt;uint8_t&gt; {
169 174
170 ////////////////////////////////////////////////////////////////////////////// 175 //////////////////////////////////////////////////////////////////////////////
171 /// \class BulkSetTrigger2250 hantek/types.h 176 /// \class BulkSetTrigger2250 hantek/types.h
172 -/// \brief The DSO-2250 BULK_CSETTRIGGERORSAMPLERATE builder.  
173 -class BulkSetTrigger2250 : public DataArray<uint8_t> { 177 +/// \brief The DSO-2250 BulkCode::CSETTRIGGERORSAMPLERATE builder.
  178 +class BulkSetTrigger2250 : public BulkCommand {
174 public: 179 public:
175 BulkSetTrigger2250(); 180 BulkSetTrigger2250();
176 BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope); 181 BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope);
@@ -186,8 +191,8 @@ class BulkSetTrigger2250 : public DataArray&lt;uint8_t&gt; { @@ -186,8 +191,8 @@ class BulkSetTrigger2250 : public DataArray&lt;uint8_t&gt; {
186 191
187 ////////////////////////////////////////////////////////////////////////////// 192 //////////////////////////////////////////////////////////////////////////////
188 /// \class BulkSetSamplerate5200 hantek/types.h 193 /// \class BulkSetSamplerate5200 hantek/types.h
189 -/// \brief The DSO-5200/DSO-5200A BULK_CSETTRIGGERORSAMPLERATE builder.  
190 -class BulkSetSamplerate5200 : public DataArray<uint8_t> { 194 +/// \brief The DSO-5200/DSO-5200A BulkCode::CSETTRIGGERORSAMPLERATE builder.
  195 +class BulkSetSamplerate5200 : public BulkCommand {
191 public: 196 public:
192 BulkSetSamplerate5200(); 197 BulkSetSamplerate5200();
193 BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast); 198 BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast);
@@ -203,8 +208,8 @@ class BulkSetSamplerate5200 : public DataArray&lt;uint8_t&gt; { @@ -203,8 +208,8 @@ class BulkSetSamplerate5200 : public DataArray&lt;uint8_t&gt; {
203 208
204 ////////////////////////////////////////////////////////////////////////////// 209 //////////////////////////////////////////////////////////////////////////////
205 /// \class BulkSetRecordLength2250 hantek/types.h 210 /// \class BulkSetRecordLength2250 hantek/types.h
206 -/// \brief The DSO-2250 BULK_DSETBUFFER builder.  
207 -class BulkSetRecordLength2250 : public DataArray<uint8_t> { 211 +/// \brief The DSO-2250 BulkCode::DSETBUFFER builder.
  212 +class BulkSetRecordLength2250 : public BulkCommand {
208 public: 213 public:
209 BulkSetRecordLength2250(); 214 BulkSetRecordLength2250();
210 BulkSetRecordLength2250(uint8_t recordLength); 215 BulkSetRecordLength2250(uint8_t recordLength);
@@ -218,8 +223,8 @@ class BulkSetRecordLength2250 : public DataArray&lt;uint8_t&gt; { @@ -218,8 +223,8 @@ class BulkSetRecordLength2250 : public DataArray&lt;uint8_t&gt; {
218 223
219 ////////////////////////////////////////////////////////////////////////////// 224 //////////////////////////////////////////////////////////////////////////////
220 /// \class BulkSetBuffer5200 hantek/types.h 225 /// \class BulkSetBuffer5200 hantek/types.h
221 -/// \brief The DSO-5200/DSO-5200A BULK_DSETBUFFER builder.  
222 -class BulkSetBuffer5200 : public DataArray<uint8_t> { 226 +/// \brief The DSO-5200/DSO-5200A BulkCode::DSETBUFFER builder.
  227 +class BulkSetBuffer5200 : public BulkCommand {
223 public: 228 public:
224 BulkSetBuffer5200(); 229 BulkSetBuffer5200();
225 BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, DTriggerPositionUsed usedPre = DTriggerPositionUsed::DTRIGGERPOSITION_OFF, 230 BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, DTriggerPositionUsed usedPre = DTriggerPositionUsed::DTRIGGERPOSITION_OFF,
@@ -242,8 +247,8 @@ class BulkSetBuffer5200 : public DataArray&lt;uint8_t&gt; { @@ -242,8 +247,8 @@ class BulkSetBuffer5200 : public DataArray&lt;uint8_t&gt; {
242 247
243 ////////////////////////////////////////////////////////////////////////////// 248 //////////////////////////////////////////////////////////////////////////////
244 /// \class BulkSetSamplerate2250 hantek/types.h 249 /// \class BulkSetSamplerate2250 hantek/types.h
245 -/// \brief The DSO-2250 BULK_ESETTRIGGERORSAMPLERATE builder.  
246 -class BulkSetSamplerate2250 : public DataArray<uint8_t> { 250 +/// \brief The DSO-2250 BulkCode::ESETTRIGGERORSAMPLERATE builder.
  251 +class BulkSetSamplerate2250 : public BulkCommand {
247 public: 252 public:
248 BulkSetSamplerate2250(); 253 BulkSetSamplerate2250();
249 BulkSetSamplerate2250(bool fastRate, bool downsampling = false, uint16_t samplerate = 0); 254 BulkSetSamplerate2250(bool fastRate, bool downsampling = false, uint16_t samplerate = 0);
@@ -261,8 +266,8 @@ class BulkSetSamplerate2250 : public DataArray&lt;uint8_t&gt; { @@ -261,8 +266,8 @@ class BulkSetSamplerate2250 : public DataArray&lt;uint8_t&gt; {
261 266
262 ////////////////////////////////////////////////////////////////////////////// 267 //////////////////////////////////////////////////////////////////////////////
263 /// \class BulkSetTrigger5200 hantek/types.h 268 /// \class BulkSetTrigger5200 hantek/types.h
264 -/// \brief The DSO-5200/DSO-5200A BULK_ESETTRIGGERORSAMPLERATE builder.  
265 -class BulkSetTrigger5200 : public DataArray<uint8_t> { 269 +/// \brief The DSO-5200/DSO-5200A BulkCode::ESETTRIGGERORSAMPLERATE builder.
  270 +class BulkSetTrigger5200 : public BulkCommand {
266 public: 271 public:
267 BulkSetTrigger5200(); 272 BulkSetTrigger5200();
268 BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate = false, uint8_t triggerSlope = 0, 273 BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate = false, uint8_t triggerSlope = 0,
@@ -285,8 +290,8 @@ class BulkSetTrigger5200 : public DataArray&lt;uint8_t&gt; { @@ -285,8 +290,8 @@ class BulkSetTrigger5200 : public DataArray&lt;uint8_t&gt; {
285 290
286 ////////////////////////////////////////////////////////////////////////////// 291 //////////////////////////////////////////////////////////////////////////////
287 /// \class BulkSetBuffer2250 hantek/types.h 292 /// \class BulkSetBuffer2250 hantek/types.h
288 -/// \brief The DSO-2250 BULK_FSETBUFFER builder.  
289 -class BulkSetBuffer2250 : public DataArray<uint8_t> { 293 +/// \brief The DSO-2250 BulkCode::FSETBUFFER builder.
  294 +class BulkSetBuffer2250 : public BulkCommand {
290 public: 295 public:
291 BulkSetBuffer2250(); 296 BulkSetBuffer2250();
292 BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost); 297 BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost);
openhantek/src/hantekprotocol/bulkcode.h
1 #pragma once 1 #pragma once
2 2
  3 +#include <inttypes.h>
  4 +
3 namespace Hantek { 5 namespace Hantek {
4 6
5 ////////////////////////////////////////////////////////////////////////////// 7 //////////////////////////////////////////////////////////////////////////////
@@ -7,7 +9,7 @@ namespace Hantek { @@ -7,7 +9,7 @@ namespace Hantek {
7 /// \brief All supported bulk commands. 9 /// \brief All supported bulk commands.
8 /// Indicies given in square brackets specify byte numbers in little endian 10 /// Indicies given in square brackets specify byte numbers in little endian
9 /// format. 11 /// format.
10 -enum BulkCode { 12 +enum class BulkCode : uint8_t {
11 /// BulkSetFilter [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO5200, 13 /// BulkSetFilter [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO5200,
12 /// ::MODEL_DSO5200A</em>] 14 /// ::MODEL_DSO5200A</em>]
13 /// <p> 15 /// <p>
@@ -29,7 +31,7 @@ enum BulkCode { @@ -29,7 +31,7 @@ enum BulkCode {
29 /// This command is used by the official %Hantek software, but doesn't seem 31 /// This command is used by the official %Hantek software, but doesn't seem
30 /// to be used by the device. 32 /// to be used by the device.
31 /// <p><br /></p> 33 /// <p><br /></p>
32 - BULK_SETFILTER, 34 + SETFILTER,
33 35
34 /// BulkSetTriggerAndSamplerate [<em>::MODEL_DSO2090, ::MODEL_DSO2150</em>] 36 /// BulkSetTriggerAndSamplerate [<em>::MODEL_DSO2090, ::MODEL_DSO2150</em>]
35 /// <p> 37 /// <p>
@@ -86,7 +88,7 @@ enum BulkCode { @@ -86,7 +88,7 @@ enum BulkCode {
86 /// using the large buffer. 88 /// using the large buffer.
87 /// </p> 89 /// </p>
88 /// <p><br /></p> 90 /// <p><br /></p>
89 - BULK_SETTRIGGERANDSAMPLERATE, 91 + SETTRIGGERANDSAMPLERATE,
90 92
91 /// BulkForceTrigger [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, 93 /// BulkForceTrigger [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250,
92 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] 94 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>]
@@ -100,7 +102,7 @@ enum BulkCode { @@ -100,7 +102,7 @@ enum BulkCode {
100 /// </table> 102 /// </table>
101 /// </p> 103 /// </p>
102 /// <p><br /></p> 104 /// <p><br /></p>
103 - BULK_FORCETRIGGER, 105 + FORCETRIGGER,
104 106
105 /// BulkCaptureStart [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, 107 /// BulkCaptureStart [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250,
106 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] 108 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>]
@@ -114,7 +116,7 @@ enum BulkCode { @@ -114,7 +116,7 @@ enum BulkCode {
114 /// </table> 116 /// </table>
115 /// </p> 117 /// </p>
116 /// <p><br /></p> 118 /// <p><br /></p>
117 - BULK_STARTSAMPLING, 119 + STARTSAMPLING,
118 120
119 /// BulkTriggerEnabled [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, 121 /// BulkTriggerEnabled [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250,
120 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] 122 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>]
@@ -128,7 +130,7 @@ enum BulkCode { @@ -128,7 +130,7 @@ enum BulkCode {
128 /// </table> 130 /// </table>
129 /// </p> 131 /// </p>
130 /// <p><br /></p> 132 /// <p><br /></p>
131 - BULK_ENABLETRIGGER, 133 + ENABLETRIGGER,
132 134
133 /// BulkGetData [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, 135 /// BulkGetData [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250,
134 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] 136 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>]
@@ -179,7 +181,7 @@ enum BulkCode { @@ -179,7 +181,7 @@ enum BulkCode {
179 /// </table> 181 /// </table>
180 /// </p> 182 /// </p>
181 /// <p><br /></p> 183 /// <p><br /></p>
182 - BULK_GETDATA, 184 + GETDATA,
183 185
184 /// BulkGetCaptureState [<em>::MODEL_DSO2090, ::MODEL_DSO2150, 186 /// BulkGetCaptureState [<em>::MODEL_DSO2090, ::MODEL_DSO2150,
185 /// ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] 187 /// ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>]
@@ -208,7 +210,7 @@ enum BulkCode { @@ -208,7 +210,7 @@ enum BulkCode {
208 /// </table> 210 /// </table>
209 /// </p> 211 /// </p>
210 /// <p><br /></p> 212 /// <p><br /></p>
211 - BULK_GETCAPTURESTATE, 213 + GETCAPTURESTATE,
212 214
213 /// BulkSetGain [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, 215 /// BulkSetGain [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250,
214 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] 216 /// ::MODEL_DSO5200, ::MODEL_DSO5200A</em>]
@@ -229,7 +231,7 @@ enum BulkCode { @@ -229,7 +231,7 @@ enum BulkCode {
229 /// It is usually used in combination with ::CONTROL_SETRELAYS. 231 /// It is usually used in combination with ::CONTROL_SETRELAYS.
230 /// </p> 232 /// </p>
231 /// <p><br /></p> 233 /// <p><br /></p>
232 - BULK_SETGAIN, 234 + SETGAIN,
233 235
234 /// BulkSetLogicalData [<em></em>] 236 /// BulkSetLogicalData [<em></em>]
235 /// <p> 237 /// <p>
@@ -249,7 +251,7 @@ enum BulkCode { @@ -249,7 +251,7 @@ enum BulkCode {
249 /// </table> 251 /// </table>
250 /// </p> 252 /// </p>
251 /// <p><br /></p> 253 /// <p><br /></p>
252 - BULK_SETLOGICALDATA, 254 + SETLOGICALDATA,
253 255
254 /// BulkGetLogicalData [<em></em>] 256 /// BulkGetLogicalData [<em></em>]
255 /// <p> 257 /// <p>
@@ -273,7 +275,7 @@ enum BulkCode { @@ -273,7 +275,7 @@ enum BulkCode {
273 /// </table> 275 /// </table>
274 /// </p> 276 /// </p>
275 /// <p><br /></p> 277 /// <p><br /></p>
276 - BULK_GETLOGICALDATA, 278 + GETLOGICALDATA,
277 279
278 /// [<em></em>] 280 /// [<em></em>]
279 /// <p> 281 /// <p>
@@ -286,7 +288,7 @@ enum BulkCode { @@ -286,7 +288,7 @@ enum BulkCode {
286 /// </table> 288 /// </table>
287 /// </p> 289 /// </p>
288 /// <p><br /></p> 290 /// <p><br /></p>
289 - BULK_AUNKNOWN, 291 + AUNKNOWN,
290 292
291 /// BulkSetChannels2250 [<em>::MODEL_DSO2250</em>] 293 /// BulkSetChannels2250 [<em>::MODEL_DSO2250</em>]
292 /// <p> 294 /// <p>
@@ -301,7 +303,7 @@ enum BulkCode { @@ -301,7 +303,7 @@ enum BulkCode {
301 /// </table> 303 /// </table>
302 /// </p> 304 /// </p>
303 /// <p><br /></p> 305 /// <p><br /></p>
304 - BULK_BSETCHANNELS, 306 + BSETCHANNELS,
305 307
306 /// BulkSetTrigger2250 [<em>::MODEL_DSO2250</em>] 308 /// BulkSetTrigger2250 [<em>::MODEL_DSO2250</em>]
307 /// <p> 309 /// <p>
@@ -348,7 +350,7 @@ enum BulkCode { @@ -348,7 +350,7 @@ enum BulkCode {
348 /// SamplerateSlow = 0 and SamplerateFast = 4. 350 /// SamplerateSlow = 0 and SamplerateFast = 4.
349 /// </p> 351 /// </p>
350 /// <p><br /></p> 352 /// <p><br /></p>
351 - BULK_CSETTRIGGERORSAMPLERATE, 353 + CSETTRIGGERORSAMPLERATE,
352 354
353 /// BulkSetRecordLength2250 [<em>::MODEL_DSO2250</em>] 355 /// BulkSetRecordLength2250 [<em>::MODEL_DSO2250</em>]
354 /// <p> 356 /// <p>
@@ -394,7 +396,7 @@ enum BulkCode { @@ -394,7 +396,7 @@ enum BulkCode {
394 /// TriggerPositionPost value is maximal for 0 % and minimal for 100%. 396 /// TriggerPositionPost value is maximal for 0 % and minimal for 100%.
395 /// </p> 397 /// </p>
396 /// <p><br /></p> 398 /// <p><br /></p>
397 - BULK_DSETBUFFER, 399 + DSETBUFFER,
398 400
399 /// BulkSetSamplerate2250 [<em>::MODEL_DSO2250</em>] 401 /// BulkSetSamplerate2250 [<em>::MODEL_DSO2250</em>]
400 /// <p> 402 /// <p>
@@ -440,7 +442,7 @@ enum BulkCode { @@ -440,7 +442,7 @@ enum BulkCode {
440 /// </table> 442 /// </table>
441 /// </p> 443 /// </p>
442 /// <p><br /></p> 444 /// <p><br /></p>
443 - BULK_ESETTRIGGERORSAMPLERATE, 445 + ESETTRIGGERORSAMPLERATE,
444 446
445 /// BulkSetBuffer2250 [<em>::MODEL_DSO2250</em>] 447 /// BulkSetBuffer2250 [<em>::MODEL_DSO2250</em>]
446 /// <p> 448 /// <p>
@@ -475,9 +477,9 @@ enum BulkCode { @@ -475,9 +477,9 @@ enum BulkCode {
475 /// TriggerPositionPost value is maximal for 0 % and minimal for 100%. 477 /// TriggerPositionPost value is maximal for 0 % and minimal for 100%.
476 /// </p> 478 /// </p>
477 /// <p><br /></p> 479 /// <p><br /></p>
478 - BULK_FSETBUFFER, 480 + FSETBUFFER,
479 481
480 - BULK_COUNT 482 + COUNT
481 }; 483 };
482 484
483 } 485 }
openhantek/src/hantekprotocol/controlStructs.cpp
@@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
6 6
7 namespace Hantek { 7 namespace Hantek {
8 8
9 -ControlSetOffset::ControlSetOffset() : DataArray<uint8_t>(17) {} 9 +ControlSetOffset::ControlSetOffset() : ControlCommand(17) {}
10 10
11 -ControlSetOffset::ControlSetOffset(uint16_t channel1, uint16_t channel2, uint16_t trigger) : DataArray<uint8_t>(17) { 11 +ControlSetOffset::ControlSetOffset(uint16_t channel1, uint16_t channel2, uint16_t trigger) : ControlCommand(17) {
12 this->setChannel(0, channel1); 12 this->setChannel(0, channel1);
13 this->setChannel(1, channel2); 13 this->setChannel(1, channel2);
14 this->setTrigger(trigger); 14 this->setTrigger(trigger);
@@ -40,7 +40,7 @@ void ControlSetOffset::setTrigger(uint16_t level) { @@ -40,7 +40,7 @@ void ControlSetOffset::setTrigger(uint16_t level) {
40 40
41 ControlSetRelays::ControlSetRelays(bool ch1Below1V, bool ch1Below100mV, bool ch1CouplingDC, bool ch2Below1V, 41 ControlSetRelays::ControlSetRelays(bool ch1Below1V, bool ch1Below100mV, bool ch1CouplingDC, bool ch2Below1V,
42 bool ch2Below100mV, bool ch2CouplingDC, bool triggerExt) 42 bool ch2Below100mV, bool ch2CouplingDC, bool triggerExt)
43 - : DataArray<uint8_t>(17) { 43 + : ControlCommand(17) {
44 this->setBelow1V(0, ch1Below1V); 44 this->setBelow1V(0, ch1Below1V);
45 this->setBelow100mV(0, ch1Below100mV); 45 this->setBelow100mV(0, ch1Below100mV);
46 this->setCoupling(0, ch1CouplingDC); 46 this->setCoupling(0, ch1CouplingDC);
@@ -96,17 +96,17 @@ bool ControlSetRelays::getTrigger() { return (this-&gt;array[7] &amp; 0x01) == 0x00; } @@ -96,17 +96,17 @@ bool ControlSetRelays::getTrigger() { return (this-&gt;array[7] &amp; 0x01) == 0x00; }
96 96
97 void ControlSetRelays::setTrigger(bool ext) { this->array[7] = ext ? 0xfe : 0x01; } 97 void ControlSetRelays::setTrigger(bool ext) { this->array[7] = ext ? 0xfe : 0x01; }
98 98
99 -ControlSetVoltDIV_CH1::ControlSetVoltDIV_CH1() : DataArray<uint8_t>(1) { this->setDiv(5); } 99 +ControlSetVoltDIV_CH1::ControlSetVoltDIV_CH1() : ControlCommand(1) { this->setDiv(5); }
100 100
101 void ControlSetVoltDIV_CH1::setDiv(uint8_t val) { this->array[0] = val; } 101 void ControlSetVoltDIV_CH1::setDiv(uint8_t val) { this->array[0] = val; }
102 102
103 -ControlSetVoltDIV_CH2::ControlSetVoltDIV_CH2() : DataArray<uint8_t>(1) { this->setDiv(5); } 103 +ControlSetVoltDIV_CH2::ControlSetVoltDIV_CH2() : ControlCommand(1) { this->setDiv(5); }
104 104
105 void ControlSetVoltDIV_CH2::setDiv(uint8_t val) { this->array[0] = val; } 105 void ControlSetVoltDIV_CH2::setDiv(uint8_t val) { this->array[0] = val; }
106 106
107 -ControlSetTimeDIV::ControlSetTimeDIV() : DataArray<uint8_t>(1) { this->setDiv(1); } 107 +ControlSetTimeDIV::ControlSetTimeDIV() : ControlCommand(1) { this->setDiv(1); }
108 108
109 void ControlSetTimeDIV::setDiv(uint8_t val) { this->array[0] = val; } 109 void ControlSetTimeDIV::setDiv(uint8_t val) { this->array[0] = val; }
110 110
111 -ControlAcquireHardData::ControlAcquireHardData() : DataArray<uint8_t>(1) { this->array[0] = 0x01; } 111 +ControlAcquireHardData::ControlAcquireHardData() : ControlCommand(1) { this->array[0] = 0x01; }
112 } 112 }
openhantek/src/hantekprotocol/controlStructs.h
@@ -5,7 +5,12 @@ @@ -5,7 +5,12 @@
5 #include "utils/dataarray.h" 5 #include "utils/dataarray.h"
6 6
7 namespace Hantek { 7 namespace Hantek {
8 -struct ControlSetOffset : public DataArray<uint8_t> { 8 +class ControlCommand : public DataArray<uint8_t> {
  9 +protected:
  10 + ControlCommand(unsigned size): DataArray<uint8_t>(size) {}
  11 +};
  12 +
  13 +struct ControlSetOffset : public ControlCommand {
9 ControlSetOffset(); 14 ControlSetOffset();
10 /// \brief Sets the offsets to the given values. 15 /// \brief Sets the offsets to the given values.
11 /// \param channel1 The offset for channel 1. 16 /// \param channel1 The offset for channel 1.
@@ -29,7 +34,7 @@ struct ControlSetOffset : public DataArray&lt;uint8_t&gt; { @@ -29,7 +34,7 @@ struct ControlSetOffset : public DataArray&lt;uint8_t&gt; {
29 void setTrigger(uint16_t level); 34 void setTrigger(uint16_t level);
30 }; 35 };
31 36
32 -struct ControlSetRelays : public DataArray<uint8_t> { 37 +struct ControlSetRelays : public ControlCommand {
33 /// \brief Sets all relay states. 38 /// \brief Sets all relay states.
34 /// \param ch1Below1V Sets the state of the Channel 1 below 1 V relay. 39 /// \param ch1Below1V Sets the state of the Channel 1 below 1 V relay.
35 /// \param ch1Below100mV Sets the state of the Channel 1 below 100 mV relay. 40 /// \param ch1Below100mV Sets the state of the Channel 1 below 100 mV relay.
@@ -74,22 +79,22 @@ struct ControlSetRelays : public DataArray&lt;uint8_t&gt; { @@ -74,22 +79,22 @@ struct ControlSetRelays : public DataArray&lt;uint8_t&gt; {
74 void setTrigger(bool ext); 79 void setTrigger(bool ext);
75 }; 80 };
76 81
77 -struct ControlSetVoltDIV_CH1 : public DataArray<uint8_t> { 82 +struct ControlSetVoltDIV_CH1 : public ControlCommand {
78 ControlSetVoltDIV_CH1(); 83 ControlSetVoltDIV_CH1();
79 void setDiv(uint8_t val); 84 void setDiv(uint8_t val);
80 }; 85 };
81 86
82 -struct ControlSetVoltDIV_CH2 : public DataArray<uint8_t> { 87 +struct ControlSetVoltDIV_CH2 : public ControlCommand {
83 ControlSetVoltDIV_CH2(); 88 ControlSetVoltDIV_CH2();
84 void setDiv(uint8_t val); 89 void setDiv(uint8_t val);
85 }; 90 };
86 91
87 -struct ControlSetTimeDIV : public DataArray<uint8_t> { 92 +struct ControlSetTimeDIV : public ControlCommand {
88 ControlSetTimeDIV(); 93 ControlSetTimeDIV();
89 void setDiv(uint8_t val); 94 void setDiv(uint8_t val);
90 }; 95 };
91 96
92 -struct ControlAcquireHardData : public DataArray<uint8_t> { 97 +struct ControlAcquireHardData : public ControlCommand {
93 ControlAcquireHardData(); 98 ControlAcquireHardData();
94 }; 99 };
95 } 100 }
openhantek/src/hantekprotocol/definitions.h
@@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
8 8
9 #define HANTEK_GAIN_STEPS 9 9 #define HANTEK_GAIN_STEPS 9
10 #define HANTEK_CHANNELS 2 ///< Number of physical channels 10 #define HANTEK_CHANNELS 2 ///< Number of physical channels
11 -#define HANTEK_SPECIAL_CHANNELS 2 ///< Number of special channels  
12 11
13 namespace Hantek { 12 namespace Hantek {
14 /// \enum UsedChannels 13 /// \enum UsedChannels
@@ -68,7 +67,7 @@ struct OffsetsPerGainStep { @@ -68,7 +67,7 @@ struct OffsetsPerGainStep {
68 }; 67 };
69 68
70 /// \struct FilterBits 69 /// \struct FilterBits
71 -/// \brief The bits for BULK_SETFILTER. 70 +/// \brief The bits for BULK::SETFILTER.
72 struct FilterBits { 71 struct FilterBits {
73 uint8_t channel1 : 1; ///< Set to true when channel 1 isn't used 72 uint8_t channel1 : 1; ///< Set to true when channel 1 isn't used
74 uint8_t channel2 : 1; ///< Set to true when channel 2 isn't used 73 uint8_t channel2 : 1; ///< Set to true when channel 2 isn't used
@@ -78,7 +77,7 @@ struct FilterBits { @@ -78,7 +77,7 @@ struct FilterBits {
78 77
79 78
80 /// \struct GainBits 79 /// \struct GainBits
81 -/// \brief The gain bits for BULK_SETGAIN. 80 +/// \brief The gain bits for BulkCode::SETGAIN.
82 struct GainBits { 81 struct GainBits {
83 uint8_t channel1 : 2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e* 82 uint8_t channel1 : 2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e*
84 uint8_t channel2 : 2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e* 83 uint8_t channel2 : 2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e*
openhantek/src/usb/usbdevice.cpp
@@ -123,14 +123,14 @@ unsigned USBDevice::getFindIteration() const @@ -123,14 +123,14 @@ unsigned USBDevice::getFindIteration() const
123 return findIteration; 123 return findIteration;
124 } 124 }
125 125
126 -int USBDevice::bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned int length, int attempts, 126 +int USBDevice::bulkTransfer(unsigned char endpoint, const unsigned char *data, unsigned int length, int attempts,
127 unsigned int timeout) { 127 unsigned int timeout) {
128 if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; 128 if (!this->handle) return LIBUSB_ERROR_NO_DEVICE;
129 129
130 int errorCode = LIBUSB_ERROR_TIMEOUT; 130 int errorCode = LIBUSB_ERROR_TIMEOUT;
131 - int transferred; 131 + int transferred = 0;
132 for (int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) 132 for (int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt)
133 - errorCode = libusb_bulk_transfer(this->handle, endpoint, data, length, &transferred, timeout); 133 + errorCode = libusb_bulk_transfer(this->handle, endpoint, (unsigned char*) data, (int)length, &transferred, timeout);
134 134
135 if (errorCode == LIBUSB_ERROR_NO_DEVICE) disconnectFromDevice(); 135 if (errorCode == LIBUSB_ERROR_NO_DEVICE) disconnectFromDevice();
136 if (errorCode < 0) 136 if (errorCode < 0)
@@ -144,7 +144,7 @@ int USBDevice::bulkTransfer(unsigned char endpoint, unsigned char *data, unsigne @@ -144,7 +144,7 @@ int USBDevice::bulkTransfer(unsigned char endpoint, unsigned char *data, unsigne
144 /// \param length The length of the packet. 144 /// \param length The length of the packet.
145 /// \param attempts The number of attempts, that are done on timeouts. 145 /// \param attempts The number of attempts, that are done on timeouts.
146 /// \return Number of sent bytes on success, libusb error code on error. 146 /// \return Number of sent bytes on success, libusb error code on error.
147 -int USBDevice::bulkWrite(unsigned char *data, unsigned int length, int attempts) { 147 +int USBDevice::bulkWrite(const unsigned char *data, unsigned int length, int attempts) {
148 if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; 148 if (!this->handle) return LIBUSB_ERROR_NO_DEVICE;
149 149
150 int errorCode = this->getConnectionSpeed(); 150 int errorCode = this->getConnectionSpeed();
@@ -171,7 +171,7 @@ int USBDevice::bulkRead(unsigned char *data, unsigned int length, int attempts) @@ -171,7 +171,7 @@ int USBDevice::bulkRead(unsigned char *data, unsigned int length, int attempts)
171 /// \param command The command, that should be sent. 171 /// \param command The command, that should be sent.
172 /// \param attempts The number of attempts, that are done on timeouts. 172 /// \param attempts The number of attempts, that are done on timeouts.
173 /// \return Number of sent bytes on success, libusb error code on error. 173 /// \return Number of sent bytes on success, libusb error code on error.
174 -int USBDevice::bulkCommand(DataArray<unsigned char> *command, int attempts) { 174 +int USBDevice::bulkCommand(const DataArray<unsigned char> *command, int attempts) {
175 if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; 175 if (!this->handle) return LIBUSB_ERROR_NO_DEVICE;
176 176
177 if (!allowBulkTransfer) return LIBUSB_SUCCESS; 177 if (!allowBulkTransfer) return LIBUSB_SUCCESS;
openhantek/src/usb/usbdevice.h
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 9
10 #include "usbdevicedefinitions.h" 10 #include "usbdevicedefinitions.h"
11 #include "controlbegin.h" 11 #include "controlbegin.h"
12 -#include "utils/dataarray.h"  
13 12
14 class DSOModel; 13 class DSOModel;
15 14
@@ -48,12 +47,12 @@ class USBDevice : public QObject { @@ -48,12 +47,12 @@ class USBDevice : public QObject {
48 /// \param timeout The timeout in ms. 47 /// \param timeout The timeout in ms.
49 /// \return Number of transferred bytes on success, libusb error code on 48 /// \return Number of transferred bytes on success, libusb error code on
50 /// error. 49 /// error.
51 - int bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS, 50 + int bulkTransfer(unsigned char endpoint, const unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS,
52 unsigned int timeout = HANTEK_TIMEOUT); 51 unsigned int timeout = HANTEK_TIMEOUT);
53 - int bulkWrite(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS); 52 + int bulkWrite(const unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS);
54 int bulkRead(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS); 53 int bulkRead(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS);
55 54
56 - int bulkCommand(DataArray<unsigned char> *command, int attempts = HANTEK_ATTEMPTS); 55 + int bulkCommand(const DataArray<unsigned char> *command, int attempts = HANTEK_ATTEMPTS);
57 int bulkReadMulti(unsigned char *data, unsigned length, int attempts = HANTEK_ATTEMPTS_MULTI); 56 int bulkReadMulti(unsigned char *data, unsigned length, int attempts = HANTEK_ATTEMPTS_MULTI);
58 57
59 int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, 58 int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value,
openhantek/src/usb/usbdevicedefinitions.h
@@ -23,7 +23,7 @@ enum BulkIndex { @@ -23,7 +23,7 @@ enum BulkIndex {
23 COMMANDINDEX_0 = 0x03, ///< Used most of the time 23 COMMANDINDEX_0 = 0x03, ///< Used most of the time
24 COMMANDINDEX_1 = 0x0a, 24 COMMANDINDEX_1 = 0x0a,
25 COMMANDINDEX_2 = 0x09, 25 COMMANDINDEX_2 = 0x09,
26 - COMMANDINDEX_3 = 0x01, ///< Used for ::BULK_SETTRIGGERANDSAMPLERATE sometimes 26 + COMMANDINDEX_3 = 0x01, ///< Used for ::BulkCode::SETTRIGGERANDSAMPLERATE sometimes
27 COMMANDINDEX_4 = 0x02, 27 COMMANDINDEX_4 = 0x02,
28 COMMANDINDEX_5 = 0x08 28 COMMANDINDEX_5 = 0x08
29 }; 29 };
openhantek/src/utils/dataarray.h
@@ -8,7 +8,7 @@ template &lt;class T&gt; class DataArray { @@ -8,7 +8,7 @@ template &lt;class T&gt; class DataArray {
8 DataArray(unsigned int size); 8 DataArray(unsigned int size);
9 ~DataArray(); 9 ~DataArray();
10 10
11 - T *data(); 11 + T *data() const;
12 T operator[](unsigned int index); 12 T operator[](unsigned int index);
13 13
14 unsigned int getSize() const; 14 unsigned int getSize() const;
@@ -31,7 +31,7 @@ template &lt;class T&gt; DataArray&lt;T&gt;::~DataArray() { delete[] this-&gt;array; } @@ -31,7 +31,7 @@ template &lt;class T&gt; DataArray&lt;T&gt;::~DataArray() { delete[] this-&gt;array; }
31 31
32 /// \brief Returns a pointer to the array data. 32 /// \brief Returns a pointer to the array data.
33 /// \return The internal data array. 33 /// \return The internal data array.
34 -template <class T> T *DataArray<T>::data() { return this->array; } 34 +template <class T> T *DataArray<T>::data() const { return this->array; }
35 35
36 /// \brief Returns array element when using square brackets. 36 /// \brief Returns array element when using square brackets.
37 /// \return The array element. 37 /// \return The array element.