Commit dc4cbc9c163f0af72f0889e1b8661ceb8198e62f
Committed by
David Gräff
1 parent
ecbc22ed
Easier device support: Models have even more limited interaction with dsocontrol…
… now, only addCommand is called. The commands will be moved to the specification soon as well.
Showing
26 changed files
with
261 additions
and
233 deletions
openhantek/src/hantekdso/controlspecification.h
openhantek/src/hantekdso/hantekdsocontrol.cpp
| ... | ... | @@ -60,16 +60,11 @@ HantekDsoControl::HantekDsoControl(USBDevice *device) |
| 60 | 60 | |
| 61 | 61 | if (specification.useControlNoBulk) { |
| 62 | 62 | device->setEnableBulkTransfer(false); |
| 63 | - } else { | |
| 64 | - // Instantiate the commands needed for all bulk-command-enabled models | |
| 65 | - addCommand(BulkCode::FORCETRIGGER, new BulkForceTrigger(), false); | |
| 66 | - addCommand(BulkCode::STARTSAMPLING, new BulkCaptureStart(), false); | |
| 67 | - addCommand(BulkCode::ENABLETRIGGER, new BulkTriggerEnabled(), false); | |
| 68 | - addCommand(BulkCode::GETDATA, new BulkGetData(), false); | |
| 69 | - addCommand(BulkCode::GETCAPTURESTATE, new BulkGetCaptureState(), false); | |
| 70 | - addCommand(BulkCode::SETGAIN, new BulkSetGain(), false); | |
| 71 | 63 | } |
| 72 | 64 | |
| 65 | + if (specification.fixedUSBinLength) | |
| 66 | + device->overwriteInPacketLength(specification.fixedUSBinLength); | |
| 67 | + | |
| 73 | 68 | // Apply special requirements by the devices model |
| 74 | 69 | device->getModel()->applyRequirements(this); |
| 75 | 70 | |
| ... | ... | @@ -135,15 +130,16 @@ unsigned HantekDsoControl::getRecordLength() const { |
| 135 | 130 | |
| 136 | 131 | Dso::ErrorCode HantekDsoControl::retrieveChannelLevelData() { |
| 137 | 132 | // Get channel level data |
| 133 | + ControlGetLimits c(2); | |
| 138 | 134 | int errorCode = |
| 139 | - device->controlRead((uint8_t)ControlCode::CONTROL_VALUE, (unsigned char *)&(specification.offsetLimit), | |
| 140 | - sizeof(specification.offsetLimit), (uint8_t)ControlValue::VALUE_OFFSETLIMITS); | |
| 135 | + device->controlRead(&c); | |
| 141 | 136 | if (errorCode < 0) { |
| 142 | 137 | qWarning() << tr("Couldn't get channel level data from oscilloscope"); |
| 143 | 138 | emit statusMessage(tr("Couldn't get channel level data from oscilloscope"), 0); |
| 144 | 139 | emit communicationError(); |
| 145 | 140 | return Dso::ErrorCode::CONNECTION; |
| 146 | 141 | } |
| 142 | + memcpy(specification.offsetLimit,c.offsetLimit,sizeof(specification.offsetLimit)); | |
| 147 | 143 | |
| 148 | 144 | return Dso::ErrorCode::NONE; |
| 149 | 145 | } |
| ... | ... | @@ -185,8 +181,7 @@ std::vector<unsigned char> HantekDsoControl::getSamples(unsigned &previousSample |
| 185 | 181 | // Request data |
| 186 | 182 | errorCode = device->bulkCommand(getCommand(BulkCode::GETDATA), 1); |
| 187 | 183 | } else { |
| 188 | - const ControlCommand *bulkCommand = getCommand(ControlCode::CONTROL_ACQUIIRE_HARD_DATA); | |
| 189 | - errorCode = device->controlWrite((uint8_t)bulkCommand->code, bulkCommand->data(), bulkCommand->getSize()); | |
| 184 | + errorCode = device->controlWrite(getCommand(ControlCode::CONTROL_ACQUIIRE_HARD_DATA)); | |
| 190 | 185 | } |
| 191 | 186 | if (errorCode < 0) { |
| 192 | 187 | qWarning() << "Getting sample data failed: " << libUsbErrorString(errorCode); |
| ... | ... | @@ -1040,18 +1035,18 @@ Dso::ErrorCode HantekDsoControl::stringCommand(const QString &commandString) { |
| 1040 | 1035 | return Dso::ErrorCode::UNSUPPORTED; |
| 1041 | 1036 | } |
| 1042 | 1037 | |
| 1043 | -void HantekDsoControl::addCommand(BulkCode code, BulkCommand *newCommand, bool pending) { | |
| 1038 | +void HantekDsoControl::addCommand(BulkCommand *newCommand, bool pending) { | |
| 1044 | 1039 | newCommand->pending = pending; |
| 1045 | - command[(uint8_t)code] = newCommand; | |
| 1040 | + command[(uint8_t)newCommand->code] = newCommand; | |
| 1046 | 1041 | newCommand->next = firstBulkCommand; |
| 1047 | 1042 | firstBulkCommand = newCommand; |
| 1048 | 1043 | } |
| 1049 | 1044 | |
| 1050 | 1045 | const BulkCommand *HantekDsoControl::getCommand(BulkCode code) const { return command[(uint8_t)code]; } |
| 1051 | 1046 | |
| 1052 | -void HantekDsoControl::addCommand(ControlCode code, ControlCommand *newCommand, bool pending) { | |
| 1047 | +void HantekDsoControl::addCommand(ControlCommand *newCommand, bool pending) { | |
| 1053 | 1048 | newCommand->pending = pending; |
| 1054 | - control[(uint8_t)code] = newCommand; | |
| 1049 | + control[newCommand->code] = newCommand; | |
| 1055 | 1050 | newCommand->next = firstControlCommand; |
| 1056 | 1051 | firstControlCommand = newCommand; |
| 1057 | 1052 | } |
| ... | ... | @@ -1087,8 +1082,7 @@ void HantekDsoControl::run() { |
| 1087 | 1082 | .arg(QString::number(control[cIndex], 16), |
| 1088 | 1083 | hexDump(this->control[control]->data(), this->control[control]->getSize()))); |
| 1089 | 1084 | |
| 1090 | - errorCode = | |
| 1091 | - device->controlWrite((uint8_t)controlCommand->code, controlCommand->data(), controlCommand->getSize()); | |
| 1085 | + errorCode = device->controlWrite(controlCommand); | |
| 1092 | 1086 | if (errorCode < 0) { |
| 1093 | 1087 | qWarning("Sending control command %2x failed: %s", (uint8_t)controlCommand->code, |
| 1094 | 1088 | libUsbErrorString(errorCode).toLocal8Bit().data()); | ... | ... |
openhantek/src/hantekdso/hantekdsocontrol.h
| ... | ... | @@ -24,10 +24,6 @@ |
| 24 | 24 | #include <QTimer> |
| 25 | 25 | |
| 26 | 26 | class USBDevice; |
| 27 | -namespace Hantek { | |
| 28 | -class BulkCommand; | |
| 29 | -class ControlCommand; | |
| 30 | -} | |
| 31 | 27 | |
| 32 | 28 | /// \brief The DsoControl abstraction layer for %Hantek USB DSOs. |
| 33 | 29 | /// TODO Please anyone, refactor this class into smaller pieces (Separation of Concerns!). |
| ... | ... | @@ -93,19 +89,19 @@ class HantekDsoControl : public QObject { |
| 93 | 89 | /// \return See ::Dso::ErrorCode. |
| 94 | 90 | Dso::ErrorCode stringCommand(const QString &commandString); |
| 95 | 91 | |
| 96 | - void addCommand(Hantek::BulkCode code, Hantek::BulkCommand* newCommand, bool pending = true); | |
| 92 | + void addCommand(BulkCommand* newCommand, bool pending = true); | |
| 97 | 93 | template<class T> T* modifyCommand(Hantek::BulkCode code) { |
| 98 | 94 | command[(uint8_t)code]->pending = true; |
| 99 | 95 | return static_cast<T*>(command[(uint8_t)code]); |
| 100 | 96 | } |
| 101 | - const Hantek::BulkCommand* getCommand(Hantek::BulkCode code) const; | |
| 97 | + const BulkCommand* getCommand(Hantek::BulkCode code) const; | |
| 102 | 98 | |
| 103 | - void addCommand(Hantek::ControlCode code, Hantek::ControlCommand* newCommand, bool pending = true); | |
| 99 | + void addCommand(ControlCommand* newCommand, bool pending = true); | |
| 104 | 100 | template<class T> T* modifyCommand(Hantek::ControlCode code) { |
| 105 | 101 | control[(uint8_t)code]->pending = true; |
| 106 | 102 | return static_cast<T*>(control[(uint8_t)code]); |
| 107 | 103 | } |
| 108 | - const Hantek::ControlCommand* getCommand(Hantek::ControlCode code) const; | |
| 104 | + const ControlCommand* getCommand(Hantek::ControlCode code) const; | |
| 109 | 105 | private: |
| 110 | 106 | bool isRollMode() const; |
| 111 | 107 | bool isFastRate() const; |
| ... | ... | @@ -167,10 +163,10 @@ class HantekDsoControl : public QObject { |
| 167 | 163 | |
| 168 | 164 | private: |
| 169 | 165 | /// Pointers to bulk/control commands |
| 170 | - Hantek::BulkCommand *command[255] = {0}; | |
| 171 | - Hantek::BulkCommand* firstBulkCommand = nullptr; | |
| 172 | - Hantek::ControlCommand *control[255] = {0}; | |
| 173 | - Hantek::ControlCommand* firstControlCommand = nullptr; | |
| 166 | + BulkCommand *command[255] = {0}; | |
| 167 | + BulkCommand* firstBulkCommand = nullptr; | |
| 168 | + ControlCommand *control[255] = {0}; | |
| 169 | + ControlCommand* firstControlCommand = nullptr; | |
| 174 | 170 | |
| 175 | 171 | // Communication with device |
| 176 | 172 | USBDevice *device; ///< The USB device for the oscilloscope | ... | ... |
openhantek/src/hantekdso/models/modelDSO2090.cpp
| ... | ... | @@ -30,9 +30,16 @@ ModelDSO2090::ModelDSO2090() : DSOModel(ID, 0x04b5, 0x2090, 0x04b4, 0x2090, "dso |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | void ModelDSO2090::applyRequirements(HantekDsoControl *dsoControl) const { |
| 33 | - dsoControl->addCommand(BulkCode::SETTRIGGERANDSAMPLERATE, new BulkSetTriggerAndSamplerate()); | |
| 34 | - dsoControl->addCommand(ControlCode::CONTROL_SETOFFSET, new ControlSetOffset()); | |
| 35 | - dsoControl->addCommand(ControlCode::CONTROL_SETRELAYS, new ControlSetRelays()); | |
| 33 | + dsoControl->addCommand(new BulkForceTrigger(), false); | |
| 34 | + dsoControl->addCommand(new BulkCaptureStart(), false); | |
| 35 | + dsoControl->addCommand(new BulkTriggerEnabled(), false); | |
| 36 | + dsoControl->addCommand(new BulkGetData(), false); | |
| 37 | + dsoControl->addCommand(new BulkGetCaptureState(), false); | |
| 38 | + dsoControl->addCommand(new BulkSetGain(), false); | |
| 39 | + | |
| 40 | + dsoControl->addCommand(new BulkSetTriggerAndSamplerate(), false); | |
| 41 | + dsoControl->addCommand(new ControlSetOffset(), false); | |
| 42 | + dsoControl->addCommand(new ControlSetRelays(), false); | |
| 36 | 43 | } |
| 37 | 44 | |
| 38 | 45 | ModelDSO2090A::ModelDSO2090A() { | ... | ... |
openhantek/src/hantekdso/models/modelDSO2150.cpp
| ... | ... | @@ -30,7 +30,14 @@ ModelDSO2150::ModelDSO2150() : DSOModel(ID, 0x04b5, 0x2150, 0x04b4, 0x2150, "dso |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | void ModelDSO2150::applyRequirements(HantekDsoControl *dsoControl) const { |
| 33 | - dsoControl->addCommand(BulkCode::SETTRIGGERANDSAMPLERATE, new BulkSetTriggerAndSamplerate()); | |
| 34 | - dsoControl->addCommand(ControlCode::CONTROL_SETOFFSET, new ControlSetOffset()); | |
| 35 | - dsoControl->addCommand(ControlCode::CONTROL_SETRELAYS, new ControlSetRelays()); | |
| 33 | + dsoControl->addCommand(new BulkForceTrigger(), false); | |
| 34 | + dsoControl->addCommand(new BulkCaptureStart(), false); | |
| 35 | + dsoControl->addCommand(new BulkTriggerEnabled(), false); | |
| 36 | + dsoControl->addCommand(new BulkGetData(), false); | |
| 37 | + dsoControl->addCommand(new BulkGetCaptureState(), false); | |
| 38 | + dsoControl->addCommand(new BulkSetGain(), false); | |
| 39 | + | |
| 40 | + dsoControl->addCommand(new BulkSetTriggerAndSamplerate(), false); | |
| 41 | + dsoControl->addCommand(new ControlSetOffset(), false); | |
| 42 | + dsoControl->addCommand(new ControlSetRelays(), false); | |
| 36 | 43 | } | ... | ... |
openhantek/src/hantekdso/models/modelDSO2250.cpp
| ... | ... | @@ -30,12 +30,19 @@ ModelDSO2250::ModelDSO2250() : DSOModel(ID, 0x04b5, 0x2250, 0x04b4, 0x2250, "dso |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | void ModelDSO2250::applyRequirements(HantekDsoControl *dsoControl) const { |
| 33 | + dsoControl->addCommand(new BulkForceTrigger(), false); | |
| 34 | + dsoControl->addCommand(new BulkCaptureStart(), false); | |
| 35 | + dsoControl->addCommand(new BulkTriggerEnabled(), false); | |
| 36 | + dsoControl->addCommand(new BulkGetData(), false); | |
| 37 | + dsoControl->addCommand(new BulkGetCaptureState(), false); | |
| 38 | + dsoControl->addCommand(new BulkSetGain(), false); | |
| 39 | + | |
| 33 | 40 | // Instantiate additional commands for the DSO-2250 |
| 34 | - dsoControl->addCommand(BulkCode::BSETCHANNELS, new BulkSetChannels2250()); | |
| 35 | - dsoControl->addCommand(BulkCode::CSETTRIGGERORSAMPLERATE, new BulkSetTrigger2250()); | |
| 36 | - dsoControl->addCommand(BulkCode::DSETBUFFER, new BulkSetRecordLength2250()); | |
| 37 | - dsoControl->addCommand(BulkCode::ESETTRIGGERORSAMPLERATE, new BulkSetSamplerate2250()); | |
| 38 | - dsoControl->addCommand(BulkCode::FSETBUFFER, new BulkSetBuffer2250()); | |
| 39 | - dsoControl->addCommand(ControlCode::CONTROL_SETOFFSET, new ControlSetOffset()); | |
| 40 | - dsoControl->addCommand(ControlCode::CONTROL_SETRELAYS, new ControlSetRelays()); | |
| 41 | + dsoControl->addCommand(new BulkSetChannels2250(), false); | |
| 42 | + dsoControl->addCommand(new BulkSetTrigger2250(), false); | |
| 43 | + dsoControl->addCommand(new BulkSetRecordLength2250(), false); | |
| 44 | + dsoControl->addCommand(new BulkSetSamplerate2250(), false); | |
| 45 | + dsoControl->addCommand(new BulkSetBuffer2250(), false); | |
| 46 | + dsoControl->addCommand(new ControlSetOffset(), false); | |
| 47 | + dsoControl->addCommand(new ControlSetRelays(), false); | |
| 41 | 48 | } | ... | ... |
openhantek/src/hantekdso/models/modelDSO5200.cpp
| ... | ... | @@ -11,7 +11,6 @@ ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, "dso |
| 11 | 11 | specification.command.bulk.setSamplerate = BulkCode::CSETTRIGGERORSAMPLERATE; |
| 12 | 12 | specification.command.bulk.setTrigger = BulkCode::ESETTRIGGERORSAMPLERATE; |
| 13 | 13 | specification.command.bulk.setPretrigger = BulkCode::ESETTRIGGERORSAMPLERATE; |
| 14 | - // specification.command.values.voltageLimits = VALUE_ETSCORRECTION; | |
| 15 | 14 | |
| 16 | 15 | specification.samplerate.single.base = 100e6; |
| 17 | 16 | specification.samplerate.single.max = 125e6; |
| ... | ... | @@ -32,12 +31,19 @@ ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, "dso |
| 32 | 31 | } |
| 33 | 32 | |
| 34 | 33 | void ModelDSO5200::applyRequirements(HantekDsoControl *dsoControl) const { |
| 34 | + dsoControl->addCommand(new BulkForceTrigger(), false); | |
| 35 | + dsoControl->addCommand(new BulkCaptureStart(), false); | |
| 36 | + dsoControl->addCommand(new BulkTriggerEnabled(), false); | |
| 37 | + dsoControl->addCommand(new BulkGetData(), false); | |
| 38 | + dsoControl->addCommand(new BulkGetCaptureState(), false); | |
| 39 | + dsoControl->addCommand(new BulkSetGain(), false); | |
| 40 | + | |
| 35 | 41 | // Instantiate additional commands for the DSO-5200 |
| 36 | - dsoControl->addCommand(BulkCode::CSETTRIGGERORSAMPLERATE, new BulkSetSamplerate5200()); | |
| 37 | - dsoControl->addCommand(BulkCode::DSETBUFFER, new BulkSetBuffer5200()); | |
| 38 | - dsoControl->addCommand(BulkCode::ESETTRIGGERORSAMPLERATE, new BulkSetTrigger5200()); | |
| 39 | - dsoControl->addCommand(ControlCode::CONTROL_SETOFFSET, new ControlSetOffset()); | |
| 40 | - dsoControl->addCommand(ControlCode::CONTROL_SETRELAYS, new ControlSetRelays()); | |
| 42 | + dsoControl->addCommand(new BulkSetSamplerate5200(), false); | |
| 43 | + dsoControl->addCommand(new BulkSetBuffer5200(), false); | |
| 44 | + dsoControl->addCommand(new BulkSetTrigger5200(), false); | |
| 45 | + dsoControl->addCommand(new ControlSetOffset(), false); | |
| 46 | + dsoControl->addCommand(new ControlSetRelays(), false); | |
| 41 | 47 | } |
| 42 | 48 | |
| 43 | 49 | ModelDSO5200A::ModelDSO5200A() { | ... | ... |
openhantek/src/hantekdso/models/modelDSO6022.cpp
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | using namespace Hantek; |
| 7 | 7 | |
| 8 | 8 | ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022, "dso6022be", "DSO-6022BE", Dso::ControlSpecification()) { |
| 9 | - // 6022BE do not support any bulk commands | |
| 9 | + // 6022xx do not support any bulk commands | |
| 10 | 10 | specification.useControlNoBulk = true; |
| 11 | 11 | specification.isSoftwareTriggerDevice = true; |
| 12 | 12 | specification.isFixedSamplerateDevice = true; |
| ... | ... | @@ -35,15 +35,14 @@ ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022, |
| 35 | 35 | |
| 36 | 36 | specification.couplings = {Dso::Coupling::DC}; |
| 37 | 37 | specification.triggerModes = {Dso::TriggerMode::HARDWARE_SOFTWARE, Dso::TriggerMode::SINGLE}; |
| 38 | + specification.fixedUSBinLength = 16384; | |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | 41 | void ModelDSO6022BE::applyRequirements(HantekDsoControl *dsoControl) const { |
| 41 | - dsoControl->getDevice()->overwriteInPacketLength(16384); | |
| 42 | - | |
| 43 | - dsoControl->addCommand(ControlCode::CONTROL_ACQUIIRE_HARD_DATA, new ControlAcquireHardData()); | |
| 44 | - dsoControl->addCommand(ControlCode::CONTROL_SETTIMEDIV, new ControlSetTimeDIV()); | |
| 45 | - dsoControl->addCommand(ControlCode::CONTROL_SETVOLTDIV_CH2, new ControlSetVoltDIV_CH2()); | |
| 46 | - dsoControl->addCommand(ControlCode::CONTROL_SETVOLTDIV_CH1, new ControlSetVoltDIV_CH1()); | |
| 42 | + dsoControl->addCommand(new ControlAcquireHardData()); | |
| 43 | + dsoControl->addCommand(new ControlSetTimeDIV()); | |
| 44 | + dsoControl->addCommand(new ControlSetVoltDIV_CH2()); | |
| 45 | + dsoControl->addCommand(new ControlSetVoltDIV_CH1()); | |
| 47 | 46 | } |
| 48 | 47 | |
| 49 | 48 | ModelDSO6022BL::ModelDSO6022BL() { | ... | ... |
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() : BulkCommand(8) { this->init(); } | |
| 12 | +BulkSetFilter::BulkSetFilter() : BulkCommand(BulkCode::SETFILTER, 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) : BulkCommand(8) { | |
| 18 | +BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : BulkCommand(BulkCode::SETFILTER, 8) { | |
| 19 | 19 | this->init(); |
| 20 | 20 | |
| 21 | 21 | this->setChannel(0, channel1); |
| ... | ... | @@ -66,7 +66,7 @@ void BulkSetFilter::init() { |
| 66 | 66 | ////////////////////////////////////////////////////////////////////////////// |
| 67 | 67 | // class BulkSetTriggerAndSamplerate |
| 68 | 68 | /// \brief Sets the data array to the default values. |
| 69 | -BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : BulkCommand(12) { this->init(); } | |
| 69 | +BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : BulkCommand(BulkCode::SETTRIGGERANDSAMPLERATE, 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 | - : BulkCommand(12) { | |
| 85 | + : BulkCommand(BulkCode::SETTRIGGERANDSAMPLERATE, 12) { | |
| 86 | 86 | this->init(); |
| 87 | 87 | |
| 88 | 88 | this->setTriggerSource(triggerSource); |
| ... | ... | @@ -201,32 +201,32 @@ void BulkSetTriggerAndSamplerate::init() { this->array[0] = (uint8_t) BulkCode:: |
| 201 | 201 | ////////////////////////////////////////////////////////////////////////////// |
| 202 | 202 | // class BulkForceTrigger |
| 203 | 203 | /// \brief Sets the data array to needed values. |
| 204 | -BulkForceTrigger::BulkForceTrigger() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::FORCETRIGGER; } | |
| 204 | +BulkForceTrigger::BulkForceTrigger() : BulkCommand(BulkCode::FORCETRIGGER, 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() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::STARTSAMPLING; } | |
| 209 | +BulkCaptureStart::BulkCaptureStart() : BulkCommand(BulkCode::STARTSAMPLING, 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() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::ENABLETRIGGER; } | |
| 214 | +BulkTriggerEnabled::BulkTriggerEnabled() : BulkCommand(BulkCode::ENABLETRIGGER, 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() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::GETDATA; } | |
| 219 | +BulkGetData::BulkGetData() : BulkCommand(BulkCode::GETDATA, 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() : BulkCommand(2) { this->array[0] = (uint8_t) BulkCode::GETCAPTURESTATE; } | |
| 224 | +BulkGetCaptureState::BulkGetCaptureState() : BulkCommand(BulkCode::GETCAPTURESTATE, 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() : BulkCommand(512) {} | |
| 229 | +BulkResponseGetCaptureState::BulkResponseGetCaptureState() : BulkCommand(BulkCode::GETCAPTURESTATE_RESPONSE, 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() : BulkCommand(8) { this->init(); } | |
| 244 | +BulkSetGain::BulkSetGain() : BulkCommand(BulkCode::SETGAIN, 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) : BulkCommand(8) { | |
| 249 | +BulkSetGain::BulkSetGain(uint8_t channel1, uint8_t channel2) : BulkCommand(BulkCode::SETGAIN, 8) { | |
| 250 | 250 | this->init(); |
| 251 | 251 | |
| 252 | 252 | this->setGain(0, channel1); |
| ... | ... | @@ -281,11 +281,11 @@ void BulkSetGain::init() { this->array[0] = (uint8_t)BulkCode::SETGAIN; } |
| 281 | 281 | ////////////////////////////////////////////////////////////////////////////// |
| 282 | 282 | // class BulkSetLogicalData |
| 283 | 283 | /// \brief Sets the data array to needed values. |
| 284 | -BulkSetLogicalData::BulkSetLogicalData() : BulkCommand(8) { this->init(); } | |
| 284 | +BulkSetLogicalData::BulkSetLogicalData() : BulkCommand(BulkCode::SETLOGICALDATA, 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) : BulkCommand(8) { | |
| 288 | +BulkSetLogicalData::BulkSetLogicalData(uint8_t data) : BulkCommand(BulkCode::SETLOGICALDATA, 8) { | |
| 289 | 289 | this->init(); |
| 290 | 290 | |
| 291 | 291 | this->setData(data); |
| ... | ... | @@ -305,16 +305,16 @@ void BulkSetLogicalData::init() { this->array[0] = (uint8_t)BulkCode::SETLOGICAL |
| 305 | 305 | ////////////////////////////////////////////////////////////////////////////// |
| 306 | 306 | // class BulkGetLogicalData |
| 307 | 307 | /// \brief Sets the data array to needed values. |
| 308 | -BulkGetLogicalData::BulkGetLogicalData() : BulkCommand(2) { this->array[0] = (uint8_t)BulkCode::GETLOGICALDATA; } | |
| 308 | +BulkGetLogicalData::BulkGetLogicalData() : BulkCommand(BulkCode::GETLOGICALDATA, 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() : BulkCommand(4) { this->init(); } | |
| 313 | +BulkSetChannels2250::BulkSetChannels2250() : BulkCommand(BulkCode::BSETCHANNELS, 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) : BulkCommand(4) { | |
| 317 | +BulkSetChannels2250::BulkSetChannels2250(uint8_t usedChannels) : BulkCommand(BulkCode::BSETCHANNELS, 4) { | |
| 318 | 318 | this->init(); |
| 319 | 319 | |
| 320 | 320 | this->setUsedChannels(usedChannels); |
| ... | ... | @@ -334,12 +334,12 @@ void BulkSetChannels2250::init() { this->array[0] = (uint8_t)BulkCode::BSETCHANN |
| 334 | 334 | ////////////////////////////////////////////////////////////////////////////// |
| 335 | 335 | // class BulkSetTrigger2250 |
| 336 | 336 | /// \brief Sets the data array to needed values. |
| 337 | -BulkSetTrigger2250::BulkSetTrigger2250() : BulkCommand(8) { this->init(); } | |
| 337 | +BulkSetTrigger2250::BulkSetTrigger2250() : BulkCommand(BulkCode::CSETTRIGGERORSAMPLERATE, 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) : BulkCommand(8) { | |
| 342 | +BulkSetTrigger2250::BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope) : BulkCommand(BulkCode::CSETTRIGGERORSAMPLERATE, 8) { | |
| 343 | 343 | this->init(); |
| 344 | 344 | |
| 345 | 345 | this->setTriggerSource(triggerSource); |
| ... | ... | @@ -368,12 +368,12 @@ void BulkSetTrigger2250::init() { this->array[0] = (uint8_t)BulkCode::CSETTRIGGE |
| 368 | 368 | ////////////////////////////////////////////////////////////////////////////// |
| 369 | 369 | // class BulkSetSamplerate5200 |
| 370 | 370 | /// \brief Sets the data array to the default values. |
| 371 | -BulkSetSamplerate5200::BulkSetSamplerate5200() : BulkCommand(6) { this->init(); } | |
| 371 | +BulkSetSamplerate5200::BulkSetSamplerate5200() : BulkCommand(BulkCode::CSETTRIGGERORSAMPLERATE, 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) : BulkCommand(6) { | |
| 376 | +BulkSetSamplerate5200::BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast) : BulkCommand(BulkCode::CSETTRIGGERORSAMPLERATE, 6) { | |
| 377 | 377 | this->init(); |
| 378 | 378 | |
| 379 | 379 | this->setSamplerateFast(samplerateFast); |
| ... | ... | @@ -407,11 +407,11 @@ void BulkSetSamplerate5200::init() { this->array[0] = (uint8_t)BulkCode::CSETTRI |
| 407 | 407 | ////////////////////////////////////////////////////////////////////////////// |
| 408 | 408 | // class BulkSetBuffer2250 |
| 409 | 409 | /// \brief Sets the data array to the default values. |
| 410 | -BulkSetRecordLength2250::BulkSetRecordLength2250() : BulkCommand(4) { this->init(); } | |
| 410 | +BulkSetRecordLength2250::BulkSetRecordLength2250() : BulkCommand(BulkCode::DSETBUFFER, 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) : BulkCommand(4) { | |
| 414 | +BulkSetRecordLength2250::BulkSetRecordLength2250(uint8_t recordLength) : BulkCommand(BulkCode::DSETBUFFER, 4) { | |
| 415 | 415 | this->init(); |
| 416 | 416 | |
| 417 | 417 | this->setRecordLength(recordLength); |
| ... | ... | @@ -431,7 +431,7 @@ void BulkSetRecordLength2250::init() { this->array[0] = (uint8_t)BulkCode::DSETB |
| 431 | 431 | ////////////////////////////////////////////////////////////////////////////// |
| 432 | 432 | // class BulkSetBuffer5200 |
| 433 | 433 | /// \brief Sets the data array to the default values. |
| 434 | -BulkSetBuffer5200::BulkSetBuffer5200() : BulkCommand(10) { this->init(); } | |
| 434 | +BulkSetBuffer5200::BulkSetBuffer5200() : BulkCommand(BulkCode::DSETBUFFER, 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() : BulkCommand(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 | - : BulkCommand(10) { | |
| 444 | + : BulkCommand(BulkCode::DSETBUFFER, 10) { | |
| 445 | 445 | this->init(); |
| 446 | 446 | |
| 447 | 447 | this->setTriggerPositionPre(triggerPositionPre); |
| ... | ... | @@ -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() : BulkCommand(8) { this->init(); } | |
| 514 | +BulkSetSamplerate2250::BulkSetSamplerate2250() : BulkCommand(BulkCode::ESETTRIGGERORSAMPLERATE, 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 | - : BulkCommand(8) { | |
| 521 | + : BulkCommand(BulkCode::ESETTRIGGERORSAMPLERATE, 8) { | |
| 522 | 522 | this->init(); |
| 523 | 523 | |
| 524 | 524 | this->setFastRate(fastRate); |
| ... | ... | @@ -563,7 +563,7 @@ void BulkSetSamplerate2250::init() { this->array[0] = (uint8_t)BulkCode::ESETTRI |
| 563 | 563 | ////////////////////////////////////////////////////////////////////////////// |
| 564 | 564 | // class BulkSetTrigger5200 |
| 565 | 565 | /// \brief Sets the data array to the default values. |
| 566 | -BulkSetTrigger5200::BulkSetTrigger5200() : BulkCommand(8) { this->init(); } | |
| 566 | +BulkSetTrigger5200::BulkSetTrigger5200() : BulkCommand(BulkCode::ESETTRIGGERORSAMPLERATE, 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() : BulkCommand(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 | - : BulkCommand(8) { | |
| 576 | + : BulkCommand(BulkCode::ESETTRIGGERORSAMPLERATE, 8) { | |
| 577 | 577 | this->init(); |
| 578 | 578 | |
| 579 | 579 | this->setTriggerSource(triggerSource); |
| ... | ... | @@ -633,13 +633,13 @@ void BulkSetTrigger5200::init() { |
| 633 | 633 | /// \class BulkSetBuffer2250 hantek/types.h |
| 634 | 634 | /// \brief The DSO-2250 BulkCode::FSETBUFFER builder. |
| 635 | 635 | /// \brief Sets the data array to the default values. |
| 636 | -BulkSetBuffer2250::BulkSetBuffer2250() : BulkCommand(10) { this->init(); } | |
| 636 | +BulkSetBuffer2250::BulkSetBuffer2250() : BulkCommand(BulkCode::FSETBUFFER, 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 | - : BulkCommand(12) { | |
| 642 | + : BulkCommand(BulkCode::FSETBUFFER, 12) { | |
| 643 | 643 | this->init(); |
| 644 | 644 | |
| 645 | 645 | this->setTriggerPositionPre(triggerPositionPre); | ... | ... |
openhantek/src/hantekprotocol/bulkStructs.h
| ... | ... | @@ -9,20 +9,10 @@ |
| 9 | 9 | |
| 10 | 10 | #include "definitions.h" |
| 11 | 11 | #include "states.h" |
| 12 | -#include "utils/dataarray.h" | |
| 12 | +#include "usb/bulkcommand.h" | |
| 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 | -public: | |
| 20 | - bool pending = false; | |
| 21 | - BulkCommand* next = nullptr; | |
| 22 | -}; | |
| 23 | - | |
| 24 | -////////////////////////////////////////////////////////////////////////////// | |
| 25 | -/// \class BulkSetFilter hantek/types.h | |
| 26 | 16 | /// \brief The BULK::SETFILTER builder. |
| 27 | 17 | class BulkSetFilter : public BulkCommand { |
| 28 | 18 | public: |
| ... | ... | @@ -38,8 +28,6 @@ class BulkSetFilter : public BulkCommand { |
| 38 | 28 | void init(); |
| 39 | 29 | }; |
| 40 | 30 | |
| 41 | -////////////////////////////////////////////////////////////////////////////// | |
| 42 | -/// \class BulkSetTriggerAndSamplerate hantek/types.h | |
| 43 | 31 | /// \brief The BulkCode::SETTRIGGERANDSAMPLERATE builder. |
| 44 | 32 | class BulkSetTriggerAndSamplerate : public BulkCommand { |
| 45 | 33 | public: |
| ... | ... | @@ -71,48 +59,36 @@ class BulkSetTriggerAndSamplerate : public BulkCommand { |
| 71 | 59 | void init(); |
| 72 | 60 | }; |
| 73 | 61 | |
| 74 | -////////////////////////////////////////////////////////////////////////////// | |
| 75 | -/// \class BulkForceTrigger hantek/types.h | |
| 76 | 62 | /// \brief The BulkCode::FORCETRIGGER builder. |
| 77 | 63 | class BulkForceTrigger : public BulkCommand { |
| 78 | 64 | public: |
| 79 | 65 | BulkForceTrigger(); |
| 80 | 66 | }; |
| 81 | 67 | |
| 82 | -////////////////////////////////////////////////////////////////////////////// | |
| 83 | -/// \class BulkCaptureStart hantek/types.h | |
| 84 | 68 | /// \brief The BULK_CAPTURESTART builder. |
| 85 | 69 | class BulkCaptureStart : public BulkCommand { |
| 86 | 70 | public: |
| 87 | 71 | BulkCaptureStart(); |
| 88 | 72 | }; |
| 89 | 73 | |
| 90 | -////////////////////////////////////////////////////////////////////////////// | |
| 91 | -/// \class BulkTriggerEnabled hantek/types.h | |
| 92 | 74 | /// \brief The BULK_TRIGGERENABLED builder. |
| 93 | 75 | class BulkTriggerEnabled : public BulkCommand { |
| 94 | 76 | public: |
| 95 | 77 | BulkTriggerEnabled(); |
| 96 | 78 | }; |
| 97 | 79 | |
| 98 | -////////////////////////////////////////////////////////////////////////////// | |
| 99 | -/// \class BulkGetData hantek/types.h | |
| 100 | 80 | /// \brief The BulkCode::GETDATA builder. |
| 101 | 81 | class BulkGetData : public BulkCommand { |
| 102 | 82 | public: |
| 103 | 83 | BulkGetData(); |
| 104 | 84 | }; |
| 105 | 85 | |
| 106 | -////////////////////////////////////////////////////////////////////////////// | |
| 107 | -/// \class BulkGetCaptureState hantek/types.h | |
| 108 | 86 | /// \brief The BulkCode::GETCAPTURESTATE builder. |
| 109 | 87 | class BulkGetCaptureState : public BulkCommand { |
| 110 | 88 | public: |
| 111 | 89 | BulkGetCaptureState(); |
| 112 | 90 | }; |
| 113 | 91 | |
| 114 | -////////////////////////////////////////////////////////////////////////////// | |
| 115 | -/// \class BulkResponseGetCaptureState hantek/types.h | |
| 116 | 92 | /// \brief The parser for the BulkCode::GETCAPTURESTATE response. |
| 117 | 93 | class BulkResponseGetCaptureState : public BulkCommand { |
| 118 | 94 | public: |
| ... | ... | @@ -122,8 +98,6 @@ class BulkResponseGetCaptureState : public BulkCommand { |
| 122 | 98 | unsigned int getTriggerPoint(); |
| 123 | 99 | }; |
| 124 | 100 | |
| 125 | -////////////////////////////////////////////////////////////////////////////// | |
| 126 | -/// \class BulkSetGain hantek/types.h | |
| 127 | 101 | /// \brief The BulkCode::SETGAIN builder. |
| 128 | 102 | class BulkSetGain : public BulkCommand { |
| 129 | 103 | public: |
| ... | ... | @@ -137,8 +111,6 @@ class BulkSetGain : public BulkCommand { |
| 137 | 111 | void init(); |
| 138 | 112 | }; |
| 139 | 113 | |
| 140 | -////////////////////////////////////////////////////////////////////////////// | |
| 141 | -/// \class BulkSetLogicalData hantek/types.h | |
| 142 | 114 | /// \brief The BulkCode::SETLOGICALDATA builder. |
| 143 | 115 | class BulkSetLogicalData : public BulkCommand { |
| 144 | 116 | public: |
| ... | ... | @@ -152,16 +124,12 @@ class BulkSetLogicalData : public BulkCommand { |
| 152 | 124 | void init(); |
| 153 | 125 | }; |
| 154 | 126 | |
| 155 | -////////////////////////////////////////////////////////////////////////////// | |
| 156 | -/// \class BulkGetLogicalData hantek/types.h | |
| 157 | 127 | /// \brief The BulkCode::GETLOGICALDATA builder. |
| 158 | 128 | class BulkGetLogicalData : public BulkCommand { |
| 159 | 129 | public: |
| 160 | 130 | BulkGetLogicalData(); |
| 161 | 131 | }; |
| 162 | 132 | |
| 163 | -////////////////////////////////////////////////////////////////////////////// | |
| 164 | -/// \class BulkSetChannels2250 hantek/types.h | |
| 165 | 133 | /// \brief The DSO-2250 BULK_BSETFILTER builder. |
| 166 | 134 | class BulkSetChannels2250 : public BulkCommand { |
| 167 | 135 | public: |
| ... | ... | @@ -175,8 +143,6 @@ class BulkSetChannels2250 : public BulkCommand { |
| 175 | 143 | void init(); |
| 176 | 144 | }; |
| 177 | 145 | |
| 178 | -////////////////////////////////////////////////////////////////////////////// | |
| 179 | -/// \class BulkSetTrigger2250 hantek/types.h | |
| 180 | 146 | /// \brief The DSO-2250 BulkCode::CSETTRIGGERORSAMPLERATE builder. |
| 181 | 147 | class BulkSetTrigger2250 : public BulkCommand { |
| 182 | 148 | public: |
| ... | ... | @@ -192,8 +158,6 @@ class BulkSetTrigger2250 : public BulkCommand { |
| 192 | 158 | void init(); |
| 193 | 159 | }; |
| 194 | 160 | |
| 195 | -////////////////////////////////////////////////////////////////////////////// | |
| 196 | -/// \class BulkSetSamplerate5200 hantek/types.h | |
| 197 | 161 | /// \brief The DSO-5200/DSO-5200A BulkCode::CSETTRIGGERORSAMPLERATE builder. |
| 198 | 162 | class BulkSetSamplerate5200 : public BulkCommand { |
| 199 | 163 | public: |
| ... | ... | @@ -209,8 +173,6 @@ class BulkSetSamplerate5200 : public BulkCommand { |
| 209 | 173 | void init(); |
| 210 | 174 | }; |
| 211 | 175 | |
| 212 | -////////////////////////////////////////////////////////////////////////////// | |
| 213 | -/// \class BulkSetRecordLength2250 hantek/types.h | |
| 214 | 176 | /// \brief The DSO-2250 BulkCode::DSETBUFFER builder. |
| 215 | 177 | class BulkSetRecordLength2250 : public BulkCommand { |
| 216 | 178 | public: |
| ... | ... | @@ -224,8 +186,6 @@ class BulkSetRecordLength2250 : public BulkCommand { |
| 224 | 186 | void init(); |
| 225 | 187 | }; |
| 226 | 188 | |
| 227 | -////////////////////////////////////////////////////////////////////////////// | |
| 228 | -/// \class BulkSetBuffer5200 hantek/types.h | |
| 229 | 189 | /// \brief The DSO-5200/DSO-5200A BulkCode::DSETBUFFER builder. |
| 230 | 190 | class BulkSetBuffer5200 : public BulkCommand { |
| 231 | 191 | public: |
| ... | ... | @@ -248,8 +208,6 @@ class BulkSetBuffer5200 : public BulkCommand { |
| 248 | 208 | void init(); |
| 249 | 209 | }; |
| 250 | 210 | |
| 251 | -////////////////////////////////////////////////////////////////////////////// | |
| 252 | -/// \class BulkSetSamplerate2250 hantek/types.h | |
| 253 | 211 | /// \brief The DSO-2250 BulkCode::ESETTRIGGERORSAMPLERATE builder. |
| 254 | 212 | class BulkSetSamplerate2250 : public BulkCommand { |
| 255 | 213 | public: |
| ... | ... | @@ -267,8 +225,6 @@ class BulkSetSamplerate2250 : public BulkCommand { |
| 267 | 225 | void init(); |
| 268 | 226 | }; |
| 269 | 227 | |
| 270 | -////////////////////////////////////////////////////////////////////////////// | |
| 271 | -/// \class BulkSetTrigger5200 hantek/types.h | |
| 272 | 228 | /// \brief The DSO-5200/DSO-5200A BulkCode::ESETTRIGGERORSAMPLERATE builder. |
| 273 | 229 | class BulkSetTrigger5200 : public BulkCommand { |
| 274 | 230 | public: |
| ... | ... | @@ -291,8 +247,6 @@ class BulkSetTrigger5200 : public BulkCommand { |
| 291 | 247 | void init(); |
| 292 | 248 | }; |
| 293 | 249 | |
| 294 | -////////////////////////////////////////////////////////////////////////////// | |
| 295 | -/// \class BulkSetBuffer2250 hantek/types.h | |
| 296 | 250 | /// \brief The DSO-2250 BulkCode::FSETBUFFER builder. |
| 297 | 251 | class BulkSetBuffer2250 : public BulkCommand { |
| 298 | 252 | public: | ... | ... |
openhantek/src/hantekprotocol/bulkcode.h
openhantek/src/hantekprotocol/controlStructs.cpp
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | #include <cstring> |
| 4 | 4 | |
| 5 | 5 | #include "controlStructs.h" |
| 6 | +#include "controlvalue.h" | |
| 6 | 7 | |
| 7 | 8 | namespace Hantek { |
| 8 | 9 | |
| ... | ... | @@ -109,4 +110,14 @@ ControlSetTimeDIV::ControlSetTimeDIV() : ControlCommand(ControlCode::CONTROL_SET |
| 109 | 110 | void ControlSetTimeDIV::setDiv(uint8_t val) { this->array[0] = val; } |
| 110 | 111 | |
| 111 | 112 | ControlAcquireHardData::ControlAcquireHardData() : ControlCommand(ControlCode::CONTROL_ACQUIIRE_HARD_DATA,1) { this->array[0] = 0x01; } |
| 113 | + | |
| 114 | +ControlGetLimits::ControlGetLimits(unsigned channels) : ControlCommand(ControlCode::CONTROL_VALUE,1), offsetLimit(new OffsetsPerGainStep[channels]) { | |
| 115 | + value = (uint8_t)ControlValue::VALUE_OFFSETLIMITS; | |
| 116 | + array[0] = 0x01; | |
| 117 | +} | |
| 118 | + | |
| 119 | +ControlGetLimits::~ControlGetLimits() | |
| 120 | +{ | |
| 121 | + delete [] offsetLimit; | |
| 122 | +} | |
| 112 | 123 | } | ... | ... |
openhantek/src/hantekprotocol/controlStructs.h
| ... | ... | @@ -2,18 +2,10 @@ |
| 2 | 2 | |
| 3 | 3 | #include "definitions.h" |
| 4 | 4 | #include "usb/usbdevicedefinitions.h" |
| 5 | -#include "utils/dataarray.h" | |
| 5 | +#include "usb/controlcommand.h" | |
| 6 | 6 | #include "controlcode.h" |
| 7 | 7 | |
| 8 | 8 | namespace Hantek { |
| 9 | -class ControlCommand : public DataArray<uint8_t> { | |
| 10 | -protected: | |
| 11 | - ControlCommand(ControlCode code, unsigned size): DataArray<uint8_t>(size), code(code) {} | |
| 12 | -public: | |
| 13 | - bool pending = false; | |
| 14 | - ControlCode code; | |
| 15 | - ControlCommand* next = nullptr; | |
| 16 | -}; | |
| 17 | 9 | |
| 18 | 10 | struct ControlSetOffset : public ControlCommand { |
| 19 | 11 | ControlSetOffset(); |
| ... | ... | @@ -102,4 +94,10 @@ struct ControlSetTimeDIV : public ControlCommand { |
| 102 | 94 | struct ControlAcquireHardData : public ControlCommand { |
| 103 | 95 | ControlAcquireHardData(); |
| 104 | 96 | }; |
| 97 | + | |
| 98 | +struct ControlGetLimits : public ControlCommand { | |
| 99 | + OffsetsPerGainStep* offsetLimit; | |
| 100 | + ControlGetLimits(unsigned channels); | |
| 101 | + ~ControlGetLimits(); | |
| 102 | +}; | |
| 105 | 103 | } | ... | ... |
openhantek/src/usb/bulkcommand.cpp
0 → 100644
openhantek/src/usb/bulkcommand.h
0 → 100644
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | + | |
| 3 | +#pragma once | |
| 4 | + | |
| 5 | +#include <inttypes.h> | |
| 6 | +#include "dataarray.h" | |
| 7 | + | |
| 8 | +namespace Hantek { | |
| 9 | +enum class BulkCode : uint8_t; | |
| 10 | +} | |
| 11 | + | |
| 12 | +class BulkCommand : public DataArray<uint8_t> { | |
| 13 | +protected: | |
| 14 | + BulkCommand(Hantek::BulkCode code, unsigned size); | |
| 15 | +public: | |
| 16 | + Hantek::BulkCode code; | |
| 17 | + bool pending = false; | |
| 18 | + BulkCommand* next = nullptr; | |
| 19 | +}; | ... | ... |
openhantek/src/usb/controlbegin.cpp
| 1 | 1 | #include "controlbegin.h" |
| 2 | +#include "hantekprotocol/controlcode.h" | |
| 2 | 3 | |
| 3 | -ControlBeginCommand::ControlBeginCommand(BulkIndex index) : DataArray<uint8_t>(10) { | |
| 4 | +ControlBeginCommand::ControlBeginCommand(BulkIndex index) : ControlCommand(Hantek::ControlCode::CONTROL_BEGINCOMMAND, 10) { | |
| 4 | 5 | array[0] = 0x0f; |
| 5 | 6 | array[1] = (uint8_t)index; |
| 6 | 7 | } | ... | ... |
openhantek/src/usb/controlbegin.h
| ... | ... | @@ -2,13 +2,23 @@ |
| 2 | 2 | // SPDX-License-Identifier: GPL-2.0+ |
| 3 | 3 | |
| 4 | 4 | #pragma once |
| 5 | -#include "utils/dataarray.h" | |
| 5 | +#include "controlcommand.h" | |
| 6 | 6 | #include <inttypes.h> |
| 7 | -#include "usbdevicedefinitions.h" | |
| 7 | + | |
| 8 | +/// \enum BulkIndex | |
| 9 | +/// \brief Can be set by CONTROL_BEGINCOMMAND, maybe it allows multiple commands | |
| 10 | +/// at the same time? | |
| 11 | +enum BulkIndex { | |
| 12 | + COMMANDINDEX_0 = 0x03, ///< Used most of the time | |
| 13 | + COMMANDINDEX_1 = 0x0a, | |
| 14 | + COMMANDINDEX_2 = 0x09, | |
| 15 | + COMMANDINDEX_3 = 0x01, ///< Used for ::BulkCode::SETTRIGGERANDSAMPLERATE sometimes | |
| 16 | + COMMANDINDEX_4 = 0x02, | |
| 17 | + COMMANDINDEX_5 = 0x08 | |
| 18 | +}; | |
| 8 | 19 | |
| 9 | 20 | /// \class ControlBeginCommand |
| 10 | -/// \brief The CONTROL_BEGINCOMMAND builder. | |
| 11 | -class ControlBeginCommand : public DataArray<uint8_t> { | |
| 21 | +class ControlBeginCommand : public ControlCommand { | |
| 12 | 22 | public: |
| 13 | 23 | /// \brief Sets the command index to the given value. |
| 14 | 24 | /// \param index The CommandIndex for the command. | ... | ... |
openhantek/src/usb/controlcommand.cpp
0 → 100644
openhantek/src/usb/controlcommand.h
0 → 100644
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | + | |
| 3 | +#pragma once | |
| 4 | + | |
| 5 | +#include <inttypes.h> | |
| 6 | +#include "dataarray.h" | |
| 7 | + | |
| 8 | +namespace Hantek { | |
| 9 | +enum class ControlCode : uint8_t; | |
| 10 | +} | |
| 11 | + | |
| 12 | +class ControlCommand : public DataArray<uint8_t> { | |
| 13 | +protected: | |
| 14 | + ControlCommand(Hantek::ControlCode code, unsigned size); | |
| 15 | +public: | |
| 16 | + bool pending = false; | |
| 17 | + uint8_t code; | |
| 18 | + uint8_t value = 0; | |
| 19 | + ControlCommand* next = nullptr; | |
| 20 | +}; | ... | ... |
openhantek/src/usb/controlgetspeed.cpp
| 1 | 1 | #include "controlgetspeed.h" |
| 2 | +#include "hantekprotocol/controlcode.h" | |
| 2 | 3 | |
| 3 | -ControlGetSpeed::ControlGetSpeed() : DataArray<uint8_t>(10) {} | |
| 4 | +ControlGetSpeed::ControlGetSpeed() : ControlCommand(Hantek::ControlCode::CONTROL_GETSPEED, 10) {} | |
| 4 | 5 | |
| 5 | 6 | ConnectionSpeed ControlGetSpeed::getSpeed() { return (ConnectionSpeed)this->array[0]; } |
| 6 | 7 | ... | ... |
openhantek/src/usb/controlgetspeed.h
| 1 | - | |
| 2 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 3 | 2 | |
| 4 | 3 | #pragma once |
| 5 | -#include "utils/dataarray.h" | |
| 6 | -#include <inttypes.h> | |
| 4 | +#include "controlcommand.h" | |
| 7 | 5 | #include "usbdevicedefinitions.h" |
| 8 | 6 | |
| 9 | -/// \class ControlGetSpeed | |
| 10 | 7 | /// \brief The CONTROL_GETSPEED parser. |
| 11 | -class ControlGetSpeed : public DataArray<uint8_t> { | |
| 8 | +class ControlGetSpeed : public ControlCommand { | |
| 12 | 9 | public: |
| 13 | 10 | ControlGetSpeed(); |
| 14 | 11 | /// \brief Gets the speed of the connection. | ... | ... |
openhantek/src/utils/dataarray.cpp renamed to openhantek/src/usb/dataarray.cpp
openhantek/src/utils/dataarray.h renamed to openhantek/src/usb/dataarray.h
openhantek/src/usb/usbdevice.cpp
| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | |
| 7 | 7 | #include "usbdevice.h" |
| 8 | 8 | |
| 9 | +#include "hantekprotocol/controlStructs.h" | |
| 10 | +#include "hantekprotocol/bulkStructs.h" | |
| 9 | 11 | #include "controlgetspeed.h" |
| 10 | 12 | #include "models.h" |
| 11 | 13 | #include "utils/printutils.h" |
| ... | ... | @@ -139,11 +141,6 @@ int USBDevice::bulkTransfer(unsigned char endpoint, const unsigned char *data, u |
| 139 | 141 | return transferred; |
| 140 | 142 | } |
| 141 | 143 | |
| 142 | -/// \brief Bulk write to the oscilloscope. | |
| 143 | -/// \param data Buffer for the sent/recieved data. | |
| 144 | -/// \param length The length of the packet. | |
| 145 | -/// \param attempts The number of attempts, that are done on timeouts. | |
| 146 | -/// \return Number of sent bytes on success, libusb error code on error. | |
| 147 | 144 | int USBDevice::bulkWrite(const unsigned char *data, unsigned int length, int attempts) { |
| 148 | 145 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| 149 | 146 | |
| ... | ... | @@ -153,11 +150,6 @@ int USBDevice::bulkWrite(const unsigned char *data, unsigned int length, int att |
| 153 | 150 | return this->bulkTransfer(HANTEK_EP_OUT, data, length, attempts); |
| 154 | 151 | } |
| 155 | 152 | |
| 156 | -/// \brief Bulk read from the oscilloscope. | |
| 157 | -/// \param data Buffer for the sent/recieved data. | |
| 158 | -/// \param length The length of the packet. | |
| 159 | -/// \param attempts The number of attempts, that are done on timeouts. | |
| 160 | -/// \return Number of received bytes on success, libusb error code on error. | |
| 161 | 153 | int USBDevice::bulkRead(unsigned char *data, unsigned int length, int attempts) { |
| 162 | 154 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| 163 | 155 | |
| ... | ... | @@ -167,29 +159,19 @@ int USBDevice::bulkRead(unsigned char *data, unsigned int length, int attempts) |
| 167 | 159 | return this->bulkTransfer(HANTEK_EP_IN, data, length, attempts); |
| 168 | 160 | } |
| 169 | 161 | |
| 170 | -/// \brief Send a bulk command to the oscilloscope. | |
| 171 | -/// \param command The command, that should be sent. | |
| 172 | -/// \param attempts The number of attempts, that are done on timeouts. | |
| 173 | -/// \return Number of sent bytes on success, libusb error code on error. | |
| 174 | 162 | int USBDevice::bulkCommand(const DataArray<unsigned char> *command, int attempts) { |
| 175 | 163 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| 176 | 164 | |
| 177 | 165 | if (!allowBulkTransfer) return LIBUSB_SUCCESS; |
| 178 | 166 | |
| 179 | 167 | // Send BeginCommand control command |
| 180 | - int errorCode = this->controlWrite((uint8_t)Hantek::ControlCode::CONTROL_BEGINCOMMAND, beginCommandControl.data(), | |
| 181 | - beginCommandControl.getSize()); | |
| 168 | + int errorCode = this->controlWrite(&beginCommandControl); | |
| 182 | 169 | if (errorCode < 0) return errorCode; |
| 183 | 170 | |
| 184 | 171 | // Send bulk command |
| 185 | 172 | return this->bulkWrite(command->data(), command->getSize(), attempts); |
| 186 | 173 | } |
| 187 | 174 | |
| 188 | -/// \brief Multi packet bulk read from the oscilloscope. | |
| 189 | -/// \param data Buffer for the sent/recieved data. | |
| 190 | -/// \param length The length of data contained in the packets. | |
| 191 | -/// \param attempts The number of attempts, that are done on timeouts. | |
| 192 | -/// \return Number of received bytes on success, libusb error code on error. | |
| 193 | 175 | int USBDevice::bulkReadMulti(unsigned char *data, unsigned length, int attempts) { |
| 194 | 176 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| 195 | 177 | |
| ... | ... | @@ -213,15 +195,6 @@ int USBDevice::bulkReadMulti(unsigned char *data, unsigned length, int attempts) |
| 213 | 195 | return errorCode; |
| 214 | 196 | } |
| 215 | 197 | |
| 216 | -/// \brief Control transfer to the oscilloscope. | |
| 217 | -/// \param type The request type, also sets the direction of the transfer. | |
| 218 | -/// \param request The request field of the packet. | |
| 219 | -/// \param data Buffer for the sent/recieved data. | |
| 220 | -/// \param length The length field of the packet. | |
| 221 | -/// \param value The value field of the packet. | |
| 222 | -/// \param index The index field of the packet. | |
| 223 | -/// \param attempts The number of attempts, that are done on timeouts. | |
| 224 | -/// \return Number of transferred bytes on success, libusb error code on error. | |
| 225 | 198 | int USBDevice::controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, |
| 226 | 199 | int value, int index, int attempts) { |
| 227 | 200 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| ... | ... | @@ -234,52 +207,29 @@ int USBDevice::controlTransfer(unsigned char type, unsigned char request, unsign |
| 234 | 207 | return errorCode; |
| 235 | 208 | } |
| 236 | 209 | |
| 237 | -/// \brief Control write to the oscilloscope. | |
| 238 | -/// \param request The request field of the packet. | |
| 239 | -/// \param data Buffer for the sent/recieved data. | |
| 240 | -/// \param length The length field of the packet. | |
| 241 | -/// \param value The value field of the packet. | |
| 242 | -/// \param index The index field of the packet. | |
| 243 | -/// \param attempts The number of attempts, that are done on timeouts. | |
| 244 | -/// \return Number of sent bytes on success, libusb error code on error. | |
| 245 | -int USBDevice::controlWrite(uint8_t request, unsigned char *data, unsigned int length, int value, int index, | |
| 246 | - int attempts) { | |
| 210 | +int USBDevice::controlWrite(const ControlCommand* command) { | |
| 247 | 211 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| 248 | 212 | // std::cout << "control" << (int)request << " l:"<<length<<" d:"<<(int)data[0] << std::endl; |
| 249 | - return this->controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT, request, data, length, value, index, | |
| 250 | - attempts); | |
| 213 | + return this->controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT, | |
| 214 | + (uint8_t)command->code, command->data(), command->getSize(), command->value, 0, HANTEK_ATTEMPTS); | |
| 251 | 215 | } |
| 252 | 216 | |
| 253 | -/// \brief Control read to the oscilloscope. | |
| 254 | -/// \param request The request field of the packet. | |
| 255 | -/// \param data Buffer for the sent/recieved data. | |
| 256 | -/// \param length The length field of the packet. | |
| 257 | -/// \param value The value field of the packet. | |
| 258 | -/// \param index The index field of the packet. | |
| 259 | -/// \param attempts The number of attempts, that are done on timeouts. | |
| 260 | -/// \return Number of received bytes on success, libusb error code on error. | |
| 261 | -int USBDevice::controlRead(unsigned char request, unsigned char *data, unsigned int length, int value, int index, | |
| 262 | - int attempts) { | |
| 217 | +int USBDevice::controlRead(const ControlCommand *command) { | |
| 263 | 218 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| 264 | 219 | |
| 265 | - return this->controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN, request, data, length, value, index, | |
| 266 | - attempts); | |
| 220 | + return this->controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN, | |
| 221 | + (uint8_t)command->code, command->data(), command->getSize(), command->value, 0, HANTEK_ATTEMPTS); | |
| 267 | 222 | } |
| 268 | 223 | |
| 269 | -/// \brief Gets the speed of the connection. | |
| 270 | -/// \return The ::ConnectionSpeed of the USB connection. | |
| 271 | 224 | int USBDevice::getConnectionSpeed() { |
| 272 | 225 | int errorCode; |
| 273 | 226 | ControlGetSpeed response; |
| 274 | - | |
| 275 | - errorCode = this->controlRead((uint8_t)Hantek::ControlCode::CONTROL_GETSPEED, response.data(), response.getSize()); | |
| 227 | + errorCode = this->controlRead(&response); | |
| 276 | 228 | if (errorCode < 0) return errorCode; |
| 277 | 229 | |
| 278 | 230 | return response.getSpeed(); |
| 279 | 231 | } |
| 280 | 232 | |
| 281 | -/// \brief Gets the maximum size of one packet transmitted via bulk transfer. | |
| 282 | -/// \return The maximum packet size in bytes, negative libusb error code on error. | |
| 283 | 233 | int USBDevice::getPacketSize() { |
| 284 | 234 | const int s = this->getConnectionSpeed(); |
| 285 | 235 | if (s == CONNECTION_FULLSPEED) | ... | ... |
openhantek/src/usb/usbdevice.h
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #include "controlbegin.h" |
| 12 | 12 | |
| 13 | 13 | class DSOModel; |
| 14 | +class ControlCommand; | |
| 14 | 15 | |
| 15 | 16 | typedef unsigned long UniqueUSBid; |
| 16 | 17 | |
| ... | ... | @@ -28,6 +29,10 @@ class USBDevice : public QObject { |
| 28 | 29 | /// \brief Check if the oscilloscope is connected. |
| 29 | 30 | /// \return true, if a connection is up. |
| 30 | 31 | bool isConnected(); |
| 32 | + | |
| 33 | + /** | |
| 34 | + * @return Return true if this device needs a firmware first | |
| 35 | + */ | |
| 31 | 36 | bool needsFirmware(); |
| 32 | 37 | |
| 33 | 38 | /** |
| ... | ... | @@ -37,8 +42,6 @@ class USBDevice : public QObject { |
| 37 | 42 | void setFindIteration(unsigned iteration); |
| 38 | 43 | unsigned getFindIteration() const; |
| 39 | 44 | |
| 40 | - // Various methods to handle USB transfers | |
| 41 | - | |
| 42 | 45 | /// \brief Bulk transfer to/from the oscilloscope. |
| 43 | 46 | /// \param endpoint Endpoint number, also sets the direction of the transfer. |
| 44 | 47 | /// \param data Buffer for the sent/recieved data. |
| ... | ... | @@ -49,20 +52,72 @@ class USBDevice : public QObject { |
| 49 | 52 | /// error. |
| 50 | 53 | int bulkTransfer(unsigned char endpoint, const unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS, |
| 51 | 54 | unsigned int timeout = HANTEK_TIMEOUT); |
| 55 | + | |
| 56 | + /// \brief Bulk write to the oscilloscope. | |
| 57 | + /// \param data Buffer for the sent/recieved data. | |
| 58 | + /// \param length The length of the packet. | |
| 59 | + /// \param attempts The number of attempts, that are done on timeouts. | |
| 60 | + /// \return Number of sent bytes on success, libusb error code on error. | |
| 52 | 61 | int bulkWrite(const unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS); |
| 62 | + | |
| 63 | + /// \brief Bulk read from the oscilloscope. | |
| 64 | + /// \param data Buffer for the sent/recieved data. | |
| 65 | + /// \param length The length of the packet. | |
| 66 | + /// \param attempts The number of attempts, that are done on timeouts. | |
| 67 | + /// \return Number of received bytes on success, libusb error code on error. | |
| 53 | 68 | int bulkRead(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS); |
| 54 | 69 | |
| 70 | + /// \brief Send a bulk command to the oscilloscope. | |
| 71 | + /// \param command The command, that should be sent. | |
| 72 | + /// \param attempts The number of attempts, that are done on timeouts. | |
| 73 | + /// \return Number of sent bytes on success, libusb error code on error. | |
| 55 | 74 | int bulkCommand(const DataArray<unsigned char> *command, int attempts = HANTEK_ATTEMPTS); |
| 75 | + | |
| 76 | + /// \brief Multi packet bulk read from the oscilloscope. | |
| 77 | + /// \param data Buffer for the sent/recieved data. | |
| 78 | + /// \param length The length of data contained in the packets. | |
| 79 | + /// \param attempts The number of attempts, that are done on timeouts. | |
| 80 | + /// \return Number of received bytes on success, libusb error code on error. | |
| 56 | 81 | int bulkReadMulti(unsigned char *data, unsigned length, int attempts = HANTEK_ATTEMPTS_MULTI); |
| 57 | 82 | |
| 83 | + /// \brief Control transfer to the oscilloscope. | |
| 84 | + /// \param type The request type, also sets the direction of the transfer. | |
| 85 | + /// \param request The request field of the packet. | |
| 86 | + /// \param data Buffer for the sent/recieved data. | |
| 87 | + /// \param length The length field of the packet. | |
| 88 | + /// \param value The value field of the packet. | |
| 89 | + /// \param index The index field of the packet. | |
| 90 | + /// \param attempts The number of attempts, that are done on timeouts. | |
| 91 | + /// \return Number of transferred bytes on success, libusb error code on error. | |
| 58 | 92 | int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, |
| 59 | 93 | int index, int attempts = HANTEK_ATTEMPTS); |
| 60 | - int controlWrite(uint8_t request, unsigned char *data, unsigned int length, int value = 0, int index = 0, | |
| 61 | - int attempts = HANTEK_ATTEMPTS); | |
| 62 | - int controlRead(unsigned char request, unsigned char *data, unsigned int length, int value = 0, int index = 0, | |
| 63 | - int attempts = HANTEK_ATTEMPTS); | |
| 64 | 94 | |
| 95 | + /// \brief Control write to the oscilloscope. | |
| 96 | + /// \param request The request field of the packet. | |
| 97 | + /// \param data Buffer for the sent/recieved data. | |
| 98 | + /// \param length The length field of the packet. | |
| 99 | + /// \param value The value field of the packet. | |
| 100 | + /// \param index The index field of the packet. | |
| 101 | + /// \param attempts The number of attempts, that are done on timeouts. | |
| 102 | + /// \return Number of sent bytes on success, libusb error code on error. | |
| 103 | + int controlWrite(const ControlCommand *command); | |
| 104 | + | |
| 105 | + /// \brief Control read to the oscilloscope. | |
| 106 | + /// \param request The request field of the packet. | |
| 107 | + /// \param data Buffer for the sent/recieved data. | |
| 108 | + /// \param length The length field of the packet. | |
| 109 | + /// \param value The value field of the packet. | |
| 110 | + /// \param index The index field of the packet. | |
| 111 | + /// \param attempts The number of attempts, that are done on timeouts. | |
| 112 | + /// \return Number of received bytes on success, libusb error code on error. | |
| 113 | + int controlRead(const ControlCommand *command); | |
| 114 | + | |
| 115 | + /// \brief Gets the speed of the connection. | |
| 116 | + /// \return The ::ConnectionSpeed of the USB connection. | |
| 65 | 117 | int getConnectionSpeed(); |
| 118 | + | |
| 119 | + /// \brief Gets the maximum size of one packet transmitted via bulk transfer. | |
| 120 | + /// \return The maximum packet size in bytes, negative libusb error code on error. | |
| 66 | 121 | int getPacketSize(); |
| 67 | 122 | |
| 68 | 123 | /** | ... | ... |
openhantek/src/usb/usbdevicedefinitions.h
| ... | ... | @@ -15,16 +15,3 @@ enum ConnectionSpeed { |
| 15 | 15 | CONNECTION_FULLSPEED = 0, ///< FullSpeed USB, 64 byte bulk transfers |
| 16 | 16 | CONNECTION_HIGHSPEED = 1 ///< HighSpeed USB, 512 byte bulk transfers |
| 17 | 17 | }; |
| 18 | - | |
| 19 | -/// \enum BulkIndex | |
| 20 | -/// \brief Can be set by CONTROL_BEGINCOMMAND, maybe it allows multiple commands | |
| 21 | -/// at the same time? | |
| 22 | -enum BulkIndex { | |
| 23 | - COMMANDINDEX_0 = 0x03, ///< Used most of the time | |
| 24 | - COMMANDINDEX_1 = 0x0a, | |
| 25 | - COMMANDINDEX_2 = 0x09, | |
| 26 | - COMMANDINDEX_3 = 0x01, ///< Used for ::BulkCode::SETTRIGGERANDSAMPLERATE sometimes | |
| 27 | - COMMANDINDEX_4 = 0x02, | |
| 28 | - COMMANDINDEX_5 = 0x08 | |
| 29 | -}; | |
| 30 | - | ... | ... |