Commit 8b8ee5adafdc33b5dbd47ed98c334d84921c1519
1 parent
e0817938
Fixes for DSO-2250 problems
Showing
7 changed files
with
87 additions
and
93 deletions
openhantek/ChangeLog
| @@ -151,3 +151,10 @@ | @@ -151,3 +151,10 @@ | ||
| 151 | 2012-09-21 Oliver Haag <oliver.haag@gmail.com> | 151 | 2012-09-21 Oliver Haag <oliver.haag@gmail.com> |
| 152 | * Bugfix: Uninitialized bulk command pointer for BULK_FSETBUFFER | 152 | * Bugfix: Uninitialized bulk command pointer for BULK_FSETBUFFER |
| 153 | * Bugfix: Slot setTriggerPosition wasn't renamed | 153 | * Bugfix: Slot setTriggerPosition wasn't renamed |
| 154 | + | ||
| 155 | +2012-10-01 Oliver Haag <oliver.haag@gmail.com> | ||
| 156 | +* Bugfix: Wrong bit mask for extra bits in Hantek::Control::getData | ||
| 157 | + | ||
| 158 | +2012-10-02 Oliver Haag <oliver.haag@gmail.com> | ||
| 159 | +* Bugfix: Hantek::Control redesign missing for used channels | ||
| 160 | +* Bugfix: Always check DataAnalyzer::data for null pointer |
openhantek/src/dsowidget.cpp
| @@ -482,7 +482,7 @@ void DsoWidget::updateZoom(bool enabled) { | @@ -482,7 +482,7 @@ void DsoWidget::updateZoom(bool enabled) { | ||
| 482 | /// \brief Prints analyzed data. | 482 | /// \brief Prints analyzed data. |
| 483 | void DsoWidget::dataAnalyzed() { | 483 | void DsoWidget::dataAnalyzed() { |
| 484 | for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 484 | for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { |
| 485 | - if(this->settings->scope.voltage[channel].used) { | 485 | + if(this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)) { |
| 486 | // Amplitude string representation (4 significant digits) | 486 | // Amplitude string representation (4 significant digits) |
| 487 | this->measurementAmplitudeLabel[channel]->setText(Helper::valueToString(this->dataAnalyzer->data(channel)->amplitude, Helper::UNIT_VOLTS, 4)); | 487 | this->measurementAmplitudeLabel[channel]->setText(Helper::valueToString(this->dataAnalyzer->data(channel)->amplitude, Helper::UNIT_VOLTS, 4)); |
| 488 | // Frequency string representation (5 significant digits) | 488 | // Frequency string representation (5 significant digits) |
openhantek/src/exporter.cpp
| @@ -141,7 +141,7 @@ bool Exporter::doExport() { | @@ -141,7 +141,7 @@ bool Exporter::doExport() { | ||
| 141 | stretchBase = (double) (paintDevice->width() - lineHeight * 6) / 10; | 141 | stretchBase = (double) (paintDevice->width() - lineHeight * 6) / 10; |
| 142 | int channelCount = 0; | 142 | int channelCount = 0; |
| 143 | for(int channel = this->settings->scope.voltage.count() - 1; channel >= 0; channel--) { | 143 | for(int channel = this->settings->scope.voltage.count() - 1; channel >= 0; channel--) { |
| 144 | - if(this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) { | 144 | + if((this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel)) { |
| 145 | channelCount++; | 145 | channelCount++; |
| 146 | double top = (double) paintDevice->height() - channelCount * lineHeight; | 146 | double top = (double) paintDevice->height() - channelCount * lineHeight; |
| 147 | 147 | ||
| @@ -213,7 +213,7 @@ bool Exporter::doExport() { | @@ -213,7 +213,7 @@ bool Exporter::doExport() { | ||
| 213 | case Dso::GRAPHFORMAT_TY: | 213 | case Dso::GRAPHFORMAT_TY: |
| 214 | // Add graphs for channels | 214 | // Add graphs for channels |
| 215 | for(int channel = 0 ; channel < this->settings->scope.voltage.count(); channel++) { | 215 | for(int channel = 0 ; channel < this->settings->scope.voltage.count(); channel++) { |
| 216 | - if(this->settings->scope.voltage[channel].used) { | 216 | + if(this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)) { |
| 217 | painter.setPen(colorValues->voltage[channel]); | 217 | painter.setPen(colorValues->voltage[channel]); |
| 218 | 218 | ||
| 219 | // What's the horizontal distance between sampling points? | 219 | // What's the horizontal distance between sampling points? |
| @@ -241,7 +241,7 @@ bool Exporter::doExport() { | @@ -241,7 +241,7 @@ bool Exporter::doExport() { | ||
| 241 | 241 | ||
| 242 | // Add spectrum graphs | 242 | // Add spectrum graphs |
| 243 | for (int channel = 0; channel < this->settings->scope.spectrum.count(); channel++) { | 243 | for (int channel = 0; channel < this->settings->scope.spectrum.count(); channel++) { |
| 244 | - if(this->settings->scope.spectrum[channel].used) { | 244 | + if(this->settings->scope.spectrum[channel].used && this->dataAnalyzer->data(channel)) { |
| 245 | painter.setPen(colorValues->spectrum[channel]); | 245 | painter.setPen(colorValues->spectrum[channel]); |
| 246 | 246 | ||
| 247 | // What's the horizontal distance between sampling points? | 247 | // What's the horizontal distance between sampling points? |
| @@ -366,28 +366,30 @@ bool Exporter::doExport() { | @@ -366,28 +366,30 @@ bool Exporter::doExport() { | ||
| 366 | QTextStream csvStream(&csvFile); | 366 | QTextStream csvStream(&csvFile); |
| 367 | 367 | ||
| 368 | for(int channel = 0 ; channel < this->settings->scope.voltage.count(); channel++) { | 368 | for(int channel = 0 ; channel < this->settings->scope.voltage.count(); channel++) { |
| 369 | - if(this->settings->scope.voltage[channel].used) { | ||
| 370 | - // Start with channel name and the sample interval | ||
| 371 | - csvStream << "\"" << this->settings->scope.voltage[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.voltage.interval; | ||
| 372 | - | ||
| 373 | - // And now all sample values in volts | ||
| 374 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; position++) | ||
| 375 | - csvStream << "," << this->dataAnalyzer->data(channel)->samples.voltage.sample[position]; | ||
| 376 | - | ||
| 377 | - // Finally a newline | ||
| 378 | - csvStream << '\n'; | ||
| 379 | - } | ||
| 380 | - | ||
| 381 | - if(this->settings->scope.spectrum[channel].used) { | ||
| 382 | - // Start with channel name and the sample interval | ||
| 383 | - csvStream << "\"" << this->settings->scope.spectrum[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.spectrum.interval; | ||
| 384 | - | ||
| 385 | - // And now all magnitudes in dB | ||
| 386 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; position++) | ||
| 387 | - csvStream << "," << this->dataAnalyzer->data(channel)->samples.spectrum.sample[position]; | 369 | + if(this->dataAnalyzer->data(channel)) { |
| 370 | + if(this->settings->scope.voltage[channel].used) { | ||
| 371 | + // Start with channel name and the sample interval | ||
| 372 | + csvStream << "\"" << this->settings->scope.voltage[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.voltage.interval; | ||
| 373 | + | ||
| 374 | + // And now all sample values in volts | ||
| 375 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; position++) | ||
| 376 | + csvStream << "," << this->dataAnalyzer->data(channel)->samples.voltage.sample[position]; | ||
| 377 | + | ||
| 378 | + // Finally a newline | ||
| 379 | + csvStream << '\n'; | ||
| 380 | + } | ||
| 388 | 381 | ||
| 389 | - // Finally a newline | ||
| 390 | - csvStream << '\n'; | 382 | + if(this->settings->scope.spectrum[channel].used) { |
| 383 | + // Start with channel name and the sample interval | ||
| 384 | + csvStream << "\"" << this->settings->scope.spectrum[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.spectrum.interval; | ||
| 385 | + | ||
| 386 | + // And now all magnitudes in dB | ||
| 387 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; position++) | ||
| 388 | + csvStream << "," << this->dataAnalyzer->data(channel)->samples.spectrum.sample[position]; | ||
| 389 | + | ||
| 390 | + // Finally a newline | ||
| 391 | + csvStream << '\n'; | ||
| 392 | + } | ||
| 391 | } | 393 | } |
| 392 | } | 394 | } |
| 393 | 395 |
openhantek/src/glgenerator.cpp
| @@ -142,7 +142,7 @@ void GlGenerator::generateGraphs() { | @@ -142,7 +142,7 @@ void GlGenerator::generateGraphs() { | ||
| 142 | for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | 142 | for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { |
| 143 | for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 143 | for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { |
| 144 | // Check if this channel is used and available at the data analyzer | 144 | // Check if this channel is used and available at the data analyzer |
| 145 | - if(((mode == Dso::CHANNELMODE_VOLTAGE) ? this->settings->scope.voltage[channel].used : this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel)->samples.voltage.sample) { | 145 | + if(((mode == Dso::CHANNELMODE_VOLTAGE) ? this->settings->scope.voltage[channel].used : this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel) && this->dataAnalyzer->data(channel)->samples.voltage.sample) { |
| 146 | // Check if the sample count has changed | 146 | // Check if the sample count has changed |
| 147 | unsigned int neededSize = ((mode == Dso::CHANNELMODE_VOLTAGE) ? this->dataAnalyzer->data(channel)->samples.voltage.count : this->dataAnalyzer->data(channel)->samples.spectrum.count) * 2; | 147 | unsigned int neededSize = ((mode == Dso::CHANNELMODE_VOLTAGE) ? this->dataAnalyzer->data(channel)->samples.voltage.count : this->dataAnalyzer->data(channel)->samples.spectrum.count) * 2; |
| 148 | for(int index = 0; index < this->digitalPhosphorDepth; index++) { | 148 | for(int index = 0; index < this->digitalPhosphorDepth; index++) { |
| @@ -190,7 +190,7 @@ void GlGenerator::generateGraphs() { | @@ -190,7 +190,7 @@ void GlGenerator::generateGraphs() { | ||
| 190 | case Dso::GRAPHFORMAT_XY: | 190 | case Dso::GRAPHFORMAT_XY: |
| 191 | for(int channel = 0; channel < this->settings->scope.voltage.count(); channel ++) { | 191 | for(int channel = 0; channel < this->settings->scope.voltage.count(); channel ++) { |
| 192 | // For even channel numbers check if this channel is used and this and the following channel are available at the data analyzer | 192 | // For even channel numbers check if this channel is used and this and the following channel are available at the data analyzer |
| 193 | - if(channel % 2 == 0 && channel + 1 < this->settings->scope.voltage.count() && this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)->samples.voltage.sample && this->dataAnalyzer->data(channel + 1)->samples.voltage.sample) { | 193 | + if(channel % 2 == 0 && channel + 1 < this->settings->scope.voltage.count() && this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel) && this->dataAnalyzer->data(channel)->samples.voltage.sample && this->dataAnalyzer->data(channel + 1) && this->dataAnalyzer->data(channel + 1)->samples.voltage.sample) { |
| 194 | // Check if the sample count has changed | 194 | // Check if the sample count has changed |
| 195 | unsigned int neededSize = qMin(this->dataAnalyzer->data(channel)->samples.voltage.count, this->dataAnalyzer->data(channel + 1)->samples.voltage.count) * 2; | 195 | unsigned int neededSize = qMin(this->dataAnalyzer->data(channel)->samples.voltage.count, this->dataAnalyzer->data(channel + 1)->samples.voltage.count) * 2; |
| 196 | for(int index = 0; index < this->digitalPhosphorDepth; index++) { | 196 | for(int index = 0; index < this->digitalPhosphorDepth; index++) { |
openhantek/src/hantek/control.cpp
| @@ -322,11 +322,8 @@ namespace Hantek { | @@ -322,11 +322,8 @@ namespace Hantek { | ||
| 322 | // Save raw data to temporary buffer | 322 | // Save raw data to temporary buffer |
| 323 | unsigned int dataCount = this->specification.recordLengths[this->settings.recordLengthId] * HANTEK_CHANNELS; | 323 | unsigned int dataCount = this->specification.recordLengths[this->settings.recordLengthId] * HANTEK_CHANNELS; |
| 324 | unsigned int dataLength = dataCount; | 324 | unsigned int dataLength = dataCount; |
| 325 | - bool using10Bits = false; | ||
| 326 | - if(this->device->getModel() == MODEL_DSO5200 || this->device->getModel() == MODEL_DSO5200A) { | ||
| 327 | - using10Bits = true; | 325 | + if(this->specification.sampleSize > 8) |
| 328 | dataLength *= 2; | 326 | dataLength *= 2; |
| 329 | - } | ||
| 330 | 327 | ||
| 331 | unsigned char data[dataLength]; | 328 | unsigned char data[dataLength]; |
| 332 | errorCode = this->device->bulkReadMulti(data, dataLength); | 329 | errorCode = this->device->bulkReadMulti(data, dataLength); |
| @@ -337,44 +334,21 @@ namespace Hantek { | @@ -337,44 +334,21 @@ namespace Hantek { | ||
| 337 | if(process) { | 334 | if(process) { |
| 338 | // How much data did we really receive? | 335 | // How much data did we really receive? |
| 339 | dataLength = errorCode; | 336 | dataLength = errorCode; |
| 340 | - if(using10Bits) | 337 | + if(this->specification.sampleSize > 8) |
| 341 | dataCount = dataLength / 2; | 338 | dataCount = dataLength / 2; |
| 342 | else | 339 | else |
| 343 | dataCount = dataLength; | 340 | dataCount = dataLength; |
| 344 | 341 | ||
| 345 | this->samplesMutex.lock(); | 342 | this->samplesMutex.lock(); |
| 346 | 343 | ||
| 347 | - // Get oscilloscope settings | ||
| 348 | - bool fastRate = false; | ||
| 349 | - UsedChannels usedChannels = USED_NONE; | ||
| 350 | - switch(this->specification.command.bulk.setTrigger) { | ||
| 351 | - case BULK_SETTRIGGERANDSAMPLERATE: | ||
| 352 | - fastRate = ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getFastRate(); | ||
| 353 | - usedChannels = (UsedChannels) ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getUsedChannels(); | ||
| 354 | - break; | ||
| 355 | - | ||
| 356 | - case BULK_CSETTRIGGERORSAMPLERATE: | ||
| 357 | - fastRate = ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getFastRate(); | ||
| 358 | - usedChannels = (UsedChannels) ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getUsedChannels(); | ||
| 359 | - break; | ||
| 360 | - | ||
| 361 | - case BULK_ESETTRIGGERORSAMPLERATE: | ||
| 362 | - fastRate = ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getFastRate(); | ||
| 363 | - usedChannels = (UsedChannels) ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getUsedChannels(); | ||
| 364 | - break; | ||
| 365 | - | ||
| 366 | - default: | ||
| 367 | - break; | ||
| 368 | - } | ||
| 369 | - | ||
| 370 | // Convert channel data | 344 | // Convert channel data |
| 371 | - if(fastRate) { | 345 | + if(this->settings.samplerate.limits == &this->specification.samplerate.single) { |
| 372 | // Fast rate mode, one channel is using all buffers | 346 | // Fast rate mode, one channel is using all buffers |
| 373 | - int channel; | ||
| 374 | - if(usedChannels == USED_CH1) | ||
| 375 | - channel = 0; | ||
| 376 | - else | ||
| 377 | - channel = 1; | 347 | + int channel = 0; |
| 348 | + for(; channel < HANTEK_CHANNELS; ++channel) { | ||
| 349 | + if(this->settings.voltage[0].used) | ||
| 350 | + break; | ||
| 351 | + } | ||
| 378 | 352 | ||
| 379 | // Clear unused channels | 353 | // Clear unused channels |
| 380 | for(int channelCounter = 0; channelCounter < HANTEK_CHANNELS; channelCounter++) | 354 | for(int channelCounter = 0; channelCounter < HANTEK_CHANNELS; channelCounter++) |
| @@ -395,9 +369,11 @@ namespace Hantek { | @@ -395,9 +369,11 @@ namespace Hantek { | ||
| 395 | 369 | ||
| 396 | // Convert data from the oscilloscope and write it into the sample buffer | 370 | // Convert data from the oscilloscope and write it into the sample buffer |
| 397 | unsigned int bufferPosition = (this->settings.trigger.point + 1) * 2; | 371 | unsigned int bufferPosition = (this->settings.trigger.point + 1) * 2; |
| 398 | - if(using10Bits) { | ||
| 399 | - // Additional 2 most significant bits after the normal data | 372 | + if(this->specification.sampleSize > 8) { |
| 373 | + // Additional most significant bits after the normal data | ||
| 400 | unsigned int extraBitsPosition; // Track the position of the extra bits in the additional byte | 374 | unsigned int extraBitsPosition; // Track the position of the extra bits in the additional byte |
| 375 | + unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits | ||
| 376 | + unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction | ||
| 401 | 377 | ||
| 402 | for(unsigned int realPosition = 0; realPosition < dataCount; realPosition++, bufferPosition++) { | 378 | for(unsigned int realPosition = 0; realPosition < dataCount; realPosition++, bufferPosition++) { |
| 403 | if(bufferPosition >= dataCount) | 379 | if(bufferPosition >= dataCount) |
| @@ -405,7 +381,7 @@ namespace Hantek { | @@ -405,7 +381,7 @@ namespace Hantek { | ||
| 405 | 381 | ||
| 406 | extraBitsPosition = bufferPosition % HANTEK_CHANNELS; | 382 | extraBitsPosition = bufferPosition % HANTEK_CHANNELS; |
| 407 | 383 | ||
| 408 | - this->samples[channel][realPosition] = ((double) ((unsigned short int) data[bufferPosition] + (((unsigned short int) data[dataCount + bufferPosition - extraBitsPosition] << (8 - (HANTEK_CHANNELS - 1 - extraBitsPosition) * 2)) & 0x0200)) / this->specification.voltageLimit[HANTEK_CHANNELS - 1 - extraBitsPosition][this->settings.voltage[channel].gain] - this->settings.voltage[channel].offsetReal) * this->specification.gainSteps[this->settings.voltage[channel].gain]; | 384 | + this->samples[channel][realPosition] = ((double) ((unsigned short int) data[bufferPosition] + (((unsigned short int) data[dataCount + bufferPosition - extraBitsPosition] << (8 - (HANTEK_CHANNELS - 1 - extraBitsPosition) * extraBitsSize)) & extraBitsMask)) / this->specification.voltageLimit[channel][this->settings.voltage[channel].gain] - this->settings.voltage[channel].offsetReal) * this->specification.gainSteps[this->settings.voltage[channel].gain]; |
| 409 | } | 385 | } |
| 410 | } | 386 | } |
| 411 | else { | 387 | else { |
| @@ -423,7 +399,7 @@ namespace Hantek { | @@ -423,7 +399,7 @@ namespace Hantek { | ||
| 423 | unsigned int channelDataCount = dataCount / HANTEK_CHANNELS; | 399 | unsigned int channelDataCount = dataCount / HANTEK_CHANNELS; |
| 424 | 400 | ||
| 425 | for(int channel = 0; channel < HANTEK_CHANNELS; channel++) { | 401 | for(int channel = 0; channel < HANTEK_CHANNELS; channel++) { |
| 426 | - if(usedChannels == USED_CH1CH2 || channel == usedChannels) { | 402 | + if(this->settings.voltage[channel].used) { |
| 427 | // Reallocate memory for samples if the sample count has changed | 403 | // Reallocate memory for samples if the sample count has changed |
| 428 | if(!this->samples[channel] || this->samplesSize[channel] != channelDataCount) { | 404 | if(!this->samples[channel] || this->samplesSize[channel] != channelDataCount) { |
| 429 | if(this->samples[channel]) | 405 | if(this->samples[channel]) |
| @@ -434,13 +410,17 @@ namespace Hantek { | @@ -434,13 +410,17 @@ namespace Hantek { | ||
| 434 | 410 | ||
| 435 | // Convert data from the oscilloscope and write it into the sample buffer | 411 | // Convert data from the oscilloscope and write it into the sample buffer |
| 436 | unsigned int bufferPosition = (this->settings.trigger.point + 1) * 2; | 412 | unsigned int bufferPosition = (this->settings.trigger.point + 1) * 2; |
| 437 | - if(using10Bits) { | ||
| 438 | - // Additional 2 most significant bits after the normal data | 413 | + if(this->specification.sampleSize > 8) { |
| 414 | + // Additional most significant bits after the normal data | ||
| 415 | + unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits | ||
| 416 | + unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction | ||
| 417 | + unsigned int extraBitsIndex = 8 - channel * 2; // Bit position offset for extra bits extraction | ||
| 418 | + | ||
| 439 | for(unsigned int realPosition = 0; realPosition < channelDataCount; realPosition++, bufferPosition += 2) { | 419 | for(unsigned int realPosition = 0; realPosition < channelDataCount; realPosition++, bufferPosition += 2) { |
| 440 | if(bufferPosition >= dataCount) | 420 | if(bufferPosition >= dataCount) |
| 441 | bufferPosition %= dataCount; | 421 | bufferPosition %= dataCount; |
| 442 | 422 | ||
| 443 | - this->samples[channel][realPosition] = ((double) ((unsigned short int) data[bufferPosition + HANTEK_CHANNELS - 1 - channel] + (((unsigned short int) data[dataCount + bufferPosition] << (8 - channel * 2)) & 0x0200)) / this->specification.voltageLimit[channel][this->settings.voltage[channel].gain] - this->settings.voltage[channel].offsetReal) * this->specification.gainSteps[this->settings.voltage[channel].gain]; | 423 | + this->samples[channel][realPosition] = ((double) ((unsigned short int) data[bufferPosition + HANTEK_CHANNELS - 1 - channel] + (((unsigned short int) data[dataCount + bufferPosition] << extraBitsIndex) & extraBitsMask)) / this->specification.voltageLimit[channel][this->settings.voltage[channel].gain] - this->settings.voltage[channel].offsetReal) * this->specification.gainSteps[this->settings.voltage[channel].gain]; |
| 444 | } | 424 | } |
| 445 | } | 425 | } |
| 446 | else { | 426 | else { |
| @@ -659,6 +639,7 @@ namespace Hantek { | @@ -659,6 +639,7 @@ namespace Hantek { | ||
| 659 | << 368 << 454 << 908 << 368 << 454 << 908 << 368 << 454 << 908; | 639 | << 368 << 454 << 908 << 368 << 454 << 908 << 368 << 454 << 908; |
| 660 | this->specification.gainIndex | 640 | this->specification.gainIndex |
| 661 | << 1 << 0 << 0 << 1 << 0 << 0 << 1 << 0 << 0; | 641 | << 1 << 0 << 0 << 1 << 0 << 0 << 1 << 0 << 0; |
| 642 | + this->specification.sampleSize = 10; | ||
| 662 | break; | 643 | break; |
| 663 | 644 | ||
| 664 | case MODEL_DSO2250: | 645 | case MODEL_DSO2250: |
| @@ -675,6 +656,7 @@ namespace Hantek { | @@ -675,6 +656,7 @@ namespace Hantek { | ||
| 675 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; | 656 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 676 | this->specification.gainIndex | 657 | this->specification.gainIndex |
| 677 | << 0 << 1 << 2 << 0 << 1 << 2 << 0 << 1 << 2; | 658 | << 0 << 1 << 2 << 0 << 1 << 2 << 0 << 1 << 2; |
| 659 | + this->specification.sampleSize = 8; | ||
| 678 | break; | 660 | break; |
| 679 | 661 | ||
| 680 | case MODEL_DSO2150: | 662 | case MODEL_DSO2150: |
| @@ -691,6 +673,7 @@ namespace Hantek { | @@ -691,6 +673,7 @@ namespace Hantek { | ||
| 691 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; | 673 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 692 | this->specification.gainIndex | 674 | this->specification.gainIndex |
| 693 | << 0 << 1 << 2 << 0 << 1 << 2 << 0 << 1 << 2; | 675 | << 0 << 1 << 2 << 0 << 1 << 2 << 0 << 1 << 2; |
| 676 | + this->specification.sampleSize = 8; | ||
| 694 | break; | 677 | break; |
| 695 | 678 | ||
| 696 | default: | 679 | default: |
| @@ -707,6 +690,7 @@ namespace Hantek { | @@ -707,6 +690,7 @@ namespace Hantek { | ||
| 707 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; | 690 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 708 | this->specification.gainIndex | 691 | this->specification.gainIndex |
| 709 | << 0 << 1 << 2 << 0 << 1 << 2 << 0 << 1 << 2; | 692 | << 0 << 1 << 2 << 0 << 1 << 2 << 0 << 1 << 2; |
| 693 | + this->specification.sampleSize = 8; | ||
| 710 | break; | 694 | break; |
| 711 | } | 695 | } |
| 712 | this->settings.samplerate.limits = &(this->specification.samplerate.single); | 696 | this->settings.samplerate.limits = &(this->specification.samplerate.single); |
| @@ -855,8 +839,7 @@ namespace Hantek { | @@ -855,8 +839,7 @@ namespace Hantek { | ||
| 855 | if(channel >= HANTEK_CHANNELS) | 839 | if(channel >= HANTEK_CHANNELS) |
| 856 | return Dso::ERROR_PARAMETER; | 840 | return Dso::ERROR_PARAMETER; |
| 857 | 841 | ||
| 858 | - unsigned char usedChannels = USED_CH1; | ||
| 859 | - | 842 | + // Channel filtering commands |
| 860 | switch(this->specification.command.bulk.setFilter) { | 843 | switch(this->specification.command.bulk.setFilter) { |
| 861 | case BULK_SETFILTER: { | 844 | case BULK_SETFILTER: { |
| 862 | // SetFilter bulk command for channel filter (used has to be inverted!) | 845 | // SetFilter bulk command for channel filter (used has to be inverted!) |
| @@ -864,13 +847,6 @@ namespace Hantek { | @@ -864,13 +847,6 @@ namespace Hantek { | ||
| 864 | commandSetFilter->setChannel(channel, !used); | 847 | commandSetFilter->setChannel(channel, !used); |
| 865 | this->commandPending[BULK_SETFILTER] = true; | 848 | this->commandPending[BULK_SETFILTER] = true; |
| 866 | 849 | ||
| 867 | - if(!commandSetFilter->getChannel(1)) { | ||
| 868 | - if(commandSetFilter->getChannel(0)) | ||
| 869 | - usedChannels = USED_CH2; | ||
| 870 | - else | ||
| 871 | - usedChannels = USED_CH1CH2; | ||
| 872 | - } | ||
| 873 | - | ||
| 874 | break; | 850 | break; |
| 875 | } | 851 | } |
| 876 | case BULK_BSETFILTER: { | 852 | case BULK_BSETFILTER: { |
| @@ -885,7 +861,26 @@ namespace Hantek { | @@ -885,7 +861,26 @@ namespace Hantek { | ||
| 885 | return Dso::ERROR_UNSUPPORTED; | 861 | return Dso::ERROR_UNSUPPORTED; |
| 886 | } | 862 | } |
| 887 | 863 | ||
| 864 | + // Update settings | ||
| 865 | + this->settings.voltage[channel].used = used; | ||
| 866 | + unsigned int channelCount = 0; | ||
| 867 | + for(int channelCounter = 0; channelCounter < HANTEK_CHANNELS; ++channelCounter) { | ||
| 868 | + if(this->settings.voltage[channelCounter].used) | ||
| 869 | + ++channelCount; | ||
| 870 | + } | ||
| 871 | + this->settings.usedChannels = channelCount; | ||
| 872 | + | ||
| 873 | + // Additional UsedChannels field for all models except DSO-2250 | ||
| 888 | if(this->specification.command.bulk.setTrigger == BULK_SETTRIGGERANDSAMPLERATE || this->specification.command.bulk.setTrigger == BULK_ESETTRIGGERORSAMPLERATE) { | 874 | if(this->specification.command.bulk.setTrigger == BULK_SETTRIGGERANDSAMPLERATE || this->specification.command.bulk.setTrigger == BULK_ESETTRIGGERORSAMPLERATE) { |
| 875 | + unsigned char usedChannels = USED_CH1; | ||
| 876 | + | ||
| 877 | + if(this->settings.voltage[1].used) { | ||
| 878 | + if(this->settings.voltage[0].used) | ||
| 879 | + usedChannels = USED_CH1CH2; | ||
| 880 | + else | ||
| 881 | + usedChannels = USED_CH2; | ||
| 882 | + } | ||
| 883 | + | ||
| 889 | switch(this->specification.command.bulk.setTrigger) { | 884 | switch(this->specification.command.bulk.setTrigger) { |
| 890 | case BULK_SETTRIGGERANDSAMPLERATE: { | 885 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 891 | // SetTriggerAndSamplerate bulk command for trigger source | 886 | // SetTriggerAndSamplerate bulk command for trigger source |
| @@ -1119,9 +1114,7 @@ namespace Hantek { | @@ -1119,9 +1114,7 @@ namespace Hantek { | ||
| 1119 | switch(this->specification.command.bulk.setTrigger) { | 1114 | switch(this->specification.command.bulk.setTrigger) { |
| 1120 | case BULK_SETTRIGGERANDSAMPLERATE: { | 1115 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 1121 | // SetTriggerAndSamplerate bulk command for trigger slope | 1116 | // SetTriggerAndSamplerate bulk command for trigger slope |
| 1122 | - BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = (BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE]; | ||
| 1123 | - | ||
| 1124 | - commandSetTriggerAndSamplerate->setTriggerSlope(slope); | 1117 | + ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSlope(slope); |
| 1125 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 1118 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 1126 | break; | 1119 | break; |
| 1127 | } | 1120 | } |
| @@ -1154,13 +1147,12 @@ namespace Hantek { | @@ -1154,13 +1147,12 @@ namespace Hantek { | ||
| 1154 | 1147 | ||
| 1155 | // All trigger positions are measured in samples | 1148 | // All trigger positions are measured in samples |
| 1156 | unsigned long int positionSamples = position * this->settings.samplerate.current; | 1149 | unsigned long int positionSamples = position * this->settings.samplerate.current; |
| 1150 | + // Fast rate mode uses both channels | ||
| 1151 | + if(this->settings.samplerate.limits == &this->specification.samplerate.single) | ||
| 1152 | + positionSamples /= HANTEK_CHANNELS; | ||
| 1157 | 1153 | ||
| 1158 | switch(this->specification.command.bulk.setPretrigger) { | 1154 | switch(this->specification.command.bulk.setPretrigger) { |
| 1159 | case BULK_SETTRIGGERANDSAMPLERATE: { | 1155 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 1160 | - // Fast rate mode uses both channels | ||
| 1161 | - if(((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getFastRate()) | ||
| 1162 | - positionSamples /= HANTEK_CHANNELS; | ||
| 1163 | - | ||
| 1164 | // Calculate the position value (Start point depending on record length) | 1156 | // Calculate the position value (Start point depending on record length) |
| 1165 | unsigned long int position = 0x7ffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; | 1157 | unsigned long int position = 0x7ffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; |
| 1166 | 1158 | ||
| @@ -1171,10 +1163,6 @@ namespace Hantek { | @@ -1171,10 +1163,6 @@ namespace Hantek { | ||
| 1171 | break; | 1163 | break; |
| 1172 | } | 1164 | } |
| 1173 | case BULK_FSETBUFFER: { | 1165 | case BULK_FSETBUFFER: { |
| 1174 | - // Fast rate mode uses both channels | ||
| 1175 | - if(((BulkSetSamplerate2250 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getFastRate()) | ||
| 1176 | - positionSamples /= HANTEK_CHANNELS; | ||
| 1177 | - | ||
| 1178 | // Calculate the position values (Inverse, maximum is 0xffff) | 1166 | // Calculate the position values (Inverse, maximum is 0xffff) |
| 1179 | unsigned short int positionPre = 0xffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; | 1167 | unsigned short int positionPre = 0xffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; |
| 1180 | unsigned short int positionPost = 0xffff - positionSamples; | 1168 | unsigned short int positionPost = 0xffff - positionSamples; |
| @@ -1188,10 +1176,6 @@ namespace Hantek { | @@ -1188,10 +1176,6 @@ namespace Hantek { | ||
| 1188 | break; | 1176 | break; |
| 1189 | } | 1177 | } |
| 1190 | case BULK_ESETTRIGGERORSAMPLERATE: { | 1178 | case BULK_ESETTRIGGERORSAMPLERATE: { |
| 1191 | - // Fast rate mode uses both channels | ||
| 1192 | - if(((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getFastRate()) | ||
| 1193 | - positionSamples /= HANTEK_CHANNELS; | ||
| 1194 | - | ||
| 1195 | // Calculate the position values (Inverse, maximum is 0xffff) | 1179 | // Calculate the position values (Inverse, maximum is 0xffff) |
| 1196 | unsigned short int positionPre = 0xffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; | 1180 | unsigned short int positionPre = 0xffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; |
| 1197 | unsigned short int positionPost = 0xffff - positionSamples; | 1181 | unsigned short int positionPost = 0xffff - positionSamples; |
openhantek/src/hantek/control.h
| @@ -117,6 +117,7 @@ namespace Hantek { | @@ -117,6 +117,7 @@ namespace Hantek { | ||
| 117 | QList<unsigned long int> recordLengths; ///< Available record lengths, ULONG_MAX means rolling | 117 | QList<unsigned long int> recordLengths; ///< Available record lengths, ULONG_MAX means rolling |
| 118 | QList<unsigned long int> bufferDividers; ///< Samplerate dividers for record lengths | 118 | QList<unsigned long int> bufferDividers; ///< Samplerate dividers for record lengths |
| 119 | QList<double> gainSteps; ///< Available voltage steps in V/screenheight | 119 | QList<double> gainSteps; ///< Available voltage steps in V/screenheight |
| 120 | + unsigned char sampleSize; ///< Number of bits per sample | ||
| 120 | 121 | ||
| 121 | // Calibration | 122 | // Calibration |
| 122 | /// The sample values at the top of the screen | 123 | /// The sample values at the top of the screen |
openhantek/src/hantek/types.h
| @@ -300,7 +300,7 @@ namespace Hantek { | @@ -300,7 +300,7 @@ namespace Hantek { | ||
| 300 | /// <tr> | 300 | /// <tr> |
| 301 | /// <td>0x0b</td> | 301 | /// <td>0x0b</td> |
| 302 | /// <td>0x00</td> | 302 | /// <td>0x00</td> |
| 303 | - /// <td>::UsedChannels</td> | 303 | + /// <td>FilterBits</td> |
| 304 | /// <td>0x00</td> | 304 | /// <td>0x00</td> |
| 305 | /// </tr> | 305 | /// </tr> |
| 306 | /// </table> | 306 | /// </table> |