diff --git a/openhantek/ChangeLog b/openhantek/ChangeLog index 83b741b..06e44a3 100644 --- a/openhantek/ChangeLog +++ b/openhantek/ChangeLog @@ -192,3 +192,7 @@ * Added signals to DsoControl to update horizontal dock automatically * Reworks in signal connections to make this work properly * Bugfix: DSO-2250 used channels wasn't set + +2012-11-26 Oliver Haag +* Bugfix: Roll mode caused crash or hanging +* Bugfix: DSO-2150 samplerate maximum was 100 MS/s diff --git a/openhantek/src/dataanalyzer.cpp b/openhantek/src/dataanalyzer.cpp index 8ded032..e0a4cc0 100644 --- a/openhantek/src/dataanalyzer.cpp +++ b/openhantek/src/dataanalyzer.cpp @@ -81,7 +81,7 @@ const AnalyzedData *DataAnalyzer::data(int channel) const { /// \brief Returns the sample count of the analyzed data. /// \return The maximum sample count of the last analyzed data. -unsigned long int DataAnalyzer::sampleCount() { +unsigned int DataAnalyzer::sampleCount() { return this->maxSamples; } @@ -95,7 +95,7 @@ QMutex *DataAnalyzer::mutex() const { void DataAnalyzer::run() { this->analyzedDataMutex->lock(); - unsigned long int maxSamples = 0; + unsigned int maxSamples = 0; unsigned int channelCount = (unsigned int) this->settings->scope.voltage.count(); // Adapt the number of channels for analyzed data @@ -139,7 +139,7 @@ void DataAnalyzer::run() { // Set sampling interval channelData->samples.voltage.interval = 1.0 / this->waitingDataSamplerate; - unsigned long int size; + unsigned int size; if(channel < this->settings->scope.physicalChannels) { size = this->waitingDataSize[channel]; if(size > maxSamples) @@ -159,7 +159,7 @@ void DataAnalyzer::run() { if(channel < this->settings->scope.physicalChannels) { // Copy the buffer of the oscilloscope into the sample buffer if(channel < (unsigned int) this->waitingData.count()) - for(unsigned long int position = 0; position < this->waitingDataSize[channel]; ++position) + for(unsigned int position = 0; position < this->waitingDataSize[channel]; ++position) channelData->samples.voltage.sample[position] = this->waitingData[channel][position]; } // Math channel @@ -176,7 +176,7 @@ void DataAnalyzer::run() { } // Calculate values and write them into the sample buffer - for(unsigned long int realPosition = 0; realPosition < this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.count; ++realPosition) { + for(unsigned int realPosition = 0; realPosition < this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.count; ++realPosition) { switch(this->settings->scope.voltage[this->settings->scope.physicalChannels].misc) { case Dso::MATHMODE_1ADD2: this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.sample[realPosition] = this->analyzedData[0]->samples.voltage.sample[realPosition] + this->analyzedData[1]->samples.voltage.sample[realPosition]; @@ -223,24 +223,24 @@ void DataAnalyzer::run() { this->window = (double *) fftw_malloc(sizeof(double) * this->lastRecordLength); } - unsigned long int windowEnd = this->lastRecordLength - 1; + unsigned int windowEnd = this->lastRecordLength - 1; this->lastWindow = this->settings->scope.spectrumWindow; switch(this->settings->scope.spectrumWindow) { case Dso::WINDOW_HAMMING: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 0.54 - 0.46 * cos(2.0 * M_PI * windowPosition / windowEnd); break; case Dso::WINDOW_HANN: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 0.5 * (1.0 - cos(2.0 * M_PI * windowPosition / windowEnd)); break; case Dso::WINDOW_COSINE: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = sin(M_PI * windowPosition / windowEnd); break; case Dso::WINDOW_LANCZOS: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) { + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) { double sincParameter = (2.0 * windowPosition / windowEnd - 1.0) * M_PI; if(sincParameter == 0) *(this->window + windowPosition) = 1; @@ -249,55 +249,55 @@ void DataAnalyzer::run() { } break; case Dso::WINDOW_BARTLETT: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 2.0 / windowEnd * (windowEnd / 2 - abs(windowPosition - windowEnd / 2)); break; case Dso::WINDOW_TRIANGULAR: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 2.0 / this->lastRecordLength * (this->lastRecordLength / 2 - abs(windowPosition - windowEnd / 2)); break; case Dso::WINDOW_GAUSS: { double sigma = 0.4; - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = exp(-0.5 * pow(((windowPosition - windowEnd / 2) / (sigma * windowEnd / 2)), 2)); } break; case Dso::WINDOW_BARTLETTHANN: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 0.62 - 0.48 * abs(windowPosition / windowEnd - 0.5) - 0.38 * cos(2.0 * M_PI * windowPosition / windowEnd); break; case Dso::WINDOW_BLACKMAN: { double alpha = 0.16; - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = (1 - alpha) / 2 - 0.5 * cos(2.0 * M_PI * windowPosition / windowEnd) + alpha / 2 * cos(4.0 * M_PI * windowPosition / windowEnd); } break; //case WINDOW_KAISER: // TODO //double alpha = 3.0; - //for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + //for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) //*(this->window + windowPosition) = ; //break; case Dso::WINDOW_NUTTALL: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 0.355768 - 0.487396 * cos(2 * M_PI * windowPosition / windowEnd) + 0.144232 * cos(4 * M_PI * windowPosition / windowEnd) - 0.012604 * cos(6 * M_PI * windowPosition / windowEnd); break; case Dso::WINDOW_BLACKMANHARRIS: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 0.35875 - 0.48829 * cos(2 * M_PI * windowPosition / windowEnd) + 0.14128 * cos(4 * M_PI * windowPosition / windowEnd) - 0.01168 * cos(6 * M_PI * windowPosition / windowEnd); break; case Dso::WINDOW_BLACKMANNUTTALL: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 0.3635819 - 0.4891775 * cos(2 * M_PI * windowPosition / windowEnd) + 0.1365995 * cos(4 * M_PI * windowPosition / windowEnd) - 0.0106411 * cos(6 * M_PI * windowPosition / windowEnd); break; case Dso::WINDOW_FLATTOP: - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 1.0 - 1.93 * cos(2 * M_PI * windowPosition / windowEnd) + 1.29 * cos(4 * M_PI * windowPosition / windowEnd) - 0.388 * cos(6 * M_PI * windowPosition / windowEnd) + 0.032 * cos(8 * M_PI * windowPosition / windowEnd); break; default: // Dso::WINDOW_RECTANGULAR - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) *(this->window + windowPosition) = 1.0; } } @@ -306,7 +306,7 @@ void DataAnalyzer::run() { channelData->samples.spectrum.interval = 1.0 / channelData->samples.voltage.interval / channelData->samples.voltage.count; // Number of real/complex samples - unsigned long int dftLength = channelData->samples.voltage.count / 2; + unsigned int dftLength = channelData->samples.voltage.count / 2; // Reallocate memory for samples if the sample count has changed if(channelData->samples.spectrum.count != dftLength) { @@ -318,7 +318,7 @@ void DataAnalyzer::run() { // Create sample buffer and apply window double *windowedValues = new double[channelData->samples.voltage.count]; - for(unsigned long int position = 0; position < channelData->samples.voltage.count; ++position) + for(unsigned int position = 0; position < channelData->samples.voltage.count; ++position) windowedValues[position] = this->window[position] * channelData->samples.voltage.sample[position]; // Do discrete real to half-complex transformation @@ -332,7 +332,7 @@ void DataAnalyzer::run() { double *conjugateComplex = windowedValues; // Reuse the windowedValues buffer // Real values - unsigned long int position; + unsigned int position; double correctionFactor = 1.0 / dftLength / dftLength; conjugateComplex[0] = (channelData->samples.spectrum.sample[0] * channelData->samples.spectrum.sample[0]) * correctionFactor; for(position = 1; position < dftLength; ++position) @@ -353,7 +353,7 @@ void DataAnalyzer::run() { double minimalVoltage, maximalVoltage; minimalVoltage = maximalVoltage = channelData->samples.voltage.sample[0]; - for(unsigned long int position = 1; position < channelData->samples.voltage.count; ++position) { + for(unsigned int position = 1; position < channelData->samples.voltage.count; ++position) { if(channelData->samples.voltage.sample[position] < minimalVoltage) minimalVoltage = channelData->samples.voltage.sample[position]; else if(channelData->samples.voltage.sample[position] > maximalVoltage) @@ -365,9 +365,9 @@ void DataAnalyzer::run() { // Get the frequency from the correlation results double minimumCorrelation = correlation[0]; double peakCorrelation = 0; - unsigned long int peakPosition = 0; + unsigned int peakPosition = 0; - for(unsigned long int position = 1; position < channelData->samples.voltage.count / 2; ++position) { + for(unsigned int position = 1; position < channelData->samples.voltage.count / 2; ++position) { if(correlation[position] > peakCorrelation && correlation[position] > minimumCorrelation * 2) { peakCorrelation = correlation[position]; peakPosition = position; @@ -388,7 +388,7 @@ void DataAnalyzer::run() { // Convert values into dB (Relative to the reference level) double offset = 60 - this->settings->scope.spectrumReference - 20 * log10(dftLength); double offsetLimit = this->settings->scope.spectrumLimit - this->settings->scope.spectrumReference; - for(unsigned long int position = 0; position < channelData->samples.spectrum.count; ++position) { + for(unsigned int position = 0; position < channelData->samples.spectrum.count; ++position) { channelData->samples.spectrum.sample[position] = 20 * log10(fabs(channelData->samples.spectrum.sample[position])) + offset; // Check if this value has to be limited @@ -417,7 +417,7 @@ void DataAnalyzer::run() { /// \param size The sizes of the data arrays. /// \param samplerate The samplerate for all input data. /// \param mutex The mutex for all input data. -void DataAnalyzer::analyze(const QList *data, const QList *size, double samplerate, QMutex *mutex) { +void DataAnalyzer::analyze(const QList *data, const QList *size, double samplerate, QMutex *mutex) { // Previous analysis still running, drop the new data if(this->isRunning()) return; diff --git a/openhantek/src/dataanalyzer.h b/openhantek/src/dataanalyzer.h index f7d2f0c..8d3d02f 100644 --- a/openhantek/src/dataanalyzer.h +++ b/openhantek/src/dataanalyzer.h @@ -78,7 +78,7 @@ class DataAnalyzer : public QThread { ~DataAnalyzer(); const AnalyzedData *data(int channel) const; - unsigned long int sampleCount(); + unsigned int sampleCount(); QMutex *mutex() const; protected: @@ -89,18 +89,18 @@ class DataAnalyzer : public QThread { QList analyzedData; ///< The analyzed data for each channel QMutex *analyzedDataMutex; ///< A mutex for the analyzed data of all channels - unsigned long int lastRecordLength; ///< The record length of the previously analyzed data - unsigned long int maxSamples; ///< The maximum record length of the analyzed data + unsigned int lastRecordLength; ///< The record length of the previously analyzed data + unsigned int maxSamples; ///< The maximum record length of the analyzed data Dso::WindowFunction lastWindow; ///< The previously used dft window function double *window; ///< The array for the dft window factors QList waitingData; ///< Pointer to input data from device - QList waitingDataSize; ///< Number of input data samples + QList waitingDataSize; ///< Number of input data samples double waitingDataSamplerate; ///< The samplerate of the input data QMutex *waitingDataMutex; ///< A mutex for the input data public slots: - void analyze(const QList *data, const QList *size, double samplerate, QMutex *mutex); + void analyze(const QList *data, const QList *size, double samplerate, QMutex *mutex); signals: void analyzed(unsigned long samples); ///< The data with that much samples has been analyzed diff --git a/openhantek/src/dockwindows.cpp b/openhantek/src/dockwindows.cpp index 7aebe63..0a1e774 100644 --- a/openhantek/src/dockwindows.cpp +++ b/openhantek/src/dockwindows.cpp @@ -147,8 +147,8 @@ void HorizontalDock::setTimebase(double timebase) { /// \brief Changes the record length if the new value is supported. /// \param recordLength The record length in samples. -void HorizontalDock::setRecordLength(unsigned long int recordLength) { - int index = this->recordLengthComboBox->findData((uint) recordLength); // QVariant doesn't take unsigned long int, doesn't matter for 32 bit platforms at least +void HorizontalDock::setRecordLength(unsigned int recordLength) { + int index = this->recordLengthComboBox->findData(recordLength); if(index != -1) { this->suppressSignals = true; @@ -173,7 +173,7 @@ int HorizontalDock::setFormat(Dso::GraphFormat format) { /// \brief Updates the available record lengths in the combo box. /// \param recordLengths The available record lengths for the combo box. -void HorizontalDock::availableRecordLengthsChanged(const QList &recordLengths) { +void HorizontalDock::availableRecordLengthsChanged(const QList &recordLengths) { /// \todo Empty lists should be interpreted as scope supporting continuous record length values. this->recordLengthComboBox->blockSignals(true); // Avoid messing up the settings this->recordLengthComboBox->setUpdatesEnabled(false); @@ -181,13 +181,13 @@ void HorizontalDock::availableRecordLengthsChanged(const QListrecordLengthComboBox->count()) { - this->recordLengthComboBox->setItemData(index, (unsigned int) recordLengthItem); - this->recordLengthComboBox->setItemText(index, recordLengthItem == ULONG_MAX ? tr("Roll") : Helper::valueToString(recordLengthItem, Helper::UNIT_SAMPLES, 3)); + this->recordLengthComboBox->setItemData(index, recordLengthItem); + this->recordLengthComboBox->setItemText(index, recordLengthItem == UINT_MAX ? tr("Roll") : Helper::valueToString(recordLengthItem, Helper::UNIT_SAMPLES, 3)); } else { - this->recordLengthComboBox->addItem(recordLengthItem == ULONG_MAX ? tr("Roll") : Helper::valueToString(recordLengthItem, Helper::UNIT_SAMPLES, 3), (uint) recordLengthItem); + this->recordLengthComboBox->addItem(recordLengthItem == UINT_MAX ? tr("Roll") : Helper::valueToString(recordLengthItem, Helper::UNIT_SAMPLES, 3), (uint) recordLengthItem); } } // Remove extra elements diff --git a/openhantek/src/dockwindows.h b/openhantek/src/dockwindows.h index 99ba13b..dbf6b1b 100644 --- a/openhantek/src/dockwindows.h +++ b/openhantek/src/dockwindows.h @@ -56,7 +56,7 @@ class HorizontalDock : public QDockWidget { void setFrequencybase(double timebase); void setSamplerate(double samplerate); void setTimebase(double timebase); - void setRecordLength(unsigned long int recordLength); + void setRecordLength(unsigned int recordLength); int setFormat(Dso::GraphFormat format); protected: @@ -82,7 +82,7 @@ class HorizontalDock : public QDockWidget { bool suppressSignals; ///< Disable changed-signals temporarily public slots: - void availableRecordLengthsChanged(const QList &recordLengths); + void availableRecordLengthsChanged(const QList &recordLengths); void samplerateLimitsChanged(double minimum, double maximum); protected slots: diff --git a/openhantek/src/dsocontrol.h b/openhantek/src/dsocontrol.h index 13484d5..6890bd8 100644 --- a/openhantek/src/dsocontrol.h +++ b/openhantek/src/dsocontrol.h @@ -47,7 +47,7 @@ class DsoControl : public QThread { DsoControl(QObject *parent = 0); virtual unsigned int getChannelCount() = 0; ///< Get the number of channels for this oscilloscope - virtual QList *getAvailableRecordLengths() = 0; ///< Get available record lengths, empty list for continuous + virtual QList *getAvailableRecordLengths() = 0; ///< Get available record lengths, empty list for continuous virtual double getMinSamplerate() = 0; ///< The minimum samplerate supported virtual double getMaxSamplerate() = 0; ///< The maximum samplerate supported @@ -65,12 +65,12 @@ class DsoControl : public QThread { void samplingStarted(); ///< The oscilloscope started sampling/waiting for trigger void samplingStopped(); ///< The oscilloscope stopped sampling/waiting for trigger void statusMessage(const QString &message, int timeout); ///< Status message about the oscilloscope - void samplesAvailable(const QList *data, const QList *size, double samplerate, QMutex *mutex); ///< New sample data is available + void samplesAvailable(const QList *data, const QList *size, double samplerate, QMutex *mutex); ///< New sample data is available void recordLengthChanged(unsigned long duration); ///< The record length has changed void recordTimeChanged(double duration); ///< The record time duration has changed void samplerateChanged(double samplerate); ///< The samplerate has changed - void availableRecordLengthsChanged(const QList &recordLengths); ///< The available record lengths, empty list for continuous + void availableRecordLengthsChanged(const QList &recordLengths); ///< The available record lengths, empty list for continuous void samplerateLimitsChanged(double minimum, double maximum); ///< The minimum or maximum samplerate has changed public slots: @@ -80,7 +80,7 @@ class DsoControl : public QThread { virtual void startSampling(); virtual void stopSampling(); - virtual unsigned long int setRecordLength(unsigned long int size) = 0; ///< Set record length id, minimum for continuous + virtual unsigned int setRecordLength(unsigned int size) = 0; ///< Set record length id, minimum for continuous virtual double setSamplerate(double samplerate) = 0; ///< Set the samplerate that should be met virtual double setRecordTime(double duration) = 0; ///< Set the record time duration that should be met diff --git a/openhantek/src/glgenerator.cpp b/openhantek/src/glgenerator.cpp index d8bb911..3c2fcea 100644 --- a/openhantek/src/glgenerator.cpp +++ b/openhantek/src/glgenerator.cpp @@ -48,14 +48,14 @@ GlArray::~GlArray() { /// \brief Get the size of the array. /// \return Number of array elements. -unsigned long int GlArray::getSize() { +unsigned int GlArray::getSize() { return this->size; } /// \brief Set the size of the array. /// Previous array contents are lost. /// \param size New number of array elements. -void GlArray::setSize(unsigned long int size) { +void GlArray::setSize(unsigned int size) { if(this->size == size) return; diff --git a/openhantek/src/glgenerator.h b/openhantek/src/glgenerator.h index e572623..d5f8301 100644 --- a/openhantek/src/glgenerator.h +++ b/openhantek/src/glgenerator.h @@ -55,13 +55,13 @@ class GlArray { GlArray(); ~GlArray(); - unsigned long int getSize(); - void setSize(unsigned long int size); + unsigned int getSize(); + void setSize(unsigned int size); GLfloat *data; ///< Pointer to the array protected: - unsigned long int size; ///< The array size (Number of GLfloat values) + unsigned int size; ///< The array size (Number of GLfloat values) }; //////////////////////////////////////////////////////////////////////////////// diff --git a/openhantek/src/hantek/control.cpp b/openhantek/src/hantek/control.cpp index 1d2cd32..6488b07 100644 --- a/openhantek/src/hantek/control.cpp +++ b/openhantek/src/hantek/control.cpp @@ -139,7 +139,7 @@ namespace Hantek { /// \brief Get available record lengths for this oscilloscope. /// \return The number of physical channels, empty list for continuous. - QList *Control::getAvailableRecordLengths() { + QList *Control::getAvailableRecordLengths() { return &this->settings.samplerate.limits->recordLengths; } @@ -216,7 +216,11 @@ namespace Hantek { // Check the current oscilloscope state everytime 25% of the time the buffer should be refilled // Not more often than every 10 ms though - int cycleTime = qMax((unsigned long int) (this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), 10lu); + int cycleTime; + if(this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] == UINT_MAX) + cycleTime = qMax((int) ((double) this->device->getPacketSize() / this->settings.samplerate.current * 250), 1); + else + cycleTime = qMax((unsigned int) ((double) this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), 10u); this->msleep(cycleTime); if(!this->sampling) { @@ -260,10 +264,7 @@ namespace Hantek { case CAPTURE_WAITING: // Sampling hasn't started, update the expected sample count - if(this->settings.samplerate.limits == &this->specification.samplerate.multi) - this->previousSampleCount = this->specification.samplerate.multi.recordLengths[this->settings.recordLengthId]; - else - this->previousSampleCount = this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] * HANTEK_CHANNELS; + this->previousSampleCount = this->getSampleCount(); if(samplingStarted && lastTriggerMode == this->settings.trigger.mode) { ++cycleCounter; @@ -325,11 +326,11 @@ namespace Hantek { /// \brief Calculates the trigger point from the CommandGetCaptureState data. /// \param value The data value that contains the trigger point. /// \return The calculated trigger point for the given data. - unsigned long int Control::calculateTriggerPoint(unsigned long int value) { - unsigned long int result = value; + unsigned int Control::calculateTriggerPoint(unsigned int value) { + unsigned int result = value; // Each set bit inverts all bits with a lower value - for(unsigned long int bitValue = 1; bitValue; bitValue <<= 1) + for(unsigned int bitValue = 1; bitValue; bitValue <<= 1) if(result & bitValue) result ^= bitValue - 1; @@ -366,13 +367,14 @@ namespace Hantek { return errorCode; // Save raw data to temporary buffer - bool fastRate = this->settings.samplerate.limits == &this->specification.samplerate.multi; - - unsigned long int totalSampleCount = fastRate ? this->specification.samplerate.multi.recordLengths[this->settings.recordLengthId] : this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] * HANTEK_CHANNELS; + bool fastRate = false; + unsigned int totalSampleCount = this->getSampleCount(&fastRate); + if(totalSampleCount == UINT_MAX) + return LIBUSB_ERROR_INVALID_PARAM; // To make sure no samples will remain in the scope buffer, also check the sample count before the last sampling started if(totalSampleCount < this->previousSampleCount) { - unsigned long int currentSampleCount = totalSampleCount; + unsigned int currentSampleCount = totalSampleCount; totalSampleCount = this->previousSampleCount; this->previousSampleCount = currentSampleCount; // Using sampleCount as temporary buffer since it was set to totalSampleCount } @@ -380,10 +382,10 @@ namespace Hantek { this->previousSampleCount = totalSampleCount; } - unsigned long int sampleCount = totalSampleCount; + unsigned int sampleCount = totalSampleCount; if(!fastRate) sampleCount /= HANTEK_CHANNELS; - unsigned long int dataLength = totalSampleCount; + unsigned int dataLength = totalSampleCount; if(this->specification.sampleSize > 8) dataLength *= 2; @@ -431,14 +433,14 @@ namespace Hantek { } // Convert data from the oscilloscope and write it into the sample buffer - unsigned long int bufferPosition = this->settings.trigger.point * 2; + unsigned int bufferPosition = this->settings.trigger.point * 2; if(this->specification.sampleSize > 8) { // Additional most significant bits after the normal data unsigned int extraBitsPosition; // Track the position of the extra bits in the additional byte unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction - for(unsigned long int realPosition = 0; realPosition < sampleCount; ++realPosition, ++bufferPosition) { + for(unsigned int realPosition = 0; realPosition < sampleCount; ++realPosition, ++bufferPosition) { if(bufferPosition >= sampleCount) bufferPosition %= sampleCount; @@ -448,7 +450,7 @@ namespace Hantek { } } else { - for(unsigned long int realPosition = 0; realPosition < sampleCount; ++realPosition, ++bufferPosition) { + for(unsigned int realPosition = 0; realPosition < sampleCount; ++realPosition, ++bufferPosition) { if(bufferPosition >= sampleCount) bufferPosition %= sampleCount; @@ -471,14 +473,14 @@ namespace Hantek { } // Convert data from the oscilloscope and write it into the sample buffer - unsigned long int bufferPosition = this->settings.trigger.point * 2; + unsigned int bufferPosition = this->settings.trigger.point * 2; if(this->specification.sampleSize > 8) { // Additional most significant bits after the normal data unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction unsigned int extraBitsIndex = 8 - channel * 2; // Bit position offset for extra bits extraction - for(unsigned long int realPosition = 0; realPosition < sampleCount; ++realPosition, bufferPosition += HANTEK_CHANNELS) { + for(unsigned int realPosition = 0; realPosition < sampleCount; ++realPosition, bufferPosition += HANTEK_CHANNELS) { if(bufferPosition >= totalSampleCount) bufferPosition %= totalSampleCount; @@ -487,7 +489,7 @@ namespace Hantek { } else { bufferPosition += HANTEK_CHANNELS - 1 - channel; - for(unsigned long int realPosition = 0; realPosition < sampleCount; ++realPosition, bufferPosition += HANTEK_CHANNELS) { + for(unsigned int realPosition = 0; realPosition < sampleCount; ++realPosition, bufferPosition += HANTEK_CHANNELS) { if(bufferPosition >= totalSampleCount) bufferPosition %= totalSampleCount; @@ -517,7 +519,7 @@ namespace Hantek { /// \param maximum The target samplerate is the maximum allowed when true, the minimum otherwise. /// \param downsampler Pointer to where the selected downsampling factor should be written. /// \return The nearest samplerate supported, 0.0 on error. - double Control::getBestSamplerate(double samplerate, bool fastRate, bool maximum, unsigned long int *downsampler) { + double Control::getBestSamplerate(double samplerate, bool fastRate, bool maximum, unsigned int *downsampler) { // Abort if the input value is invalid if(samplerate <= 0.0) return 0.0; @@ -602,15 +604,39 @@ namespace Hantek { } if(downsampler) - *downsampler = (unsigned long int) bestDownsampler; + *downsampler = (unsigned int) bestDownsampler; return bestSamplerate; } + /// \brief Get the count of samples that are expected returned by the scope. + /// \param fastRate Is set to the state of the fast rate mode when provided. + /// \return The total number of samples the scope should return. + unsigned int Control::getSampleCount(bool *fastRate) { + unsigned int totalSampleCount = this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId]; + bool fastRateEnabled = this->settings.samplerate.limits == &this->specification.samplerate.multi; + + if(totalSampleCount == UINT_MAX) { + // Roll mode + const int packetSize = this->device->getPacketSize(); + if(packetSize < 0) + totalSampleCount = UINT_MAX; + else + totalSampleCount = packetSize; + } + else { + if(!fastRateEnabled) + totalSampleCount *= HANTEK_CHANNELS; + } + if(fastRate) + *fastRate = fastRateEnabled; + return totalSampleCount; + } + /// \brief Sets the size of the sample buffer without updating dependencies. /// \param index The record length index that should be set. /// \return The record length that has been set, 0 on error. - unsigned long int Control::updateRecordLength(unsigned long int index) { - if(index >= (unsigned long int) this->settings.samplerate.limits->recordLengths.size()) + unsigned int Control::updateRecordLength(unsigned int index) { + if(index >= (unsigned int) this->settings.samplerate.limits->recordLengths.size()) return 0; switch(this->specification.command.bulk.setRecordLength) { @@ -654,7 +680,10 @@ namespace Hantek { /// \param downsampler The downsampling factor. /// \param fastRate true, if one channel uses all buffers. /// \return The downsampling factor that has been set. - unsigned long int Control::updateSamplerate(unsigned long int downsampler, bool fastRate) { + unsigned int Control::updateSamplerate(unsigned int downsampler, bool fastRate) { + // Get samplerate limits + Hantek::ControlSamplerateLimits *limits = fastRate ? &this->specification.samplerate.multi : &this->specification.samplerate.single; + // Set the calculated samplerate switch(this->specification.command.bulk.setSamplerate) { case BULK_SETTRIGGERANDSAMPLERATE: { @@ -664,7 +693,7 @@ namespace Hantek { if(downsampler <= 5) { // All dividers up to 5 are done using the special samplerate IDs - if(downsampler == 0) + if(downsampler == 0 && limits->base >= limits->max) samplerateId = 1; else if(downsampler <= 2) samplerateId = downsampler; @@ -737,16 +766,13 @@ namespace Hantek { break; } default: - return ULONG_MAX; + return UINT_MAX; } // Update settings bool fastRateChanged = fastRate != (this->settings.samplerate.limits == &this->specification.samplerate.multi); if(fastRateChanged) { - if(fastRate) - this->settings.samplerate.limits = &this->specification.samplerate.multi; - else - this->settings.samplerate.limits = &this->specification.samplerate.single; + this->settings.samplerate.limits = limits; } this->settings.samplerate.downsampler = downsampler; @@ -763,8 +789,12 @@ namespace Hantek { emit availableRecordLengthsChanged(this->settings.samplerate.limits->recordLengths); emit recordLengthChanged(this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId]); } - emit recordTimeChanged((double) this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current); - emit samplerateChanged(this->settings.samplerate.current); + + // Check for Roll mode + if(this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] != UINT_MAX) { + emit recordTimeChanged((double) this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current); + emit samplerateChanged(this->settings.samplerate.current); + } return downsampler; } @@ -896,11 +926,11 @@ namespace Hantek { this->specification.samplerate.single.base = 100e6; this->specification.samplerate.single.max = 125e6; this->specification.samplerate.single.maxDownsampler = 131072; - this->specification.samplerate.single.recordLengths << ULONG_MAX << 10240 << 14336; + this->specification.samplerate.single.recordLengths << UINT_MAX << 10240 << 14336; this->specification.samplerate.multi.base = 200e6; this->specification.samplerate.multi.max = 250e6; this->specification.samplerate.multi.maxDownsampler = 131072; - this->specification.samplerate.multi.recordLengths << ULONG_MAX << 20480 << 28672; + this->specification.samplerate.multi.recordLengths << UINT_MAX << 20480 << 28672; this->specification.bufferDividers << 1000 << 1 << 1; this->specification.gainSteps << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0; @@ -917,11 +947,11 @@ namespace Hantek { this->specification.samplerate.single.base = 100e6; this->specification.samplerate.single.max = 100e6; this->specification.samplerate.single.maxDownsampler = 65536; - this->specification.samplerate.single.recordLengths << ULONG_MAX << 10240 << 524288; + this->specification.samplerate.single.recordLengths << UINT_MAX << 10240 << 524288; this->specification.samplerate.multi.base = 200e6; this->specification.samplerate.multi.max = 250e6; this->specification.samplerate.multi.maxDownsampler = 65536; - this->specification.samplerate.multi.recordLengths << ULONG_MAX << 20480 << 1048576; + this->specification.samplerate.multi.recordLengths << UINT_MAX << 20480 << 1048576; this->specification.bufferDividers << 1000 << 1 << 1; this->specification.gainSteps << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; @@ -937,11 +967,11 @@ namespace Hantek { this->specification.samplerate.single.base = 50e6; this->specification.samplerate.single.max = 75e6; this->specification.samplerate.single.maxDownsampler = 131072; - this->specification.samplerate.single.recordLengths << ULONG_MAX << 10240 << 32768; + this->specification.samplerate.single.recordLengths << UINT_MAX << 10240 << 32768; this->specification.samplerate.multi.base = 100e6; this->specification.samplerate.multi.max = 150e6; this->specification.samplerate.multi.maxDownsampler = 131072; - this->specification.samplerate.multi.recordLengths << ULONG_MAX << 20480 << 65536; + this->specification.samplerate.multi.recordLengths << UINT_MAX << 20480 << 65536; this->specification.bufferDividers << 1000 << 1 << 1; this->specification.gainSteps << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; @@ -957,11 +987,11 @@ namespace Hantek { this->specification.samplerate.single.base = 50e6; this->specification.samplerate.single.max = 50e6; this->specification.samplerate.single.maxDownsampler = 131072; - this->specification.samplerate.single.recordLengths << ULONG_MAX << 10240 << 32768; + this->specification.samplerate.single.recordLengths << UINT_MAX << 10240 << 32768; this->specification.samplerate.multi.base = 100e6; this->specification.samplerate.multi.max = 100e6; this->specification.samplerate.multi.maxDownsampler = 131072; - this->specification.samplerate.multi.recordLengths << ULONG_MAX << 20480 << 65536; + this->specification.samplerate.multi.recordLengths << UINT_MAX << 20480 << 65536; this->specification.bufferDividers << 1000 << 1 << 1; this->specification.gainSteps << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; @@ -992,7 +1022,7 @@ namespace Hantek { /// \brief Sets the size of the oscilloscopes sample buffer. /// \param index The record length index that should be set. /// \return The record length that has been set, 0 on error. - unsigned long int Control::setRecordLength(unsigned long int index) { + unsigned int Control::setRecordLength(unsigned int index) { if(!this->device->isConnected()) return 0; @@ -1022,11 +1052,11 @@ namespace Hantek { bool fastRate = (this->settings.usedChannels <= 1) && (samplerate > this->specification.samplerate.single.max); // What is the nearest, at least as high samplerate the scope can provide? - unsigned long int downsampler = 0; + unsigned int downsampler = 0; double bestSamplerate = getBestSamplerate(samplerate, fastRate, false, &(downsampler)); // Set the calculated samplerate - if(this->updateSamplerate(downsampler, fastRate) == ULONG_MAX) + if(this->updateSamplerate(downsampler, fastRate) == UINT_MAX) return 0.0; else { return bestSamplerate; @@ -1052,11 +1082,11 @@ namespace Hantek { bool fastRate = (this->settings.usedChannels <= 1) && (maxSamplerate >= this->specification.samplerate.multi.base); // What is the nearest, at most as high samplerate the scope can provide? - unsigned long int downsampler = 0; + unsigned int downsampler = 0; double bestSamplerate = getBestSamplerate(maxSamplerate, fastRate, true, &(downsampler)); // Set the calculated samplerate - if(this->updateSamplerate(downsampler, fastRate) == ULONG_MAX) + if(this->updateSamplerate(downsampler, fastRate) == UINT_MAX) return 0.0; else { return (double) this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / bestSamplerate; @@ -1375,7 +1405,7 @@ namespace Hantek { return -2; // All trigger positions are measured in samples - unsigned long int positionSamples = position * this->settings.samplerate.current; + unsigned int positionSamples = position * this->settings.samplerate.current; // Fast rate mode uses both channels if(this->settings.samplerate.limits == &this->specification.samplerate.multi) positionSamples /= HANTEK_CHANNELS; @@ -1383,7 +1413,7 @@ namespace Hantek { switch(this->specification.command.bulk.setPretrigger) { case BULK_SETTRIGGERANDSAMPLERATE: { // Calculate the position value (Start point depending on record length) - unsigned long int position = 0x7ffff - this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] + positionSamples; + unsigned int position = 0x7ffff - this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] + positionSamples; // SetTriggerAndSamplerate bulk command for trigger position static_cast(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position); @@ -1393,8 +1423,8 @@ namespace Hantek { } case BULK_FSETBUFFER: { // Calculate the position values (Inverse, maximum is 0x7ffff) - unsigned long int positionPre = 0x7fffful - this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] + positionSamples; - unsigned long int positionPost = 0x7fffful - positionSamples; + unsigned int positionPre = 0x7fffful - this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] + positionSamples; + unsigned int positionPost = 0x7fffful - positionSamples; // SetBuffer2250 bulk command for trigger position BulkSetBuffer2250 *commandSetBuffer2250 = static_cast(this->command[BULK_FSETBUFFER]); diff --git a/openhantek/src/hantek/control.h b/openhantek/src/hantek/control.h index 268e0d9..615ccf8 100644 --- a/openhantek/src/hantek/control.h +++ b/openhantek/src/hantek/control.h @@ -93,10 +93,10 @@ namespace Hantek { /// \struct ControlSamplerateLimits hantek/control.h /// \brief Stores the samplerate limits for calculations. struct ControlSamplerateLimits { - unsigned long int base; ///< The base for sample rate calculations - unsigned long int max; ///< The maximum sample rate - unsigned long int maxDownsampler; ///< The maximum downsampling ratio - QList recordLengths; ///< Available record lengths, ULONG_MAX means rolling + double base; ///< The base for sample rate calculations + double max; ///< The maximum sample rate + unsigned int maxDownsampler; ///< The maximum downsampling ratio + QList recordLengths; ///< Available record lengths, UINT_MAX means rolling }; ////////////////////////////////////////////////////////////////////////////// @@ -116,7 +116,7 @@ namespace Hantek { // Limits ControlSpecificationSamplerate samplerate; ///< The samplerate specifications - QList bufferDividers; ///< Samplerate dividers for record lengths + QList bufferDividers; ///< Samplerate dividers for record lengths QList gainSteps; ///< Available voltage steps in V/screenheight unsigned char sampleSize; ///< Number of bits per sample @@ -144,7 +144,7 @@ namespace Hantek { struct ControlSettingsSamplerate { ControlSettingsSamplerateTarget target; ///< The target samplerate values ControlSamplerateLimits *limits; ///< The samplerate limits - unsigned long int downsampler; ///< The variable downsampling factor + unsigned int downsampler; ///< The variable downsampling factor double current; ///< The current samplerate }; @@ -193,19 +193,20 @@ namespace Hantek { ~Control(); unsigned int getChannelCount(); - QList *getAvailableRecordLengths(); + QList *getAvailableRecordLengths(); double getMinSamplerate(); double getMaxSamplerate(); protected: void run(); - unsigned long int calculateTriggerPoint(unsigned long int value); + unsigned int calculateTriggerPoint(unsigned int value); int getCaptureState(); int getSamples(bool process); - double getBestSamplerate(double samplerate, bool fastRate = false, bool maximum = false, unsigned long int *downsampler = 0); - unsigned long int updateRecordLength(unsigned long int size); - unsigned long int updateSamplerate(unsigned long int downsampler, bool fastRate); + double getBestSamplerate(double samplerate, bool fastRate = false, bool maximum = false, unsigned int *downsampler = 0); + unsigned int getSampleCount(bool *fastRate = 0); + unsigned int updateRecordLength(unsigned int size); + unsigned int updateSamplerate(unsigned int downsampler, bool fastRate); void restoreTargets(); // Communication with device @@ -223,14 +224,14 @@ namespace Hantek { // Results QList samples; ///< Sample data arrays - QList samplesSize; ///< Number of samples data array - unsigned long int previousSampleCount; ///< The expected total number of samples at the last check before sampling started + QList samplesSize; ///< Number of samples data array + unsigned int previousSampleCount; ///< The expected total number of samples at the last check before sampling started QMutex samplesMutex; ///< Mutex for the sample data public slots: virtual void connectDevice(); - unsigned long int setRecordLength(unsigned long int size); + unsigned int setRecordLength(unsigned int size); double setSamplerate(double samplerate = 0.0); double setRecordTime(double duration = 0.0); diff --git a/openhantek/src/hantek/device.cpp b/openhantek/src/hantek/device.cpp index 953df9c..223d1de 100644 --- a/openhantek/src/hantek/device.cpp +++ b/openhantek/src/hantek/device.cpp @@ -281,7 +281,7 @@ namespace Hantek { /// \param attempts The number of attempts, that are done on timeouts. /// \param timeout The timeout in ms. /// \return Number of transferred bytes on success, libusb error code on error. - int Device::bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned long int length, int attempts, unsigned int timeout) { + int Device::bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned int length, int attempts, unsigned int timeout) { if(!this->handle) return LIBUSB_ERROR_NO_DEVICE; @@ -304,7 +304,7 @@ namespace Hantek { /// \param length The length of the packet. /// \param attempts The number of attempts, that are done on timeouts. /// \return Number of sent bytes on success, libusb error code on error. - int Device::bulkWrite(unsigned char *data, unsigned long int length, int attempts) { + int Device::bulkWrite(unsigned char *data, unsigned int length, int attempts) { if(!this->handle) return LIBUSB_ERROR_NO_DEVICE; @@ -331,7 +331,7 @@ namespace Hantek { /// \param length The length of the packet. /// \param attempts The number of attempts, that are done on timeouts. /// \return Number of received bytes on success, libusb error code on error. - int Device::bulkRead(unsigned char *data, unsigned long int length, int attempts) { + int Device::bulkRead(unsigned char *data, unsigned int length, int attempts) { if(!this->handle) return LIBUSB_ERROR_NO_DEVICE; @@ -375,7 +375,7 @@ namespace Hantek { /// \param length The length of data contained in the packets. /// \param attempts The number of attempts, that are done on timeouts. /// \return Number of received bytes on success, libusb error code on error. - int Device::bulkReadMulti(unsigned char *data, unsigned long int length, int attempts) { + int Device::bulkReadMulti(unsigned char *data, unsigned int length, int attempts) { if(!this->handle) return LIBUSB_ERROR_NO_DEVICE; @@ -386,14 +386,14 @@ namespace Hantek { return errorCode; errorCode = this->inPacketLength; - unsigned long int packet, received = 0; + unsigned int packet, received = 0; for(packet = 0; received < length && errorCode == this->inPacketLength; ++packet) { #if LIBUSB_VERSION == 0 errorCode = LIBUSB_ERROR_TIMEOUT; for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) - errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data + packet * this->inPacketLength, qMin(length - received, (unsigned long int) this->inPacketLength), HANTEK_TIMEOUT); + errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), HANTEK_TIMEOUT); #else - errorCode = this->bulkTransfer(HANTEK_EP_IN, data + packet * this->inPacketLength, qMin(length - received, (unsigned long int) this->inPacketLength), attempts, HANTEK_TIMEOUT_MULTI); + errorCode = this->bulkTransfer(HANTEK_EP_IN, data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), attempts, HANTEK_TIMEOUT_MULTI); #endif if(errorCode > 0) received += errorCode; @@ -414,7 +414,7 @@ namespace Hantek { /// \param index The index field of the packet. /// \param attempts The number of attempts, that are done on timeouts. /// \return Number of transferred bytes on success, libusb error code on error. - int Device::controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned long int length, int value, int index, int attempts) { + int Device::controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts) { if(!this->handle) return LIBUSB_ERROR_NO_DEVICE; @@ -439,7 +439,7 @@ namespace Hantek { /// \param index The index field of the packet. /// \param attempts The number of attempts, that are done on timeouts. /// \return Number of sent bytes on success, libusb error code on error. - int Device::controlWrite(unsigned char request, unsigned char *data, unsigned long int length, int value, int index, int attempts) { + int Device::controlWrite(unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts) { if(!this->handle) return LIBUSB_ERROR_NO_DEVICE; @@ -454,7 +454,7 @@ namespace Hantek { /// \param index The index field of the packet. /// \param attempts The number of attempts, that are done on timeouts. /// \return Number of received bytes on success, libusb error code on error. - int Device::controlRead(unsigned char request, unsigned char *data, unsigned long int length, int value, int index, int attempts) { + int Device::controlRead(unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts) { if(!this->handle) return LIBUSB_ERROR_NO_DEVICE; @@ -474,6 +474,22 @@ namespace Hantek { return response.getSpeed(); } + /// \brief Gets the maximum size of one packet transmitted via bulk transfer. + /// \return The maximum packet size in bytes, -1 on error. + int Device::getPacketSize() { + switch(this->getConnectionSpeed()) { + case CONNECTION_FULLSPEED: + return 64; + break; + case CONNECTION_HIGHSPEED: + return 512; + break; + default: + return -1; + break; + } + } + /// \brief Get the oscilloscope model. /// \return The ::Model of the connected Hantek DSO. Model Device::getModel() { diff --git a/openhantek/src/hantek/device.h b/openhantek/src/hantek/device.h index 633bb20..6669c0b 100644 --- a/openhantek/src/hantek/device.h +++ b/openhantek/src/hantek/device.h @@ -60,19 +60,20 @@ namespace Hantek { // Various methods to handle USB transfers #if LIBUSB_VERSION != 0 - int bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned long int length, int attempts = HANTEK_ATTEMPTS, unsigned int timeout = HANTEK_TIMEOUT); + int bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS, unsigned int timeout = HANTEK_TIMEOUT); #endif - int bulkWrite(unsigned char *data, unsigned long int length, int attempts = HANTEK_ATTEMPTS); - int bulkRead(unsigned char *data, unsigned long int length, int attempts = HANTEK_ATTEMPTS); + int bulkWrite(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS); + int bulkRead(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS); int bulkCommand(Helper::DataArray *command, int attempts = HANTEK_ATTEMPTS); - int bulkReadMulti(unsigned char *data, unsigned long int length, int attempts = HANTEK_ATTEMPTS_MULTI); + int bulkReadMulti(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS_MULTI); - int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned long int length, int value, int index, int attempts = HANTEK_ATTEMPTS); - int controlWrite(unsigned char request, unsigned char *data, unsigned long int length, int value = 0, int index = 0, int attempts = HANTEK_ATTEMPTS); - int controlRead(unsigned char request, unsigned char *data, unsigned long int length, int value = 0, int index = 0, int attempts = HANTEK_ATTEMPTS); + int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts = HANTEK_ATTEMPTS); + int controlWrite(unsigned char request, unsigned char *data, unsigned int length, int value = 0, int index = 0, int attempts = HANTEK_ATTEMPTS); + int controlRead(unsigned char request, unsigned char *data, unsigned int length, int value = 0, int index = 0, int attempts = HANTEK_ATTEMPTS); int getConnectionSpeed(); + int getPacketSize(); Model getModel(); protected: diff --git a/openhantek/src/hantek/types.cpp b/openhantek/src/hantek/types.cpp index 11a9081..f4bf6b7 100644 --- a/openhantek/src/hantek/types.cpp +++ b/openhantek/src/hantek/types.cpp @@ -34,7 +34,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetFilter /// \brief Sets the data array to the default values. - BulkSetFilter::BulkSetFilter() : Helper::DataArray(8) { + BulkSetFilter::BulkSetFilter() : Helper::DataArray(8) { this->init(); } @@ -42,7 +42,7 @@ namespace Hantek { /// \param channel1 true if channel 1 is filtered. /// \param channel2 true if channel 2 is filtered. /// \param trigger true if trigger is filtered. - BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : Helper::DataArray(8) { + BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : Helper::DataArray(8) { this->init(); this->setChannel(0, channel1); @@ -96,7 +96,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetTriggerAndSamplerate /// \brief Sets the data array to the default values. - BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : Helper::DataArray(12) { + BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : Helper::DataArray(12) { this->init(); } @@ -110,7 +110,7 @@ namespace Hantek { /// \param usedChannels The enabled channels (Tsr2). /// \param fastRate The fastRate state (Tsr2). /// \param triggerSlope The triggerSlope value (Tsr2). - BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate(unsigned short int downsampler, unsigned long int triggerPosition, unsigned char triggerSource, unsigned char recordLength, unsigned char samplerateId, bool downsamplingMode, unsigned char usedChannels, bool fastRate, unsigned char triggerSlope) : Helper::DataArray(12) { + BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate(uint16_t downsampler, uint32_t triggerPosition, uint8_t triggerSource, uint8_t recordLength, uint8_t samplerateId, bool downsamplingMode, uint8_t usedChannels, bool fastRate, uint8_t triggerSlope) : Helper::DataArray(12) { this->init(); this->setTriggerSource(triggerSource); @@ -126,37 +126,37 @@ namespace Hantek { /// \brief Get the triggerSource value in Tsr1Bits. /// \return The triggerSource value. - unsigned char BulkSetTriggerAndSamplerate::getTriggerSource() { + uint8_t BulkSetTriggerAndSamplerate::getTriggerSource() { return ((Tsr1Bits *) &(this->array[2]))->triggerSource; } /// \brief Set the triggerSource in Tsr1Bits to the given value. /// \param value The new triggerSource value. - void BulkSetTriggerAndSamplerate::setTriggerSource(unsigned char value) { + void BulkSetTriggerAndSamplerate::setTriggerSource(uint8_t value) { ((Tsr1Bits *) &(this->array[2]))->triggerSource = value; } /// \brief Get the recordLength value in Tsr1Bits. /// \return The ::RecordLengthId value. - unsigned char BulkSetTriggerAndSamplerate::getRecordLength() { + uint8_t BulkSetTriggerAndSamplerate::getRecordLength() { return ((Tsr1Bits *) &(this->array[2]))->recordLength; } /// \brief Set the recordLength in Tsr1Bits to the given value. /// \param value The new ::RecordLengthId value. - void BulkSetTriggerAndSamplerate::setRecordLength(unsigned char value) { + void BulkSetTriggerAndSamplerate::setRecordLength(uint8_t value) { ((Tsr1Bits *) &(this->array[2]))->recordLength = value; } /// \brief Get the samplerateId value in Tsr1Bits. /// \return The samplerateId value. - unsigned char BulkSetTriggerAndSamplerate::getSamplerateId() { + uint8_t BulkSetTriggerAndSamplerate::getSamplerateId() { return ((Tsr1Bits *) &(this->array[2]))->samplerateId; } /// \brief Set the samplerateId in Tsr1Bits to the given value. /// \param value The new samplerateId value. - void BulkSetTriggerAndSamplerate::setSamplerateId(unsigned char value) { + void BulkSetTriggerAndSamplerate::setSamplerateId(uint8_t value) { ((Tsr1Bits *) &(this->array[2]))->samplerateId = value; } @@ -174,13 +174,13 @@ namespace Hantek { /// \brief Get the usedChannels value in Tsr2Bits. /// \return The usedChannels value. - unsigned char BulkSetTriggerAndSamplerate::getUsedChannels() { + uint8_t BulkSetTriggerAndSamplerate::getUsedChannels() { return ((Tsr2Bits *) &(this->array[3]))->usedChannels; } /// \brief Set the usedChannels in Tsr2Bits to the given value. /// \param value The new usedChannels value. - void BulkSetTriggerAndSamplerate::setUsedChannels(unsigned char value) { + void BulkSetTriggerAndSamplerate::setUsedChannels(uint8_t value) { ((Tsr2Bits *) &(this->array[3]))->usedChannels = value; } @@ -198,41 +198,41 @@ namespace Hantek { /// \brief Get the triggerSlope value in Tsr2Bits. /// \return The triggerSlope value. - unsigned char BulkSetTriggerAndSamplerate::getTriggerSlope() { + uint8_t BulkSetTriggerAndSamplerate::getTriggerSlope() { return ((Tsr2Bits *) &(this->array[3]))->triggerSlope; } /// \brief Set the triggerSlope in Tsr2Bits to the given value. /// \param slope The new triggerSlope value. - void BulkSetTriggerAndSamplerate::setTriggerSlope(unsigned char slope) { + void BulkSetTriggerAndSamplerate::setTriggerSlope(uint8_t slope) { ((Tsr2Bits *) &(this->array[3]))->triggerSlope = slope; } /// \brief Get the Downsampler value. /// \return The Downsampler value. - unsigned short int BulkSetTriggerAndSamplerate::getDownsampler() { - return (unsigned short int) this->array[4] | ((unsigned short int) this->array[5] << 8); + uint16_t BulkSetTriggerAndSamplerate::getDownsampler() { + return (uint16_t) this->array[4] | ((uint16_t) this->array[5] << 8); } /// \brief Set the Downsampler to the given value. /// \param downsampler The new Downsampler value. - void BulkSetTriggerAndSamplerate::setDownsampler(unsigned short int downsampler) { - this->array[4] = (unsigned char) downsampler; - this->array[5] = (unsigned char) (downsampler >> 8); + void BulkSetTriggerAndSamplerate::setDownsampler(uint16_t downsampler) { + this->array[4] = (uint8_t) downsampler; + this->array[5] = (uint8_t) (downsampler >> 8); } /// \brief Get the TriggerPosition value. /// \return The horizontal trigger position. - unsigned long int BulkSetTriggerAndSamplerate::getTriggerPosition() { - return (unsigned long int) this->array[6] | ((unsigned long int) this->array[7] << 8) | ((unsigned long int) this->array[10] << 16); + uint32_t BulkSetTriggerAndSamplerate::getTriggerPosition() { + return (uint32_t) this->array[6] | ((uint32_t) this->array[7] << 8) | ((uint32_t) this->array[10] << 16); } /// \brief Set the TriggerPosition to the given value. /// \param position The new horizontal trigger position. - void BulkSetTriggerAndSamplerate::setTriggerPosition(unsigned long int position) { - this->array[6] = (unsigned char) position; - this->array[7] = (unsigned char) (position >> 8); - this->array[10] = (unsigned char) (position >> 16); + void BulkSetTriggerAndSamplerate::setTriggerPosition(uint32_t position) { + this->array[6] = (uint8_t) position; + this->array[7] = (uint8_t) (position >> 8); + this->array[10] = (uint8_t) (position >> 16); } /// \brief Initialize the array to the needed values. @@ -244,7 +244,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkForceTrigger /// \brief Sets the data array to needed values. - BulkForceTrigger::BulkForceTrigger() : Helper::DataArray(2) { + BulkForceTrigger::BulkForceTrigger() : Helper::DataArray(2) { this->array[0] = BULK_FORCETRIGGER; } @@ -252,7 +252,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkCaptureStart /// \brief Sets the data array to needed values. - BulkCaptureStart::BulkCaptureStart() : Helper::DataArray(2) { + BulkCaptureStart::BulkCaptureStart() : Helper::DataArray(2) { this->array[0] = BULK_STARTSAMPLING; } @@ -260,7 +260,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkTriggerEnabled /// \brief Sets the data array to needed values. - BulkTriggerEnabled::BulkTriggerEnabled() : Helper::DataArray(2) { + BulkTriggerEnabled::BulkTriggerEnabled() : Helper::DataArray(2) { this->array[0] = BULK_ENABLETRIGGER; } @@ -268,7 +268,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkGetData /// \brief Sets the data array to needed values. - BulkGetData::BulkGetData() : Helper::DataArray(2) { + BulkGetData::BulkGetData() : Helper::DataArray(2) { this->array[0] = BULK_GETDATA; } @@ -276,7 +276,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkGetCaptureState /// \brief Sets the data array to needed values. - BulkGetCaptureState::BulkGetCaptureState() : Helper::DataArray(2) { + BulkGetCaptureState::BulkGetCaptureState() : Helper::DataArray(2) { this->array[0] = BULK_GETCAPTURESTATE; } @@ -284,7 +284,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkResponseGetCaptureState /// \brief Initializes the array. - BulkResponseGetCaptureState::BulkResponseGetCaptureState() : Helper::DataArray(512) { + BulkResponseGetCaptureState::BulkResponseGetCaptureState() : Helper::DataArray(512) { } /// \brief Gets the capture state. @@ -303,14 +303,14 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetGain /// \brief Sets the data array to needed values. - BulkSetGain::BulkSetGain() : Helper::DataArray(8) { + BulkSetGain::BulkSetGain() : Helper::DataArray(8) { this->init(); } /// \brief Sets the gain to the given values. /// \param channel1 The gain value for channel 1. /// \param channel2 The gain value for channel 2. - BulkSetGain::BulkSetGain(unsigned char channel1, unsigned char channel2) : Helper::DataArray(8) { + BulkSetGain::BulkSetGain(uint8_t channel1, uint8_t channel2) : Helper::DataArray(8) { this->init(); this->setGain(0, channel1); @@ -320,7 +320,7 @@ namespace Hantek { /// \brief Get the gain for the given channel. /// \param channel The channel whose gain should be returned. /// \returns The gain value. - unsigned char BulkSetGain::getGain(unsigned int channel) { + uint8_t BulkSetGain::getGain(unsigned int channel) { GainBits *gainBits = (GainBits *) &(this->array[2]); if(channel == 0) return gainBits->channel1; @@ -331,7 +331,7 @@ namespace Hantek { /// \brief Set the gain for the given channel. /// \param channel The channel that should be set. /// \param value The new gain value for the channel. - void BulkSetGain::setGain(unsigned int channel, unsigned char value) { + void BulkSetGain::setGain(unsigned int channel, uint8_t value) { GainBits *gainBits = (GainBits *) &(this->array[2]); if(channel == 0) gainBits->channel1 = value; @@ -348,13 +348,13 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetLogicalData /// \brief Sets the data array to needed values. - BulkSetLogicalData::BulkSetLogicalData() : Helper::DataArray(8) { + BulkSetLogicalData::BulkSetLogicalData() : Helper::DataArray(8) { this->init(); } /// \brief Sets the data to the given value. /// \param data The data byte. - BulkSetLogicalData::BulkSetLogicalData(unsigned char data) : Helper::DataArray(8) { + BulkSetLogicalData::BulkSetLogicalData(uint8_t data) : Helper::DataArray(8) { this->init(); this->setData(data); @@ -362,13 +362,13 @@ namespace Hantek { /// \brief Gets the data. /// \returns The data byte. - unsigned char BulkSetLogicalData::getData() { + uint8_t BulkSetLogicalData::getData() { return this->array[2]; } /// \brief Sets the data to the given value. /// \param data The new data byte. - void BulkSetLogicalData::setData(unsigned char data) { + void BulkSetLogicalData::setData(uint8_t data) { this->array[2] = data; } @@ -381,7 +381,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkGetLogicalData /// \brief Sets the data array to needed values. - BulkGetLogicalData::BulkGetLogicalData() : Helper::DataArray(2) { + BulkGetLogicalData::BulkGetLogicalData() : Helper::DataArray(2) { this->array[0] = BULK_GETLOGICALDATA; } @@ -389,13 +389,13 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetFilter2250 /// \brief Sets the data array to needed values. - BulkSetChannels2250::BulkSetChannels2250() : Helper::DataArray(4) { + BulkSetChannels2250::BulkSetChannels2250() : Helper::DataArray(4) { this->init(); } /// \brief Sets the used channels. /// \param usedChannels The UsedChannels value. - BulkSetChannels2250::BulkSetChannels2250(unsigned char usedChannels) : Helper::DataArray(4) { + BulkSetChannels2250::BulkSetChannels2250(uint8_t usedChannels) : Helper::DataArray(4) { this->init(); this->setUsedChannels(usedChannels); @@ -403,13 +403,13 @@ namespace Hantek { /// \brief Get the UsedChannels value /// \return The UsedChannels value. - unsigned char BulkSetChannels2250::getUsedChannels() { + uint8_t BulkSetChannels2250::getUsedChannels() { return this->array[2]; } /// \brief Set the UsedChannels to the given value. /// \param value The new UsedChannels value. - void BulkSetChannels2250::setUsedChannels(unsigned char value) { + void BulkSetChannels2250::setUsedChannels(uint8_t value) { this->array[2] = value; } @@ -422,14 +422,14 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetTrigger2250 /// \brief Sets the data array to needed values. - BulkSetTrigger2250::BulkSetTrigger2250() : Helper::DataArray(8) { + BulkSetTrigger2250::BulkSetTrigger2250() : Helper::DataArray(8) { this->init(); } /// \brief Sets the used channels. /// \param triggerSource The trigger source id (CTriggerBits). /// \param triggerSlope The triggerSlope value (CTriggerBits). - BulkSetTrigger2250::BulkSetTrigger2250(unsigned char triggerSource, unsigned char triggerSlope) : Helper::DataArray(8) { + BulkSetTrigger2250::BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope) : Helper::DataArray(8) { this->init(); this->setTriggerSource(triggerSource); @@ -438,25 +438,25 @@ namespace Hantek { /// \brief Get the triggerSource value in CTriggerBits. /// \return The triggerSource value. - unsigned char BulkSetTrigger2250::getTriggerSource() { + uint8_t BulkSetTrigger2250::getTriggerSource() { return ((CTriggerBits *) &(this->array[2]))->triggerSource; } /// \brief Set the triggerSource in CTriggerBits to the given value. /// \param value The new triggerSource value. - void BulkSetTrigger2250::setTriggerSource(unsigned char value) { + void BulkSetTrigger2250::setTriggerSource(uint8_t value) { ((CTriggerBits *) &(this->array[2]))->triggerSource = value; } /// \brief Get the triggerSlope value in CTriggerBits. /// \return The triggerSlope value. - unsigned char BulkSetTrigger2250::getTriggerSlope() { + uint8_t BulkSetTrigger2250::getTriggerSlope() { return ((CTriggerBits *) &(this->array[2]))->triggerSlope; } /// \brief Set the triggerSlope in CTriggerBits to the given value. /// \param slope The new triggerSlope value. - void BulkSetTrigger2250::setTriggerSlope(unsigned char slope) { + void BulkSetTrigger2250::setTriggerSlope(uint8_t slope) { ((CTriggerBits *) &(this->array[2]))->triggerSlope = slope; } @@ -469,14 +469,14 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetSamplerate5200 /// \brief Sets the data array to the default values. - BulkSetSamplerate5200::BulkSetSamplerate5200() : Helper::DataArray(6) { + BulkSetSamplerate5200::BulkSetSamplerate5200() : Helper::DataArray(6) { this->init(); } /// \brief Sets the data bytes to the specified values. /// \param samplerateSlow The SamplerateSlow value. /// \param samplerateFast The SamplerateFast value. - BulkSetSamplerate5200::BulkSetSamplerate5200(unsigned short int samplerateSlow, unsigned char samplerateFast) : Helper::DataArray(6) { + BulkSetSamplerate5200::BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast) : Helper::DataArray(6) { this->init(); this->setSamplerateFast(samplerateFast); @@ -485,27 +485,27 @@ namespace Hantek { /// \brief Get the SamplerateFast value. /// \return The SamplerateFast value. - unsigned char BulkSetSamplerate5200::getSamplerateFast() { + uint8_t BulkSetSamplerate5200::getSamplerateFast() { return this->array[4]; } /// \brief Set the SamplerateFast to the given value. /// \param value The new SamplerateFast value. - void BulkSetSamplerate5200::setSamplerateFast(unsigned char value) { + void BulkSetSamplerate5200::setSamplerateFast(uint8_t value) { this->array[4] = value; } /// \brief Get the SamplerateSlow value. /// \return The SamplerateSlow value. - unsigned short int BulkSetSamplerate5200::getSamplerateSlow() { - return (unsigned short int) this->array[2] | ((unsigned short int) this->array[3] << 8); + uint16_t BulkSetSamplerate5200::getSamplerateSlow() { + return (uint16_t) this->array[2] | ((uint16_t) this->array[3] << 8); } /// \brief Set the SamplerateSlow to the given value. /// \param samplerate The new SamplerateSlow value. - void BulkSetSamplerate5200::setSamplerateSlow(unsigned short int samplerate) { - this->array[2] = (unsigned char) samplerate; - this->array[3] = (unsigned char) (samplerate >> 8); + void BulkSetSamplerate5200::setSamplerateSlow(uint16_t samplerate) { + this->array[2] = (uint8_t) samplerate; + this->array[3] = (uint8_t) (samplerate >> 8); } /// \brief Initialize the array to the needed values. @@ -517,13 +517,13 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetBuffer2250 /// \brief Sets the data array to the default values. - BulkSetRecordLength2250::BulkSetRecordLength2250() : Helper::DataArray(4) { + BulkSetRecordLength2250::BulkSetRecordLength2250() : Helper::DataArray(4) { this->init(); } /// \brief Sets the data bytes to the specified values. /// \param recordLength The ::RecordLengthId value. - BulkSetRecordLength2250::BulkSetRecordLength2250(unsigned char recordLength) : Helper::DataArray(4) { + BulkSetRecordLength2250::BulkSetRecordLength2250(uint8_t recordLength) : Helper::DataArray(4) { this->init(); this->setRecordLength(recordLength); @@ -531,13 +531,13 @@ namespace Hantek { /// \brief Get the ::RecordLengthId value. /// \return The ::RecordLengthId value. - unsigned char BulkSetRecordLength2250::getRecordLength() { + uint8_t BulkSetRecordLength2250::getRecordLength() { return this->array[2]; } /// \brief Set the ::RecordLengthId to the given value. /// \param value The new ::RecordLengthId value. - void BulkSetRecordLength2250::setRecordLength(unsigned char value) { + void BulkSetRecordLength2250::setRecordLength(uint8_t value) { this->array[2] = value; } @@ -550,7 +550,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetBuffer5200 /// \brief Sets the data array to the default values. - BulkSetBuffer5200::BulkSetBuffer5200() : Helper::DataArray(10) { + BulkSetBuffer5200::BulkSetBuffer5200() : Helper::DataArray(10) { this->init(); } @@ -560,7 +560,7 @@ namespace Hantek { /// \param usedPre The TriggerPositionUsedPre value. /// \param usedPost The TriggerPositionUsedPost value. /// \param recordLength The ::RecordLengthId value. - BulkSetBuffer5200::BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre, unsigned char usedPost, unsigned char recordLength) : Helper::DataArray(10) { + BulkSetBuffer5200::BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, uint8_t usedPre, uint8_t usedPost, uint8_t recordLength) : Helper::DataArray(10) { this->init(); this->setTriggerPositionPre(triggerPositionPre); @@ -572,63 +572,63 @@ namespace Hantek { /// \brief Get the TriggerPositionPre value. /// \return The TriggerPositionPre value. - unsigned short int BulkSetBuffer5200::getTriggerPositionPre() { - return (unsigned short int) this->array[2] | ((unsigned short int) this->array[3] << 8); + uint16_t BulkSetBuffer5200::getTriggerPositionPre() { + return (uint16_t) this->array[2] | ((uint16_t) this->array[3] << 8); } /// \brief Set the TriggerPositionPre to the given value. /// \param position The new TriggerPositionPre value. - void BulkSetBuffer5200::setTriggerPositionPre(unsigned short int position) { - this->array[2] = (unsigned char) position; - this->array[3] = (unsigned char) (position >> 8); + void BulkSetBuffer5200::setTriggerPositionPre(uint16_t position) { + this->array[2] = (uint8_t) position; + this->array[3] = (uint8_t) (position >> 8); } /// \brief Get the TriggerPositionPost value. /// \return The TriggerPositionPost value. - unsigned short int BulkSetBuffer5200::getTriggerPositionPost() { - return (unsigned short int) this->array[6] | ((unsigned short int) this->array[7] << 8); + uint16_t BulkSetBuffer5200::getTriggerPositionPost() { + return (uint16_t) this->array[6] | ((uint16_t) this->array[7] << 8); } /// \brief Set the TriggerPositionPost to the given value. /// \param position The new TriggerPositionPost value. - void BulkSetBuffer5200::setTriggerPositionPost(unsigned short int position) { - this->array[6] = (unsigned char) position; - this->array[7] = (unsigned char) (position >> 8); + void BulkSetBuffer5200::setTriggerPositionPost(uint16_t position) { + this->array[6] = (uint8_t) position; + this->array[7] = (uint8_t) (position >> 8); } /// \brief Get the TriggerPositionUsedPre value. /// \return The ::DTriggerPositionUsed value for the pre position. - unsigned char BulkSetBuffer5200::getUsedPre() { + uint8_t BulkSetBuffer5200::getUsedPre() { return this->array[4]; } /// \brief Set the TriggerPositionUsedPre to the given value. /// \param value The new ::DTriggerPositionUsed value for the pre position. - void BulkSetBuffer5200::setUsedPre(unsigned char value) { + void BulkSetBuffer5200::setUsedPre(uint8_t value) { this->array[4] = value; } /// \brief Get the TriggerPositionUsedPost value. /// \return The ::DTriggerPositionUsed value for the post position. - unsigned char BulkSetBuffer5200::getUsedPost() { + uint8_t BulkSetBuffer5200::getUsedPost() { return ((DBufferBits *) &(this->array[8]))->triggerPositionUsed; } /// \brief Set the TriggerPositionUsedPost to the given value. /// \param value The new ::DTriggerPositionUsed value for the post position. - void BulkSetBuffer5200::setUsedPost(unsigned char value) { + void BulkSetBuffer5200::setUsedPost(uint8_t value) { ((DBufferBits *) &(this->array[8]))->triggerPositionUsed = value; } /// \brief Get the recordLength value in DBufferBits. /// \return The ::RecordLengthId value. - unsigned char BulkSetBuffer5200::getRecordLength() { + uint8_t BulkSetBuffer5200::getRecordLength() { return ((DBufferBits *) &(this->array[8]))->recordLength; } /// \brief Set the recordLength in DBufferBits to the given value. /// \param value The new ::RecordLengthId value. - void BulkSetBuffer5200::setRecordLength(unsigned char value) { + void BulkSetBuffer5200::setRecordLength(uint8_t value) { ((DBufferBits *) &(this->array[8]))->recordLength = value; } @@ -643,7 +643,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetSamplerate2250 /// \brief Sets the data array to the default values. - BulkSetSamplerate2250::BulkSetSamplerate2250() : Helper::DataArray(8) { + BulkSetSamplerate2250::BulkSetSamplerate2250() : Helper::DataArray(8) { this->init(); } @@ -651,7 +651,7 @@ namespace Hantek { /// \param fastRate The fastRate state (ESamplerateBits). /// \param downsampling The downsampling state (ESamplerateBits). /// \param samplerate The Samplerate value. - BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, unsigned short int samplerate) : Helper::DataArray(8) { + BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, uint16_t samplerate) : Helper::DataArray(8) { this->init(); this->setFastRate(fastRate); @@ -685,15 +685,15 @@ namespace Hantek { /// \brief Get the Samplerate value. /// \return The Samplerate value. - unsigned short int BulkSetSamplerate2250::getSamplerate() { - return (unsigned short int) this->array[4] | ((unsigned short int) this->array[5] << 8); + uint16_t BulkSetSamplerate2250::getSamplerate() { + return (uint16_t) this->array[4] | ((uint16_t) this->array[5] << 8); } /// \brief Set the Samplerate to the given value. /// \param samplerate The new Samplerate value. - void BulkSetSamplerate2250::setSamplerate(unsigned short int samplerate) { - this->array[4] = (unsigned char) samplerate; - this->array[5] = (unsigned char) (samplerate >> 8); + void BulkSetSamplerate2250::setSamplerate(uint16_t samplerate) { + this->array[4] = (uint8_t) samplerate; + this->array[5] = (uint8_t) (samplerate >> 8); } /// \brief Initialize the array to the needed values. @@ -705,7 +705,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class BulkSetTrigger5200 /// \brief Sets the data array to the default values. - BulkSetTrigger5200::BulkSetTrigger5200() : Helper::DataArray(8) { + BulkSetTrigger5200::BulkSetTrigger5200() : Helper::DataArray(8) { this->init(); } @@ -715,7 +715,7 @@ namespace Hantek { /// \param fastRate The fastRate state. /// \param triggerSlope The triggerSlope value. /// \param triggerPulse The triggerPulse value. - BulkSetTrigger5200::BulkSetTrigger5200(unsigned char triggerSource, unsigned char usedChannels, bool fastRate, unsigned char triggerSlope, unsigned char triggerPulse) : Helper::DataArray(8) { + BulkSetTrigger5200::BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate, uint8_t triggerSlope, uint8_t triggerPulse) : Helper::DataArray(8) { this->init(); this->setTriggerSource(triggerSource); @@ -727,25 +727,25 @@ namespace Hantek { /// \brief Get the triggerSource value in ETsrBits. /// \return The ::TriggerSource value. - unsigned char BulkSetTrigger5200::getTriggerSource() { + uint8_t BulkSetTrigger5200::getTriggerSource() { return ((ETsrBits *) &(this->array[2]))->triggerSource; } /// \brief Set the triggerSource in ETsrBits to the given value. /// \param value The new ::TriggerSource value. - void BulkSetTrigger5200::setTriggerSource(unsigned char value) { + void BulkSetTrigger5200::setTriggerSource(uint8_t value) { ((ETsrBits *) &(this->array[2]))->triggerSource = value; } /// \brief Get the usedChannels value in ETsrBits. /// \return The ::UsedChannels value. - unsigned char BulkSetTrigger5200::getUsedChannels() { + uint8_t BulkSetTrigger5200::getUsedChannels() { return ((ETsrBits *) &(this->array[2]))->usedChannels; } /// \brief Set the usedChannels in ETsrBits to the given value. /// \param value The new ::UsedChannels value. - void BulkSetTrigger5200::setUsedChannels(unsigned char value) { + void BulkSetTrigger5200::setUsedChannels(uint8_t value) { ((ETsrBits *) &(this->array[2]))->usedChannels = value; } @@ -763,13 +763,13 @@ namespace Hantek { /// \brief Get the triggerSlope value in ETsrBits. /// \return The triggerSlope value. - unsigned char BulkSetTrigger5200::getTriggerSlope() { + uint8_t BulkSetTrigger5200::getTriggerSlope() { return ((ETsrBits *) &(this->array[2]))->triggerSlope; } /// \brief Set the triggerSlope in ETsrBits to the given value. /// \param slope The new triggerSlope value. - void BulkSetTrigger5200::setTriggerSlope(unsigned char slope) { + void BulkSetTrigger5200::setTriggerSlope(uint8_t slope) { ((ETsrBits *) &(this->array[2]))->triggerSlope = slope; } @@ -796,14 +796,14 @@ namespace Hantek { /// \class BulkSetBuffer2250 hantek/types.h /// \brief The DSO-2250 BULK_FSETBUFFER builder. /// \brief Sets the data array to the default values. - BulkSetBuffer2250::BulkSetBuffer2250() : Helper::DataArray(10) { + BulkSetBuffer2250::BulkSetBuffer2250() : Helper::DataArray(10) { this->init(); } /// \brief Sets the data bytes to the specified values. /// \param triggerPositionPre The TriggerPositionPre value. /// \param triggerPositionPost The TriggerPositionPost value. - BulkSetBuffer2250::BulkSetBuffer2250(unsigned long int triggerPositionPre, unsigned long int triggerPositionPost) : Helper::DataArray(12) { + BulkSetBuffer2250::BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost) : Helper::DataArray(12) { this->init(); this->setTriggerPositionPre(triggerPositionPre); @@ -812,30 +812,30 @@ namespace Hantek { /// \brief Get the TriggerPositionPost value. /// \return The TriggerPositionPost value. - unsigned long int BulkSetBuffer2250::getTriggerPositionPost() { - return (unsigned long int) this->array[2] | ((unsigned long int) this->array[3] << 8) | ((unsigned long int) this->array[4] << 16); + uint32_t BulkSetBuffer2250::getTriggerPositionPost() { + return (uint32_t) this->array[2] | ((uint32_t) this->array[3] << 8) | ((uint32_t) this->array[4] << 16); } /// \brief Set the TriggerPositionPost to the given value. /// \param position The new TriggerPositionPost value. - void BulkSetBuffer2250::setTriggerPositionPost(unsigned long int position) { - this->array[2] = (unsigned char) position; - this->array[3] = (unsigned char) (position >> 8); - this->array[4] = (unsigned char) (position >> 16); + void BulkSetBuffer2250::setTriggerPositionPost(uint32_t position) { + this->array[2] = (uint8_t) position; + this->array[3] = (uint8_t) (position >> 8); + this->array[4] = (uint8_t) (position >> 16); } /// \brief Get the TriggerPositionPre value. /// \return The TriggerPositionPre value. - unsigned long int BulkSetBuffer2250::getTriggerPositionPre() { - return (unsigned long int) this->array[6] | ((unsigned short int) this->array[7] << 8) | ((unsigned short int) this->array[8] << 16); + uint32_t BulkSetBuffer2250::getTriggerPositionPre() { + return (uint32_t) this->array[6] | ((uint16_t) this->array[7] << 8) | ((uint16_t) this->array[8] << 16); } /// \brief Set the TriggerPositionPre to the given value. /// \param position The new TriggerPositionPre value. - void BulkSetBuffer2250::setTriggerPositionPre(unsigned long int position) { - this->array[6] = (unsigned char) position; - this->array[7] = (unsigned char) (position >> 8); - this->array[8] = (unsigned char) (position >> 16); + void BulkSetBuffer2250::setTriggerPositionPre(uint32_t position) { + this->array[6] = (uint8_t) position; + this->array[7] = (uint8_t) (position >> 8); + this->array[8] = (uint8_t) (position >> 16); } /// \brief Initialize the array to the needed values. @@ -847,7 +847,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class ControlGetSpeed /// \brief Initializes the array. - ControlGetSpeed::ControlGetSpeed() : Helper::DataArray(10) { + ControlGetSpeed::ControlGetSpeed() : Helper::DataArray(10) { } /// \brief Gets the speed of the connection. @@ -861,7 +861,7 @@ namespace Hantek { // class ControlBeginCommand /// \brief Sets the command index to the given value. /// \param index The CommandIndex for the command. - ControlBeginCommand::ControlBeginCommand(BulkIndex index) : Helper::DataArray(10) { + ControlBeginCommand::ControlBeginCommand(BulkIndex index) : Helper::DataArray(10) { this->init(); this->setIndex(index); @@ -876,7 +876,7 @@ namespace Hantek { /// \brief Sets the command index to the given value. /// \param index The new CommandIndex for the command. void ControlBeginCommand::setIndex(BulkIndex index) { - memset(&(this->array[1]), (unsigned char) index, 3); + memset(&(this->array[1]), (uint8_t) index, 3); } /// \brief Initialize the array to the needed values. @@ -888,14 +888,14 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// // class ControlSetOffset /// \brief Sets the data array to the default values. - ControlSetOffset::ControlSetOffset() : Helper::DataArray(17) { + ControlSetOffset::ControlSetOffset() : Helper::DataArray(17) { } /// \brief Sets the offsets to the given values. /// \param channel1 The offset for channel 1. /// \param channel2 The offset for channel 2. /// \param trigger The offset for ext. trigger. - ControlSetOffset::ControlSetOffset(unsigned short int channel1, unsigned short int channel2, unsigned short int trigger) : Helper::DataArray(17) { + ControlSetOffset::ControlSetOffset(uint16_t channel1, uint16_t channel2, uint16_t trigger) : Helper::DataArray(17) { this->setChannel(0, channel1); this->setChannel(1, channel2); this->setTrigger(trigger); @@ -904,7 +904,7 @@ namespace Hantek { /// \brief Get the offset for the given channel. /// \param channel The channel whose offset should be returned. /// \return The channel offset value. - unsigned short int ControlSetOffset::getChannel(unsigned int channel) { + uint16_t ControlSetOffset::getChannel(unsigned int channel) { if(channel == 0) return ((this->array[0] & 0x0f) << 8) | this->array[1]; else @@ -914,28 +914,28 @@ namespace Hantek { /// \brief Set the offset for the given channel. /// \param channel The channel that should be set. /// \param offset The new channel offset value. - void ControlSetOffset::setChannel(unsigned int channel, unsigned short int offset) { + void ControlSetOffset::setChannel(unsigned int channel, uint16_t offset) { if(channel == 0) { - this->array[0] = (unsigned char) (offset >> 8); - this->array[1] = (unsigned char) offset; + this->array[0] = (uint8_t) (offset >> 8); + this->array[1] = (uint8_t) offset; } else { - this->array[2] = (unsigned char) (offset >> 8); - this->array[3] = (unsigned char) offset; + this->array[2] = (uint8_t) (offset >> 8); + this->array[3] = (uint8_t) offset; } } /// \brief Get the trigger level. /// \return The trigger level value. - unsigned short int ControlSetOffset::getTrigger() { + uint16_t ControlSetOffset::getTrigger() { return ((this->array[4] & 0x0f) << 8) | this->array[5]; } /// \brief Set the trigger level. /// \param level The new trigger level value. - void ControlSetOffset::setTrigger(unsigned short int level) { - this->array[4] = (unsigned char) (level >> 8); - this->array[5] = (unsigned char) level; + void ControlSetOffset::setTrigger(uint16_t level) { + this->array[4] = (uint8_t) (level >> 8); + this->array[5] = (uint8_t) level; } @@ -949,7 +949,7 @@ namespace Hantek { /// \param ch2Below100mV Sets the state of the Channel 2 below 100 mV relay. /// \param ch2CouplingDC Sets the state of the Channel 2 coupling relay. /// \param triggerExt Sets the state of the external trigger relay. - ControlSetRelays::ControlSetRelays(bool ch1Below1V, bool ch1Below100mV, bool ch1CouplingDC, bool ch2Below1V, bool ch2Below100mV, bool ch2CouplingDC, bool triggerExt) : Helper::DataArray(17) { + ControlSetRelays::ControlSetRelays(bool ch1Below1V, bool ch1Below100mV, bool ch1CouplingDC, bool ch2Below1V, bool ch2Below100mV, bool ch2CouplingDC, bool triggerExt) : Helper::DataArray(17) { this->setBelow1V(0, ch1Below1V); this->setBelow100mV(0, ch1Below100mV); this->setCoupling(0, ch1CouplingDC); diff --git a/openhantek/src/hantek/types.h b/openhantek/src/hantek/types.h index 45fd443..786ad7e 100644 --- a/openhantek/src/hantek/types.h +++ b/openhantek/src/hantek/types.h @@ -29,6 +29,9 @@ #define HANTEK_TYPES_H +#include + + #include "helper.h" @@ -738,83 +741,83 @@ namespace Hantek { /// \struct FilterBits hantek/types.h /// \brief The bits for BULK_SETFILTER. struct FilterBits { - unsigned char channel1:1; ///< Set to true when channel 1 isn't used - unsigned char channel2:1; ///< Set to true when channel 2 isn't used - unsigned char trigger:1; ///< Set to true when trigger isn't used - unsigned char reserved:5; ///< Unused bits + uint8_t channel1:1; ///< Set to true when channel 1 isn't used + uint8_t channel2:1; ///< Set to true when channel 2 isn't used + uint8_t trigger:1; ///< Set to true when trigger isn't used + uint8_t reserved:5; ///< Unused bits }; ////////////////////////////////////////////////////////////////////////////// /// \struct GainBits hantek/types.h /// \brief The gain bits for BULK_SETGAIN. struct GainBits { - unsigned char channel1:2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e* - unsigned char channel2:2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e* - unsigned char reserved:4; ///< Unused bits + uint8_t channel1:2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e* + uint8_t channel2:2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e* + uint8_t reserved:4; ///< Unused bits }; ////////////////////////////////////////////////////////////////////////////// /// \struct Tsr1Bits hantek/types.h /// \brief Trigger and samplerate bits (Byte 1). struct Tsr1Bits { - unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource - unsigned char recordLength:3; ///< See ::RecordLengthId - unsigned char samplerateId:2; ///< Samplerate ID when downsampler is disabled - unsigned char downsamplingMode:1; ///< true, if Downsampler is used + uint8_t triggerSource:2; ///< The trigger source, see Hantek::TriggerSource + uint8_t recordLength:3; ///< See ::RecordLengthId + uint8_t samplerateId:2; ///< Samplerate ID when downsampler is disabled + uint8_t downsamplingMode:1; ///< true, if Downsampler is used }; ////////////////////////////////////////////////////////////////////////////// /// \struct Tsr2Bits hantek/types.h /// \brief Trigger and samplerate bits (Byte 2). struct Tsr2Bits { - unsigned char usedChannels:2; ///< Used channels, see Hantek::UsedChannels - unsigned char fastRate:1; ///< true, if one channels uses all buffers - unsigned char triggerSlope:1; ///< The trigger slope, see Dso::Slope, inverted when Tsr1Bits.samplerateFast is uneven - unsigned char reserved:4; ///< Unused bits + uint8_t usedChannels:2; ///< Used channels, see Hantek::UsedChannels + uint8_t fastRate:1; ///< true, if one channels uses all buffers + uint8_t triggerSlope:1; ///< The trigger slope, see Dso::Slope, inverted when Tsr1Bits.samplerateFast is uneven + uint8_t reserved:4; ///< Unused bits }; ////////////////////////////////////////////////////////////////////////////// /// \struct CTriggerBits hantek/types.h /// \brief Trigger bits for 0x0c command. struct CTriggerBits { - unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource - unsigned char triggerSlope:1; ///< The trigger slope, see Dso::Slope - unsigned char reserved:5; ///< Unused bits + uint8_t triggerSource:2; ///< The trigger source, see Hantek::TriggerSource + uint8_t triggerSlope:1; ///< The trigger slope, see Dso::Slope + uint8_t reserved:5; ///< Unused bits }; ////////////////////////////////////////////////////////////////////////////// /// \struct DBufferBits hantek/types.h /// \brief Buffer mode bits for 0x0d command. struct DBufferBits { - unsigned char triggerPositionUsed:3; ///< See ::DTriggerPositionUsed - unsigned char recordLength:3; ///< See ::RecordLengthId - unsigned char reserved:2; ///< Unused bits + uint8_t triggerPositionUsed:3; ///< See ::DTriggerPositionUsed + uint8_t recordLength:3; ///< See ::RecordLengthId + uint8_t reserved:2; ///< Unused bits }; ////////////////////////////////////////////////////////////////////////////// /// \struct ESamplerateBits hantek/types.h /// \brief Samplerate bits for DSO-2250 0x0e command. struct ESamplerateBits { - unsigned char fastRate:1; ///< false, if one channels uses all buffers - unsigned char downsampling:1; ///< true, if the downsampler is activated - unsigned char reserved:4; ///< Unused bits + uint8_t fastRate:1; ///< false, if one channels uses all buffers + uint8_t downsampling:1; ///< true, if the downsampler is activated + uint8_t reserved:4; ///< Unused bits }; ////////////////////////////////////////////////////////////////////////////// /// \struct ETsrBits hantek/types.h /// \brief Trigger and samplerate bits for DSO-5200/DSO-5200A 0x0e command. struct ETsrBits { - unsigned char fastRate:1; ///< false, if one channels uses all buffers - unsigned char usedChannels:2; ///< Used channels, see Hantek::UsedChannels - unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource - unsigned char triggerSlope:2; ///< The trigger slope, see Dso::Slope - unsigned char triggerPulse:1; ///< Pulses are causing trigger events + uint8_t fastRate:1; ///< false, if one channels uses all buffers + uint8_t usedChannels:2; ///< Used channels, see Hantek::UsedChannels + uint8_t triggerSource:2; ///< The trigger source, see Hantek::TriggerSource + uint8_t triggerSlope:2; ///< The trigger slope, see Dso::Slope + uint8_t triggerPulse:1; ///< Pulses are causing trigger events }; ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetFilter hantek/types.h /// \brief The BULK_SETFILTER builder. - class BulkSetFilter : public Helper::DataArray { + class BulkSetFilter : public Helper::DataArray { public: BulkSetFilter(); BulkSetFilter(bool channel1, bool channel2, bool trigger); @@ -831,29 +834,29 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetTriggerAndSamplerate hantek/types.h /// \brief The BULK_SETTRIGGERANDSAMPLERATE builder. - class BulkSetTriggerAndSamplerate : public Helper::DataArray { + class BulkSetTriggerAndSamplerate : public Helper::DataArray { public: BulkSetTriggerAndSamplerate(); - BulkSetTriggerAndSamplerate(unsigned short int downsampler, unsigned long int triggerPosition, unsigned char triggerSource = 0, unsigned char recordLength = 0, unsigned char samplerateId = 0, bool downsamplingMode = true, unsigned char usedChannels = 0, bool fastRate = false, unsigned char triggerSlope = 0); + BulkSetTriggerAndSamplerate(uint16_t downsampler, uint32_t triggerPosition, uint8_t triggerSource = 0, uint8_t recordLength = 0, uint8_t samplerateId = 0, bool downsamplingMode = true, uint8_t usedChannels = 0, bool fastRate = false, uint8_t triggerSlope = 0); - unsigned char getTriggerSource(); - void setTriggerSource(unsigned char value); - unsigned char getRecordLength(); - void setRecordLength(unsigned char value); - unsigned char getSamplerateId(); - void setSamplerateId(unsigned char value); + uint8_t getTriggerSource(); + void setTriggerSource(uint8_t value); + uint8_t getRecordLength(); + void setRecordLength(uint8_t value); + uint8_t getSamplerateId(); + void setSamplerateId(uint8_t value); bool getDownsamplingMode(); void setDownsamplingMode(bool downsampling); - unsigned char getUsedChannels(); - void setUsedChannels(unsigned char value); + uint8_t getUsedChannels(); + void setUsedChannels(uint8_t value); bool getFastRate(); void setFastRate(bool fastRate); - unsigned char getTriggerSlope(); - void setTriggerSlope(unsigned char slope); - unsigned short int getDownsampler(); - void setDownsampler(unsigned short int downsampler); - unsigned long int getTriggerPosition(); - void setTriggerPosition(unsigned long int position); + uint8_t getTriggerSlope(); + void setTriggerSlope(uint8_t slope); + uint16_t getDownsampler(); + void setDownsampler(uint16_t downsampler); + uint32_t getTriggerPosition(); + void setTriggerPosition(uint32_t position); private: void init(); @@ -862,7 +865,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkForceTrigger hantek/types.h /// \brief The BULK_FORCETRIGGER builder. - class BulkForceTrigger : public Helper::DataArray { + class BulkForceTrigger : public Helper::DataArray { public: BulkForceTrigger(); }; @@ -870,7 +873,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkCaptureStart hantek/types.h /// \brief The BULK_CAPTURESTART builder. - class BulkCaptureStart : public Helper::DataArray { + class BulkCaptureStart : public Helper::DataArray { public: BulkCaptureStart(); }; @@ -878,7 +881,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkTriggerEnabled hantek/types.h /// \brief The BULK_TRIGGERENABLED builder. - class BulkTriggerEnabled : public Helper::DataArray { + class BulkTriggerEnabled : public Helper::DataArray { public: BulkTriggerEnabled(); }; @@ -886,7 +889,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkGetData hantek/types.h /// \brief The BULK_GETDATA builder. - class BulkGetData : public Helper::DataArray { + class BulkGetData : public Helper::DataArray { public: BulkGetData(); }; @@ -894,7 +897,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkGetCaptureState hantek/types.h /// \brief The BULK_GETCAPTURESTATE builder. - class BulkGetCaptureState : public Helper::DataArray { + class BulkGetCaptureState : public Helper::DataArray { public: BulkGetCaptureState(); }; @@ -902,7 +905,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkResponseGetCaptureState hantek/types.h /// \brief The parser for the BULK_GETCAPTURESTATE response. - class BulkResponseGetCaptureState : public Helper::DataArray { + class BulkResponseGetCaptureState : public Helper::DataArray { public: BulkResponseGetCaptureState(); @@ -913,13 +916,13 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetGain hantek/types.h /// \brief The BULK_SETGAIN builder. - class BulkSetGain : public Helper::DataArray { + class BulkSetGain : public Helper::DataArray { public: BulkSetGain(); - BulkSetGain(unsigned char channel1, unsigned char channel2); + BulkSetGain(uint8_t channel1, uint8_t channel2); - unsigned char getGain(unsigned int channel); - void setGain(unsigned int channel, unsigned char value); + uint8_t getGain(unsigned int channel); + void setGain(unsigned int channel, uint8_t value); private: void init(); @@ -928,13 +931,13 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetLogicalData hantek/types.h /// \brief The BULK_SETLOGICALDATA builder. - class BulkSetLogicalData : public Helper::DataArray { + class BulkSetLogicalData : public Helper::DataArray { public: BulkSetLogicalData(); - BulkSetLogicalData(unsigned char data); + BulkSetLogicalData(uint8_t data); - unsigned char getData(); - void setData(unsigned char data); + uint8_t getData(); + void setData(uint8_t data); private: void init(); @@ -943,7 +946,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkGetLogicalData hantek/types.h /// \brief The BULK_GETLOGICALDATA builder. - class BulkGetLogicalData : public Helper::DataArray { + class BulkGetLogicalData : public Helper::DataArray { public: BulkGetLogicalData(); }; @@ -951,13 +954,13 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetChannels2250 hantek/types.h /// \brief The DSO-2250 BULK_BSETFILTER builder. - class BulkSetChannels2250 : public Helper::DataArray { + class BulkSetChannels2250 : public Helper::DataArray { public: BulkSetChannels2250(); - BulkSetChannels2250(unsigned char usedChannels); + BulkSetChannels2250(uint8_t usedChannels); - unsigned char getUsedChannels(); - void setUsedChannels(unsigned char value); + uint8_t getUsedChannels(); + void setUsedChannels(uint8_t value); private: void init(); @@ -966,15 +969,15 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetTrigger2250 hantek/types.h /// \brief The DSO-2250 BULK_CSETTRIGGERORSAMPLERATE builder. - class BulkSetTrigger2250 : public Helper::DataArray { + class BulkSetTrigger2250 : public Helper::DataArray { public: BulkSetTrigger2250(); - BulkSetTrigger2250(unsigned char triggerSource, unsigned char triggerSlope); + BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope); - unsigned char getTriggerSource(); - void setTriggerSource(unsigned char value); - unsigned char getTriggerSlope(); - void setTriggerSlope(unsigned char slope); + uint8_t getTriggerSource(); + void setTriggerSource(uint8_t value); + uint8_t getTriggerSlope(); + void setTriggerSlope(uint8_t slope); private: void init(); @@ -983,15 +986,15 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetSamplerate5200 hantek/types.h /// \brief The DSO-5200/DSO-5200A BULK_CSETTRIGGERORSAMPLERATE builder. - class BulkSetSamplerate5200 : public Helper::DataArray { + class BulkSetSamplerate5200 : public Helper::DataArray { public: BulkSetSamplerate5200(); - BulkSetSamplerate5200(unsigned short int samplerateSlow, unsigned char samplerateFast); + BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast); - unsigned char getSamplerateFast(); - void setSamplerateFast(unsigned char value); - unsigned short int getSamplerateSlow(); - void setSamplerateSlow(unsigned short int samplerate); + uint8_t getSamplerateFast(); + void setSamplerateFast(uint8_t value); + uint16_t getSamplerateSlow(); + void setSamplerateSlow(uint16_t samplerate); private: void init(); @@ -1000,13 +1003,13 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetRecordLength2250 hantek/types.h /// \brief The DSO-2250 BULK_DSETBUFFER builder. - class BulkSetRecordLength2250 : public Helper::DataArray { + class BulkSetRecordLength2250 : public Helper::DataArray { public: BulkSetRecordLength2250(); - BulkSetRecordLength2250(unsigned char recordLength); + BulkSetRecordLength2250(uint8_t recordLength); - unsigned char getRecordLength(); - void setRecordLength(unsigned char value); + uint8_t getRecordLength(); + void setRecordLength(uint8_t value); private: void init(); @@ -1015,21 +1018,21 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetBuffer5200 hantek/types.h /// \brief The DSO-5200/DSO-5200A BULK_DSETBUFFER builder. - class BulkSetBuffer5200 : public Helper::DataArray { + class BulkSetBuffer5200 : public Helper::DataArray { public: BulkSetBuffer5200(); - BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre = 0, unsigned char usedPost = 0, unsigned char recordLength = 0); + BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, uint8_t usedPre = 0, uint8_t usedPost = 0, uint8_t recordLength = 0); - unsigned short int getTriggerPositionPre(); - void setTriggerPositionPre(unsigned short int value); - unsigned short int getTriggerPositionPost(); - void setTriggerPositionPost(unsigned short int value); - unsigned char getUsedPre(); - void setUsedPre(unsigned char value); - unsigned char getUsedPost(); - void setUsedPost(unsigned char value); - unsigned char getRecordLength(); - void setRecordLength(unsigned char value); + uint16_t getTriggerPositionPre(); + void setTriggerPositionPre(uint16_t value); + uint16_t getTriggerPositionPost(); + void setTriggerPositionPost(uint16_t value); + uint8_t getUsedPre(); + void setUsedPre(uint8_t value); + uint8_t getUsedPost(); + void setUsedPost(uint8_t value); + uint8_t getRecordLength(); + void setRecordLength(uint8_t value); private: void init(); @@ -1038,17 +1041,17 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetSamplerate2250 hantek/types.h /// \brief The DSO-2250 BULK_ESETTRIGGERORSAMPLERATE builder. - class BulkSetSamplerate2250 : public Helper::DataArray { + class BulkSetSamplerate2250 : public Helper::DataArray { public: BulkSetSamplerate2250(); - BulkSetSamplerate2250(bool fastRate, bool downsampling = false, unsigned short int samplerate = 0); + BulkSetSamplerate2250(bool fastRate, bool downsampling = false, uint16_t samplerate = 0); bool getFastRate(); void setFastRate(bool fastRate); bool getDownsampling(); void setDownsampling(bool downsampling); - unsigned short int getSamplerate(); - void setSamplerate(unsigned short int samplerate); + uint16_t getSamplerate(); + void setSamplerate(uint16_t samplerate); private: void init(); @@ -1057,19 +1060,19 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetTrigger5200 hantek/types.h /// \brief The DSO-5200/DSO-5200A BULK_ESETTRIGGERORSAMPLERATE builder. - class BulkSetTrigger5200 : public Helper::DataArray { + class BulkSetTrigger5200 : public Helper::DataArray { public: BulkSetTrigger5200(); - BulkSetTrigger5200(unsigned char triggerSource, unsigned char usedChannels, bool fastRate = false, unsigned char triggerSlope = 0, unsigned char triggerPulse = 0); + BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate = false, uint8_t triggerSlope = 0, uint8_t triggerPulse = 0); - unsigned char getTriggerSource(); - void setTriggerSource(unsigned char value); - unsigned char getUsedChannels(); - void setUsedChannels(unsigned char value); + uint8_t getTriggerSource(); + void setTriggerSource(uint8_t value); + uint8_t getUsedChannels(); + void setUsedChannels(uint8_t value); bool getFastRate(); void setFastRate(bool fastRate); - unsigned char getTriggerSlope(); - void setTriggerSlope(unsigned char slope); + uint8_t getTriggerSlope(); + void setTriggerSlope(uint8_t slope); bool getTriggerPulse(); void setTriggerPulse(bool pulse); @@ -1080,15 +1083,15 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class BulkSetBuffer2250 hantek/types.h /// \brief The DSO-2250 BULK_FSETBUFFER builder. - class BulkSetBuffer2250 : public Helper::DataArray { + class BulkSetBuffer2250 : public Helper::DataArray { public: BulkSetBuffer2250(); - BulkSetBuffer2250(unsigned long int triggerPositionPre, unsigned long int triggerPositionPost); + BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost); - unsigned long int getTriggerPositionPost(); - void setTriggerPositionPost(unsigned long int value); - unsigned long int getTriggerPositionPre(); - void setTriggerPositionPre(unsigned long int value); + uint32_t getTriggerPositionPost(); + void setTriggerPositionPost(uint32_t value); + uint32_t getTriggerPositionPre(); + void setTriggerPositionPre(uint32_t value); private: void init(); @@ -1097,7 +1100,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class ControlGetSpeed hantek/types.h /// \brief The CONTROL_GETSPEED parser. - class ControlGetSpeed : public Helper::DataArray { + class ControlGetSpeed : public Helper::DataArray { public: ControlGetSpeed(); @@ -1107,7 +1110,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class ControlBeginCommand hantek/types.h /// \brief The CONTROL_BEGINCOMMAND builder. - class ControlBeginCommand : public Helper::DataArray { + class ControlBeginCommand : public Helper::DataArray { public: ControlBeginCommand(BulkIndex index = COMMANDINDEX_0); @@ -1121,15 +1124,15 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class ControlSetOffset hantek/types.h /// \brief The CONTROL_SETOFFSET builder. - class ControlSetOffset : public Helper::DataArray { + class ControlSetOffset : public Helper::DataArray { public: ControlSetOffset(); - ControlSetOffset(unsigned short int channel1, unsigned short int channel2, unsigned short int trigger); + ControlSetOffset(uint16_t channel1, uint16_t channel2, uint16_t trigger); - unsigned short int getChannel(unsigned int channel); - void setChannel(unsigned int channel, unsigned short int offset); - unsigned short int getTrigger(); - void setTrigger(unsigned short int level); + uint16_t getChannel(unsigned int channel); + void setChannel(unsigned int channel, uint16_t offset); + uint16_t getTrigger(); + void setTrigger(uint16_t level); private: void init(); @@ -1138,7 +1141,7 @@ namespace Hantek { ////////////////////////////////////////////////////////////////////////////// /// \class ControlSetRelays hantek/types.h /// \brief The CONTROL_SETRELAYS builder. - class ControlSetRelays : public Helper::DataArray { + class ControlSetRelays : public Helper::DataArray { public: ControlSetRelays(bool ch1Below1V = false, bool ch1Below100mV = false, bool ch1CouplingDC = false, bool ch2Below1V = false, bool ch2Below100mV = false, bool ch2CouplingDC = false, bool triggerExt = false); diff --git a/openhantek/src/openhantek.cpp b/openhantek/src/openhantek.cpp index 8a76ff1..aa261e6 100644 --- a/openhantek/src/openhantek.cpp +++ b/openhantek/src/openhantek.cpp @@ -276,7 +276,7 @@ void OpenHantekMainWindow::connectSignals() { connect(this, SIGNAL(settingsChanged()), this, SLOT(applySettings())); //connect(this->dsoWidget, SIGNAL(stopped()), this, SLOT(stopped())); connect(this->dsoControl, SIGNAL(statusMessage(QString, int)), this->statusBar(), SLOT(showMessage(QString, int))); - connect(this->dsoControl, SIGNAL(samplesAvailable(const QList *, const QList *, double, QMutex *)), this->dataAnalyzer, SLOT(analyze(const QList *, const QList *, double, QMutex *))); + connect(this->dsoControl, SIGNAL(samplesAvailable(const QList *, const QList *, double, QMutex *)), this->dataAnalyzer, SLOT(analyze(const QList *, const QList *, double, QMutex *))); // Connect signals to DSO controller and widget connect(this->horizontalDock, SIGNAL(samplerateChanged(double)), this, SLOT(samplerateSelected())); @@ -315,7 +315,7 @@ void OpenHantekMainWindow::connectSignals() { connect(this->dsoControl, SIGNAL(recordTimeChanged(double)), this, SLOT(recordTimeChanged(double))); connect(this->dsoControl, SIGNAL(samplerateChanged(double)), this, SLOT(samplerateChanged(double))); - connect(this->dsoControl, SIGNAL(availableRecordLengthsChanged(QList)), this->horizontalDock, SLOT(availableRecordLengthsChanged(QList))); + connect(this->dsoControl, SIGNAL(availableRecordLengthsChanged(QList)), this->horizontalDock, SLOT(availableRecordLengthsChanged(QList))); connect(this->dsoControl, SIGNAL(samplerateLimitsChanged(double, double)), this->horizontalDock, SLOT(samplerateLimitsChanged(double, double))); } @@ -328,14 +328,14 @@ void OpenHantekMainWindow::initializeDevice() { this->dsoControl->setTriggerLevel(channel, this->settings->scope.voltage[channel].trigger); } this->updateUsed(this->settings->scope.physicalChannels); - if(this->dsoControl->getAvailableRecordLengths()->isEmpty()) - this->dsoControl->setRecordLength(this->settings->scope.horizontal.recordLength); - else - this->dsoControl->setRecordLength(this->dsoControl->getAvailableRecordLengths()->indexOf(this->settings->scope.horizontal.recordLength)); if(this->settings->scope.horizontal.samplerateSet) this->samplerateSelected(); else this->timebaseSelected(); + if(this->dsoControl->getAvailableRecordLengths()->isEmpty()) + this->dsoControl->setRecordLength(this->settings->scope.horizontal.recordLength); + else + this->dsoControl->setRecordLength(this->dsoControl->getAvailableRecordLengths()->indexOf(this->settings->scope.horizontal.recordLength)); this->dsoControl->setTriggerMode(this->settings->scope.trigger.mode); this->dsoControl->setPretriggerPosition(this->settings->scope.trigger.position * this->settings->scope.horizontal.timebase * DIVS_TIME); this->dsoControl->setTriggerSlope(this->settings->scope.trigger.slope); diff --git a/openhantek/src/settings.cpp b/openhantek/src/settings.cpp index f2cbf1e..60d4c64 100644 --- a/openhantek/src/settings.cpp +++ b/openhantek/src/settings.cpp @@ -456,7 +456,7 @@ int DsoSettings::save(const QString &fileName) { for(int marker = 0; marker < 2; ++marker) settingsSaver->setValue(QString("marker%1").arg(marker), this->scope.horizontal.marker[marker]); settingsSaver->setValue("timebase", this->scope.horizontal.timebase); - settingsSaver->setValue("recordLength", (unsigned int) this->scope.horizontal.recordLength); + settingsSaver->setValue("recordLength", this->scope.horizontal.recordLength); settingsSaver->setValue("samplerate", this->scope.horizontal.samplerate); settingsSaver->setValue("samplerateSet", this->scope.horizontal.samplerateSet); settingsSaver->endGroup(); diff --git a/openhantek/src/settings.h b/openhantek/src/settings.h index 4746a0a..0191cc5 100644 --- a/openhantek/src/settings.h +++ b/openhantek/src/settings.h @@ -93,7 +93,7 @@ struct DsoSettingsScopeHorizontal { double frequencybase; ///< Frequencybase in Hz/div double marker[2]; ///< Marker positions in div double timebase; ///< Timebase in s/div - unsigned long int recordLength; ///< Sample count + unsigned int recordLength; ///< Sample count double samplerate; ///< The samplerate of the oscilloscope in S bool samplerateSet; ///< The samplerate was set by the user, not the timebase };