Commit db76656c3cd51f50ba166726b6acf2983dc15edf

Authored by oliverhaag
1 parent d52c9b82

Roll mode bugfix

openhantek/ChangeLog
... ... @@ -192,3 +192,7 @@
192 192 * Added signals to DsoControl to update horizontal dock automatically
193 193 * Reworks in signal connections to make this work properly
194 194 * Bugfix: DSO-2250 used channels wasn't set
  195 +
  196 +2012-11-26 Oliver Haag <oliver.haag@gmail.com>
  197 +* Bugfix: Roll mode caused crash or hanging
  198 +* Bugfix: DSO-2150 samplerate maximum was 100 MS/s
... ...
openhantek/src/dataanalyzer.cpp
... ... @@ -81,7 +81,7 @@ const AnalyzedData *DataAnalyzer::data(int channel) const {
81 81  
82 82 /// \brief Returns the sample count of the analyzed data.
83 83 /// \return The maximum sample count of the last analyzed data.
84   -unsigned long int DataAnalyzer::sampleCount() {
  84 +unsigned int DataAnalyzer::sampleCount() {
85 85 return this->maxSamples;
86 86 }
87 87  
... ... @@ -95,7 +95,7 @@ QMutex *DataAnalyzer::mutex() const {
95 95 void DataAnalyzer::run() {
96 96 this->analyzedDataMutex->lock();
97 97  
98   - unsigned long int maxSamples = 0;
  98 + unsigned int maxSamples = 0;
99 99 unsigned int channelCount = (unsigned int) this->settings->scope.voltage.count();
100 100  
101 101 // Adapt the number of channels for analyzed data
... ... @@ -139,7 +139,7 @@ void DataAnalyzer::run() {
139 139 // Set sampling interval
140 140 channelData->samples.voltage.interval = 1.0 / this->waitingDataSamplerate;
141 141  
142   - unsigned long int size;
  142 + unsigned int size;
143 143 if(channel < this->settings->scope.physicalChannels) {
144 144 size = this->waitingDataSize[channel];
145 145 if(size > maxSamples)
... ... @@ -159,7 +159,7 @@ void DataAnalyzer::run() {
159 159 if(channel < this->settings->scope.physicalChannels) {
160 160 // Copy the buffer of the oscilloscope into the sample buffer
161 161 if(channel < (unsigned int) this->waitingData.count())
162   - for(unsigned long int position = 0; position < this->waitingDataSize[channel]; ++position)
  162 + for(unsigned int position = 0; position < this->waitingDataSize[channel]; ++position)
163 163 channelData->samples.voltage.sample[position] = this->waitingData[channel][position];
164 164 }
165 165 // Math channel
... ... @@ -176,7 +176,7 @@ void DataAnalyzer::run() {
176 176 }
177 177  
178 178 // Calculate values and write them into the sample buffer
179   - for(unsigned long int realPosition = 0; realPosition < this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.count; ++realPosition) {
  179 + for(unsigned int realPosition = 0; realPosition < this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.count; ++realPosition) {
180 180 switch(this->settings->scope.voltage[this->settings->scope.physicalChannels].misc) {
181 181 case Dso::MATHMODE_1ADD2:
182 182 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() {
223 223 this->window = (double *) fftw_malloc(sizeof(double) * this->lastRecordLength);
224 224 }
225 225  
226   - unsigned long int windowEnd = this->lastRecordLength - 1;
  226 + unsigned int windowEnd = this->lastRecordLength - 1;
227 227 this->lastWindow = this->settings->scope.spectrumWindow;
228 228  
229 229 switch(this->settings->scope.spectrumWindow) {
230 230 case Dso::WINDOW_HAMMING:
231   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  231 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
232 232 *(this->window + windowPosition) = 0.54 - 0.46 * cos(2.0 * M_PI * windowPosition / windowEnd);
233 233 break;
234 234 case Dso::WINDOW_HANN:
235   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  235 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
236 236 *(this->window + windowPosition) = 0.5 * (1.0 - cos(2.0 * M_PI * windowPosition / windowEnd));
237 237 break;
238 238 case Dso::WINDOW_COSINE:
239   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  239 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
240 240 *(this->window + windowPosition) = sin(M_PI * windowPosition / windowEnd);
241 241 break;
242 242 case Dso::WINDOW_LANCZOS:
243   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) {
  243 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) {
244 244 double sincParameter = (2.0 * windowPosition / windowEnd - 1.0) * M_PI;
245 245 if(sincParameter == 0)
246 246 *(this->window + windowPosition) = 1;
... ... @@ -249,55 +249,55 @@ void DataAnalyzer::run() {
249 249 }
250 250 break;
251 251 case Dso::WINDOW_BARTLETT:
252   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  252 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
253 253 *(this->window + windowPosition) = 2.0 / windowEnd * (windowEnd / 2 - abs(windowPosition - windowEnd / 2));
254 254 break;
255 255 case Dso::WINDOW_TRIANGULAR:
256   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  256 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
257 257 *(this->window + windowPosition) = 2.0 / this->lastRecordLength * (this->lastRecordLength / 2 - abs(windowPosition - windowEnd / 2));
258 258 break;
259 259 case Dso::WINDOW_GAUSS:
260 260 {
261 261 double sigma = 0.4;
262   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  262 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
263 263 *(this->window + windowPosition) = exp(-0.5 * pow(((windowPosition - windowEnd / 2) / (sigma * windowEnd / 2)), 2));
264 264 }
265 265 break;
266 266 case Dso::WINDOW_BARTLETTHANN:
267   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  267 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
268 268 *(this->window + windowPosition) = 0.62 - 0.48 * abs(windowPosition / windowEnd - 0.5) - 0.38 * cos(2.0 * M_PI * windowPosition / windowEnd);
269 269 break;
270 270 case Dso::WINDOW_BLACKMAN:
271 271 {
272 272 double alpha = 0.16;
273   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  273 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
274 274 *(this->window + windowPosition) = (1 - alpha) / 2 - 0.5 * cos(2.0 * M_PI * windowPosition / windowEnd) + alpha / 2 * cos(4.0 * M_PI * windowPosition / windowEnd);
275 275 }
276 276 break;
277 277 //case WINDOW_KAISER:
278 278 // TODO
279 279 //double alpha = 3.0;
280   - //for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  280 + //for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
281 281 //*(this->window + windowPosition) = ;
282 282 //break;
283 283 case Dso::WINDOW_NUTTALL:
284   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  284 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
285 285 *(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);
286 286 break;
287 287 case Dso::WINDOW_BLACKMANHARRIS:
288   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  288 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
289 289 *(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);
290 290 break;
291 291 case Dso::WINDOW_BLACKMANNUTTALL:
292   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  292 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
293 293 *(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);
294 294 break;
295 295 case Dso::WINDOW_FLATTOP:
296   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  296 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
297 297 *(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);
298 298 break;
299 299 default: // Dso::WINDOW_RECTANGULAR
300   - for(unsigned long int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
  300 + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition)
301 301 *(this->window + windowPosition) = 1.0;
302 302 }
303 303 }
... ... @@ -306,7 +306,7 @@ void DataAnalyzer::run() {
306 306 channelData->samples.spectrum.interval = 1.0 / channelData->samples.voltage.interval / channelData->samples.voltage.count;
307 307  
308 308 // Number of real/complex samples
309   - unsigned long int dftLength = channelData->samples.voltage.count / 2;
  309 + unsigned int dftLength = channelData->samples.voltage.count / 2;
310 310  
311 311 // Reallocate memory for samples if the sample count has changed
312 312 if(channelData->samples.spectrum.count != dftLength) {
... ... @@ -318,7 +318,7 @@ void DataAnalyzer::run() {
318 318  
319 319 // Create sample buffer and apply window
320 320 double *windowedValues = new double[channelData->samples.voltage.count];
321   - for(unsigned long int position = 0; position < channelData->samples.voltage.count; ++position)
  321 + for(unsigned int position = 0; position < channelData->samples.voltage.count; ++position)
322 322 windowedValues[position] = this->window[position] * channelData->samples.voltage.sample[position];
323 323  
324 324 // Do discrete real to half-complex transformation
... ... @@ -332,7 +332,7 @@ void DataAnalyzer::run() {
332 332 double *conjugateComplex = windowedValues; // Reuse the windowedValues buffer
333 333  
334 334 // Real values
335   - unsigned long int position;
  335 + unsigned int position;
336 336 double correctionFactor = 1.0 / dftLength / dftLength;
337 337 conjugateComplex[0] = (channelData->samples.spectrum.sample[0] * channelData->samples.spectrum.sample[0]) * correctionFactor;
338 338 for(position = 1; position < dftLength; ++position)
... ... @@ -353,7 +353,7 @@ void DataAnalyzer::run() {
353 353 double minimalVoltage, maximalVoltage;
354 354 minimalVoltage = maximalVoltage = channelData->samples.voltage.sample[0];
355 355  
356   - for(unsigned long int position = 1; position < channelData->samples.voltage.count; ++position) {
  356 + for(unsigned int position = 1; position < channelData->samples.voltage.count; ++position) {
357 357 if(channelData->samples.voltage.sample[position] < minimalVoltage)
358 358 minimalVoltage = channelData->samples.voltage.sample[position];
359 359 else if(channelData->samples.voltage.sample[position] > maximalVoltage)
... ... @@ -365,9 +365,9 @@ void DataAnalyzer::run() {
365 365 // Get the frequency from the correlation results
366 366 double minimumCorrelation = correlation[0];
367 367 double peakCorrelation = 0;
368   - unsigned long int peakPosition = 0;
  368 + unsigned int peakPosition = 0;
369 369  
370   - for(unsigned long int position = 1; position < channelData->samples.voltage.count / 2; ++position) {
  370 + for(unsigned int position = 1; position < channelData->samples.voltage.count / 2; ++position) {
371 371 if(correlation[position] > peakCorrelation && correlation[position] > minimumCorrelation * 2) {
372 372 peakCorrelation = correlation[position];
373 373 peakPosition = position;
... ... @@ -388,7 +388,7 @@ void DataAnalyzer::run() {
388 388 // Convert values into dB (Relative to the reference level)
389 389 double offset = 60 - this->settings->scope.spectrumReference - 20 * log10(dftLength);
390 390 double offsetLimit = this->settings->scope.spectrumLimit - this->settings->scope.spectrumReference;
391   - for(unsigned long int position = 0; position < channelData->samples.spectrum.count; ++position) {
  391 + for(unsigned int position = 0; position < channelData->samples.spectrum.count; ++position) {
392 392 channelData->samples.spectrum.sample[position] = 20 * log10(fabs(channelData->samples.spectrum.sample[position])) + offset;
393 393  
394 394 // Check if this value has to be limited
... ... @@ -417,7 +417,7 @@ void DataAnalyzer::run() {
417 417 /// \param size The sizes of the data arrays.
418 418 /// \param samplerate The samplerate for all input data.
419 419 /// \param mutex The mutex for all input data.
420   -void DataAnalyzer::analyze(const QList<double *> *data, const QList<unsigned long int> *size, double samplerate, QMutex *mutex) {
  420 +void DataAnalyzer::analyze(const QList<double *> *data, const QList<unsigned int> *size, double samplerate, QMutex *mutex) {
421 421 // Previous analysis still running, drop the new data
422 422 if(this->isRunning())
423 423 return;
... ...
openhantek/src/dataanalyzer.h
... ... @@ -78,7 +78,7 @@ class DataAnalyzer : public QThread {
78 78 ~DataAnalyzer();
79 79  
80 80 const AnalyzedData *data(int channel) const;
81   - unsigned long int sampleCount();
  81 + unsigned int sampleCount();
82 82 QMutex *mutex() const;
83 83  
84 84 protected:
... ... @@ -89,18 +89,18 @@ class DataAnalyzer : public QThread {
89 89 QList<AnalyzedData *> analyzedData; ///< The analyzed data for each channel
90 90 QMutex *analyzedDataMutex; ///< A mutex for the analyzed data of all channels
91 91  
92   - unsigned long int lastRecordLength; ///< The record length of the previously analyzed data
93   - unsigned long int maxSamples; ///< The maximum record length of the analyzed data
  92 + unsigned int lastRecordLength; ///< The record length of the previously analyzed data
  93 + unsigned int maxSamples; ///< The maximum record length of the analyzed data
94 94 Dso::WindowFunction lastWindow; ///< The previously used dft window function
95 95 double *window; ///< The array for the dft window factors
96 96  
97 97 QList<double *> waitingData; ///< Pointer to input data from device
98   - QList<unsigned long int> waitingDataSize; ///< Number of input data samples
  98 + QList<unsigned int> waitingDataSize; ///< Number of input data samples
99 99 double waitingDataSamplerate; ///< The samplerate of the input data
100 100 QMutex *waitingDataMutex; ///< A mutex for the input data
101 101  
102 102 public slots:
103   - void analyze(const QList<double *> *data, const QList<unsigned long int> *size, double samplerate, QMutex *mutex);
  103 + void analyze(const QList<double *> *data, const QList<unsigned int> *size, double samplerate, QMutex *mutex);
104 104  
105 105 signals:
106 106 void analyzed(unsigned long samples); ///< The data with that much samples has been analyzed
... ...
openhantek/src/dockwindows.cpp
... ... @@ -147,8 +147,8 @@ void HorizontalDock::setTimebase(double timebase) {
147 147  
148 148 /// \brief Changes the record length if the new value is supported.
149 149 /// \param recordLength The record length in samples.
150   -void HorizontalDock::setRecordLength(unsigned long int recordLength) {
151   - int index = this->recordLengthComboBox->findData((uint) recordLength); // QVariant doesn't take unsigned long int, doesn't matter for 32 bit platforms at least
  150 +void HorizontalDock::setRecordLength(unsigned int recordLength) {
  151 + int index = this->recordLengthComboBox->findData(recordLength);
152 152  
153 153 if(index != -1) {
154 154 this->suppressSignals = true;
... ... @@ -173,7 +173,7 @@ int HorizontalDock::setFormat(Dso::GraphFormat format) {
173 173  
174 174 /// \brief Updates the available record lengths in the combo box.
175 175 /// \param recordLengths The available record lengths for the combo box.
176   -void HorizontalDock::availableRecordLengthsChanged(const QList<unsigned long int> &recordLengths) {
  176 +void HorizontalDock::availableRecordLengthsChanged(const QList<unsigned int> &recordLengths) {
177 177 /// \todo Empty lists should be interpreted as scope supporting continuous record length values.
178 178 this->recordLengthComboBox->blockSignals(true); // Avoid messing up the settings
179 179 this->recordLengthComboBox->setUpdatesEnabled(false);
... ... @@ -181,13 +181,13 @@ void HorizontalDock::availableRecordLengthsChanged(const QList&lt;unsigned long int
181 181 // Update existing elements to avoid unnecessary index updates
182 182 int index = 0;
183 183 for(; index < recordLengths.size(); ++index) {
184   - unsigned long int recordLengthItem = recordLengths[index];
  184 + unsigned int recordLengthItem = recordLengths[index];
185 185 if(index < this->recordLengthComboBox->count()) {
186   - this->recordLengthComboBox->setItemData(index, (unsigned int) recordLengthItem);
187   - this->recordLengthComboBox->setItemText(index, recordLengthItem == ULONG_MAX ? tr("Roll") : Helper::valueToString(recordLengthItem, Helper::UNIT_SAMPLES, 3));
  186 + this->recordLengthComboBox->setItemData(index, recordLengthItem);
  187 + this->recordLengthComboBox->setItemText(index, recordLengthItem == UINT_MAX ? tr("Roll") : Helper::valueToString(recordLengthItem, Helper::UNIT_SAMPLES, 3));
188 188 }
189 189 else {
190   - this->recordLengthComboBox->addItem(recordLengthItem == ULONG_MAX ? tr("Roll") : Helper::valueToString(recordLengthItem, Helper::UNIT_SAMPLES, 3), (uint) recordLengthItem);
  190 + this->recordLengthComboBox->addItem(recordLengthItem == UINT_MAX ? tr("Roll") : Helper::valueToString(recordLengthItem, Helper::UNIT_SAMPLES, 3), (uint) recordLengthItem);
191 191 }
192 192 }
193 193 // Remove extra elements
... ...
openhantek/src/dockwindows.h
... ... @@ -56,7 +56,7 @@ class HorizontalDock : public QDockWidget {
56 56 void setFrequencybase(double timebase);
57 57 void setSamplerate(double samplerate);
58 58 void setTimebase(double timebase);
59   - void setRecordLength(unsigned long int recordLength);
  59 + void setRecordLength(unsigned int recordLength);
60 60 int setFormat(Dso::GraphFormat format);
61 61  
62 62 protected:
... ... @@ -82,7 +82,7 @@ class HorizontalDock : public QDockWidget {
82 82 bool suppressSignals; ///< Disable changed-signals temporarily
83 83  
84 84 public slots:
85   - void availableRecordLengthsChanged(const QList<unsigned long int> &recordLengths);
  85 + void availableRecordLengthsChanged(const QList<unsigned int> &recordLengths);
86 86 void samplerateLimitsChanged(double minimum, double maximum);
87 87  
88 88 protected slots:
... ...
openhantek/src/dsocontrol.h
... ... @@ -47,7 +47,7 @@ class DsoControl : public QThread {
47 47 DsoControl(QObject *parent = 0);
48 48  
49 49 virtual unsigned int getChannelCount() = 0; ///< Get the number of channels for this oscilloscope
50   - virtual QList<unsigned long int> *getAvailableRecordLengths() = 0; ///< Get available record lengths, empty list for continuous
  50 + virtual QList<unsigned int> *getAvailableRecordLengths() = 0; ///< Get available record lengths, empty list for continuous
51 51 virtual double getMinSamplerate() = 0; ///< The minimum samplerate supported
52 52 virtual double getMaxSamplerate() = 0; ///< The maximum samplerate supported
53 53  
... ... @@ -65,12 +65,12 @@ class DsoControl : public QThread {
65 65 void samplingStarted(); ///< The oscilloscope started sampling/waiting for trigger
66 66 void samplingStopped(); ///< The oscilloscope stopped sampling/waiting for trigger
67 67 void statusMessage(const QString &message, int timeout); ///< Status message about the oscilloscope
68   - void samplesAvailable(const QList<double *> *data, const QList<unsigned long int> *size, double samplerate, QMutex *mutex); ///< New sample data is available
  68 + void samplesAvailable(const QList<double *> *data, const QList<unsigned int> *size, double samplerate, QMutex *mutex); ///< New sample data is available
69 69  
70 70 void recordLengthChanged(unsigned long duration); ///< The record length has changed
71 71 void recordTimeChanged(double duration); ///< The record time duration has changed
72 72 void samplerateChanged(double samplerate); ///< The samplerate has changed
73   - void availableRecordLengthsChanged(const QList<unsigned long int> &recordLengths); ///< The available record lengths, empty list for continuous
  73 + void availableRecordLengthsChanged(const QList<unsigned int> &recordLengths); ///< The available record lengths, empty list for continuous
74 74 void samplerateLimitsChanged(double minimum, double maximum); ///< The minimum or maximum samplerate has changed
75 75  
76 76 public slots:
... ... @@ -80,7 +80,7 @@ class DsoControl : public QThread {
80 80 virtual void startSampling();
81 81 virtual void stopSampling();
82 82  
83   - virtual unsigned long int setRecordLength(unsigned long int size) = 0; ///< Set record length id, minimum for continuous
  83 + virtual unsigned int setRecordLength(unsigned int size) = 0; ///< Set record length id, minimum for continuous
84 84 virtual double setSamplerate(double samplerate) = 0; ///< Set the samplerate that should be met
85 85 virtual double setRecordTime(double duration) = 0; ///< Set the record time duration that should be met
86 86  
... ...
openhantek/src/glgenerator.cpp
... ... @@ -48,14 +48,14 @@ GlArray::~GlArray() {
48 48  
49 49 /// \brief Get the size of the array.
50 50 /// \return Number of array elements.
51   -unsigned long int GlArray::getSize() {
  51 +unsigned int GlArray::getSize() {
52 52 return this->size;
53 53 }
54 54  
55 55 /// \brief Set the size of the array.
56 56 /// Previous array contents are lost.
57 57 /// \param size New number of array elements.
58   -void GlArray::setSize(unsigned long int size) {
  58 +void GlArray::setSize(unsigned int size) {
59 59 if(this->size == size)
60 60 return;
61 61  
... ...
openhantek/src/glgenerator.h
... ... @@ -55,13 +55,13 @@ class GlArray {
55 55 GlArray();
56 56 ~GlArray();
57 57  
58   - unsigned long int getSize();
59   - void setSize(unsigned long int size);
  58 + unsigned int getSize();
  59 + void setSize(unsigned int size);
60 60  
61 61 GLfloat *data; ///< Pointer to the array
62 62  
63 63 protected:
64   - unsigned long int size; ///< The array size (Number of GLfloat values)
  64 + unsigned int size; ///< The array size (Number of GLfloat values)
65 65 };
66 66  
67 67 ////////////////////////////////////////////////////////////////////////////////
... ...
openhantek/src/hantek/control.cpp
... ... @@ -139,7 +139,7 @@ namespace Hantek {
139 139  
140 140 /// \brief Get available record lengths for this oscilloscope.
141 141 /// \return The number of physical channels, empty list for continuous.
142   - QList<unsigned long int> *Control::getAvailableRecordLengths() {
  142 + QList<unsigned int> *Control::getAvailableRecordLengths() {
143 143 return &this->settings.samplerate.limits->recordLengths;
144 144 }
145 145  
... ... @@ -216,7 +216,11 @@ namespace Hantek {
216 216  
217 217 // Check the current oscilloscope state everytime 25% of the time the buffer should be refilled
218 218 // Not more often than every 10 ms though
219   - int cycleTime = qMax((unsigned long int) (this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), 10lu);
  219 + int cycleTime;
  220 + if(this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] == UINT_MAX)
  221 + cycleTime = qMax((int) ((double) this->device->getPacketSize() / this->settings.samplerate.current * 250), 1);
  222 + else
  223 + cycleTime = qMax((unsigned int) ((double) this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), 10u);
220 224 this->msleep(cycleTime);
221 225  
222 226 if(!this->sampling) {
... ... @@ -260,10 +264,7 @@ namespace Hantek {
260 264  
261 265 case CAPTURE_WAITING:
262 266 // Sampling hasn't started, update the expected sample count
263   - if(this->settings.samplerate.limits == &this->specification.samplerate.multi)
264   - this->previousSampleCount = this->specification.samplerate.multi.recordLengths[this->settings.recordLengthId];
265   - else
266   - this->previousSampleCount = this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] * HANTEK_CHANNELS;
  267 + this->previousSampleCount = this->getSampleCount();
267 268  
268 269 if(samplingStarted && lastTriggerMode == this->settings.trigger.mode) {
269 270 ++cycleCounter;
... ... @@ -325,11 +326,11 @@ namespace Hantek {
325 326 /// \brief Calculates the trigger point from the CommandGetCaptureState data.
326 327 /// \param value The data value that contains the trigger point.
327 328 /// \return The calculated trigger point for the given data.
328   - unsigned long int Control::calculateTriggerPoint(unsigned long int value) {
329   - unsigned long int result = value;
  329 + unsigned int Control::calculateTriggerPoint(unsigned int value) {
  330 + unsigned int result = value;
330 331  
331 332 // Each set bit inverts all bits with a lower value
332   - for(unsigned long int bitValue = 1; bitValue; bitValue <<= 1)
  333 + for(unsigned int bitValue = 1; bitValue; bitValue <<= 1)
333 334 if(result & bitValue)
334 335 result ^= bitValue - 1;
335 336  
... ... @@ -366,13 +367,14 @@ namespace Hantek {
366 367 return errorCode;
367 368  
368 369 // Save raw data to temporary buffer
369   - bool fastRate = this->settings.samplerate.limits == &this->specification.samplerate.multi;
370   -
371   - unsigned long int totalSampleCount = fastRate ? this->specification.samplerate.multi.recordLengths[this->settings.recordLengthId] : this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] * HANTEK_CHANNELS;
  370 + bool fastRate = false;
  371 + unsigned int totalSampleCount = this->getSampleCount(&fastRate);
  372 + if(totalSampleCount == UINT_MAX)
  373 + return LIBUSB_ERROR_INVALID_PARAM;
372 374  
373 375 // To make sure no samples will remain in the scope buffer, also check the sample count before the last sampling started
374 376 if(totalSampleCount < this->previousSampleCount) {
375   - unsigned long int currentSampleCount = totalSampleCount;
  377 + unsigned int currentSampleCount = totalSampleCount;
376 378 totalSampleCount = this->previousSampleCount;
377 379 this->previousSampleCount = currentSampleCount; // Using sampleCount as temporary buffer since it was set to totalSampleCount
378 380 }
... ... @@ -380,10 +382,10 @@ namespace Hantek {
380 382 this->previousSampleCount = totalSampleCount;
381 383 }
382 384  
383   - unsigned long int sampleCount = totalSampleCount;
  385 + unsigned int sampleCount = totalSampleCount;
384 386 if(!fastRate)
385 387 sampleCount /= HANTEK_CHANNELS;
386   - unsigned long int dataLength = totalSampleCount;
  388 + unsigned int dataLength = totalSampleCount;
387 389 if(this->specification.sampleSize > 8)
388 390 dataLength *= 2;
389 391  
... ... @@ -431,14 +433,14 @@ namespace Hantek {
431 433 }
432 434  
433 435 // Convert data from the oscilloscope and write it into the sample buffer
434   - unsigned long int bufferPosition = this->settings.trigger.point * 2;
  436 + unsigned int bufferPosition = this->settings.trigger.point * 2;
435 437 if(this->specification.sampleSize > 8) {
436 438 // Additional most significant bits after the normal data
437 439 unsigned int extraBitsPosition; // Track the position of the extra bits in the additional byte
438 440 unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits
439 441 unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction
440 442  
441   - for(unsigned long int realPosition = 0; realPosition < sampleCount; ++realPosition, ++bufferPosition) {
  443 + for(unsigned int realPosition = 0; realPosition < sampleCount; ++realPosition, ++bufferPosition) {
442 444 if(bufferPosition >= sampleCount)
443 445 bufferPosition %= sampleCount;
444 446  
... ... @@ -448,7 +450,7 @@ namespace Hantek {
448 450 }
449 451 }
450 452 else {
451   - for(unsigned long int realPosition = 0; realPosition < sampleCount; ++realPosition, ++bufferPosition) {
  453 + for(unsigned int realPosition = 0; realPosition < sampleCount; ++realPosition, ++bufferPosition) {
452 454 if(bufferPosition >= sampleCount)
453 455 bufferPosition %= sampleCount;
454 456  
... ... @@ -471,14 +473,14 @@ namespace Hantek {
471 473 }
472 474  
473 475 // Convert data from the oscilloscope and write it into the sample buffer
474   - unsigned long int bufferPosition = this->settings.trigger.point * 2;
  476 + unsigned int bufferPosition = this->settings.trigger.point * 2;
475 477 if(this->specification.sampleSize > 8) {
476 478 // Additional most significant bits after the normal data
477 479 unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits
478 480 unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction
479 481 unsigned int extraBitsIndex = 8 - channel * 2; // Bit position offset for extra bits extraction
480 482  
481   - for(unsigned long int realPosition = 0; realPosition < sampleCount; ++realPosition, bufferPosition += HANTEK_CHANNELS) {
  483 + for(unsigned int realPosition = 0; realPosition < sampleCount; ++realPosition, bufferPosition += HANTEK_CHANNELS) {
482 484 if(bufferPosition >= totalSampleCount)
483 485 bufferPosition %= totalSampleCount;
484 486  
... ... @@ -487,7 +489,7 @@ namespace Hantek {
487 489 }
488 490 else {
489 491 bufferPosition += HANTEK_CHANNELS - 1 - channel;
490   - for(unsigned long int realPosition = 0; realPosition < sampleCount; ++realPosition, bufferPosition += HANTEK_CHANNELS) {
  492 + for(unsigned int realPosition = 0; realPosition < sampleCount; ++realPosition, bufferPosition += HANTEK_CHANNELS) {
491 493 if(bufferPosition >= totalSampleCount)
492 494 bufferPosition %= totalSampleCount;
493 495  
... ... @@ -517,7 +519,7 @@ namespace Hantek {
517 519 /// \param maximum The target samplerate is the maximum allowed when true, the minimum otherwise.
518 520 /// \param downsampler Pointer to where the selected downsampling factor should be written.
519 521 /// \return The nearest samplerate supported, 0.0 on error.
520   - double Control::getBestSamplerate(double samplerate, bool fastRate, bool maximum, unsigned long int *downsampler) {
  522 + double Control::getBestSamplerate(double samplerate, bool fastRate, bool maximum, unsigned int *downsampler) {
521 523 // Abort if the input value is invalid
522 524 if(samplerate <= 0.0)
523 525 return 0.0;
... ... @@ -602,15 +604,39 @@ namespace Hantek {
602 604 }
603 605  
604 606 if(downsampler)
605   - *downsampler = (unsigned long int) bestDownsampler;
  607 + *downsampler = (unsigned int) bestDownsampler;
606 608 return bestSamplerate;
607 609 }
608 610  
  611 + /// \brief Get the count of samples that are expected returned by the scope.
  612 + /// \param fastRate Is set to the state of the fast rate mode when provided.
  613 + /// \return The total number of samples the scope should return.
  614 + unsigned int Control::getSampleCount(bool *fastRate) {
  615 + unsigned int totalSampleCount = this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId];
  616 + bool fastRateEnabled = this->settings.samplerate.limits == &this->specification.samplerate.multi;
  617 +
  618 + if(totalSampleCount == UINT_MAX) {
  619 + // Roll mode
  620 + const int packetSize = this->device->getPacketSize();
  621 + if(packetSize < 0)
  622 + totalSampleCount = UINT_MAX;
  623 + else
  624 + totalSampleCount = packetSize;
  625 + }
  626 + else {
  627 + if(!fastRateEnabled)
  628 + totalSampleCount *= HANTEK_CHANNELS;
  629 + }
  630 + if(fastRate)
  631 + *fastRate = fastRateEnabled;
  632 + return totalSampleCount;
  633 + }
  634 +
609 635 /// \brief Sets the size of the sample buffer without updating dependencies.
610 636 /// \param index The record length index that should be set.
611 637 /// \return The record length that has been set, 0 on error.
612   - unsigned long int Control::updateRecordLength(unsigned long int index) {
613   - if(index >= (unsigned long int) this->settings.samplerate.limits->recordLengths.size())
  638 + unsigned int Control::updateRecordLength(unsigned int index) {
  639 + if(index >= (unsigned int) this->settings.samplerate.limits->recordLengths.size())
614 640 return 0;
615 641  
616 642 switch(this->specification.command.bulk.setRecordLength) {
... ... @@ -654,7 +680,10 @@ namespace Hantek {
654 680 /// \param downsampler The downsampling factor.
655 681 /// \param fastRate true, if one channel uses all buffers.
656 682 /// \return The downsampling factor that has been set.
657   - unsigned long int Control::updateSamplerate(unsigned long int downsampler, bool fastRate) {
  683 + unsigned int Control::updateSamplerate(unsigned int downsampler, bool fastRate) {
  684 + // Get samplerate limits
  685 + Hantek::ControlSamplerateLimits *limits = fastRate ? &this->specification.samplerate.multi : &this->specification.samplerate.single;
  686 +
658 687 // Set the calculated samplerate
659 688 switch(this->specification.command.bulk.setSamplerate) {
660 689 case BULK_SETTRIGGERANDSAMPLERATE: {
... ... @@ -664,7 +693,7 @@ namespace Hantek {
664 693  
665 694 if(downsampler <= 5) {
666 695 // All dividers up to 5 are done using the special samplerate IDs
667   - if(downsampler == 0)
  696 + if(downsampler == 0 && limits->base >= limits->max)
668 697 samplerateId = 1;
669 698 else if(downsampler <= 2)
670 699 samplerateId = downsampler;
... ... @@ -737,16 +766,13 @@ namespace Hantek {
737 766 break;
738 767 }
739 768 default:
740   - return ULONG_MAX;
  769 + return UINT_MAX;
741 770 }
742 771  
743 772 // Update settings
744 773 bool fastRateChanged = fastRate != (this->settings.samplerate.limits == &this->specification.samplerate.multi);
745 774 if(fastRateChanged) {
746   - if(fastRate)
747   - this->settings.samplerate.limits = &this->specification.samplerate.multi;
748   - else
749   - this->settings.samplerate.limits = &this->specification.samplerate.single;
  775 + this->settings.samplerate.limits = limits;
750 776 }
751 777  
752 778 this->settings.samplerate.downsampler = downsampler;
... ... @@ -763,8 +789,12 @@ namespace Hantek {
763 789 emit availableRecordLengthsChanged(this->settings.samplerate.limits->recordLengths);
764 790 emit recordLengthChanged(this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId]);
765 791 }
766   - emit recordTimeChanged((double) this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current);
767   - emit samplerateChanged(this->settings.samplerate.current);
  792 +
  793 + // Check for Roll mode
  794 + if(this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] != UINT_MAX) {
  795 + emit recordTimeChanged((double) this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current);
  796 + emit samplerateChanged(this->settings.samplerate.current);
  797 + }
768 798  
769 799 return downsampler;
770 800 }
... ... @@ -896,11 +926,11 @@ namespace Hantek {
896 926 this->specification.samplerate.single.base = 100e6;
897 927 this->specification.samplerate.single.max = 125e6;
898 928 this->specification.samplerate.single.maxDownsampler = 131072;
899   - this->specification.samplerate.single.recordLengths << ULONG_MAX << 10240 << 14336;
  929 + this->specification.samplerate.single.recordLengths << UINT_MAX << 10240 << 14336;
900 930 this->specification.samplerate.multi.base = 200e6;
901 931 this->specification.samplerate.multi.max = 250e6;
902 932 this->specification.samplerate.multi.maxDownsampler = 131072;
903   - this->specification.samplerate.multi.recordLengths << ULONG_MAX << 20480 << 28672;
  933 + this->specification.samplerate.multi.recordLengths << UINT_MAX << 20480 << 28672;
904 934 this->specification.bufferDividers << 1000 << 1 << 1;
905 935 this->specification.gainSteps
906 936 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0;
... ... @@ -917,11 +947,11 @@ namespace Hantek {
917 947 this->specification.samplerate.single.base = 100e6;
918 948 this->specification.samplerate.single.max = 100e6;
919 949 this->specification.samplerate.single.maxDownsampler = 65536;
920   - this->specification.samplerate.single.recordLengths << ULONG_MAX << 10240 << 524288;
  950 + this->specification.samplerate.single.recordLengths << UINT_MAX << 10240 << 524288;
921 951 this->specification.samplerate.multi.base = 200e6;
922 952 this->specification.samplerate.multi.max = 250e6;
923 953 this->specification.samplerate.multi.maxDownsampler = 65536;
924   - this->specification.samplerate.multi.recordLengths << ULONG_MAX << 20480 << 1048576;
  954 + this->specification.samplerate.multi.recordLengths << UINT_MAX << 20480 << 1048576;
925 955 this->specification.bufferDividers << 1000 << 1 << 1;
926 956 this->specification.gainSteps
927 957 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0;
... ... @@ -937,11 +967,11 @@ namespace Hantek {
937 967 this->specification.samplerate.single.base = 50e6;
938 968 this->specification.samplerate.single.max = 75e6;
939 969 this->specification.samplerate.single.maxDownsampler = 131072;
940   - this->specification.samplerate.single.recordLengths << ULONG_MAX << 10240 << 32768;
  970 + this->specification.samplerate.single.recordLengths << UINT_MAX << 10240 << 32768;
941 971 this->specification.samplerate.multi.base = 100e6;
942 972 this->specification.samplerate.multi.max = 150e6;
943 973 this->specification.samplerate.multi.maxDownsampler = 131072;
944   - this->specification.samplerate.multi.recordLengths << ULONG_MAX << 20480 << 65536;
  974 + this->specification.samplerate.multi.recordLengths << UINT_MAX << 20480 << 65536;
945 975 this->specification.bufferDividers << 1000 << 1 << 1;
946 976 this->specification.gainSteps
947 977 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0;
... ... @@ -957,11 +987,11 @@ namespace Hantek {
957 987 this->specification.samplerate.single.base = 50e6;
958 988 this->specification.samplerate.single.max = 50e6;
959 989 this->specification.samplerate.single.maxDownsampler = 131072;
960   - this->specification.samplerate.single.recordLengths << ULONG_MAX << 10240 << 32768;
  990 + this->specification.samplerate.single.recordLengths << UINT_MAX << 10240 << 32768;
961 991 this->specification.samplerate.multi.base = 100e6;
962 992 this->specification.samplerate.multi.max = 100e6;
963 993 this->specification.samplerate.multi.maxDownsampler = 131072;
964   - this->specification.samplerate.multi.recordLengths << ULONG_MAX << 20480 << 65536;
  994 + this->specification.samplerate.multi.recordLengths << UINT_MAX << 20480 << 65536;
965 995 this->specification.bufferDividers << 1000 << 1 << 1;
966 996 this->specification.gainSteps
967 997 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0;
... ... @@ -992,7 +1022,7 @@ namespace Hantek {
992 1022 /// \brief Sets the size of the oscilloscopes sample buffer.
993 1023 /// \param index The record length index that should be set.
994 1024 /// \return The record length that has been set, 0 on error.
995   - unsigned long int Control::setRecordLength(unsigned long int index) {
  1025 + unsigned int Control::setRecordLength(unsigned int index) {
996 1026 if(!this->device->isConnected())
997 1027 return 0;
998 1028  
... ... @@ -1022,11 +1052,11 @@ namespace Hantek {
1022 1052 bool fastRate = (this->settings.usedChannels <= 1) && (samplerate > this->specification.samplerate.single.max);
1023 1053  
1024 1054 // What is the nearest, at least as high samplerate the scope can provide?
1025   - unsigned long int downsampler = 0;
  1055 + unsigned int downsampler = 0;
1026 1056 double bestSamplerate = getBestSamplerate(samplerate, fastRate, false, &(downsampler));
1027 1057  
1028 1058 // Set the calculated samplerate
1029   - if(this->updateSamplerate(downsampler, fastRate) == ULONG_MAX)
  1059 + if(this->updateSamplerate(downsampler, fastRate) == UINT_MAX)
1030 1060 return 0.0;
1031 1061 else {
1032 1062 return bestSamplerate;
... ... @@ -1052,11 +1082,11 @@ namespace Hantek {
1052 1082 bool fastRate = (this->settings.usedChannels <= 1) && (maxSamplerate >= this->specification.samplerate.multi.base);
1053 1083  
1054 1084 // What is the nearest, at most as high samplerate the scope can provide?
1055   - unsigned long int downsampler = 0;
  1085 + unsigned int downsampler = 0;
1056 1086 double bestSamplerate = getBestSamplerate(maxSamplerate, fastRate, true, &(downsampler));
1057 1087  
1058 1088 // Set the calculated samplerate
1059   - if(this->updateSamplerate(downsampler, fastRate) == ULONG_MAX)
  1089 + if(this->updateSamplerate(downsampler, fastRate) == UINT_MAX)
1060 1090 return 0.0;
1061 1091 else {
1062 1092 return (double) this->settings.samplerate.limits->recordLengths[this->settings.recordLengthId] / bestSamplerate;
... ... @@ -1375,7 +1405,7 @@ namespace Hantek {
1375 1405 return -2;
1376 1406  
1377 1407 // All trigger positions are measured in samples
1378   - unsigned long int positionSamples = position * this->settings.samplerate.current;
  1408 + unsigned int positionSamples = position * this->settings.samplerate.current;
1379 1409 // Fast rate mode uses both channels
1380 1410 if(this->settings.samplerate.limits == &this->specification.samplerate.multi)
1381 1411 positionSamples /= HANTEK_CHANNELS;
... ... @@ -1383,7 +1413,7 @@ namespace Hantek {
1383 1413 switch(this->specification.command.bulk.setPretrigger) {
1384 1414 case BULK_SETTRIGGERANDSAMPLERATE: {
1385 1415 // Calculate the position value (Start point depending on record length)
1386   - unsigned long int position = 0x7ffff - this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] + positionSamples;
  1416 + unsigned int position = 0x7ffff - this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] + positionSamples;
1387 1417  
1388 1418 // SetTriggerAndSamplerate bulk command for trigger position
1389 1419 static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position);
... ... @@ -1393,8 +1423,8 @@ namespace Hantek {
1393 1423 }
1394 1424 case BULK_FSETBUFFER: {
1395 1425 // Calculate the position values (Inverse, maximum is 0x7ffff)
1396   - unsigned long int positionPre = 0x7fffful - this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] + positionSamples;
1397   - unsigned long int positionPost = 0x7fffful - positionSamples;
  1426 + unsigned int positionPre = 0x7fffful - this->specification.samplerate.single.recordLengths[this->settings.recordLengthId] + positionSamples;
  1427 + unsigned int positionPost = 0x7fffful - positionSamples;
1398 1428  
1399 1429 // SetBuffer2250 bulk command for trigger position
1400 1430 BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(this->command[BULK_FSETBUFFER]);
... ...
openhantek/src/hantek/control.h
... ... @@ -93,10 +93,10 @@ namespace Hantek {
93 93 /// \struct ControlSamplerateLimits hantek/control.h
94 94 /// \brief Stores the samplerate limits for calculations.
95 95 struct ControlSamplerateLimits {
96   - unsigned long int base; ///< The base for sample rate calculations
97   - unsigned long int max; ///< The maximum sample rate
98   - unsigned long int maxDownsampler; ///< The maximum downsampling ratio
99   - QList<unsigned long int> recordLengths; ///< Available record lengths, ULONG_MAX means rolling
  96 + double base; ///< The base for sample rate calculations
  97 + double max; ///< The maximum sample rate
  98 + unsigned int maxDownsampler; ///< The maximum downsampling ratio
  99 + QList<unsigned int> recordLengths; ///< Available record lengths, UINT_MAX means rolling
100 100 };
101 101  
102 102 //////////////////////////////////////////////////////////////////////////////
... ... @@ -116,7 +116,7 @@ namespace Hantek {
116 116  
117 117 // Limits
118 118 ControlSpecificationSamplerate samplerate; ///< The samplerate specifications
119   - QList<unsigned long int> bufferDividers; ///< Samplerate dividers for record lengths
  119 + QList<unsigned int> bufferDividers; ///< Samplerate dividers for record lengths
120 120 QList<double> gainSteps; ///< Available voltage steps in V/screenheight
121 121 unsigned char sampleSize; ///< Number of bits per sample
122 122  
... ... @@ -144,7 +144,7 @@ namespace Hantek {
144 144 struct ControlSettingsSamplerate {
145 145 ControlSettingsSamplerateTarget target; ///< The target samplerate values
146 146 ControlSamplerateLimits *limits; ///< The samplerate limits
147   - unsigned long int downsampler; ///< The variable downsampling factor
  147 + unsigned int downsampler; ///< The variable downsampling factor
148 148 double current; ///< The current samplerate
149 149 };
150 150  
... ... @@ -193,19 +193,20 @@ namespace Hantek {
193 193 ~Control();
194 194  
195 195 unsigned int getChannelCount();
196   - QList<unsigned long int> *getAvailableRecordLengths();
  196 + QList<unsigned int> *getAvailableRecordLengths();
197 197 double getMinSamplerate();
198 198 double getMaxSamplerate();
199 199  
200 200 protected:
201 201 void run();
202 202  
203   - unsigned long int calculateTriggerPoint(unsigned long int value);
  203 + unsigned int calculateTriggerPoint(unsigned int value);
204 204 int getCaptureState();
205 205 int getSamples(bool process);
206   - double getBestSamplerate(double samplerate, bool fastRate = false, bool maximum = false, unsigned long int *downsampler = 0);
207   - unsigned long int updateRecordLength(unsigned long int size);
208   - unsigned long int updateSamplerate(unsigned long int downsampler, bool fastRate);
  206 + double getBestSamplerate(double samplerate, bool fastRate = false, bool maximum = false, unsigned int *downsampler = 0);
  207 + unsigned int getSampleCount(bool *fastRate = 0);
  208 + unsigned int updateRecordLength(unsigned int size);
  209 + unsigned int updateSamplerate(unsigned int downsampler, bool fastRate);
209 210 void restoreTargets();
210 211  
211 212 // Communication with device
... ... @@ -223,14 +224,14 @@ namespace Hantek {
223 224  
224 225 // Results
225 226 QList<double *> samples; ///< Sample data arrays
226   - QList<unsigned long int> samplesSize; ///< Number of samples data array
227   - unsigned long int previousSampleCount; ///< The expected total number of samples at the last check before sampling started
  227 + QList<unsigned int> samplesSize; ///< Number of samples data array
  228 + unsigned int previousSampleCount; ///< The expected total number of samples at the last check before sampling started
228 229 QMutex samplesMutex; ///< Mutex for the sample data
229 230  
230 231 public slots:
231 232 virtual void connectDevice();
232 233  
233   - unsigned long int setRecordLength(unsigned long int size);
  234 + unsigned int setRecordLength(unsigned int size);
234 235 double setSamplerate(double samplerate = 0.0);
235 236 double setRecordTime(double duration = 0.0);
236 237  
... ...
openhantek/src/hantek/device.cpp
... ... @@ -281,7 +281,7 @@ namespace Hantek {
281 281 /// \param attempts The number of attempts, that are done on timeouts.
282 282 /// \param timeout The timeout in ms.
283 283 /// \return Number of transferred bytes on success, libusb error code on error.
284   - int Device::bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned long int length, int attempts, unsigned int timeout) {
  284 + int Device::bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned int length, int attempts, unsigned int timeout) {
285 285 if(!this->handle)
286 286 return LIBUSB_ERROR_NO_DEVICE;
287 287  
... ... @@ -304,7 +304,7 @@ namespace Hantek {
304 304 /// \param length The length of the packet.
305 305 /// \param attempts The number of attempts, that are done on timeouts.
306 306 /// \return Number of sent bytes on success, libusb error code on error.
307   - int Device::bulkWrite(unsigned char *data, unsigned long int length, int attempts) {
  307 + int Device::bulkWrite(unsigned char *data, unsigned int length, int attempts) {
308 308 if(!this->handle)
309 309 return LIBUSB_ERROR_NO_DEVICE;
310 310  
... ... @@ -331,7 +331,7 @@ namespace Hantek {
331 331 /// \param length The length of the packet.
332 332 /// \param attempts The number of attempts, that are done on timeouts.
333 333 /// \return Number of received bytes on success, libusb error code on error.
334   - int Device::bulkRead(unsigned char *data, unsigned long int length, int attempts) {
  334 + int Device::bulkRead(unsigned char *data, unsigned int length, int attempts) {
335 335 if(!this->handle)
336 336 return LIBUSB_ERROR_NO_DEVICE;
337 337  
... ... @@ -375,7 +375,7 @@ namespace Hantek {
375 375 /// \param length The length of data contained in the packets.
376 376 /// \param attempts The number of attempts, that are done on timeouts.
377 377 /// \return Number of received bytes on success, libusb error code on error.
378   - int Device::bulkReadMulti(unsigned char *data, unsigned long int length, int attempts) {
  378 + int Device::bulkReadMulti(unsigned char *data, unsigned int length, int attempts) {
379 379 if(!this->handle)
380 380 return LIBUSB_ERROR_NO_DEVICE;
381 381  
... ... @@ -386,14 +386,14 @@ namespace Hantek {
386 386 return errorCode;
387 387  
388 388 errorCode = this->inPacketLength;
389   - unsigned long int packet, received = 0;
  389 + unsigned int packet, received = 0;
390 390 for(packet = 0; received < length && errorCode == this->inPacketLength; ++packet) {
391 391 #if LIBUSB_VERSION == 0
392 392 errorCode = LIBUSB_ERROR_TIMEOUT;
393 393 for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt)
394   - errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data + packet * this->inPacketLength, qMin(length - received, (unsigned long int) this->inPacketLength), HANTEK_TIMEOUT);
  394 + errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), HANTEK_TIMEOUT);
395 395 #else
396   - errorCode = this->bulkTransfer(HANTEK_EP_IN, data + packet * this->inPacketLength, qMin(length - received, (unsigned long int) this->inPacketLength), attempts, HANTEK_TIMEOUT_MULTI);
  396 + errorCode = this->bulkTransfer(HANTEK_EP_IN, data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), attempts, HANTEK_TIMEOUT_MULTI);
397 397 #endif
398 398 if(errorCode > 0)
399 399 received += errorCode;
... ... @@ -414,7 +414,7 @@ namespace Hantek {
414 414 /// \param index The index field of the packet.
415 415 /// \param attempts The number of attempts, that are done on timeouts.
416 416 /// \return Number of transferred bytes on success, libusb error code on error.
417   - int Device::controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned long int length, int value, int index, int attempts) {
  417 + int Device::controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts) {
418 418 if(!this->handle)
419 419 return LIBUSB_ERROR_NO_DEVICE;
420 420  
... ... @@ -439,7 +439,7 @@ namespace Hantek {
439 439 /// \param index The index field of the packet.
440 440 /// \param attempts The number of attempts, that are done on timeouts.
441 441 /// \return Number of sent bytes on success, libusb error code on error.
442   - int Device::controlWrite(unsigned char request, unsigned char *data, unsigned long int length, int value, int index, int attempts) {
  442 + int Device::controlWrite(unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts) {
443 443 if(!this->handle)
444 444 return LIBUSB_ERROR_NO_DEVICE;
445 445  
... ... @@ -454,7 +454,7 @@ namespace Hantek {
454 454 /// \param index The index field of the packet.
455 455 /// \param attempts The number of attempts, that are done on timeouts.
456 456 /// \return Number of received bytes on success, libusb error code on error.
457   - int Device::controlRead(unsigned char request, unsigned char *data, unsigned long int length, int value, int index, int attempts) {
  457 + int Device::controlRead(unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts) {
458 458 if(!this->handle)
459 459 return LIBUSB_ERROR_NO_DEVICE;
460 460  
... ... @@ -474,6 +474,22 @@ namespace Hantek {
474 474 return response.getSpeed();
475 475 }
476 476  
  477 + /// \brief Gets the maximum size of one packet transmitted via bulk transfer.
  478 + /// \return The maximum packet size in bytes, -1 on error.
  479 + int Device::getPacketSize() {
  480 + switch(this->getConnectionSpeed()) {
  481 + case CONNECTION_FULLSPEED:
  482 + return 64;
  483 + break;
  484 + case CONNECTION_HIGHSPEED:
  485 + return 512;
  486 + break;
  487 + default:
  488 + return -1;
  489 + break;
  490 + }
  491 + }
  492 +
477 493 /// \brief Get the oscilloscope model.
478 494 /// \return The ::Model of the connected Hantek DSO.
479 495 Model Device::getModel() {
... ...
openhantek/src/hantek/device.h
... ... @@ -60,19 +60,20 @@ namespace Hantek {
60 60  
61 61 // Various methods to handle USB transfers
62 62 #if LIBUSB_VERSION != 0
63   - int bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned long int length, int attempts = HANTEK_ATTEMPTS, unsigned int timeout = HANTEK_TIMEOUT);
  63 + int bulkTransfer(unsigned char endpoint, unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS, unsigned int timeout = HANTEK_TIMEOUT);
64 64 #endif
65   - int bulkWrite(unsigned char *data, unsigned long int length, int attempts = HANTEK_ATTEMPTS);
66   - int bulkRead(unsigned char *data, unsigned long int length, int attempts = HANTEK_ATTEMPTS);
  65 + int bulkWrite(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS);
  66 + int bulkRead(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS);
67 67  
68 68 int bulkCommand(Helper::DataArray<unsigned char> *command, int attempts = HANTEK_ATTEMPTS);
69   - int bulkReadMulti(unsigned char *data, unsigned long int length, int attempts = HANTEK_ATTEMPTS_MULTI);
  69 + int bulkReadMulti(unsigned char *data, unsigned int length, int attempts = HANTEK_ATTEMPTS_MULTI);
70 70  
71   - int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned long int length, int value, int index, int attempts = HANTEK_ATTEMPTS);
72   - int controlWrite(unsigned char request, unsigned char *data, unsigned long int length, int value = 0, int index = 0, int attempts = HANTEK_ATTEMPTS);
73   - int controlRead(unsigned char request, unsigned char *data, unsigned long int length, int value = 0, int index = 0, int attempts = HANTEK_ATTEMPTS);
  71 + int controlTransfer(unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts = HANTEK_ATTEMPTS);
  72 + int controlWrite(unsigned char request, unsigned char *data, unsigned int length, int value = 0, int index = 0, int attempts = HANTEK_ATTEMPTS);
  73 + int controlRead(unsigned char request, unsigned char *data, unsigned int length, int value = 0, int index = 0, int attempts = HANTEK_ATTEMPTS);
74 74  
75 75 int getConnectionSpeed();
  76 + int getPacketSize();
76 77 Model getModel();
77 78  
78 79 protected:
... ...
openhantek/src/hantek/types.cpp
... ... @@ -34,7 +34,7 @@ namespace Hantek {
34 34 //////////////////////////////////////////////////////////////////////////////
35 35 // class BulkSetFilter
36 36 /// \brief Sets the data array to the default values.
37   - BulkSetFilter::BulkSetFilter() : Helper::DataArray<unsigned char>(8) {
  37 + BulkSetFilter::BulkSetFilter() : Helper::DataArray<uint8_t>(8) {
38 38 this->init();
39 39 }
40 40  
... ... @@ -42,7 +42,7 @@ namespace Hantek {
42 42 /// \param channel1 true if channel 1 is filtered.
43 43 /// \param channel2 true if channel 2 is filtered.
44 44 /// \param trigger true if trigger is filtered.
45   - BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : Helper::DataArray<unsigned char>(8) {
  45 + BulkSetFilter::BulkSetFilter(bool channel1, bool channel2, bool trigger) : Helper::DataArray<uint8_t>(8) {
46 46 this->init();
47 47  
48 48 this->setChannel(0, channel1);
... ... @@ -96,7 +96,7 @@ namespace Hantek {
96 96 //////////////////////////////////////////////////////////////////////////////
97 97 // class BulkSetTriggerAndSamplerate
98 98 /// \brief Sets the data array to the default values.
99   - BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : Helper::DataArray<unsigned char>(12) {
  99 + BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate() : Helper::DataArray<uint8_t>(12) {
100 100 this->init();
101 101 }
102 102  
... ... @@ -110,7 +110,7 @@ namespace Hantek {
110 110 /// \param usedChannels The enabled channels (Tsr2).
111 111 /// \param fastRate The fastRate state (Tsr2).
112 112 /// \param triggerSlope The triggerSlope value (Tsr2).
113   - 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<unsigned char>(12) {
  113 + 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<uint8_t>(12) {
114 114 this->init();
115 115  
116 116 this->setTriggerSource(triggerSource);
... ... @@ -126,37 +126,37 @@ namespace Hantek {
126 126  
127 127 /// \brief Get the triggerSource value in Tsr1Bits.
128 128 /// \return The triggerSource value.
129   - unsigned char BulkSetTriggerAndSamplerate::getTriggerSource() {
  129 + uint8_t BulkSetTriggerAndSamplerate::getTriggerSource() {
130 130 return ((Tsr1Bits *) &(this->array[2]))->triggerSource;
131 131 }
132 132  
133 133 /// \brief Set the triggerSource in Tsr1Bits to the given value.
134 134 /// \param value The new triggerSource value.
135   - void BulkSetTriggerAndSamplerate::setTriggerSource(unsigned char value) {
  135 + void BulkSetTriggerAndSamplerate::setTriggerSource(uint8_t value) {
136 136 ((Tsr1Bits *) &(this->array[2]))->triggerSource = value;
137 137 }
138 138  
139 139 /// \brief Get the recordLength value in Tsr1Bits.
140 140 /// \return The ::RecordLengthId value.
141   - unsigned char BulkSetTriggerAndSamplerate::getRecordLength() {
  141 + uint8_t BulkSetTriggerAndSamplerate::getRecordLength() {
142 142 return ((Tsr1Bits *) &(this->array[2]))->recordLength;
143 143 }
144 144  
145 145 /// \brief Set the recordLength in Tsr1Bits to the given value.
146 146 /// \param value The new ::RecordLengthId value.
147   - void BulkSetTriggerAndSamplerate::setRecordLength(unsigned char value) {
  147 + void BulkSetTriggerAndSamplerate::setRecordLength(uint8_t value) {
148 148 ((Tsr1Bits *) &(this->array[2]))->recordLength = value;
149 149 }
150 150  
151 151 /// \brief Get the samplerateId value in Tsr1Bits.
152 152 /// \return The samplerateId value.
153   - unsigned char BulkSetTriggerAndSamplerate::getSamplerateId() {
  153 + uint8_t BulkSetTriggerAndSamplerate::getSamplerateId() {
154 154 return ((Tsr1Bits *) &(this->array[2]))->samplerateId;
155 155 }
156 156  
157 157 /// \brief Set the samplerateId in Tsr1Bits to the given value.
158 158 /// \param value The new samplerateId value.
159   - void BulkSetTriggerAndSamplerate::setSamplerateId(unsigned char value) {
  159 + void BulkSetTriggerAndSamplerate::setSamplerateId(uint8_t value) {
160 160 ((Tsr1Bits *) &(this->array[2]))->samplerateId = value;
161 161 }
162 162  
... ... @@ -174,13 +174,13 @@ namespace Hantek {
174 174  
175 175 /// \brief Get the usedChannels value in Tsr2Bits.
176 176 /// \return The usedChannels value.
177   - unsigned char BulkSetTriggerAndSamplerate::getUsedChannels() {
  177 + uint8_t BulkSetTriggerAndSamplerate::getUsedChannels() {
178 178 return ((Tsr2Bits *) &(this->array[3]))->usedChannels;
179 179 }
180 180  
181 181 /// \brief Set the usedChannels in Tsr2Bits to the given value.
182 182 /// \param value The new usedChannels value.
183   - void BulkSetTriggerAndSamplerate::setUsedChannels(unsigned char value) {
  183 + void BulkSetTriggerAndSamplerate::setUsedChannels(uint8_t value) {
184 184 ((Tsr2Bits *) &(this->array[3]))->usedChannels = value;
185 185 }
186 186  
... ... @@ -198,41 +198,41 @@ namespace Hantek {
198 198  
199 199 /// \brief Get the triggerSlope value in Tsr2Bits.
200 200 /// \return The triggerSlope value.
201   - unsigned char BulkSetTriggerAndSamplerate::getTriggerSlope() {
  201 + uint8_t BulkSetTriggerAndSamplerate::getTriggerSlope() {
202 202 return ((Tsr2Bits *) &(this->array[3]))->triggerSlope;
203 203 }
204 204  
205 205 /// \brief Set the triggerSlope in Tsr2Bits to the given value.
206 206 /// \param slope The new triggerSlope value.
207   - void BulkSetTriggerAndSamplerate::setTriggerSlope(unsigned char slope) {
  207 + void BulkSetTriggerAndSamplerate::setTriggerSlope(uint8_t slope) {
208 208 ((Tsr2Bits *) &(this->array[3]))->triggerSlope = slope;
209 209 }
210 210  
211 211 /// \brief Get the Downsampler value.
212 212 /// \return The Downsampler value.
213   - unsigned short int BulkSetTriggerAndSamplerate::getDownsampler() {
214   - return (unsigned short int) this->array[4] | ((unsigned short int) this->array[5] << 8);
  213 + uint16_t BulkSetTriggerAndSamplerate::getDownsampler() {
  214 + return (uint16_t) this->array[4] | ((uint16_t) this->array[5] << 8);
215 215 }
216 216  
217 217 /// \brief Set the Downsampler to the given value.
218 218 /// \param downsampler The new Downsampler value.
219   - void BulkSetTriggerAndSamplerate::setDownsampler(unsigned short int downsampler) {
220   - this->array[4] = (unsigned char) downsampler;
221   - this->array[5] = (unsigned char) (downsampler >> 8);
  219 + void BulkSetTriggerAndSamplerate::setDownsampler(uint16_t downsampler) {
  220 + this->array[4] = (uint8_t) downsampler;
  221 + this->array[5] = (uint8_t) (downsampler >> 8);
222 222 }
223 223  
224 224 /// \brief Get the TriggerPosition value.
225 225 /// \return The horizontal trigger position.
226   - unsigned long int BulkSetTriggerAndSamplerate::getTriggerPosition() {
227   - return (unsigned long int) this->array[6] | ((unsigned long int) this->array[7] << 8) | ((unsigned long int) this->array[10] << 16);
  226 + uint32_t BulkSetTriggerAndSamplerate::getTriggerPosition() {
  227 + return (uint32_t) this->array[6] | ((uint32_t) this->array[7] << 8) | ((uint32_t) this->array[10] << 16);
228 228 }
229 229  
230 230 /// \brief Set the TriggerPosition to the given value.
231 231 /// \param position The new horizontal trigger position.
232   - void BulkSetTriggerAndSamplerate::setTriggerPosition(unsigned long int position) {
233   - this->array[6] = (unsigned char) position;
234   - this->array[7] = (unsigned char) (position >> 8);
235   - this->array[10] = (unsigned char) (position >> 16);
  232 + void BulkSetTriggerAndSamplerate::setTriggerPosition(uint32_t position) {
  233 + this->array[6] = (uint8_t) position;
  234 + this->array[7] = (uint8_t) (position >> 8);
  235 + this->array[10] = (uint8_t) (position >> 16);
236 236 }
237 237  
238 238 /// \brief Initialize the array to the needed values.
... ... @@ -244,7 +244,7 @@ namespace Hantek {
244 244 //////////////////////////////////////////////////////////////////////////////
245 245 // class BulkForceTrigger
246 246 /// \brief Sets the data array to needed values.
247   - BulkForceTrigger::BulkForceTrigger() : Helper::DataArray<unsigned char>(2) {
  247 + BulkForceTrigger::BulkForceTrigger() : Helper::DataArray<uint8_t>(2) {
248 248 this->array[0] = BULK_FORCETRIGGER;
249 249 }
250 250  
... ... @@ -252,7 +252,7 @@ namespace Hantek {
252 252 //////////////////////////////////////////////////////////////////////////////
253 253 // class BulkCaptureStart
254 254 /// \brief Sets the data array to needed values.
255   - BulkCaptureStart::BulkCaptureStart() : Helper::DataArray<unsigned char>(2) {
  255 + BulkCaptureStart::BulkCaptureStart() : Helper::DataArray<uint8_t>(2) {
256 256 this->array[0] = BULK_STARTSAMPLING;
257 257 }
258 258  
... ... @@ -260,7 +260,7 @@ namespace Hantek {
260 260 //////////////////////////////////////////////////////////////////////////////
261 261 // class BulkTriggerEnabled
262 262 /// \brief Sets the data array to needed values.
263   - BulkTriggerEnabled::BulkTriggerEnabled() : Helper::DataArray<unsigned char>(2) {
  263 + BulkTriggerEnabled::BulkTriggerEnabled() : Helper::DataArray<uint8_t>(2) {
264 264 this->array[0] = BULK_ENABLETRIGGER;
265 265 }
266 266  
... ... @@ -268,7 +268,7 @@ namespace Hantek {
268 268 //////////////////////////////////////////////////////////////////////////////
269 269 // class BulkGetData
270 270 /// \brief Sets the data array to needed values.
271   - BulkGetData::BulkGetData() : Helper::DataArray<unsigned char>(2) {
  271 + BulkGetData::BulkGetData() : Helper::DataArray<uint8_t>(2) {
272 272 this->array[0] = BULK_GETDATA;
273 273 }
274 274  
... ... @@ -276,7 +276,7 @@ namespace Hantek {
276 276 //////////////////////////////////////////////////////////////////////////////
277 277 // class BulkGetCaptureState
278 278 /// \brief Sets the data array to needed values.
279   - BulkGetCaptureState::BulkGetCaptureState() : Helper::DataArray<unsigned char>(2) {
  279 + BulkGetCaptureState::BulkGetCaptureState() : Helper::DataArray<uint8_t>(2) {
280 280 this->array[0] = BULK_GETCAPTURESTATE;
281 281 }
282 282  
... ... @@ -284,7 +284,7 @@ namespace Hantek {
284 284 //////////////////////////////////////////////////////////////////////////////
285 285 // class BulkResponseGetCaptureState
286 286 /// \brief Initializes the array.
287   - BulkResponseGetCaptureState::BulkResponseGetCaptureState() : Helper::DataArray<unsigned char>(512) {
  287 + BulkResponseGetCaptureState::BulkResponseGetCaptureState() : Helper::DataArray<uint8_t>(512) {
288 288 }
289 289  
290 290 /// \brief Gets the capture state.
... ... @@ -303,14 +303,14 @@ namespace Hantek {
303 303 //////////////////////////////////////////////////////////////////////////////
304 304 // class BulkSetGain
305 305 /// \brief Sets the data array to needed values.
306   - BulkSetGain::BulkSetGain() : Helper::DataArray<unsigned char>(8) {
  306 + BulkSetGain::BulkSetGain() : Helper::DataArray<uint8_t>(8) {
307 307 this->init();
308 308 }
309 309  
310 310 /// \brief Sets the gain to the given values.
311 311 /// \param channel1 The gain value for channel 1.
312 312 /// \param channel2 The gain value for channel 2.
313   - BulkSetGain::BulkSetGain(unsigned char channel1, unsigned char channel2) : Helper::DataArray<unsigned char>(8) {
  313 + BulkSetGain::BulkSetGain(uint8_t channel1, uint8_t channel2) : Helper::DataArray<uint8_t>(8) {
314 314 this->init();
315 315  
316 316 this->setGain(0, channel1);
... ... @@ -320,7 +320,7 @@ namespace Hantek {
320 320 /// \brief Get the gain for the given channel.
321 321 /// \param channel The channel whose gain should be returned.
322 322 /// \returns The gain value.
323   - unsigned char BulkSetGain::getGain(unsigned int channel) {
  323 + uint8_t BulkSetGain::getGain(unsigned int channel) {
324 324 GainBits *gainBits = (GainBits *) &(this->array[2]);
325 325 if(channel == 0)
326 326 return gainBits->channel1;
... ... @@ -331,7 +331,7 @@ namespace Hantek {
331 331 /// \brief Set the gain for the given channel.
332 332 /// \param channel The channel that should be set.
333 333 /// \param value The new gain value for the channel.
334   - void BulkSetGain::setGain(unsigned int channel, unsigned char value) {
  334 + void BulkSetGain::setGain(unsigned int channel, uint8_t value) {
335 335 GainBits *gainBits = (GainBits *) &(this->array[2]);
336 336 if(channel == 0)
337 337 gainBits->channel1 = value;
... ... @@ -348,13 +348,13 @@ namespace Hantek {
348 348 //////////////////////////////////////////////////////////////////////////////
349 349 // class BulkSetLogicalData
350 350 /// \brief Sets the data array to needed values.
351   - BulkSetLogicalData::BulkSetLogicalData() : Helper::DataArray<unsigned char>(8) {
  351 + BulkSetLogicalData::BulkSetLogicalData() : Helper::DataArray<uint8_t>(8) {
352 352 this->init();
353 353 }
354 354  
355 355 /// \brief Sets the data to the given value.
356 356 /// \param data The data byte.
357   - BulkSetLogicalData::BulkSetLogicalData(unsigned char data) : Helper::DataArray<unsigned char>(8) {
  357 + BulkSetLogicalData::BulkSetLogicalData(uint8_t data) : Helper::DataArray<uint8_t>(8) {
358 358 this->init();
359 359  
360 360 this->setData(data);
... ... @@ -362,13 +362,13 @@ namespace Hantek {
362 362  
363 363 /// \brief Gets the data.
364 364 /// \returns The data byte.
365   - unsigned char BulkSetLogicalData::getData() {
  365 + uint8_t BulkSetLogicalData::getData() {
366 366 return this->array[2];
367 367 }
368 368  
369 369 /// \brief Sets the data to the given value.
370 370 /// \param data The new data byte.
371   - void BulkSetLogicalData::setData(unsigned char data) {
  371 + void BulkSetLogicalData::setData(uint8_t data) {
372 372 this->array[2] = data;
373 373 }
374 374  
... ... @@ -381,7 +381,7 @@ namespace Hantek {
381 381 //////////////////////////////////////////////////////////////////////////////
382 382 // class BulkGetLogicalData
383 383 /// \brief Sets the data array to needed values.
384   - BulkGetLogicalData::BulkGetLogicalData() : Helper::DataArray<unsigned char>(2) {
  384 + BulkGetLogicalData::BulkGetLogicalData() : Helper::DataArray<uint8_t>(2) {
385 385 this->array[0] = BULK_GETLOGICALDATA;
386 386 }
387 387  
... ... @@ -389,13 +389,13 @@ namespace Hantek {
389 389 //////////////////////////////////////////////////////////////////////////////
390 390 // class BulkSetFilter2250
391 391 /// \brief Sets the data array to needed values.
392   - BulkSetChannels2250::BulkSetChannels2250() : Helper::DataArray<unsigned char>(4) {
  392 + BulkSetChannels2250::BulkSetChannels2250() : Helper::DataArray<uint8_t>(4) {
393 393 this->init();
394 394 }
395 395  
396 396 /// \brief Sets the used channels.
397 397 /// \param usedChannels The UsedChannels value.
398   - BulkSetChannels2250::BulkSetChannels2250(unsigned char usedChannels) : Helper::DataArray<unsigned char>(4) {
  398 + BulkSetChannels2250::BulkSetChannels2250(uint8_t usedChannels) : Helper::DataArray<uint8_t>(4) {
399 399 this->init();
400 400  
401 401 this->setUsedChannels(usedChannels);
... ... @@ -403,13 +403,13 @@ namespace Hantek {
403 403  
404 404 /// \brief Get the UsedChannels value
405 405 /// \return The UsedChannels value.
406   - unsigned char BulkSetChannels2250::getUsedChannels() {
  406 + uint8_t BulkSetChannels2250::getUsedChannels() {
407 407 return this->array[2];
408 408 }
409 409  
410 410 /// \brief Set the UsedChannels to the given value.
411 411 /// \param value The new UsedChannels value.
412   - void BulkSetChannels2250::setUsedChannels(unsigned char value) {
  412 + void BulkSetChannels2250::setUsedChannels(uint8_t value) {
413 413 this->array[2] = value;
414 414 }
415 415  
... ... @@ -422,14 +422,14 @@ namespace Hantek {
422 422 //////////////////////////////////////////////////////////////////////////////
423 423 // class BulkSetTrigger2250
424 424 /// \brief Sets the data array to needed values.
425   - BulkSetTrigger2250::BulkSetTrigger2250() : Helper::DataArray<unsigned char>(8) {
  425 + BulkSetTrigger2250::BulkSetTrigger2250() : Helper::DataArray<uint8_t>(8) {
426 426 this->init();
427 427 }
428 428  
429 429 /// \brief Sets the used channels.
430 430 /// \param triggerSource The trigger source id (CTriggerBits).
431 431 /// \param triggerSlope The triggerSlope value (CTriggerBits).
432   - BulkSetTrigger2250::BulkSetTrigger2250(unsigned char triggerSource, unsigned char triggerSlope) : Helper::DataArray<unsigned char>(8) {
  432 + BulkSetTrigger2250::BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope) : Helper::DataArray<uint8_t>(8) {
433 433 this->init();
434 434  
435 435 this->setTriggerSource(triggerSource);
... ... @@ -438,25 +438,25 @@ namespace Hantek {
438 438  
439 439 /// \brief Get the triggerSource value in CTriggerBits.
440 440 /// \return The triggerSource value.
441   - unsigned char BulkSetTrigger2250::getTriggerSource() {
  441 + uint8_t BulkSetTrigger2250::getTriggerSource() {
442 442 return ((CTriggerBits *) &(this->array[2]))->triggerSource;
443 443 }
444 444  
445 445 /// \brief Set the triggerSource in CTriggerBits to the given value.
446 446 /// \param value The new triggerSource value.
447   - void BulkSetTrigger2250::setTriggerSource(unsigned char value) {
  447 + void BulkSetTrigger2250::setTriggerSource(uint8_t value) {
448 448 ((CTriggerBits *) &(this->array[2]))->triggerSource = value;
449 449 }
450 450  
451 451 /// \brief Get the triggerSlope value in CTriggerBits.
452 452 /// \return The triggerSlope value.
453   - unsigned char BulkSetTrigger2250::getTriggerSlope() {
  453 + uint8_t BulkSetTrigger2250::getTriggerSlope() {
454 454 return ((CTriggerBits *) &(this->array[2]))->triggerSlope;
455 455 }
456 456  
457 457 /// \brief Set the triggerSlope in CTriggerBits to the given value.
458 458 /// \param slope The new triggerSlope value.
459   - void BulkSetTrigger2250::setTriggerSlope(unsigned char slope) {
  459 + void BulkSetTrigger2250::setTriggerSlope(uint8_t slope) {
460 460 ((CTriggerBits *) &(this->array[2]))->triggerSlope = slope;
461 461 }
462 462  
... ... @@ -469,14 +469,14 @@ namespace Hantek {
469 469 //////////////////////////////////////////////////////////////////////////////
470 470 // class BulkSetSamplerate5200
471 471 /// \brief Sets the data array to the default values.
472   - BulkSetSamplerate5200::BulkSetSamplerate5200() : Helper::DataArray<unsigned char>(6) {
  472 + BulkSetSamplerate5200::BulkSetSamplerate5200() : Helper::DataArray<uint8_t>(6) {
473 473 this->init();
474 474 }
475 475  
476 476 /// \brief Sets the data bytes to the specified values.
477 477 /// \param samplerateSlow The SamplerateSlow value.
478 478 /// \param samplerateFast The SamplerateFast value.
479   - BulkSetSamplerate5200::BulkSetSamplerate5200(unsigned short int samplerateSlow, unsigned char samplerateFast) : Helper::DataArray<unsigned char>(6) {
  479 + BulkSetSamplerate5200::BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast) : Helper::DataArray<uint8_t>(6) {
480 480 this->init();
481 481  
482 482 this->setSamplerateFast(samplerateFast);
... ... @@ -485,27 +485,27 @@ namespace Hantek {
485 485  
486 486 /// \brief Get the SamplerateFast value.
487 487 /// \return The SamplerateFast value.
488   - unsigned char BulkSetSamplerate5200::getSamplerateFast() {
  488 + uint8_t BulkSetSamplerate5200::getSamplerateFast() {
489 489 return this->array[4];
490 490 }
491 491  
492 492 /// \brief Set the SamplerateFast to the given value.
493 493 /// \param value The new SamplerateFast value.
494   - void BulkSetSamplerate5200::setSamplerateFast(unsigned char value) {
  494 + void BulkSetSamplerate5200::setSamplerateFast(uint8_t value) {
495 495 this->array[4] = value;
496 496 }
497 497  
498 498 /// \brief Get the SamplerateSlow value.
499 499 /// \return The SamplerateSlow value.
500   - unsigned short int BulkSetSamplerate5200::getSamplerateSlow() {
501   - return (unsigned short int) this->array[2] | ((unsigned short int) this->array[3] << 8);
  500 + uint16_t BulkSetSamplerate5200::getSamplerateSlow() {
  501 + return (uint16_t) this->array[2] | ((uint16_t) this->array[3] << 8);
502 502 }
503 503  
504 504 /// \brief Set the SamplerateSlow to the given value.
505 505 /// \param samplerate The new SamplerateSlow value.
506   - void BulkSetSamplerate5200::setSamplerateSlow(unsigned short int samplerate) {
507   - this->array[2] = (unsigned char) samplerate;
508   - this->array[3] = (unsigned char) (samplerate >> 8);
  506 + void BulkSetSamplerate5200::setSamplerateSlow(uint16_t samplerate) {
  507 + this->array[2] = (uint8_t) samplerate;
  508 + this->array[3] = (uint8_t) (samplerate >> 8);
509 509 }
510 510  
511 511 /// \brief Initialize the array to the needed values.
... ... @@ -517,13 +517,13 @@ namespace Hantek {
517 517 //////////////////////////////////////////////////////////////////////////////
518 518 // class BulkSetBuffer2250
519 519 /// \brief Sets the data array to the default values.
520   - BulkSetRecordLength2250::BulkSetRecordLength2250() : Helper::DataArray<unsigned char>(4) {
  520 + BulkSetRecordLength2250::BulkSetRecordLength2250() : Helper::DataArray<uint8_t>(4) {
521 521 this->init();
522 522 }
523 523  
524 524 /// \brief Sets the data bytes to the specified values.
525 525 /// \param recordLength The ::RecordLengthId value.
526   - BulkSetRecordLength2250::BulkSetRecordLength2250(unsigned char recordLength) : Helper::DataArray<unsigned char>(4) {
  526 + BulkSetRecordLength2250::BulkSetRecordLength2250(uint8_t recordLength) : Helper::DataArray<uint8_t>(4) {
527 527 this->init();
528 528  
529 529 this->setRecordLength(recordLength);
... ... @@ -531,13 +531,13 @@ namespace Hantek {
531 531  
532 532 /// \brief Get the ::RecordLengthId value.
533 533 /// \return The ::RecordLengthId value.
534   - unsigned char BulkSetRecordLength2250::getRecordLength() {
  534 + uint8_t BulkSetRecordLength2250::getRecordLength() {
535 535 return this->array[2];
536 536 }
537 537  
538 538 /// \brief Set the ::RecordLengthId to the given value.
539 539 /// \param value The new ::RecordLengthId value.
540   - void BulkSetRecordLength2250::setRecordLength(unsigned char value) {
  540 + void BulkSetRecordLength2250::setRecordLength(uint8_t value) {
541 541 this->array[2] = value;
542 542 }
543 543  
... ... @@ -550,7 +550,7 @@ namespace Hantek {
550 550 //////////////////////////////////////////////////////////////////////////////
551 551 // class BulkSetBuffer5200
552 552 /// \brief Sets the data array to the default values.
553   - BulkSetBuffer5200::BulkSetBuffer5200() : Helper::DataArray<unsigned char>(10) {
  553 + BulkSetBuffer5200::BulkSetBuffer5200() : Helper::DataArray<uint8_t>(10) {
554 554 this->init();
555 555 }
556 556  
... ... @@ -560,7 +560,7 @@ namespace Hantek {
560 560 /// \param usedPre The TriggerPositionUsedPre value.
561 561 /// \param usedPost The TriggerPositionUsedPost value.
562 562 /// \param recordLength The ::RecordLengthId value.
563   - BulkSetBuffer5200::BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre, unsigned char usedPost, unsigned char recordLength) : Helper::DataArray<unsigned char>(10) {
  563 + BulkSetBuffer5200::BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, uint8_t usedPre, uint8_t usedPost, uint8_t recordLength) : Helper::DataArray<uint8_t>(10) {
564 564 this->init();
565 565  
566 566 this->setTriggerPositionPre(triggerPositionPre);
... ... @@ -572,63 +572,63 @@ namespace Hantek {
572 572  
573 573 /// \brief Get the TriggerPositionPre value.
574 574 /// \return The TriggerPositionPre value.
575   - unsigned short int BulkSetBuffer5200::getTriggerPositionPre() {
576   - return (unsigned short int) this->array[2] | ((unsigned short int) this->array[3] << 8);
  575 + uint16_t BulkSetBuffer5200::getTriggerPositionPre() {
  576 + return (uint16_t) this->array[2] | ((uint16_t) this->array[3] << 8);
577 577 }
578 578  
579 579 /// \brief Set the TriggerPositionPre to the given value.
580 580 /// \param position The new TriggerPositionPre value.
581   - void BulkSetBuffer5200::setTriggerPositionPre(unsigned short int position) {
582   - this->array[2] = (unsigned char) position;
583   - this->array[3] = (unsigned char) (position >> 8);
  581 + void BulkSetBuffer5200::setTriggerPositionPre(uint16_t position) {
  582 + this->array[2] = (uint8_t) position;
  583 + this->array[3] = (uint8_t) (position >> 8);
584 584 }
585 585  
586 586 /// \brief Get the TriggerPositionPost value.
587 587 /// \return The TriggerPositionPost value.
588   - unsigned short int BulkSetBuffer5200::getTriggerPositionPost() {
589   - return (unsigned short int) this->array[6] | ((unsigned short int) this->array[7] << 8);
  588 + uint16_t BulkSetBuffer5200::getTriggerPositionPost() {
  589 + return (uint16_t) this->array[6] | ((uint16_t) this->array[7] << 8);
590 590 }
591 591  
592 592 /// \brief Set the TriggerPositionPost to the given value.
593 593 /// \param position The new TriggerPositionPost value.
594   - void BulkSetBuffer5200::setTriggerPositionPost(unsigned short int position) {
595   - this->array[6] = (unsigned char) position;
596   - this->array[7] = (unsigned char) (position >> 8);
  594 + void BulkSetBuffer5200::setTriggerPositionPost(uint16_t position) {
  595 + this->array[6] = (uint8_t) position;
  596 + this->array[7] = (uint8_t) (position >> 8);
597 597 }
598 598  
599 599 /// \brief Get the TriggerPositionUsedPre value.
600 600 /// \return The ::DTriggerPositionUsed value for the pre position.
601   - unsigned char BulkSetBuffer5200::getUsedPre() {
  601 + uint8_t BulkSetBuffer5200::getUsedPre() {
602 602 return this->array[4];
603 603 }
604 604  
605 605 /// \brief Set the TriggerPositionUsedPre to the given value.
606 606 /// \param value The new ::DTriggerPositionUsed value for the pre position.
607   - void BulkSetBuffer5200::setUsedPre(unsigned char value) {
  607 + void BulkSetBuffer5200::setUsedPre(uint8_t value) {
608 608 this->array[4] = value;
609 609 }
610 610  
611 611 /// \brief Get the TriggerPositionUsedPost value.
612 612 /// \return The ::DTriggerPositionUsed value for the post position.
613   - unsigned char BulkSetBuffer5200::getUsedPost() {
  613 + uint8_t BulkSetBuffer5200::getUsedPost() {
614 614 return ((DBufferBits *) &(this->array[8]))->triggerPositionUsed;
615 615 }
616 616  
617 617 /// \brief Set the TriggerPositionUsedPost to the given value.
618 618 /// \param value The new ::DTriggerPositionUsed value for the post position.
619   - void BulkSetBuffer5200::setUsedPost(unsigned char value) {
  619 + void BulkSetBuffer5200::setUsedPost(uint8_t value) {
620 620 ((DBufferBits *) &(this->array[8]))->triggerPositionUsed = value;
621 621 }
622 622  
623 623 /// \brief Get the recordLength value in DBufferBits.
624 624 /// \return The ::RecordLengthId value.
625   - unsigned char BulkSetBuffer5200::getRecordLength() {
  625 + uint8_t BulkSetBuffer5200::getRecordLength() {
626 626 return ((DBufferBits *) &(this->array[8]))->recordLength;
627 627 }
628 628  
629 629 /// \brief Set the recordLength in DBufferBits to the given value.
630 630 /// \param value The new ::RecordLengthId value.
631   - void BulkSetBuffer5200::setRecordLength(unsigned char value) {
  631 + void BulkSetBuffer5200::setRecordLength(uint8_t value) {
632 632 ((DBufferBits *) &(this->array[8]))->recordLength = value;
633 633 }
634 634  
... ... @@ -643,7 +643,7 @@ namespace Hantek {
643 643 //////////////////////////////////////////////////////////////////////////////
644 644 // class BulkSetSamplerate2250
645 645 /// \brief Sets the data array to the default values.
646   - BulkSetSamplerate2250::BulkSetSamplerate2250() : Helper::DataArray<unsigned char>(8) {
  646 + BulkSetSamplerate2250::BulkSetSamplerate2250() : Helper::DataArray<uint8_t>(8) {
647 647 this->init();
648 648 }
649 649  
... ... @@ -651,7 +651,7 @@ namespace Hantek {
651 651 /// \param fastRate The fastRate state (ESamplerateBits).
652 652 /// \param downsampling The downsampling state (ESamplerateBits).
653 653 /// \param samplerate The Samplerate value.
654   - BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, unsigned short int samplerate) : Helper::DataArray<unsigned char>(8) {
  654 + BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, uint16_t samplerate) : Helper::DataArray<uint8_t>(8) {
655 655 this->init();
656 656  
657 657 this->setFastRate(fastRate);
... ... @@ -685,15 +685,15 @@ namespace Hantek {
685 685  
686 686 /// \brief Get the Samplerate value.
687 687 /// \return The Samplerate value.
688   - unsigned short int BulkSetSamplerate2250::getSamplerate() {
689   - return (unsigned short int) this->array[4] | ((unsigned short int) this->array[5] << 8);
  688 + uint16_t BulkSetSamplerate2250::getSamplerate() {
  689 + return (uint16_t) this->array[4] | ((uint16_t) this->array[5] << 8);
690 690 }
691 691  
692 692 /// \brief Set the Samplerate to the given value.
693 693 /// \param samplerate The new Samplerate value.
694   - void BulkSetSamplerate2250::setSamplerate(unsigned short int samplerate) {
695   - this->array[4] = (unsigned char) samplerate;
696   - this->array[5] = (unsigned char) (samplerate >> 8);
  694 + void BulkSetSamplerate2250::setSamplerate(uint16_t samplerate) {
  695 + this->array[4] = (uint8_t) samplerate;
  696 + this->array[5] = (uint8_t) (samplerate >> 8);
697 697 }
698 698  
699 699 /// \brief Initialize the array to the needed values.
... ... @@ -705,7 +705,7 @@ namespace Hantek {
705 705 //////////////////////////////////////////////////////////////////////////////
706 706 // class BulkSetTrigger5200
707 707 /// \brief Sets the data array to the default values.
708   - BulkSetTrigger5200::BulkSetTrigger5200() : Helper::DataArray<unsigned char>(8) {
  708 + BulkSetTrigger5200::BulkSetTrigger5200() : Helper::DataArray<uint8_t>(8) {
709 709 this->init();
710 710 }
711 711  
... ... @@ -715,7 +715,7 @@ namespace Hantek {
715 715 /// \param fastRate The fastRate state.
716 716 /// \param triggerSlope The triggerSlope value.
717 717 /// \param triggerPulse The triggerPulse value.
718   - BulkSetTrigger5200::BulkSetTrigger5200(unsigned char triggerSource, unsigned char usedChannels, bool fastRate, unsigned char triggerSlope, unsigned char triggerPulse) : Helper::DataArray<unsigned char>(8) {
  718 + BulkSetTrigger5200::BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate, uint8_t triggerSlope, uint8_t triggerPulse) : Helper::DataArray<uint8_t>(8) {
719 719 this->init();
720 720  
721 721 this->setTriggerSource(triggerSource);
... ... @@ -727,25 +727,25 @@ namespace Hantek {
727 727  
728 728 /// \brief Get the triggerSource value in ETsrBits.
729 729 /// \return The ::TriggerSource value.
730   - unsigned char BulkSetTrigger5200::getTriggerSource() {
  730 + uint8_t BulkSetTrigger5200::getTriggerSource() {
731 731 return ((ETsrBits *) &(this->array[2]))->triggerSource;
732 732 }
733 733  
734 734 /// \brief Set the triggerSource in ETsrBits to the given value.
735 735 /// \param value The new ::TriggerSource value.
736   - void BulkSetTrigger5200::setTriggerSource(unsigned char value) {
  736 + void BulkSetTrigger5200::setTriggerSource(uint8_t value) {
737 737 ((ETsrBits *) &(this->array[2]))->triggerSource = value;
738 738 }
739 739  
740 740 /// \brief Get the usedChannels value in ETsrBits.
741 741 /// \return The ::UsedChannels value.
742   - unsigned char BulkSetTrigger5200::getUsedChannels() {
  742 + uint8_t BulkSetTrigger5200::getUsedChannels() {
743 743 return ((ETsrBits *) &(this->array[2]))->usedChannels;
744 744 }
745 745  
746 746 /// \brief Set the usedChannels in ETsrBits to the given value.
747 747 /// \param value The new ::UsedChannels value.
748   - void BulkSetTrigger5200::setUsedChannels(unsigned char value) {
  748 + void BulkSetTrigger5200::setUsedChannels(uint8_t value) {
749 749 ((ETsrBits *) &(this->array[2]))->usedChannels = value;
750 750 }
751 751  
... ... @@ -763,13 +763,13 @@ namespace Hantek {
763 763  
764 764 /// \brief Get the triggerSlope value in ETsrBits.
765 765 /// \return The triggerSlope value.
766   - unsigned char BulkSetTrigger5200::getTriggerSlope() {
  766 + uint8_t BulkSetTrigger5200::getTriggerSlope() {
767 767 return ((ETsrBits *) &(this->array[2]))->triggerSlope;
768 768 }
769 769  
770 770 /// \brief Set the triggerSlope in ETsrBits to the given value.
771 771 /// \param slope The new triggerSlope value.
772   - void BulkSetTrigger5200::setTriggerSlope(unsigned char slope) {
  772 + void BulkSetTrigger5200::setTriggerSlope(uint8_t slope) {
773 773 ((ETsrBits *) &(this->array[2]))->triggerSlope = slope;
774 774 }
775 775  
... ... @@ -796,14 +796,14 @@ namespace Hantek {
796 796 /// \class BulkSetBuffer2250 hantek/types.h
797 797 /// \brief The DSO-2250 BULK_FSETBUFFER builder.
798 798 /// \brief Sets the data array to the default values.
799   - BulkSetBuffer2250::BulkSetBuffer2250() : Helper::DataArray<unsigned char>(10) {
  799 + BulkSetBuffer2250::BulkSetBuffer2250() : Helper::DataArray<uint8_t>(10) {
800 800 this->init();
801 801 }
802 802  
803 803 /// \brief Sets the data bytes to the specified values.
804 804 /// \param triggerPositionPre The TriggerPositionPre value.
805 805 /// \param triggerPositionPost The TriggerPositionPost value.
806   - BulkSetBuffer2250::BulkSetBuffer2250(unsigned long int triggerPositionPre, unsigned long int triggerPositionPost) : Helper::DataArray<unsigned char>(12) {
  806 + BulkSetBuffer2250::BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost) : Helper::DataArray<uint8_t>(12) {
807 807 this->init();
808 808  
809 809 this->setTriggerPositionPre(triggerPositionPre);
... ... @@ -812,30 +812,30 @@ namespace Hantek {
812 812  
813 813 /// \brief Get the TriggerPositionPost value.
814 814 /// \return The TriggerPositionPost value.
815   - unsigned long int BulkSetBuffer2250::getTriggerPositionPost() {
816   - return (unsigned long int) this->array[2] | ((unsigned long int) this->array[3] << 8) | ((unsigned long int) this->array[4] << 16);
  815 + uint32_t BulkSetBuffer2250::getTriggerPositionPost() {
  816 + return (uint32_t) this->array[2] | ((uint32_t) this->array[3] << 8) | ((uint32_t) this->array[4] << 16);
817 817 }
818 818  
819 819 /// \brief Set the TriggerPositionPost to the given value.
820 820 /// \param position The new TriggerPositionPost value.
821   - void BulkSetBuffer2250::setTriggerPositionPost(unsigned long int position) {
822   - this->array[2] = (unsigned char) position;
823   - this->array[3] = (unsigned char) (position >> 8);
824   - this->array[4] = (unsigned char) (position >> 16);
  821 + void BulkSetBuffer2250::setTriggerPositionPost(uint32_t position) {
  822 + this->array[2] = (uint8_t) position;
  823 + this->array[3] = (uint8_t) (position >> 8);
  824 + this->array[4] = (uint8_t) (position >> 16);
825 825 }
826 826  
827 827 /// \brief Get the TriggerPositionPre value.
828 828 /// \return The TriggerPositionPre value.
829   - unsigned long int BulkSetBuffer2250::getTriggerPositionPre() {
830   - return (unsigned long int) this->array[6] | ((unsigned short int) this->array[7] << 8) | ((unsigned short int) this->array[8] << 16);
  829 + uint32_t BulkSetBuffer2250::getTriggerPositionPre() {
  830 + return (uint32_t) this->array[6] | ((uint16_t) this->array[7] << 8) | ((uint16_t) this->array[8] << 16);
831 831 }
832 832  
833 833 /// \brief Set the TriggerPositionPre to the given value.
834 834 /// \param position The new TriggerPositionPre value.
835   - void BulkSetBuffer2250::setTriggerPositionPre(unsigned long int position) {
836   - this->array[6] = (unsigned char) position;
837   - this->array[7] = (unsigned char) (position >> 8);
838   - this->array[8] = (unsigned char) (position >> 16);
  835 + void BulkSetBuffer2250::setTriggerPositionPre(uint32_t position) {
  836 + this->array[6] = (uint8_t) position;
  837 + this->array[7] = (uint8_t) (position >> 8);
  838 + this->array[8] = (uint8_t) (position >> 16);
839 839 }
840 840  
841 841 /// \brief Initialize the array to the needed values.
... ... @@ -847,7 +847,7 @@ namespace Hantek {
847 847 //////////////////////////////////////////////////////////////////////////////
848 848 // class ControlGetSpeed
849 849 /// \brief Initializes the array.
850   - ControlGetSpeed::ControlGetSpeed() : Helper::DataArray<unsigned char>(10) {
  850 + ControlGetSpeed::ControlGetSpeed() : Helper::DataArray<uint8_t>(10) {
851 851 }
852 852  
853 853 /// \brief Gets the speed of the connection.
... ... @@ -861,7 +861,7 @@ namespace Hantek {
861 861 // class ControlBeginCommand
862 862 /// \brief Sets the command index to the given value.
863 863 /// \param index The CommandIndex for the command.
864   - ControlBeginCommand::ControlBeginCommand(BulkIndex index) : Helper::DataArray<unsigned char>(10) {
  864 + ControlBeginCommand::ControlBeginCommand(BulkIndex index) : Helper::DataArray<uint8_t>(10) {
865 865 this->init();
866 866  
867 867 this->setIndex(index);
... ... @@ -876,7 +876,7 @@ namespace Hantek {
876 876 /// \brief Sets the command index to the given value.
877 877 /// \param index The new CommandIndex for the command.
878 878 void ControlBeginCommand::setIndex(BulkIndex index) {
879   - memset(&(this->array[1]), (unsigned char) index, 3);
  879 + memset(&(this->array[1]), (uint8_t) index, 3);
880 880 }
881 881  
882 882 /// \brief Initialize the array to the needed values.
... ... @@ -888,14 +888,14 @@ namespace Hantek {
888 888 //////////////////////////////////////////////////////////////////////////////
889 889 // class ControlSetOffset
890 890 /// \brief Sets the data array to the default values.
891   - ControlSetOffset::ControlSetOffset() : Helper::DataArray<unsigned char>(17) {
  891 + ControlSetOffset::ControlSetOffset() : Helper::DataArray<uint8_t>(17) {
892 892 }
893 893  
894 894 /// \brief Sets the offsets to the given values.
895 895 /// \param channel1 The offset for channel 1.
896 896 /// \param channel2 The offset for channel 2.
897 897 /// \param trigger The offset for ext. trigger.
898   - ControlSetOffset::ControlSetOffset(unsigned short int channel1, unsigned short int channel2, unsigned short int trigger) : Helper::DataArray<unsigned char>(17) {
  898 + ControlSetOffset::ControlSetOffset(uint16_t channel1, uint16_t channel2, uint16_t trigger) : Helper::DataArray<uint8_t>(17) {
899 899 this->setChannel(0, channel1);
900 900 this->setChannel(1, channel2);
901 901 this->setTrigger(trigger);
... ... @@ -904,7 +904,7 @@ namespace Hantek {
904 904 /// \brief Get the offset for the given channel.
905 905 /// \param channel The channel whose offset should be returned.
906 906 /// \return The channel offset value.
907   - unsigned short int ControlSetOffset::getChannel(unsigned int channel) {
  907 + uint16_t ControlSetOffset::getChannel(unsigned int channel) {
908 908 if(channel == 0)
909 909 return ((this->array[0] & 0x0f) << 8) | this->array[1];
910 910 else
... ... @@ -914,28 +914,28 @@ namespace Hantek {
914 914 /// \brief Set the offset for the given channel.
915 915 /// \param channel The channel that should be set.
916 916 /// \param offset The new channel offset value.
917   - void ControlSetOffset::setChannel(unsigned int channel, unsigned short int offset) {
  917 + void ControlSetOffset::setChannel(unsigned int channel, uint16_t offset) {
918 918 if(channel == 0) {
919   - this->array[0] = (unsigned char) (offset >> 8);
920   - this->array[1] = (unsigned char) offset;
  919 + this->array[0] = (uint8_t) (offset >> 8);
  920 + this->array[1] = (uint8_t) offset;
921 921 }
922 922 else {
923   - this->array[2] = (unsigned char) (offset >> 8);
924   - this->array[3] = (unsigned char) offset;
  923 + this->array[2] = (uint8_t) (offset >> 8);
  924 + this->array[3] = (uint8_t) offset;
925 925 }
926 926 }
927 927  
928 928 /// \brief Get the trigger level.
929 929 /// \return The trigger level value.
930   - unsigned short int ControlSetOffset::getTrigger() {
  930 + uint16_t ControlSetOffset::getTrigger() {
931 931 return ((this->array[4] & 0x0f) << 8) | this->array[5];
932 932 }
933 933  
934 934 /// \brief Set the trigger level.
935 935 /// \param level The new trigger level value.
936   - void ControlSetOffset::setTrigger(unsigned short int level) {
937   - this->array[4] = (unsigned char) (level >> 8);
938   - this->array[5] = (unsigned char) level;
  936 + void ControlSetOffset::setTrigger(uint16_t level) {
  937 + this->array[4] = (uint8_t) (level >> 8);
  938 + this->array[5] = (uint8_t) level;
939 939 }
940 940  
941 941  
... ... @@ -949,7 +949,7 @@ namespace Hantek {
949 949 /// \param ch2Below100mV Sets the state of the Channel 2 below 100 mV relay.
950 950 /// \param ch2CouplingDC Sets the state of the Channel 2 coupling relay.
951 951 /// \param triggerExt Sets the state of the external trigger relay.
952   - ControlSetRelays::ControlSetRelays(bool ch1Below1V, bool ch1Below100mV, bool ch1CouplingDC, bool ch2Below1V, bool ch2Below100mV, bool ch2CouplingDC, bool triggerExt) : Helper::DataArray<unsigned char>(17) {
  952 + ControlSetRelays::ControlSetRelays(bool ch1Below1V, bool ch1Below100mV, bool ch1CouplingDC, bool ch2Below1V, bool ch2Below100mV, bool ch2CouplingDC, bool triggerExt) : Helper::DataArray<uint8_t>(17) {
953 953 this->setBelow1V(0, ch1Below1V);
954 954 this->setBelow100mV(0, ch1Below100mV);
955 955 this->setCoupling(0, ch1CouplingDC);
... ...
openhantek/src/hantek/types.h
... ... @@ -29,6 +29,9 @@
29 29 #define HANTEK_TYPES_H
30 30  
31 31  
  32 +#include <stdint.h>
  33 +
  34 +
32 35 #include "helper.h"
33 36  
34 37  
... ... @@ -738,83 +741,83 @@ namespace Hantek {
738 741 /// \struct FilterBits hantek/types.h
739 742 /// \brief The bits for BULK_SETFILTER.
740 743 struct FilterBits {
741   - unsigned char channel1:1; ///< Set to true when channel 1 isn't used
742   - unsigned char channel2:1; ///< Set to true when channel 2 isn't used
743   - unsigned char trigger:1; ///< Set to true when trigger isn't used
744   - unsigned char reserved:5; ///< Unused bits
  744 + uint8_t channel1:1; ///< Set to true when channel 1 isn't used
  745 + uint8_t channel2:1; ///< Set to true when channel 2 isn't used
  746 + uint8_t trigger:1; ///< Set to true when trigger isn't used
  747 + uint8_t reserved:5; ///< Unused bits
745 748 };
746 749  
747 750 //////////////////////////////////////////////////////////////////////////////
748 751 /// \struct GainBits hantek/types.h
749 752 /// \brief The gain bits for BULK_SETGAIN.
750 753 struct GainBits {
751   - unsigned char channel1:2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e*
752   - unsigned char channel2:2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e*
753   - unsigned char reserved:4; ///< Unused bits
  754 + uint8_t channel1:2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e*
  755 + uint8_t channel2:2; ///< Gain for CH1, 0 = 1e* V, 1 = 2e*, 2 = 5e*
  756 + uint8_t reserved:4; ///< Unused bits
754 757 };
755 758  
756 759 //////////////////////////////////////////////////////////////////////////////
757 760 /// \struct Tsr1Bits hantek/types.h
758 761 /// \brief Trigger and samplerate bits (Byte 1).
759 762 struct Tsr1Bits {
760   - unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource
761   - unsigned char recordLength:3; ///< See ::RecordLengthId
762   - unsigned char samplerateId:2; ///< Samplerate ID when downsampler is disabled
763   - unsigned char downsamplingMode:1; ///< true, if Downsampler is used
  763 + uint8_t triggerSource:2; ///< The trigger source, see Hantek::TriggerSource
  764 + uint8_t recordLength:3; ///< See ::RecordLengthId
  765 + uint8_t samplerateId:2; ///< Samplerate ID when downsampler is disabled
  766 + uint8_t downsamplingMode:1; ///< true, if Downsampler is used
764 767 };
765 768  
766 769 //////////////////////////////////////////////////////////////////////////////
767 770 /// \struct Tsr2Bits hantek/types.h
768 771 /// \brief Trigger and samplerate bits (Byte 2).
769 772 struct Tsr2Bits {
770   - unsigned char usedChannels:2; ///< Used channels, see Hantek::UsedChannels
771   - unsigned char fastRate:1; ///< true, if one channels uses all buffers
772   - unsigned char triggerSlope:1; ///< The trigger slope, see Dso::Slope, inverted when Tsr1Bits.samplerateFast is uneven
773   - unsigned char reserved:4; ///< Unused bits
  773 + uint8_t usedChannels:2; ///< Used channels, see Hantek::UsedChannels
  774 + uint8_t fastRate:1; ///< true, if one channels uses all buffers
  775 + uint8_t triggerSlope:1; ///< The trigger slope, see Dso::Slope, inverted when Tsr1Bits.samplerateFast is uneven
  776 + uint8_t reserved:4; ///< Unused bits
774 777 };
775 778  
776 779 //////////////////////////////////////////////////////////////////////////////
777 780 /// \struct CTriggerBits hantek/types.h
778 781 /// \brief Trigger bits for 0x0c command.
779 782 struct CTriggerBits {
780   - unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource
781   - unsigned char triggerSlope:1; ///< The trigger slope, see Dso::Slope
782   - unsigned char reserved:5; ///< Unused bits
  783 + uint8_t triggerSource:2; ///< The trigger source, see Hantek::TriggerSource
  784 + uint8_t triggerSlope:1; ///< The trigger slope, see Dso::Slope
  785 + uint8_t reserved:5; ///< Unused bits
783 786 };
784 787  
785 788 //////////////////////////////////////////////////////////////////////////////
786 789 /// \struct DBufferBits hantek/types.h
787 790 /// \brief Buffer mode bits for 0x0d command.
788 791 struct DBufferBits {
789   - unsigned char triggerPositionUsed:3; ///< See ::DTriggerPositionUsed
790   - unsigned char recordLength:3; ///< See ::RecordLengthId
791   - unsigned char reserved:2; ///< Unused bits
  792 + uint8_t triggerPositionUsed:3; ///< See ::DTriggerPositionUsed
  793 + uint8_t recordLength:3; ///< See ::RecordLengthId
  794 + uint8_t reserved:2; ///< Unused bits
792 795 };
793 796  
794 797 //////////////////////////////////////////////////////////////////////////////
795 798 /// \struct ESamplerateBits hantek/types.h
796 799 /// \brief Samplerate bits for DSO-2250 0x0e command.
797 800 struct ESamplerateBits {
798   - unsigned char fastRate:1; ///< false, if one channels uses all buffers
799   - unsigned char downsampling:1; ///< true, if the downsampler is activated
800   - unsigned char reserved:4; ///< Unused bits
  801 + uint8_t fastRate:1; ///< false, if one channels uses all buffers
  802 + uint8_t downsampling:1; ///< true, if the downsampler is activated
  803 + uint8_t reserved:4; ///< Unused bits
801 804 };
802 805  
803 806 //////////////////////////////////////////////////////////////////////////////
804 807 /// \struct ETsrBits hantek/types.h
805 808 /// \brief Trigger and samplerate bits for DSO-5200/DSO-5200A 0x0e command.
806 809 struct ETsrBits {
807   - unsigned char fastRate:1; ///< false, if one channels uses all buffers
808   - unsigned char usedChannels:2; ///< Used channels, see Hantek::UsedChannels
809   - unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource
810   - unsigned char triggerSlope:2; ///< The trigger slope, see Dso::Slope
811   - unsigned char triggerPulse:1; ///< Pulses are causing trigger events
  810 + uint8_t fastRate:1; ///< false, if one channels uses all buffers
  811 + uint8_t usedChannels:2; ///< Used channels, see Hantek::UsedChannels
  812 + uint8_t triggerSource:2; ///< The trigger source, see Hantek::TriggerSource
  813 + uint8_t triggerSlope:2; ///< The trigger slope, see Dso::Slope
  814 + uint8_t triggerPulse:1; ///< Pulses are causing trigger events
812 815 };
813 816  
814 817 //////////////////////////////////////////////////////////////////////////////
815 818 /// \class BulkSetFilter hantek/types.h
816 819 /// \brief The BULK_SETFILTER builder.
817   - class BulkSetFilter : public Helper::DataArray<unsigned char> {
  820 + class BulkSetFilter : public Helper::DataArray<uint8_t> {
818 821 public:
819 822 BulkSetFilter();
820 823 BulkSetFilter(bool channel1, bool channel2, bool trigger);
... ... @@ -831,29 +834,29 @@ namespace Hantek {
831 834 //////////////////////////////////////////////////////////////////////////////
832 835 /// \class BulkSetTriggerAndSamplerate hantek/types.h
833 836 /// \brief The BULK_SETTRIGGERANDSAMPLERATE builder.
834   - class BulkSetTriggerAndSamplerate : public Helper::DataArray<unsigned char> {
  837 + class BulkSetTriggerAndSamplerate : public Helper::DataArray<uint8_t> {
835 838 public:
836 839 BulkSetTriggerAndSamplerate();
837   - 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);
  840 + 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);
838 841  
839   - unsigned char getTriggerSource();
840   - void setTriggerSource(unsigned char value);
841   - unsigned char getRecordLength();
842   - void setRecordLength(unsigned char value);
843   - unsigned char getSamplerateId();
844   - void setSamplerateId(unsigned char value);
  842 + uint8_t getTriggerSource();
  843 + void setTriggerSource(uint8_t value);
  844 + uint8_t getRecordLength();
  845 + void setRecordLength(uint8_t value);
  846 + uint8_t getSamplerateId();
  847 + void setSamplerateId(uint8_t value);
845 848 bool getDownsamplingMode();
846 849 void setDownsamplingMode(bool downsampling);
847   - unsigned char getUsedChannels();
848   - void setUsedChannels(unsigned char value);
  850 + uint8_t getUsedChannels();
  851 + void setUsedChannels(uint8_t value);
849 852 bool getFastRate();
850 853 void setFastRate(bool fastRate);
851   - unsigned char getTriggerSlope();
852   - void setTriggerSlope(unsigned char slope);
853   - unsigned short int getDownsampler();
854   - void setDownsampler(unsigned short int downsampler);
855   - unsigned long int getTriggerPosition();
856   - void setTriggerPosition(unsigned long int position);
  854 + uint8_t getTriggerSlope();
  855 + void setTriggerSlope(uint8_t slope);
  856 + uint16_t getDownsampler();
  857 + void setDownsampler(uint16_t downsampler);
  858 + uint32_t getTriggerPosition();
  859 + void setTriggerPosition(uint32_t position);
857 860  
858 861 private:
859 862 void init();
... ... @@ -862,7 +865,7 @@ namespace Hantek {
862 865 //////////////////////////////////////////////////////////////////////////////
863 866 /// \class BulkForceTrigger hantek/types.h
864 867 /// \brief The BULK_FORCETRIGGER builder.
865   - class BulkForceTrigger : public Helper::DataArray<unsigned char> {
  868 + class BulkForceTrigger : public Helper::DataArray<uint8_t> {
866 869 public:
867 870 BulkForceTrigger();
868 871 };
... ... @@ -870,7 +873,7 @@ namespace Hantek {
870 873 //////////////////////////////////////////////////////////////////////////////
871 874 /// \class BulkCaptureStart hantek/types.h
872 875 /// \brief The BULK_CAPTURESTART builder.
873   - class BulkCaptureStart : public Helper::DataArray<unsigned char> {
  876 + class BulkCaptureStart : public Helper::DataArray<uint8_t> {
874 877 public:
875 878 BulkCaptureStart();
876 879 };
... ... @@ -878,7 +881,7 @@ namespace Hantek {
878 881 //////////////////////////////////////////////////////////////////////////////
879 882 /// \class BulkTriggerEnabled hantek/types.h
880 883 /// \brief The BULK_TRIGGERENABLED builder.
881   - class BulkTriggerEnabled : public Helper::DataArray<unsigned char> {
  884 + class BulkTriggerEnabled : public Helper::DataArray<uint8_t> {
882 885 public:
883 886 BulkTriggerEnabled();
884 887 };
... ... @@ -886,7 +889,7 @@ namespace Hantek {
886 889 //////////////////////////////////////////////////////////////////////////////
887 890 /// \class BulkGetData hantek/types.h
888 891 /// \brief The BULK_GETDATA builder.
889   - class BulkGetData : public Helper::DataArray<unsigned char> {
  892 + class BulkGetData : public Helper::DataArray<uint8_t> {
890 893 public:
891 894 BulkGetData();
892 895 };
... ... @@ -894,7 +897,7 @@ namespace Hantek {
894 897 //////////////////////////////////////////////////////////////////////////////
895 898 /// \class BulkGetCaptureState hantek/types.h
896 899 /// \brief The BULK_GETCAPTURESTATE builder.
897   - class BulkGetCaptureState : public Helper::DataArray<unsigned char> {
  900 + class BulkGetCaptureState : public Helper::DataArray<uint8_t> {
898 901 public:
899 902 BulkGetCaptureState();
900 903 };
... ... @@ -902,7 +905,7 @@ namespace Hantek {
902 905 //////////////////////////////////////////////////////////////////////////////
903 906 /// \class BulkResponseGetCaptureState hantek/types.h
904 907 /// \brief The parser for the BULK_GETCAPTURESTATE response.
905   - class BulkResponseGetCaptureState : public Helper::DataArray<unsigned char> {
  908 + class BulkResponseGetCaptureState : public Helper::DataArray<uint8_t> {
906 909 public:
907 910 BulkResponseGetCaptureState();
908 911  
... ... @@ -913,13 +916,13 @@ namespace Hantek {
913 916 //////////////////////////////////////////////////////////////////////////////
914 917 /// \class BulkSetGain hantek/types.h
915 918 /// \brief The BULK_SETGAIN builder.
916   - class BulkSetGain : public Helper::DataArray<unsigned char> {
  919 + class BulkSetGain : public Helper::DataArray<uint8_t> {
917 920 public:
918 921 BulkSetGain();
919   - BulkSetGain(unsigned char channel1, unsigned char channel2);
  922 + BulkSetGain(uint8_t channel1, uint8_t channel2);
920 923  
921   - unsigned char getGain(unsigned int channel);
922   - void setGain(unsigned int channel, unsigned char value);
  924 + uint8_t getGain(unsigned int channel);
  925 + void setGain(unsigned int channel, uint8_t value);
923 926  
924 927 private:
925 928 void init();
... ... @@ -928,13 +931,13 @@ namespace Hantek {
928 931 //////////////////////////////////////////////////////////////////////////////
929 932 /// \class BulkSetLogicalData hantek/types.h
930 933 /// \brief The BULK_SETLOGICALDATA builder.
931   - class BulkSetLogicalData : public Helper::DataArray<unsigned char> {
  934 + class BulkSetLogicalData : public Helper::DataArray<uint8_t> {
932 935 public:
933 936 BulkSetLogicalData();
934   - BulkSetLogicalData(unsigned char data);
  937 + BulkSetLogicalData(uint8_t data);
935 938  
936   - unsigned char getData();
937   - void setData(unsigned char data);
  939 + uint8_t getData();
  940 + void setData(uint8_t data);
938 941  
939 942 private:
940 943 void init();
... ... @@ -943,7 +946,7 @@ namespace Hantek {
943 946 //////////////////////////////////////////////////////////////////////////////
944 947 /// \class BulkGetLogicalData hantek/types.h
945 948 /// \brief The BULK_GETLOGICALDATA builder.
946   - class BulkGetLogicalData : public Helper::DataArray<unsigned char> {
  949 + class BulkGetLogicalData : public Helper::DataArray<uint8_t> {
947 950 public:
948 951 BulkGetLogicalData();
949 952 };
... ... @@ -951,13 +954,13 @@ namespace Hantek {
951 954 //////////////////////////////////////////////////////////////////////////////
952 955 /// \class BulkSetChannels2250 hantek/types.h
953 956 /// \brief The DSO-2250 BULK_BSETFILTER builder.
954   - class BulkSetChannels2250 : public Helper::DataArray<unsigned char> {
  957 + class BulkSetChannels2250 : public Helper::DataArray<uint8_t> {
955 958 public:
956 959 BulkSetChannels2250();
957   - BulkSetChannels2250(unsigned char usedChannels);
  960 + BulkSetChannels2250(uint8_t usedChannels);
958 961  
959   - unsigned char getUsedChannels();
960   - void setUsedChannels(unsigned char value);
  962 + uint8_t getUsedChannels();
  963 + void setUsedChannels(uint8_t value);
961 964  
962 965 private:
963 966 void init();
... ... @@ -966,15 +969,15 @@ namespace Hantek {
966 969 //////////////////////////////////////////////////////////////////////////////
967 970 /// \class BulkSetTrigger2250 hantek/types.h
968 971 /// \brief The DSO-2250 BULK_CSETTRIGGERORSAMPLERATE builder.
969   - class BulkSetTrigger2250 : public Helper::DataArray<unsigned char> {
  972 + class BulkSetTrigger2250 : public Helper::DataArray<uint8_t> {
970 973 public:
971 974 BulkSetTrigger2250();
972   - BulkSetTrigger2250(unsigned char triggerSource, unsigned char triggerSlope);
  975 + BulkSetTrigger2250(uint8_t triggerSource, uint8_t triggerSlope);
973 976  
974   - unsigned char getTriggerSource();
975   - void setTriggerSource(unsigned char value);
976   - unsigned char getTriggerSlope();
977   - void setTriggerSlope(unsigned char slope);
  977 + uint8_t getTriggerSource();
  978 + void setTriggerSource(uint8_t value);
  979 + uint8_t getTriggerSlope();
  980 + void setTriggerSlope(uint8_t slope);
978 981  
979 982 private:
980 983 void init();
... ... @@ -983,15 +986,15 @@ namespace Hantek {
983 986 //////////////////////////////////////////////////////////////////////////////
984 987 /// \class BulkSetSamplerate5200 hantek/types.h
985 988 /// \brief The DSO-5200/DSO-5200A BULK_CSETTRIGGERORSAMPLERATE builder.
986   - class BulkSetSamplerate5200 : public Helper::DataArray<unsigned char> {
  989 + class BulkSetSamplerate5200 : public Helper::DataArray<uint8_t> {
987 990 public:
988 991 BulkSetSamplerate5200();
989   - BulkSetSamplerate5200(unsigned short int samplerateSlow, unsigned char samplerateFast);
  992 + BulkSetSamplerate5200(uint16_t samplerateSlow, uint8_t samplerateFast);
990 993  
991   - unsigned char getSamplerateFast();
992   - void setSamplerateFast(unsigned char value);
993   - unsigned short int getSamplerateSlow();
994   - void setSamplerateSlow(unsigned short int samplerate);
  994 + uint8_t getSamplerateFast();
  995 + void setSamplerateFast(uint8_t value);
  996 + uint16_t getSamplerateSlow();
  997 + void setSamplerateSlow(uint16_t samplerate);
995 998  
996 999 private:
997 1000 void init();
... ... @@ -1000,13 +1003,13 @@ namespace Hantek {
1000 1003 //////////////////////////////////////////////////////////////////////////////
1001 1004 /// \class BulkSetRecordLength2250 hantek/types.h
1002 1005 /// \brief The DSO-2250 BULK_DSETBUFFER builder.
1003   - class BulkSetRecordLength2250 : public Helper::DataArray<unsigned char> {
  1006 + class BulkSetRecordLength2250 : public Helper::DataArray<uint8_t> {
1004 1007 public:
1005 1008 BulkSetRecordLength2250();
1006   - BulkSetRecordLength2250(unsigned char recordLength);
  1009 + BulkSetRecordLength2250(uint8_t recordLength);
1007 1010  
1008   - unsigned char getRecordLength();
1009   - void setRecordLength(unsigned char value);
  1011 + uint8_t getRecordLength();
  1012 + void setRecordLength(uint8_t value);
1010 1013  
1011 1014 private:
1012 1015 void init();
... ... @@ -1015,21 +1018,21 @@ namespace Hantek {
1015 1018 //////////////////////////////////////////////////////////////////////////////
1016 1019 /// \class BulkSetBuffer5200 hantek/types.h
1017 1020 /// \brief The DSO-5200/DSO-5200A BULK_DSETBUFFER builder.
1018   - class BulkSetBuffer5200 : public Helper::DataArray<unsigned char> {
  1021 + class BulkSetBuffer5200 : public Helper::DataArray<uint8_t> {
1019 1022 public:
1020 1023 BulkSetBuffer5200();
1021   - BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre = 0, unsigned char usedPost = 0, unsigned char recordLength = 0);
  1024 + BulkSetBuffer5200(uint16_t triggerPositionPre, uint16_t triggerPositionPost, uint8_t usedPre = 0, uint8_t usedPost = 0, uint8_t recordLength = 0);
1022 1025  
1023   - unsigned short int getTriggerPositionPre();
1024   - void setTriggerPositionPre(unsigned short int value);
1025   - unsigned short int getTriggerPositionPost();
1026   - void setTriggerPositionPost(unsigned short int value);
1027   - unsigned char getUsedPre();
1028   - void setUsedPre(unsigned char value);
1029   - unsigned char getUsedPost();
1030   - void setUsedPost(unsigned char value);
1031   - unsigned char getRecordLength();
1032   - void setRecordLength(unsigned char value);
  1026 + uint16_t getTriggerPositionPre();
  1027 + void setTriggerPositionPre(uint16_t value);
  1028 + uint16_t getTriggerPositionPost();
  1029 + void setTriggerPositionPost(uint16_t value);
  1030 + uint8_t getUsedPre();
  1031 + void setUsedPre(uint8_t value);
  1032 + uint8_t getUsedPost();
  1033 + void setUsedPost(uint8_t value);
  1034 + uint8_t getRecordLength();
  1035 + void setRecordLength(uint8_t value);
1033 1036  
1034 1037 private:
1035 1038 void init();
... ... @@ -1038,17 +1041,17 @@ namespace Hantek {
1038 1041 //////////////////////////////////////////////////////////////////////////////
1039 1042 /// \class BulkSetSamplerate2250 hantek/types.h
1040 1043 /// \brief The DSO-2250 BULK_ESETTRIGGERORSAMPLERATE builder.
1041   - class BulkSetSamplerate2250 : public Helper::DataArray<unsigned char> {
  1044 + class BulkSetSamplerate2250 : public Helper::DataArray<uint8_t> {
1042 1045 public:
1043 1046 BulkSetSamplerate2250();
1044   - BulkSetSamplerate2250(bool fastRate, bool downsampling = false, unsigned short int samplerate = 0);
  1047 + BulkSetSamplerate2250(bool fastRate, bool downsampling = false, uint16_t samplerate = 0);
1045 1048  
1046 1049 bool getFastRate();
1047 1050 void setFastRate(bool fastRate);
1048 1051 bool getDownsampling();
1049 1052 void setDownsampling(bool downsampling);
1050   - unsigned short int getSamplerate();
1051   - void setSamplerate(unsigned short int samplerate);
  1053 + uint16_t getSamplerate();
  1054 + void setSamplerate(uint16_t samplerate);
1052 1055  
1053 1056 private:
1054 1057 void init();
... ... @@ -1057,19 +1060,19 @@ namespace Hantek {
1057 1060 //////////////////////////////////////////////////////////////////////////////
1058 1061 /// \class BulkSetTrigger5200 hantek/types.h
1059 1062 /// \brief The DSO-5200/DSO-5200A BULK_ESETTRIGGERORSAMPLERATE builder.
1060   - class BulkSetTrigger5200 : public Helper::DataArray<unsigned char> {
  1063 + class BulkSetTrigger5200 : public Helper::DataArray<uint8_t> {
1061 1064 public:
1062 1065 BulkSetTrigger5200();
1063   - BulkSetTrigger5200(unsigned char triggerSource, unsigned char usedChannels, bool fastRate = false, unsigned char triggerSlope = 0, unsigned char triggerPulse = 0);
  1066 + BulkSetTrigger5200(uint8_t triggerSource, uint8_t usedChannels, bool fastRate = false, uint8_t triggerSlope = 0, uint8_t triggerPulse = 0);
1064 1067  
1065   - unsigned char getTriggerSource();
1066   - void setTriggerSource(unsigned char value);
1067   - unsigned char getUsedChannels();
1068   - void setUsedChannels(unsigned char value);
  1068 + uint8_t getTriggerSource();
  1069 + void setTriggerSource(uint8_t value);
  1070 + uint8_t getUsedChannels();
  1071 + void setUsedChannels(uint8_t value);
1069 1072 bool getFastRate();
1070 1073 void setFastRate(bool fastRate);
1071   - unsigned char getTriggerSlope();
1072   - void setTriggerSlope(unsigned char slope);
  1074 + uint8_t getTriggerSlope();
  1075 + void setTriggerSlope(uint8_t slope);
1073 1076 bool getTriggerPulse();
1074 1077 void setTriggerPulse(bool pulse);
1075 1078  
... ... @@ -1080,15 +1083,15 @@ namespace Hantek {
1080 1083 //////////////////////////////////////////////////////////////////////////////
1081 1084 /// \class BulkSetBuffer2250 hantek/types.h
1082 1085 /// \brief The DSO-2250 BULK_FSETBUFFER builder.
1083   - class BulkSetBuffer2250 : public Helper::DataArray<unsigned char> {
  1086 + class BulkSetBuffer2250 : public Helper::DataArray<uint8_t> {
1084 1087 public:
1085 1088 BulkSetBuffer2250();
1086   - BulkSetBuffer2250(unsigned long int triggerPositionPre, unsigned long int triggerPositionPost);
  1089 + BulkSetBuffer2250(uint32_t triggerPositionPre, uint32_t triggerPositionPost);
1087 1090  
1088   - unsigned long int getTriggerPositionPost();
1089   - void setTriggerPositionPost(unsigned long int value);
1090   - unsigned long int getTriggerPositionPre();
1091   - void setTriggerPositionPre(unsigned long int value);
  1091 + uint32_t getTriggerPositionPost();
  1092 + void setTriggerPositionPost(uint32_t value);
  1093 + uint32_t getTriggerPositionPre();
  1094 + void setTriggerPositionPre(uint32_t value);
1092 1095  
1093 1096 private:
1094 1097 void init();
... ... @@ -1097,7 +1100,7 @@ namespace Hantek {
1097 1100 //////////////////////////////////////////////////////////////////////////////
1098 1101 /// \class ControlGetSpeed hantek/types.h
1099 1102 /// \brief The CONTROL_GETSPEED parser.
1100   - class ControlGetSpeed : public Helper::DataArray<unsigned char> {
  1103 + class ControlGetSpeed : public Helper::DataArray<uint8_t> {
1101 1104 public:
1102 1105 ControlGetSpeed();
1103 1106  
... ... @@ -1107,7 +1110,7 @@ namespace Hantek {
1107 1110 //////////////////////////////////////////////////////////////////////////////
1108 1111 /// \class ControlBeginCommand hantek/types.h
1109 1112 /// \brief The CONTROL_BEGINCOMMAND builder.
1110   - class ControlBeginCommand : public Helper::DataArray<unsigned char> {
  1113 + class ControlBeginCommand : public Helper::DataArray<uint8_t> {
1111 1114 public:
1112 1115 ControlBeginCommand(BulkIndex index = COMMANDINDEX_0);
1113 1116  
... ... @@ -1121,15 +1124,15 @@ namespace Hantek {
1121 1124 //////////////////////////////////////////////////////////////////////////////
1122 1125 /// \class ControlSetOffset hantek/types.h
1123 1126 /// \brief The CONTROL_SETOFFSET builder.
1124   - class ControlSetOffset : public Helper::DataArray<unsigned char> {
  1127 + class ControlSetOffset : public Helper::DataArray<uint8_t> {
1125 1128 public:
1126 1129 ControlSetOffset();
1127   - ControlSetOffset(unsigned short int channel1, unsigned short int channel2, unsigned short int trigger);
  1130 + ControlSetOffset(uint16_t channel1, uint16_t channel2, uint16_t trigger);
1128 1131  
1129   - unsigned short int getChannel(unsigned int channel);
1130   - void setChannel(unsigned int channel, unsigned short int offset);
1131   - unsigned short int getTrigger();
1132   - void setTrigger(unsigned short int level);
  1132 + uint16_t getChannel(unsigned int channel);
  1133 + void setChannel(unsigned int channel, uint16_t offset);
  1134 + uint16_t getTrigger();
  1135 + void setTrigger(uint16_t level);
1133 1136  
1134 1137 private:
1135 1138 void init();
... ... @@ -1138,7 +1141,7 @@ namespace Hantek {
1138 1141 //////////////////////////////////////////////////////////////////////////////
1139 1142 /// \class ControlSetRelays hantek/types.h
1140 1143 /// \brief The CONTROL_SETRELAYS builder.
1141   - class ControlSetRelays : public Helper::DataArray<unsigned char> {
  1144 + class ControlSetRelays : public Helper::DataArray<uint8_t> {
1142 1145 public:
1143 1146 ControlSetRelays(bool ch1Below1V = false, bool ch1Below100mV = false, bool ch1CouplingDC = false, bool ch2Below1V = false, bool ch2Below100mV = false, bool ch2CouplingDC = false, bool triggerExt = false);
1144 1147  
... ...
openhantek/src/openhantek.cpp
... ... @@ -276,7 +276,7 @@ void OpenHantekMainWindow::connectSignals() {
276 276 connect(this, SIGNAL(settingsChanged()), this, SLOT(applySettings()));
277 277 //connect(this->dsoWidget, SIGNAL(stopped()), this, SLOT(stopped()));
278 278 connect(this->dsoControl, SIGNAL(statusMessage(QString, int)), this->statusBar(), SLOT(showMessage(QString, int)));
279   - connect(this->dsoControl, SIGNAL(samplesAvailable(const QList<double *> *, const QList<unsigned long int> *, double, QMutex *)), this->dataAnalyzer, SLOT(analyze(const QList<double *> *, const QList<unsigned long int> *, double, QMutex *)));
  279 + connect(this->dsoControl, SIGNAL(samplesAvailable(const QList<double *> *, const QList<unsigned int> *, double, QMutex *)), this->dataAnalyzer, SLOT(analyze(const QList<double *> *, const QList<unsigned int> *, double, QMutex *)));
280 280  
281 281 // Connect signals to DSO controller and widget
282 282 connect(this->horizontalDock, SIGNAL(samplerateChanged(double)), this, SLOT(samplerateSelected()));
... ... @@ -315,7 +315,7 @@ void OpenHantekMainWindow::connectSignals() {
315 315 connect(this->dsoControl, SIGNAL(recordTimeChanged(double)), this, SLOT(recordTimeChanged(double)));
316 316 connect(this->dsoControl, SIGNAL(samplerateChanged(double)), this, SLOT(samplerateChanged(double)));
317 317  
318   - connect(this->dsoControl, SIGNAL(availableRecordLengthsChanged(QList<unsigned long int>)), this->horizontalDock, SLOT(availableRecordLengthsChanged(QList<unsigned long int>)));
  318 + connect(this->dsoControl, SIGNAL(availableRecordLengthsChanged(QList<unsigned int>)), this->horizontalDock, SLOT(availableRecordLengthsChanged(QList<unsigned int>)));
319 319 connect(this->dsoControl, SIGNAL(samplerateLimitsChanged(double, double)), this->horizontalDock, SLOT(samplerateLimitsChanged(double, double)));
320 320 }
321 321  
... ... @@ -328,14 +328,14 @@ void OpenHantekMainWindow::initializeDevice() {
328 328 this->dsoControl->setTriggerLevel(channel, this->settings->scope.voltage[channel].trigger);
329 329 }
330 330 this->updateUsed(this->settings->scope.physicalChannels);
331   - if(this->dsoControl->getAvailableRecordLengths()->isEmpty())
332   - this->dsoControl->setRecordLength(this->settings->scope.horizontal.recordLength);
333   - else
334   - this->dsoControl->setRecordLength(this->dsoControl->getAvailableRecordLengths()->indexOf(this->settings->scope.horizontal.recordLength));
335 331 if(this->settings->scope.horizontal.samplerateSet)
336 332 this->samplerateSelected();
337 333 else
338 334 this->timebaseSelected();
  335 + if(this->dsoControl->getAvailableRecordLengths()->isEmpty())
  336 + this->dsoControl->setRecordLength(this->settings->scope.horizontal.recordLength);
  337 + else
  338 + this->dsoControl->setRecordLength(this->dsoControl->getAvailableRecordLengths()->indexOf(this->settings->scope.horizontal.recordLength));
339 339 this->dsoControl->setTriggerMode(this->settings->scope.trigger.mode);
340 340 this->dsoControl->setPretriggerPosition(this->settings->scope.trigger.position * this->settings->scope.horizontal.timebase * DIVS_TIME);
341 341 this->dsoControl->setTriggerSlope(this->settings->scope.trigger.slope);
... ...
openhantek/src/settings.cpp
... ... @@ -456,7 +456,7 @@ int DsoSettings::save(const QString &amp;fileName) {
456 456 for(int marker = 0; marker < 2; ++marker)
457 457 settingsSaver->setValue(QString("marker%1").arg(marker), this->scope.horizontal.marker[marker]);
458 458 settingsSaver->setValue("timebase", this->scope.horizontal.timebase);
459   - settingsSaver->setValue("recordLength", (unsigned int) this->scope.horizontal.recordLength);
  459 + settingsSaver->setValue("recordLength", this->scope.horizontal.recordLength);
460 460 settingsSaver->setValue("samplerate", this->scope.horizontal.samplerate);
461 461 settingsSaver->setValue("samplerateSet", this->scope.horizontal.samplerateSet);
462 462 settingsSaver->endGroup();
... ...
openhantek/src/settings.h
... ... @@ -93,7 +93,7 @@ struct DsoSettingsScopeHorizontal {
93 93 double frequencybase; ///< Frequencybase in Hz/div
94 94 double marker[2]; ///< Marker positions in div
95 95 double timebase; ///< Timebase in s/div
96   - unsigned long int recordLength; ///< Sample count
  96 + unsigned int recordLength; ///< Sample count
97 97 double samplerate; ///< The samplerate of the oscilloscope in S
98 98 bool samplerateSet; ///< The samplerate was set by the user, not the timebase
99 99 };
... ...