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
| @@ -94,5 +94,6 @@ struct ControlSpecification { | @@ -94,5 +94,6 @@ struct ControlSpecification { | ||
| 94 | bool supportsCaptureState = true; | 94 | bool supportsCaptureState = true; |
| 95 | bool supportsOffset = true; | 95 | bool supportsOffset = true; |
| 96 | bool supportsCouplingRelays = true; | 96 | bool supportsCouplingRelays = true; |
| 97 | + int fixedUSBinLength = 0; | ||
| 97 | }; | 98 | }; |
| 98 | } | 99 | } |
openhantek/src/hantekdso/hantekdsocontrol.cpp
| @@ -60,16 +60,11 @@ HantekDsoControl::HantekDsoControl(USBDevice *device) | @@ -60,16 +60,11 @@ HantekDsoControl::HantekDsoControl(USBDevice *device) | ||
| 60 | 60 | ||
| 61 | if (specification.useControlNoBulk) { | 61 | if (specification.useControlNoBulk) { |
| 62 | device->setEnableBulkTransfer(false); | 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 | // Apply special requirements by the devices model | 68 | // Apply special requirements by the devices model |
| 74 | device->getModel()->applyRequirements(this); | 69 | device->getModel()->applyRequirements(this); |
| 75 | 70 | ||
| @@ -135,15 +130,16 @@ unsigned HantekDsoControl::getRecordLength() const { | @@ -135,15 +130,16 @@ unsigned HantekDsoControl::getRecordLength() const { | ||
| 135 | 130 | ||
| 136 | Dso::ErrorCode HantekDsoControl::retrieveChannelLevelData() { | 131 | Dso::ErrorCode HantekDsoControl::retrieveChannelLevelData() { |
| 137 | // Get channel level data | 132 | // Get channel level data |
| 133 | + ControlGetLimits c(2); | ||
| 138 | int errorCode = | 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 | if (errorCode < 0) { | 136 | if (errorCode < 0) { |
| 142 | qWarning() << tr("Couldn't get channel level data from oscilloscope"); | 137 | qWarning() << tr("Couldn't get channel level data from oscilloscope"); |
| 143 | emit statusMessage(tr("Couldn't get channel level data from oscilloscope"), 0); | 138 | emit statusMessage(tr("Couldn't get channel level data from oscilloscope"), 0); |
| 144 | emit communicationError(); | 139 | emit communicationError(); |
| 145 | return Dso::ErrorCode::CONNECTION; | 140 | return Dso::ErrorCode::CONNECTION; |
| 146 | } | 141 | } |
| 142 | + memcpy(specification.offsetLimit,c.offsetLimit,sizeof(specification.offsetLimit)); | ||
| 147 | 143 | ||
| 148 | return Dso::ErrorCode::NONE; | 144 | return Dso::ErrorCode::NONE; |
| 149 | } | 145 | } |
| @@ -185,8 +181,7 @@ std::vector<unsigned char> HantekDsoControl::getSamples(unsigned &previousSample | @@ -185,8 +181,7 @@ std::vector<unsigned char> HantekDsoControl::getSamples(unsigned &previousSample | ||
| 185 | // Request data | 181 | // Request data |
| 186 | errorCode = device->bulkCommand(getCommand(BulkCode::GETDATA), 1); | 182 | errorCode = device->bulkCommand(getCommand(BulkCode::GETDATA), 1); |
| 187 | } else { | 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 | if (errorCode < 0) { | 186 | if (errorCode < 0) { |
| 192 | qWarning() << "Getting sample data failed: " << libUsbErrorString(errorCode); | 187 | qWarning() << "Getting sample data failed: " << libUsbErrorString(errorCode); |
| @@ -1040,18 +1035,18 @@ Dso::ErrorCode HantekDsoControl::stringCommand(const QString &commandString) { | @@ -1040,18 +1035,18 @@ Dso::ErrorCode HantekDsoControl::stringCommand(const QString &commandString) { | ||
| 1040 | return Dso::ErrorCode::UNSUPPORTED; | 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 | newCommand->pending = pending; | 1039 | newCommand->pending = pending; |
| 1045 | - command[(uint8_t)code] = newCommand; | 1040 | + command[(uint8_t)newCommand->code] = newCommand; |
| 1046 | newCommand->next = firstBulkCommand; | 1041 | newCommand->next = firstBulkCommand; |
| 1047 | firstBulkCommand = newCommand; | 1042 | firstBulkCommand = newCommand; |
| 1048 | } | 1043 | } |
| 1049 | 1044 | ||
| 1050 | const BulkCommand *HantekDsoControl::getCommand(BulkCode code) const { return command[(uint8_t)code]; } | 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 | newCommand->pending = pending; | 1048 | newCommand->pending = pending; |
| 1054 | - control[(uint8_t)code] = newCommand; | 1049 | + control[newCommand->code] = newCommand; |
| 1055 | newCommand->next = firstControlCommand; | 1050 | newCommand->next = firstControlCommand; |
| 1056 | firstControlCommand = newCommand; | 1051 | firstControlCommand = newCommand; |
| 1057 | } | 1052 | } |
| @@ -1087,8 +1082,7 @@ void HantekDsoControl::run() { | @@ -1087,8 +1082,7 @@ void HantekDsoControl::run() { | ||
| 1087 | .arg(QString::number(control[cIndex], 16), | 1082 | .arg(QString::number(control[cIndex], 16), |
| 1088 | hexDump(this->control[control]->data(), this->control[control]->getSize()))); | 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 | if (errorCode < 0) { | 1086 | if (errorCode < 0) { |
| 1093 | qWarning("Sending control command %2x failed: %s", (uint8_t)controlCommand->code, | 1087 | qWarning("Sending control command %2x failed: %s", (uint8_t)controlCommand->code, |
| 1094 | libUsbErrorString(errorCode).toLocal8Bit().data()); | 1088 | libUsbErrorString(errorCode).toLocal8Bit().data()); |
openhantek/src/hantekdso/hantekdsocontrol.h
| @@ -24,10 +24,6 @@ | @@ -24,10 +24,6 @@ | ||
| 24 | #include <QTimer> | 24 | #include <QTimer> |
| 25 | 25 | ||
| 26 | class USBDevice; | 26 | class USBDevice; |
| 27 | -namespace Hantek { | ||
| 28 | -class BulkCommand; | ||
| 29 | -class ControlCommand; | ||
| 30 | -} | ||
| 31 | 27 | ||
| 32 | /// \brief The DsoControl abstraction layer for %Hantek USB DSOs. | 28 | /// \brief The DsoControl abstraction layer for %Hantek USB DSOs. |
| 33 | /// TODO Please anyone, refactor this class into smaller pieces (Separation of Concerns!). | 29 | /// TODO Please anyone, refactor this class into smaller pieces (Separation of Concerns!). |
| @@ -93,19 +89,19 @@ class HantekDsoControl : public QObject { | @@ -93,19 +89,19 @@ class HantekDsoControl : public QObject { | ||
| 93 | /// \return See ::Dso::ErrorCode. | 89 | /// \return See ::Dso::ErrorCode. |
| 94 | Dso::ErrorCode stringCommand(const QString &commandString); | 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 | template<class T> T* modifyCommand(Hantek::BulkCode code) { | 93 | template<class T> T* modifyCommand(Hantek::BulkCode code) { |
| 98 | command[(uint8_t)code]->pending = true; | 94 | command[(uint8_t)code]->pending = true; |
| 99 | return static_cast<T*>(command[(uint8_t)code]); | 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 | template<class T> T* modifyCommand(Hantek::ControlCode code) { | 100 | template<class T> T* modifyCommand(Hantek::ControlCode code) { |
| 105 | control[(uint8_t)code]->pending = true; | 101 | control[(uint8_t)code]->pending = true; |
| 106 | return static_cast<T*>(control[(uint8_t)code]); | 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 | private: | 105 | private: |
| 110 | bool isRollMode() const; | 106 | bool isRollMode() const; |
| 111 | bool isFastRate() const; | 107 | bool isFastRate() const; |
| @@ -167,10 +163,10 @@ class HantekDsoControl : public QObject { | @@ -167,10 +163,10 @@ class HantekDsoControl : public QObject { | ||
| 167 | 163 | ||
| 168 | private: | 164 | private: |
| 169 | /// Pointers to bulk/control commands | 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 | // Communication with device | 171 | // Communication with device |
| 176 | USBDevice *device; ///< The USB device for the oscilloscope | 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,9 +30,16 @@ ModelDSO2090::ModelDSO2090() : DSOModel(ID, 0x04b5, 0x2090, 0x04b4, 0x2090, "dso | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | void ModelDSO2090::applyRequirements(HantekDsoControl *dsoControl) const { | 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 | ModelDSO2090A::ModelDSO2090A() { | 45 | ModelDSO2090A::ModelDSO2090A() { |
openhantek/src/hantekdso/models/modelDSO2150.cpp
| @@ -30,7 +30,14 @@ ModelDSO2150::ModelDSO2150() : DSOModel(ID, 0x04b5, 0x2150, 0x04b4, 0x2150, "dso | @@ -30,7 +30,14 @@ ModelDSO2150::ModelDSO2150() : DSOModel(ID, 0x04b5, 0x2150, 0x04b4, 0x2150, "dso | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | void ModelDSO2150::applyRequirements(HantekDsoControl *dsoControl) const { | 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,12 +30,19 @@ ModelDSO2250::ModelDSO2250() : DSOModel(ID, 0x04b5, 0x2250, 0x04b4, 0x2250, "dso | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | void ModelDSO2250::applyRequirements(HantekDsoControl *dsoControl) const { | 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 | // Instantiate additional commands for the DSO-2250 | 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,7 +11,6 @@ ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, "dso | ||
| 11 | specification.command.bulk.setSamplerate = BulkCode::CSETTRIGGERORSAMPLERATE; | 11 | specification.command.bulk.setSamplerate = BulkCode::CSETTRIGGERORSAMPLERATE; |
| 12 | specification.command.bulk.setTrigger = BulkCode::ESETTRIGGERORSAMPLERATE; | 12 | specification.command.bulk.setTrigger = BulkCode::ESETTRIGGERORSAMPLERATE; |
| 13 | specification.command.bulk.setPretrigger = BulkCode::ESETTRIGGERORSAMPLERATE; | 13 | specification.command.bulk.setPretrigger = BulkCode::ESETTRIGGERORSAMPLERATE; |
| 14 | - // specification.command.values.voltageLimits = VALUE_ETSCORRECTION; | ||
| 15 | 14 | ||
| 16 | specification.samplerate.single.base = 100e6; | 15 | specification.samplerate.single.base = 100e6; |
| 17 | specification.samplerate.single.max = 125e6; | 16 | specification.samplerate.single.max = 125e6; |
| @@ -32,12 +31,19 @@ ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, "dso | @@ -32,12 +31,19 @@ ModelDSO5200::ModelDSO5200() : DSOModel(ID, 0x04b5, 0x5200, 0x04b4, 0x5200, "dso | ||
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | void ModelDSO5200::applyRequirements(HantekDsoControl *dsoControl) const { | 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 | // Instantiate additional commands for the DSO-5200 | 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 | ModelDSO5200A::ModelDSO5200A() { | 49 | ModelDSO5200A::ModelDSO5200A() { |
openhantek/src/hantekdso/models/modelDSO6022.cpp
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | using namespace Hantek; | 6 | using namespace Hantek; |
| 7 | 7 | ||
| 8 | ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022, "dso6022be", "DSO-6022BE", Dso::ControlSpecification()) { | 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 | specification.useControlNoBulk = true; | 10 | specification.useControlNoBulk = true; |
| 11 | specification.isSoftwareTriggerDevice = true; | 11 | specification.isSoftwareTriggerDevice = true; |
| 12 | specification.isFixedSamplerateDevice = true; | 12 | specification.isFixedSamplerateDevice = true; |
| @@ -35,15 +35,14 @@ ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022, | @@ -35,15 +35,14 @@ ModelDSO6022BE::ModelDSO6022BE() : DSOModel(ID, 0x04b5, 0x6022, 0x04b4, 0x6022, | ||
| 35 | 35 | ||
| 36 | specification.couplings = {Dso::Coupling::DC}; | 36 | specification.couplings = {Dso::Coupling::DC}; |
| 37 | specification.triggerModes = {Dso::TriggerMode::HARDWARE_SOFTWARE, Dso::TriggerMode::SINGLE}; | 37 | specification.triggerModes = {Dso::TriggerMode::HARDWARE_SOFTWARE, Dso::TriggerMode::SINGLE}; |
| 38 | + specification.fixedUSBinLength = 16384; | ||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | void ModelDSO6022BE::applyRequirements(HantekDsoControl *dsoControl) const { | 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 | ModelDSO6022BL::ModelDSO6022BL() { | 48 | ModelDSO6022BL::ModelDSO6022BL() { |
openhantek/src/hantekprotocol/bulkStructs.cpp
| @@ -9,13 +9,13 @@ namespace Hantek { | @@ -9,13 +9,13 @@ namespace Hantek { | ||
| 9 | ////////////////////////////////////////////////////////////////////////////// | 9 | ////////////////////////////////////////////////////////////////////////////// |
| 10 | // class BulkSetFilter | 10 | // class BulkSetFilter |
| 11 | /// \brief Sets the data array to the default values. | 11 | /// \brief Sets the data array to the default values. |
| 12 | -BulkSetFilter::BulkSetFilter() : BulkCommand(8) { this->init(); } | 12 | +BulkSetFilter::BulkSetFilter() : BulkCommand(BulkCode::SETFILTER, 8) { this->init(); } |
| 13 | 13 | ||
| 14 | /// \brief Sets the FilterByte to the given value. | 14 | /// \brief Sets the FilterByte to the given value. |
| 15 | /// \param channel1 true if channel 1 is filtered. | 15 | /// \param channel1 true if channel 1 is filtered. |
| 16 | /// \param channel2 true if channel 2 is filtered. | 16 | /// \param channel2 true if channel 2 is filtered. |
| 17 | /// \param trigger true if trigger is filtered. | 17 | /// \param trigger true if trigger is filtered. |
| 18 | -BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : BulkCommand(8) { | 18 | +BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : BulkCommand(BulkCode::SETFILTER, 8) { |
| 19 | this->init(); | 19 | this->init(); |
| 20 | 20 | ||
| 21 | this->setChannel(0, channel1); | 21 | this->setChannel(0, channel1); |
| @@ -66,7 +66,7 @@ void BulkSetFilter::init() { | @@ -66,7 +66,7 @@ void BulkSetFilter::init() { | ||
| 66 | ////////////////////////////////////////////////////////////////////////////// | 66 | ////////////////////////////////////////////////////////////////////////////// |
| 67 | // class BulkSetTriggerAndSamplerate | 67 | // class BulkSetTriggerAndSamplerate |
| 68 | /// \brief Sets the data array to the default values. | 68 | /// \brief Sets the data array to the default values. |
| 69 | -BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : BulkCommand(12) { this->init(); } | 69 | +BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : BulkCommand(BulkCode::SETTRIGGERANDSAMPLERATE, 12) { this->init(); } |
| 70 | 70 | ||
| 71 | /// \brief Sets the data bytes to the specified values. | 71 | /// \brief Sets the data bytes to the specified values. |
| 72 | /// \param downsampler The Downsampler value. | 72 | /// \param downsampler The Downsampler value. |
| @@ -82,7 +82,7 @@ BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate(uint16_t downsampler, u | @@ -82,7 +82,7 @@ BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate(uint16_t downsampler, u | ||
| 82 | uint8_t triggerSource, uint8_t recordLength, | 82 | uint8_t triggerSource, uint8_t recordLength, |
| 83 | uint8_t samplerateId, bool downsamplingMode, | 83 | uint8_t samplerateId, bool downsamplingMode, |
| 84 | uint8_t usedChannels, bool fastRate, uint8_t triggerSlope) | 84 | uint8_t usedChannels, bool fastRate, uint8_t triggerSlope) |
| 85 | - : BulkCommand(12) { | 85 | + : BulkCommand(BulkCode::SETTRIGGERANDSAMPLERATE, 12) { |
| 86 | this->init(); | 86 | this->init(); |
| 87 | 87 | ||
| 88 | this->setTriggerSource(triggerSource); | 88 | this->setTriggerSource(triggerSource); |
| @@ -201,32 +201,32 @@ void BulkSetTriggerAndSamplerate::init() { this->array[0] = (uint8_t) BulkCode:: | @@ -201,32 +201,32 @@ void BulkSetTriggerAndSamplerate::init() { this->array[0] = (uint8_t) BulkCode:: | ||
| 201 | ////////////////////////////////////////////////////////////////////////////// | 201 | ////////////////////////////////////////////////////////////////////////////// |
| 202 | // class BulkForceTrigger | 202 | // class BulkForceTrigger |
| 203 | /// \brief Sets the data array to needed values. | 203 | /// \brief Sets the data array to needed values. |
| 204 | -BulkForceTrigger::BulkForceTrigger() : 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 | // class BulkCaptureStart | 207 | // class BulkCaptureStart |
| 208 | /// \brief Sets the data array to needed values. | 208 | /// \brief Sets the data array to needed values. |
| 209 | -BulkCaptureStart::BulkCaptureStart() : 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 | // class BulkTriggerEnabled | 212 | // class BulkTriggerEnabled |
| 213 | /// \brief Sets the data array to needed values. | 213 | /// \brief Sets the data array to needed values. |
| 214 | -BulkTriggerEnabled::BulkTriggerEnabled() : 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 | // class BulkGetData | 217 | // class BulkGetData |
| 218 | /// \brief Sets the data array to needed values. | 218 | /// \brief Sets the data array to needed values. |
| 219 | -BulkGetData::BulkGetData() : 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 | // class BulkGetCaptureState | 222 | // class BulkGetCaptureState |
| 223 | /// \brief Sets the data array to needed values. | 223 | /// \brief Sets the data array to needed values. |
| 224 | -BulkGetCaptureState::BulkGetCaptureState() : 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 | // class BulkResponseGetCaptureState | 227 | // class BulkResponseGetCaptureState |
| 228 | /// \brief Initializes the array. | 228 | /// \brief Initializes the array. |
| 229 | -BulkResponseGetCaptureState::BulkResponseGetCaptureState() : BulkCommand(512) {} | 229 | +BulkResponseGetCaptureState::BulkResponseGetCaptureState() : BulkCommand(BulkCode::GETCAPTURESTATE_RESPONSE, 512) {} |
| 230 | 230 | ||
| 231 | /// \brief Gets the capture state. | 231 | /// \brief Gets the capture state. |
| 232 | /// \return The CaptureState of the oscilloscope. | 232 | /// \return The CaptureState of the oscilloscope. |
| @@ -241,12 +241,12 @@ unsigned int BulkResponseGetCaptureState::getTriggerPoint() { | @@ -241,12 +241,12 @@ unsigned int BulkResponseGetCaptureState::getTriggerPoint() { | ||
| 241 | ////////////////////////////////////////////////////////////////////////////// | 241 | ////////////////////////////////////////////////////////////////////////////// |
| 242 | // class BulkSetGain | 242 | // class BulkSetGain |
| 243 | /// \brief Sets the data array to needed values. | 243 | /// \brief Sets the data array to needed values. |
| 244 | -BulkSetGain::BulkSetGain() : BulkCommand(8) { this->init(); } | 244 | +BulkSetGain::BulkSetGain() : BulkCommand(BulkCode::SETGAIN, 8) { this->init(); } |
| 245 | 245 | ||
| 246 | /// \brief Sets the gain to the given values. | 246 | /// \brief Sets the gain to the given values. |
| 247 | /// \param channel1 The gain value for channel 1. | 247 | /// \param channel1 The gain value for channel 1. |
| 248 | /// \param channel2 The gain value for channel 2. | 248 | /// \param channel2 The gain value for channel 2. |
| 249 | -BulkSetGain::BulkSetGain(uint8_t channel1, uint8_t channel2) : BulkCommand(8) { | 249 | +BulkSetGain::BulkSetGain(uint8_t channel1, uint8_t channel2) : BulkCommand(BulkCode::SETGAIN, 8) { |
| 250 | this->init(); | 250 | this->init(); |
| 251 | 251 | ||
| 252 | this->setGain(0, channel1); | 252 | this->setGain(0, channel1); |
| @@ -281,11 +281,11 @@ void BulkSetGain::init() { this->array[0] = (uint8_t)BulkCode::SETGAIN; } | @@ -281,11 +281,11 @@ void BulkSetGain::init() { this->array[0] = (uint8_t)BulkCode::SETGAIN; } | ||
| 281 | ////////////////////////////////////////////////////////////////////////////// | 281 | ////////////////////////////////////////////////////////////////////////////// |
| 282 | // class BulkSetLogicalData | 282 | // class BulkSetLogicalData |
| 283 | /// \brief Sets the data array to needed values. | 283 | /// \brief Sets the data array to needed values. |
| 284 | -BulkSetLogicalData::BulkSetLogicalData() : BulkCommand(8) { this->init(); } | 284 | +BulkSetLogicalData::BulkSetLogicalData() : BulkCommand(BulkCode::SETLOGICALDATA, 8) { this->init(); } |
| 285 | 285 | ||
| 286 | /// \brief Sets the data to the given value. | 286 | /// \brief Sets the data to the given value. |
| 287 | /// \param data The data byte. | 287 | /// \param data The data byte. |
| 288 | -BulkSetLogicalData::BulkSetLogicalData(uint8_t data) : BulkCommand(8) { | 288 | +BulkSetLogicalData::BulkSetLogicalData(uint8_t data) : BulkCommand(BulkCode::SETLOGICALDATA, 8) { |
| 289 | this->init(); | 289 | this->init(); |
| 290 | 290 | ||
| 291 | this->setData(data); | 291 | this->setData(data); |
| @@ -305,16 +305,16 @@ void BulkSetLogicalData::init() { this->array[0] = (uint8_t)BulkCode::SETLOGICAL | @@ -305,16 +305,16 @@ void BulkSetLogicalData::init() { this->array[0] = (uint8_t)BulkCode::SETLOGICAL | ||
| 305 | ////////////////////////////////////////////////////////////////////////////// | 305 | ////////////////////////////////////////////////////////////////////////////// |
| 306 | // class BulkGetLogicalData | 306 | // class BulkGetLogicalData |
| 307 | /// \brief Sets the data array to needed values. | 307 | /// \brief Sets the data array to needed values. |
| 308 | -BulkGetLogicalData::BulkGetLogicalData() : 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 | // class BulkSetFilter2250 | 311 | // class BulkSetFilter2250 |
| 312 | /// \brief Sets the data array to needed values. | 312 | /// \brief Sets the data array to needed values. |
| 313 | -BulkSetChannels2250::BulkSetChannels2250() : BulkCommand(4) { this->init(); } | 313 | +BulkSetChannels2250::BulkSetChannels2250() : BulkCommand(BulkCode::BSETCHANNELS, 4) { this->init(); } |
| 314 | 314 | ||
| 315 | /// \brief Sets the used channels. | 315 | /// \brief Sets the used channels. |
| 316 | /// \param usedChannels The UsedChannels value. | 316 | /// \param usedChannels The UsedChannels value. |
| 317 | -BulkSetChannels2250::BulkSetChannels2250(uint8_t usedChannels) : BulkCommand(4) { | 317 | +BulkSetChannels2250::BulkSetChannels2250(uint8_t usedChannels) : BulkCommand(BulkCode::BSETCHANNELS, 4) { |
| 318 | this->init(); | 318 | this->init(); |
| 319 | 319 | ||
| 320 | this->setUsedChannels(usedChannels); | 320 | this->setUsedChannels(usedChannels); |
| @@ -334,12 +334,12 @@ void BulkSetChannels2250::init() { this->array[0] = (uint8_t)BulkCode::BSETCHANN | @@ -334,12 +334,12 @@ void BulkSetChannels2250::init() { this->array[0] = (uint8_t)BulkCode::BSETCHANN | ||
| 334 | ////////////////////////////////////////////////////////////////////////////// | 334 | ////////////////////////////////////////////////////////////////////////////// |
| 335 | // class BulkSetTrigger2250 | 335 | // class BulkSetTrigger2250 |
| 336 | /// \brief Sets the data array to needed values. | 336 | /// \brief Sets the data array to needed values. |
| 337 | -BulkSetTrigger2250::BulkSetTrigger2250() : BulkCommand(8) { this->init(); } | 337 | +BulkSetTrigger2250::BulkSetTrigger2250() : BulkCommand(BulkCode::CSETTRIGGERORSAMPLERATE, 8) { this->init(); } |
| 338 | 338 | ||
| 339 | /// \brief Sets the used channels. | 339 | /// \brief Sets the used channels. |
| 340 | /// \param triggerSource The trigger source id (CTriggerBits). | 340 | /// \param triggerSource The trigger source id (CTriggerBits). |
| 341 | /// \param triggerSlope The triggerSlope value (CTriggerBits). | 341 | /// \param triggerSlope The triggerSlope value (CTriggerBits). |
| 342 | -BulkSetTrigger2250::BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope) : BulkCommand(8) { | 342 | +BulkSetTrigger2250::BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope) : BulkCommand(BulkCode::CSETTRIGGERORSAMPLERATE, 8) { |
| 343 | this->init(); | 343 | this->init(); |
| 344 | 344 | ||
| 345 | this->setTriggerSource(triggerSource); | 345 | this->setTriggerSource(triggerSource); |
| @@ -368,12 +368,12 @@ void BulkSetTrigger2250::init() { this->array[0] = (uint8_t)BulkCode::CSETTRIGGE | @@ -368,12 +368,12 @@ void BulkSetTrigger2250::init() { this->array[0] = (uint8_t)BulkCode::CSETTRIGGE | ||
| 368 | ////////////////////////////////////////////////////////////////////////////// | 368 | ////////////////////////////////////////////////////////////////////////////// |
| 369 | // class BulkSetSamplerate5200 | 369 | // class BulkSetSamplerate5200 |
| 370 | /// \brief Sets the data array to the default values. | 370 | /// \brief Sets the data array to the default values. |
| 371 | -BulkSetSamplerate5200::BulkSetSamplerate5200() : BulkCommand(6) { this->init(); } | 371 | +BulkSetSamplerate5200::BulkSetSamplerate5200() : BulkCommand(BulkCode::CSETTRIGGERORSAMPLERATE, 6) { this->init(); } |
| 372 | 372 | ||
| 373 | /// \brief Sets the data bytes to the specified values. | 373 | /// \brief Sets the data bytes to the specified values. |
| 374 | /// \param samplerateSlow The SamplerateSlow value. | 374 | /// \param samplerateSlow The SamplerateSlow value. |
| 375 | /// \param samplerateFast The SamplerateFast value. | 375 | /// \param samplerateFast The SamplerateFast value. |
| 376 | -BulkSetSamplerate5200::BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast) : BulkCommand(6) { | 376 | +BulkSetSamplerate5200::BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast) : BulkCommand(BulkCode::CSETTRIGGERORSAMPLERATE, 6) { |
| 377 | this->init(); | 377 | this->init(); |
| 378 | 378 | ||
| 379 | this->setSamplerateFast(samplerateFast); | 379 | this->setSamplerateFast(samplerateFast); |
| @@ -407,11 +407,11 @@ void BulkSetSamplerate5200::init() { this->array[0] = (uint8_t)BulkCode::CSETTRI | @@ -407,11 +407,11 @@ void BulkSetSamplerate5200::init() { this->array[0] = (uint8_t)BulkCode::CSETTRI | ||
| 407 | ////////////////////////////////////////////////////////////////////////////// | 407 | ////////////////////////////////////////////////////////////////////////////// |
| 408 | // class BulkSetBuffer2250 | 408 | // class BulkSetBuffer2250 |
| 409 | /// \brief Sets the data array to the default values. | 409 | /// \brief Sets the data array to the default values. |
| 410 | -BulkSetRecordLength2250::BulkSetRecordLength2250() : BulkCommand(4) { this->init(); } | 410 | +BulkSetRecordLength2250::BulkSetRecordLength2250() : BulkCommand(BulkCode::DSETBUFFER, 4) { this->init(); } |
| 411 | 411 | ||
| 412 | /// \brief Sets the data bytes to the specified values. | 412 | /// \brief Sets the data bytes to the specified values. |
| 413 | /// \param recordLength The ::RecordLengthId value. | 413 | /// \param recordLength The ::RecordLengthId value. |
| 414 | -BulkSetRecordLength2250::BulkSetRecordLength2250(uint8_t recordLength) : BulkCommand(4) { | 414 | +BulkSetRecordLength2250::BulkSetRecordLength2250(uint8_t recordLength) : BulkCommand(BulkCode::DSETBUFFER, 4) { |
| 415 | this->init(); | 415 | this->init(); |
| 416 | 416 | ||
| 417 | this->setRecordLength(recordLength); | 417 | this->setRecordLength(recordLength); |
| @@ -431,7 +431,7 @@ void BulkSetRecordLength2250::init() { this->array[0] = (uint8_t)BulkCode::DSETB | @@ -431,7 +431,7 @@ void BulkSetRecordLength2250::init() { this->array[0] = (uint8_t)BulkCode::DSETB | ||
| 431 | ////////////////////////////////////////////////////////////////////////////// | 431 | ////////////////////////////////////////////////////////////////////////////// |
| 432 | // class BulkSetBuffer5200 | 432 | // class BulkSetBuffer5200 |
| 433 | /// \brief Sets the data array to the default values. | 433 | /// \brief Sets the data array to the default values. |
| 434 | -BulkSetBuffer5200::BulkSetBuffer5200() : BulkCommand(10) { this->init(); } | 434 | +BulkSetBuffer5200::BulkSetBuffer5200() : BulkCommand(BulkCode::DSETBUFFER, 10) { this->init(); } |
| 435 | 435 | ||
| 436 | /// \brief Sets the data bytes to the specified values. | 436 | /// \brief Sets the data bytes to the specified values. |
| 437 | /// \param triggerPositionPre The TriggerPositionPre value. | 437 | /// \param triggerPositionPre The TriggerPositionPre value. |
| @@ -441,7 +441,7 @@ BulkSetBuffer5200::BulkSetBuffer5200() : BulkCommand(10) { this->init(); } | @@ -441,7 +441,7 @@ BulkSetBuffer5200::BulkSetBuffer5200() : BulkCommand(10) { this->init(); } | ||
| 441 | /// \param recordLength The ::RecordLengthId value. | 441 | /// \param recordLength The ::RecordLengthId value. |
| 442 | BulkSetBuffer5200::BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, DTriggerPositionUsed usedPre, | 442 | BulkSetBuffer5200::BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, DTriggerPositionUsed usedPre, |
| 443 | DTriggerPositionUsed usedPost, uint8_t recordLength) | 443 | DTriggerPositionUsed usedPost, uint8_t recordLength) |
| 444 | - : BulkCommand(10) { | 444 | + : BulkCommand(BulkCode::DSETBUFFER, 10) { |
| 445 | this->init(); | 445 | this->init(); |
| 446 | 446 | ||
| 447 | this->setTriggerPositionPre(triggerPositionPre); | 447 | this->setTriggerPositionPre(triggerPositionPre); |
| @@ -511,14 +511,14 @@ void BulkSetBuffer5200::init() { | @@ -511,14 +511,14 @@ void BulkSetBuffer5200::init() { | ||
| 511 | ////////////////////////////////////////////////////////////////////////////// | 511 | ////////////////////////////////////////////////////////////////////////////// |
| 512 | // class BulkSetSamplerate2250 | 512 | // class BulkSetSamplerate2250 |
| 513 | /// \brief Sets the data array to the default values. | 513 | /// \brief Sets the data array to the default values. |
| 514 | -BulkSetSamplerate2250::BulkSetSamplerate2250() : BulkCommand(8) { this->init(); } | 514 | +BulkSetSamplerate2250::BulkSetSamplerate2250() : BulkCommand(BulkCode::ESETTRIGGERORSAMPLERATE, 8) { this->init(); } |
| 515 | 515 | ||
| 516 | /// \brief Sets the data bytes to the specified values. | 516 | /// \brief Sets the data bytes to the specified values. |
| 517 | /// \param fastRate The fastRate state (ESamplerateBits). | 517 | /// \param fastRate The fastRate state (ESamplerateBits). |
| 518 | /// \param downsampling The downsampling state (ESamplerateBits). | 518 | /// \param downsampling The downsampling state (ESamplerateBits). |
| 519 | /// \param samplerate The Samplerate value. | 519 | /// \param samplerate The Samplerate value. |
| 520 | BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, uint16_t samplerate) | 520 | BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, uint16_t samplerate) |
| 521 | - : BulkCommand(8) { | 521 | + : BulkCommand(BulkCode::ESETTRIGGERORSAMPLERATE, 8) { |
| 522 | this->init(); | 522 | this->init(); |
| 523 | 523 | ||
| 524 | this->setFastRate(fastRate); | 524 | this->setFastRate(fastRate); |
| @@ -563,7 +563,7 @@ void BulkSetSamplerate2250::init() { this->array[0] = (uint8_t)BulkCode::ESETTRI | @@ -563,7 +563,7 @@ void BulkSetSamplerate2250::init() { this->array[0] = (uint8_t)BulkCode::ESETTRI | ||
| 563 | ////////////////////////////////////////////////////////////////////////////// | 563 | ////////////////////////////////////////////////////////////////////////////// |
| 564 | // class BulkSetTrigger5200 | 564 | // class BulkSetTrigger5200 |
| 565 | /// \brief Sets the data array to the default values. | 565 | /// \brief Sets the data array to the default values. |
| 566 | -BulkSetTrigger5200::BulkSetTrigger5200() : BulkCommand(8) { this->init(); } | 566 | +BulkSetTrigger5200::BulkSetTrigger5200() : BulkCommand(BulkCode::ESETTRIGGERORSAMPLERATE, 8) { this->init(); } |
| 567 | 567 | ||
| 568 | /// \brief Sets the data bytes to the specified values. | 568 | /// \brief Sets the data bytes to the specified values. |
| 569 | /// \param triggerSource The trigger source id. | 569 | /// \param triggerSource The trigger source id. |
| @@ -573,7 +573,7 @@ BulkSetTrigger5200::BulkSetTrigger5200() : BulkCommand(8) { this->init(); } | @@ -573,7 +573,7 @@ BulkSetTrigger5200::BulkSetTrigger5200() : BulkCommand(8) { this->init(); } | ||
| 573 | /// \param triggerPulse The triggerPulse value. | 573 | /// \param triggerPulse The triggerPulse value. |
| 574 | BulkSetTrigger5200::BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate, uint8_t triggerSlope, | 574 | BulkSetTrigger5200::BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate, uint8_t triggerSlope, |
| 575 | uint8_t triggerPulse) | 575 | uint8_t triggerPulse) |
| 576 | - : BulkCommand(8) { | 576 | + : BulkCommand(BulkCode::ESETTRIGGERORSAMPLERATE, 8) { |
| 577 | this->init(); | 577 | this->init(); |
| 578 | 578 | ||
| 579 | this->setTriggerSource(triggerSource); | 579 | this->setTriggerSource(triggerSource); |
| @@ -633,13 +633,13 @@ void BulkSetTrigger5200::init() { | @@ -633,13 +633,13 @@ void BulkSetTrigger5200::init() { | ||
| 633 | /// \class BulkSetBuffer2250 hantek/types.h | 633 | /// \class BulkSetBuffer2250 hantek/types.h |
| 634 | /// \brief The DSO-2250 BulkCode::FSETBUFFER builder. | 634 | /// \brief The DSO-2250 BulkCode::FSETBUFFER builder. |
| 635 | /// \brief Sets the data array to the default values. | 635 | /// \brief Sets the data array to the default values. |
| 636 | -BulkSetBuffer2250::BulkSetBuffer2250() : BulkCommand(10) { this->init(); } | 636 | +BulkSetBuffer2250::BulkSetBuffer2250() : BulkCommand(BulkCode::FSETBUFFER, 10) { this->init(); } |
| 637 | 637 | ||
| 638 | /// \brief Sets the data bytes to the specified values. | 638 | /// \brief Sets the data bytes to the specified values. |
| 639 | /// \param triggerPositionPre The TriggerPositionPre value. | 639 | /// \param triggerPositionPre The TriggerPositionPre value. |
| 640 | /// \param triggerPositionPost The TriggerPositionPost value. | 640 | /// \param triggerPositionPost The TriggerPositionPost value. |
| 641 | BulkSetBuffer2250::BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost) | 641 | BulkSetBuffer2250::BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost) |
| 642 | - : BulkCommand(12) { | 642 | + : BulkCommand(BulkCode::FSETBUFFER, 12) { |
| 643 | this->init(); | 643 | this->init(); |
| 644 | 644 | ||
| 645 | this->setTriggerPositionPre(triggerPositionPre); | 645 | this->setTriggerPositionPre(triggerPositionPre); |
openhantek/src/hantekprotocol/bulkStructs.h
| @@ -9,20 +9,10 @@ | @@ -9,20 +9,10 @@ | ||
| 9 | 9 | ||
| 10 | #include "definitions.h" | 10 | #include "definitions.h" |
| 11 | #include "states.h" | 11 | #include "states.h" |
| 12 | -#include "utils/dataarray.h" | 12 | +#include "usb/bulkcommand.h" |
| 13 | 13 | ||
| 14 | namespace Hantek { | 14 | namespace Hantek { |
| 15 | 15 | ||
| 16 | -class BulkCommand : public DataArray<uint8_t> { | ||
| 17 | -protected: | ||
| 18 | - BulkCommand(unsigned size): DataArray<uint8_t>(size) {} | ||
| 19 | -public: | ||
| 20 | - bool pending = false; | ||
| 21 | - BulkCommand* next = nullptr; | ||
| 22 | -}; | ||
| 23 | - | ||
| 24 | -////////////////////////////////////////////////////////////////////////////// | ||
| 25 | -/// \class BulkSetFilter hantek/types.h | ||
| 26 | /// \brief The BULK::SETFILTER builder. | 16 | /// \brief The BULK::SETFILTER builder. |
| 27 | class BulkSetFilter : public BulkCommand { | 17 | class BulkSetFilter : public BulkCommand { |
| 28 | public: | 18 | public: |
| @@ -38,8 +28,6 @@ class BulkSetFilter : public BulkCommand { | @@ -38,8 +28,6 @@ class BulkSetFilter : public BulkCommand { | ||
| 38 | void init(); | 28 | void init(); |
| 39 | }; | 29 | }; |
| 40 | 30 | ||
| 41 | -////////////////////////////////////////////////////////////////////////////// | ||
| 42 | -/// \class BulkSetTriggerAndSamplerate hantek/types.h | ||
| 43 | /// \brief The BulkCode::SETTRIGGERANDSAMPLERATE builder. | 31 | /// \brief The BulkCode::SETTRIGGERANDSAMPLERATE builder. |
| 44 | class BulkSetTriggerAndSamplerate : public BulkCommand { | 32 | class BulkSetTriggerAndSamplerate : public BulkCommand { |
| 45 | public: | 33 | public: |
| @@ -71,48 +59,36 @@ class BulkSetTriggerAndSamplerate : public BulkCommand { | @@ -71,48 +59,36 @@ class BulkSetTriggerAndSamplerate : public BulkCommand { | ||
| 71 | void init(); | 59 | void init(); |
| 72 | }; | 60 | }; |
| 73 | 61 | ||
| 74 | -////////////////////////////////////////////////////////////////////////////// | ||
| 75 | -/// \class BulkForceTrigger hantek/types.h | ||
| 76 | /// \brief The BulkCode::FORCETRIGGER builder. | 62 | /// \brief The BulkCode::FORCETRIGGER builder. |
| 77 | class BulkForceTrigger : public BulkCommand { | 63 | class BulkForceTrigger : public BulkCommand { |
| 78 | public: | 64 | public: |
| 79 | BulkForceTrigger(); | 65 | BulkForceTrigger(); |
| 80 | }; | 66 | }; |
| 81 | 67 | ||
| 82 | -////////////////////////////////////////////////////////////////////////////// | ||
| 83 | -/// \class BulkCaptureStart hantek/types.h | ||
| 84 | /// \brief The BULK_CAPTURESTART builder. | 68 | /// \brief The BULK_CAPTURESTART builder. |
| 85 | class BulkCaptureStart : public BulkCommand { | 69 | class BulkCaptureStart : public BulkCommand { |
| 86 | public: | 70 | public: |
| 87 | BulkCaptureStart(); | 71 | BulkCaptureStart(); |
| 88 | }; | 72 | }; |
| 89 | 73 | ||
| 90 | -////////////////////////////////////////////////////////////////////////////// | ||
| 91 | -/// \class BulkTriggerEnabled hantek/types.h | ||
| 92 | /// \brief The BULK_TRIGGERENABLED builder. | 74 | /// \brief The BULK_TRIGGERENABLED builder. |
| 93 | class BulkTriggerEnabled : public BulkCommand { | 75 | class BulkTriggerEnabled : public BulkCommand { |
| 94 | public: | 76 | public: |
| 95 | BulkTriggerEnabled(); | 77 | BulkTriggerEnabled(); |
| 96 | }; | 78 | }; |
| 97 | 79 | ||
| 98 | -////////////////////////////////////////////////////////////////////////////// | ||
| 99 | -/// \class BulkGetData hantek/types.h | ||
| 100 | /// \brief The BulkCode::GETDATA builder. | 80 | /// \brief The BulkCode::GETDATA builder. |
| 101 | class BulkGetData : public BulkCommand { | 81 | class BulkGetData : public BulkCommand { |
| 102 | public: | 82 | public: |
| 103 | BulkGetData(); | 83 | BulkGetData(); |
| 104 | }; | 84 | }; |
| 105 | 85 | ||
| 106 | -////////////////////////////////////////////////////////////////////////////// | ||
| 107 | -/// \class BulkGetCaptureState hantek/types.h | ||
| 108 | /// \brief The BulkCode::GETCAPTURESTATE builder. | 86 | /// \brief The BulkCode::GETCAPTURESTATE builder. |
| 109 | class BulkGetCaptureState : public BulkCommand { | 87 | class BulkGetCaptureState : public BulkCommand { |
| 110 | public: | 88 | public: |
| 111 | BulkGetCaptureState(); | 89 | BulkGetCaptureState(); |
| 112 | }; | 90 | }; |
| 113 | 91 | ||
| 114 | -////////////////////////////////////////////////////////////////////////////// | ||
| 115 | -/// \class BulkResponseGetCaptureState hantek/types.h | ||
| 116 | /// \brief The parser for the BulkCode::GETCAPTURESTATE response. | 92 | /// \brief The parser for the BulkCode::GETCAPTURESTATE response. |
| 117 | class BulkResponseGetCaptureState : public BulkCommand { | 93 | class BulkResponseGetCaptureState : public BulkCommand { |
| 118 | public: | 94 | public: |
| @@ -122,8 +98,6 @@ class BulkResponseGetCaptureState : public BulkCommand { | @@ -122,8 +98,6 @@ class BulkResponseGetCaptureState : public BulkCommand { | ||
| 122 | unsigned int getTriggerPoint(); | 98 | unsigned int getTriggerPoint(); |
| 123 | }; | 99 | }; |
| 124 | 100 | ||
| 125 | -////////////////////////////////////////////////////////////////////////////// | ||
| 126 | -/// \class BulkSetGain hantek/types.h | ||
| 127 | /// \brief The BulkCode::SETGAIN builder. | 101 | /// \brief The BulkCode::SETGAIN builder. |
| 128 | class BulkSetGain : public BulkCommand { | 102 | class BulkSetGain : public BulkCommand { |
| 129 | public: | 103 | public: |
| @@ -137,8 +111,6 @@ class BulkSetGain : public BulkCommand { | @@ -137,8 +111,6 @@ class BulkSetGain : public BulkCommand { | ||
| 137 | void init(); | 111 | void init(); |
| 138 | }; | 112 | }; |
| 139 | 113 | ||
| 140 | -////////////////////////////////////////////////////////////////////////////// | ||
| 141 | -/// \class BulkSetLogicalData hantek/types.h | ||
| 142 | /// \brief The BulkCode::SETLOGICALDATA builder. | 114 | /// \brief The BulkCode::SETLOGICALDATA builder. |
| 143 | class BulkSetLogicalData : public BulkCommand { | 115 | class BulkSetLogicalData : public BulkCommand { |
| 144 | public: | 116 | public: |
| @@ -152,16 +124,12 @@ class BulkSetLogicalData : public BulkCommand { | @@ -152,16 +124,12 @@ class BulkSetLogicalData : public BulkCommand { | ||
| 152 | void init(); | 124 | void init(); |
| 153 | }; | 125 | }; |
| 154 | 126 | ||
| 155 | -////////////////////////////////////////////////////////////////////////////// | ||
| 156 | -/// \class BulkGetLogicalData hantek/types.h | ||
| 157 | /// \brief The BulkCode::GETLOGICALDATA builder. | 127 | /// \brief The BulkCode::GETLOGICALDATA builder. |
| 158 | class BulkGetLogicalData : public BulkCommand { | 128 | class BulkGetLogicalData : public BulkCommand { |
| 159 | public: | 129 | public: |
| 160 | BulkGetLogicalData(); | 130 | BulkGetLogicalData(); |
| 161 | }; | 131 | }; |
| 162 | 132 | ||
| 163 | -////////////////////////////////////////////////////////////////////////////// | ||
| 164 | -/// \class BulkSetChannels2250 hantek/types.h | ||
| 165 | /// \brief The DSO-2250 BULK_BSETFILTER builder. | 133 | /// \brief The DSO-2250 BULK_BSETFILTER builder. |
| 166 | class BulkSetChannels2250 : public BulkCommand { | 134 | class BulkSetChannels2250 : public BulkCommand { |
| 167 | public: | 135 | public: |
| @@ -175,8 +143,6 @@ class BulkSetChannels2250 : public BulkCommand { | @@ -175,8 +143,6 @@ class BulkSetChannels2250 : public BulkCommand { | ||
| 175 | void init(); | 143 | void init(); |
| 176 | }; | 144 | }; |
| 177 | 145 | ||
| 178 | -////////////////////////////////////////////////////////////////////////////// | ||
| 179 | -/// \class BulkSetTrigger2250 hantek/types.h | ||
| 180 | /// \brief The DSO-2250 BulkCode::CSETTRIGGERORSAMPLERATE builder. | 146 | /// \brief The DSO-2250 BulkCode::CSETTRIGGERORSAMPLERATE builder. |
| 181 | class BulkSetTrigger2250 : public BulkCommand { | 147 | class BulkSetTrigger2250 : public BulkCommand { |
| 182 | public: | 148 | public: |
| @@ -192,8 +158,6 @@ class BulkSetTrigger2250 : public BulkCommand { | @@ -192,8 +158,6 @@ class BulkSetTrigger2250 : public BulkCommand { | ||
| 192 | void init(); | 158 | void init(); |
| 193 | }; | 159 | }; |
| 194 | 160 | ||
| 195 | -////////////////////////////////////////////////////////////////////////////// | ||
| 196 | -/// \class BulkSetSamplerate5200 hantek/types.h | ||
| 197 | /// \brief The DSO-5200/DSO-5200A BulkCode::CSETTRIGGERORSAMPLERATE builder. | 161 | /// \brief The DSO-5200/DSO-5200A BulkCode::CSETTRIGGERORSAMPLERATE builder. |
| 198 | class BulkSetSamplerate5200 : public BulkCommand { | 162 | class BulkSetSamplerate5200 : public BulkCommand { |
| 199 | public: | 163 | public: |
| @@ -209,8 +173,6 @@ class BulkSetSamplerate5200 : public BulkCommand { | @@ -209,8 +173,6 @@ class BulkSetSamplerate5200 : public BulkCommand { | ||
| 209 | void init(); | 173 | void init(); |
| 210 | }; | 174 | }; |
| 211 | 175 | ||
| 212 | -////////////////////////////////////////////////////////////////////////////// | ||
| 213 | -/// \class BulkSetRecordLength2250 hantek/types.h | ||
| 214 | /// \brief The DSO-2250 BulkCode::DSETBUFFER builder. | 176 | /// \brief The DSO-2250 BulkCode::DSETBUFFER builder. |
| 215 | class BulkSetRecordLength2250 : public BulkCommand { | 177 | class BulkSetRecordLength2250 : public BulkCommand { |
| 216 | public: | 178 | public: |
| @@ -224,8 +186,6 @@ class BulkSetRecordLength2250 : public BulkCommand { | @@ -224,8 +186,6 @@ class BulkSetRecordLength2250 : public BulkCommand { | ||
| 224 | void init(); | 186 | void init(); |
| 225 | }; | 187 | }; |
| 226 | 188 | ||
| 227 | -////////////////////////////////////////////////////////////////////////////// | ||
| 228 | -/// \class BulkSetBuffer5200 hantek/types.h | ||
| 229 | /// \brief The DSO-5200/DSO-5200A BulkCode::DSETBUFFER builder. | 189 | /// \brief The DSO-5200/DSO-5200A BulkCode::DSETBUFFER builder. |
| 230 | class BulkSetBuffer5200 : public BulkCommand { | 190 | class BulkSetBuffer5200 : public BulkCommand { |
| 231 | public: | 191 | public: |
| @@ -248,8 +208,6 @@ class BulkSetBuffer5200 : public BulkCommand { | @@ -248,8 +208,6 @@ class BulkSetBuffer5200 : public BulkCommand { | ||
| 248 | void init(); | 208 | void init(); |
| 249 | }; | 209 | }; |
| 250 | 210 | ||
| 251 | -////////////////////////////////////////////////////////////////////////////// | ||
| 252 | -/// \class BulkSetSamplerate2250 hantek/types.h | ||
| 253 | /// \brief The DSO-2250 BulkCode::ESETTRIGGERORSAMPLERATE builder. | 211 | /// \brief The DSO-2250 BulkCode::ESETTRIGGERORSAMPLERATE builder. |
| 254 | class BulkSetSamplerate2250 : public BulkCommand { | 212 | class BulkSetSamplerate2250 : public BulkCommand { |
| 255 | public: | 213 | public: |
| @@ -267,8 +225,6 @@ class BulkSetSamplerate2250 : public BulkCommand { | @@ -267,8 +225,6 @@ class BulkSetSamplerate2250 : public BulkCommand { | ||
| 267 | void init(); | 225 | void init(); |
| 268 | }; | 226 | }; |
| 269 | 227 | ||
| 270 | -////////////////////////////////////////////////////////////////////////////// | ||
| 271 | -/// \class BulkSetTrigger5200 hantek/types.h | ||
| 272 | /// \brief The DSO-5200/DSO-5200A BulkCode::ESETTRIGGERORSAMPLERATE builder. | 228 | /// \brief The DSO-5200/DSO-5200A BulkCode::ESETTRIGGERORSAMPLERATE builder. |
| 273 | class BulkSetTrigger5200 : public BulkCommand { | 229 | class BulkSetTrigger5200 : public BulkCommand { |
| 274 | public: | 230 | public: |
| @@ -291,8 +247,6 @@ class BulkSetTrigger5200 : public BulkCommand { | @@ -291,8 +247,6 @@ class BulkSetTrigger5200 : public BulkCommand { | ||
| 291 | void init(); | 247 | void init(); |
| 292 | }; | 248 | }; |
| 293 | 249 | ||
| 294 | -////////////////////////////////////////////////////////////////////////////// | ||
| 295 | -/// \class BulkSetBuffer2250 hantek/types.h | ||
| 296 | /// \brief The DSO-2250 BulkCode::FSETBUFFER builder. | 250 | /// \brief The DSO-2250 BulkCode::FSETBUFFER builder. |
| 297 | class BulkSetBuffer2250 : public BulkCommand { | 251 | class BulkSetBuffer2250 : public BulkCommand { |
| 298 | public: | 252 | public: |
openhantek/src/hantekprotocol/bulkcode.h
| @@ -457,6 +457,8 @@ enum class BulkCode : uint8_t { | @@ -457,6 +457,8 @@ enum class BulkCode : uint8_t { | ||
| 457 | DSETBUFFER = 0x0d, | 457 | DSETBUFFER = 0x0d, |
| 458 | ESETTRIGGERORSAMPLERATE = 0x0e, | 458 | ESETTRIGGERORSAMPLERATE = 0x0e, |
| 459 | FSETBUFFER = 0x0f, | 459 | FSETBUFFER = 0x0f, |
| 460 | + | ||
| 461 | + GETCAPTURESTATE_RESPONSE=0xfe, | ||
| 460 | INVALID=0xff | 462 | INVALID=0xff |
| 461 | }; | 463 | }; |
| 462 | 464 |
openhantek/src/hantekprotocol/controlStructs.cpp
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | #include <cstring> | 3 | #include <cstring> |
| 4 | 4 | ||
| 5 | #include "controlStructs.h" | 5 | #include "controlStructs.h" |
| 6 | +#include "controlvalue.h" | ||
| 6 | 7 | ||
| 7 | namespace Hantek { | 8 | namespace Hantek { |
| 8 | 9 | ||
| @@ -109,4 +110,14 @@ ControlSetTimeDIV::ControlSetTimeDIV() : ControlCommand(ControlCode::CONTROL_SET | @@ -109,4 +110,14 @@ ControlSetTimeDIV::ControlSetTimeDIV() : ControlCommand(ControlCode::CONTROL_SET | ||
| 109 | void ControlSetTimeDIV::setDiv(uint8_t val) { this->array[0] = val; } | 110 | void ControlSetTimeDIV::setDiv(uint8_t val) { this->array[0] = val; } |
| 110 | 111 | ||
| 111 | ControlAcquireHardData::ControlAcquireHardData() : ControlCommand(ControlCode::CONTROL_ACQUIIRE_HARD_DATA,1) { this->array[0] = 0x01; } | 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,18 +2,10 @@ | ||
| 2 | 2 | ||
| 3 | #include "definitions.h" | 3 | #include "definitions.h" |
| 4 | #include "usb/usbdevicedefinitions.h" | 4 | #include "usb/usbdevicedefinitions.h" |
| 5 | -#include "utils/dataarray.h" | 5 | +#include "usb/controlcommand.h" |
| 6 | #include "controlcode.h" | 6 | #include "controlcode.h" |
| 7 | 7 | ||
| 8 | namespace Hantek { | 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 | struct ControlSetOffset : public ControlCommand { | 10 | struct ControlSetOffset : public ControlCommand { |
| 19 | ControlSetOffset(); | 11 | ControlSetOffset(); |
| @@ -102,4 +94,10 @@ struct ControlSetTimeDIV : public ControlCommand { | @@ -102,4 +94,10 @@ struct ControlSetTimeDIV : public ControlCommand { | ||
| 102 | struct ControlAcquireHardData : public ControlCommand { | 94 | struct ControlAcquireHardData : public ControlCommand { |
| 103 | ControlAcquireHardData(); | 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 | #include "controlbegin.h" | 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 | array[0] = 0x0f; | 5 | array[0] = 0x0f; |
| 5 | array[1] = (uint8_t)index; | 6 | array[1] = (uint8_t)index; |
| 6 | } | 7 | } |
openhantek/src/usb/controlbegin.h
| @@ -2,13 +2,23 @@ | @@ -2,13 +2,23 @@ | ||
| 2 | // SPDX-License-Identifier: GPL-2.0+ | 2 | // SPDX-License-Identifier: GPL-2.0+ |
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | -#include "utils/dataarray.h" | 5 | +#include "controlcommand.h" |
| 6 | #include <inttypes.h> | 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 | /// \class ControlBeginCommand | 20 | /// \class ControlBeginCommand |
| 10 | -/// \brief The CONTROL_BEGINCOMMAND builder. | ||
| 11 | -class ControlBeginCommand : public DataArray<uint8_t> { | 21 | +class ControlBeginCommand : public ControlCommand { |
| 12 | public: | 22 | public: |
| 13 | /// \brief Sets the command index to the given value. | 23 | /// \brief Sets the command index to the given value. |
| 14 | /// \param index The CommandIndex for the command. | 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 | #include "controlgetspeed.h" | 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 | ConnectionSpeed ControlGetSpeed::getSpeed() { return (ConnectionSpeed)this->array[0]; } | 6 | ConnectionSpeed ControlGetSpeed::getSpeed() { return (ConnectionSpeed)this->array[0]; } |
| 6 | 7 |
openhantek/src/usb/controlgetspeed.h
| 1 | - | ||
| 2 | // SPDX-License-Identifier: GPL-2.0+ | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 3 | 2 | ||
| 4 | #pragma once | 3 | #pragma once |
| 5 | -#include "utils/dataarray.h" | ||
| 6 | -#include <inttypes.h> | 4 | +#include "controlcommand.h" |
| 7 | #include "usbdevicedefinitions.h" | 5 | #include "usbdevicedefinitions.h" |
| 8 | 6 | ||
| 9 | -/// \class ControlGetSpeed | ||
| 10 | /// \brief The CONTROL_GETSPEED parser. | 7 | /// \brief The CONTROL_GETSPEED parser. |
| 11 | -class ControlGetSpeed : public DataArray<uint8_t> { | 8 | +class ControlGetSpeed : public ControlCommand { |
| 12 | public: | 9 | public: |
| 13 | ControlGetSpeed(); | 10 | ControlGetSpeed(); |
| 14 | /// \brief Gets the speed of the connection. | 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 +6,8 @@ | ||
| 6 | 6 | ||
| 7 | #include "usbdevice.h" | 7 | #include "usbdevice.h" |
| 8 | 8 | ||
| 9 | +#include "hantekprotocol/controlStructs.h" | ||
| 10 | +#include "hantekprotocol/bulkStructs.h" | ||
| 9 | #include "controlgetspeed.h" | 11 | #include "controlgetspeed.h" |
| 10 | #include "models.h" | 12 | #include "models.h" |
| 11 | #include "utils/printutils.h" | 13 | #include "utils/printutils.h" |
| @@ -139,11 +141,6 @@ int USBDevice::bulkTransfer(unsigned char endpoint, const unsigned char *data, u | @@ -139,11 +141,6 @@ int USBDevice::bulkTransfer(unsigned char endpoint, const unsigned char *data, u | ||
| 139 | return transferred; | 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 | int USBDevice::bulkWrite(const unsigned char *data, unsigned int length, int attempts) { | 144 | int USBDevice::bulkWrite(const unsigned char *data, unsigned int length, int attempts) { |
| 148 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; | 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,11 +150,6 @@ int USBDevice::bulkWrite(const unsigned char *data, unsigned int length, int att | ||
| 153 | return this->bulkTransfer(HANTEK_EP_OUT, data, length, attempts); | 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 | int USBDevice::bulkRead(unsigned char *data, unsigned int length, int attempts) { | 153 | int USBDevice::bulkRead(unsigned char *data, unsigned int length, int attempts) { |
| 162 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; | 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,29 +159,19 @@ int USBDevice::bulkRead(unsigned char *data, unsigned int length, int attempts) | ||
| 167 | return this->bulkTransfer(HANTEK_EP_IN, data, length, attempts); | 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 | int USBDevice::bulkCommand(const DataArray<unsigned char> *command, int attempts) { | 162 | int USBDevice::bulkCommand(const DataArray<unsigned char> *command, int attempts) { |
| 175 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; | 163 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| 176 | 164 | ||
| 177 | if (!allowBulkTransfer) return LIBUSB_SUCCESS; | 165 | if (!allowBulkTransfer) return LIBUSB_SUCCESS; |
| 178 | 166 | ||
| 179 | // Send BeginCommand control command | 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 | if (errorCode < 0) return errorCode; | 169 | if (errorCode < 0) return errorCode; |
| 183 | 170 | ||
| 184 | // Send bulk command | 171 | // Send bulk command |
| 185 | return this->bulkWrite(command->data(), command->getSize(), attempts); | 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 | int USBDevice::bulkReadMulti(unsigned char *data, unsigned length, int attempts) { | 175 | int USBDevice::bulkReadMulti(unsigned char *data, unsigned length, int attempts) { |
| 194 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; | 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,15 +195,6 @@ int USBDevice::bulkReadMulti(unsigned char *data, unsigned length, int attempts) | ||
| 213 | return errorCode; | 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 | int USBDevice::controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, | 198 | int USBDevice::controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, |
| 226 | int value, int index, int attempts) { | 199 | int value, int index, int attempts) { |
| 227 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; | 200 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| @@ -234,52 +207,29 @@ int USBDevice::controlTransfer(unsigned char type, unsigned char request, unsign | @@ -234,52 +207,29 @@ int USBDevice::controlTransfer(unsigned char type, unsigned char request, unsign | ||
| 234 | return errorCode; | 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 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; | 211 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; |
| 248 | // std::cout << "control" << (int)request << " l:"<<length<<" d:"<<(int)data[0] << std::endl; | 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 | if (!this->handle) return LIBUSB_ERROR_NO_DEVICE; | 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 | int USBDevice::getConnectionSpeed() { | 224 | int USBDevice::getConnectionSpeed() { |
| 272 | int errorCode; | 225 | int errorCode; |
| 273 | ControlGetSpeed response; | 226 | ControlGetSpeed response; |
| 274 | - | ||
| 275 | - errorCode = this->controlRead((uint8_t)Hantek::ControlCode::CONTROL_GETSPEED, response.data(), response.getSize()); | 227 | + errorCode = this->controlRead(&response); |
| 276 | if (errorCode < 0) return errorCode; | 228 | if (errorCode < 0) return errorCode; |
| 277 | 229 | ||
| 278 | return response.getSpeed(); | 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 | int USBDevice::getPacketSize() { | 233 | int USBDevice::getPacketSize() { |
| 284 | const int s = this->getConnectionSpeed(); | 234 | const int s = this->getConnectionSpeed(); |
| 285 | if (s == CONNECTION_FULLSPEED) | 235 | if (s == CONNECTION_FULLSPEED) |
openhantek/src/usb/usbdevice.h
| @@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
| 11 | #include "controlbegin.h" | 11 | #include "controlbegin.h" |
| 12 | 12 | ||
| 13 | class DSOModel; | 13 | class DSOModel; |
| 14 | +class ControlCommand; | ||
| 14 | 15 | ||
| 15 | typedef unsigned long UniqueUSBid; | 16 | typedef unsigned long UniqueUSBid; |
| 16 | 17 | ||
| @@ -28,6 +29,10 @@ class USBDevice : public QObject { | @@ -28,6 +29,10 @@ class USBDevice : public QObject { | ||
| 28 | /// \brief Check if the oscilloscope is connected. | 29 | /// \brief Check if the oscilloscope is connected. |
| 29 | /// \return true, if a connection is up. | 30 | /// \return true, if a connection is up. |
| 30 | bool isConnected(); | 31 | bool isConnected(); |
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @return Return true if this device needs a firmware first | ||
| 35 | + */ | ||
| 31 | bool needsFirmware(); | 36 | bool needsFirmware(); |
| 32 | 37 | ||
| 33 | /** | 38 | /** |
| @@ -37,8 +42,6 @@ class USBDevice : public QObject { | @@ -37,8 +42,6 @@ class USBDevice : public QObject { | ||
| 37 | void setFindIteration(unsigned iteration); | 42 | void setFindIteration(unsigned iteration); |
| 38 | unsigned getFindIteration() const; | 43 | unsigned getFindIteration() const; |
| 39 | 44 | ||
| 40 | - // Various methods to handle USB transfers | ||
| 41 | - | ||
| 42 | /// \brief Bulk transfer to/from the oscilloscope. | 45 | /// \brief Bulk transfer to/from the oscilloscope. |
| 43 | /// \param endpoint Endpoint number, also sets the direction of the transfer. | 46 | /// \param endpoint Endpoint number, also sets the direction of the transfer. |
| 44 | /// \param data Buffer for the sent/recieved data. | 47 | /// \param data Buffer for the sent/recieved data. |
| @@ -49,20 +52,72 @@ class USBDevice : public QObject { | @@ -49,20 +52,72 @@ class USBDevice : public QObject { | ||
| 49 | /// error. | 52 | /// error. |
| 50 | int bulkTransfer(unsigned char endpoint, const unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS, | 53 | int bulkTransfer(unsigned char endpoint, const unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS, |
| 51 | unsigned int timeout = HANTEK_TIMEOUT); | 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 | int bulkWrite(const unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS); | 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 | int bulkRead(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS); | 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 | int bulkCommand(const DataArray<unsigned char> *command, int attempts = HANTEK_ATTEMPTS); | 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 | int bulkReadMulti(unsigned char *data, unsigned length, int attempts = HANTEK_ATTEMPTS_MULTI); | 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 | int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, | 92 | int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, |
| 59 | int index, int attempts = HANTEK_ATTEMPTS); | 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 | int getConnectionSpeed(); | 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 | int getPacketSize(); | 121 | int getPacketSize(); |
| 67 | 122 | ||
| 68 | /** | 123 | /** |
openhantek/src/usb/usbdevicedefinitions.h
| @@ -15,16 +15,3 @@ enum ConnectionSpeed { | @@ -15,16 +15,3 @@ enum ConnectionSpeed { | ||
| 15 | CONNECTION_FULLSPEED = 0, ///< FullSpeed USB, 64 byte bulk transfers | 15 | CONNECTION_FULLSPEED = 0, ///< FullSpeed USB, 64 byte bulk transfers |
| 16 | CONNECTION_HIGHSPEED = 1 ///< HighSpeed USB, 512 byte bulk transfers | 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 | - |