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