Commit 4081ecc90e860630583bd5b78210b789149a4fea

Authored by oliverhaag
1 parent 77f4c7b5

More DSO-2250 fixes

openhantek/ChangeLog
@@ -169,3 +169,7 @@ @@ -169,3 +169,7 @@
169 * Change back workaround for Mac OS that is most probably not required anymore 169 * Change back workaround for Mac OS that is most probably not required anymore
170 * Various performance improvements and small fixes 170 * Various performance improvements and small fixes
171 * New cppcheck build target 171 * New cppcheck build target
  172 +
  173 +2012-10-28 Oliver Haag <oliver.haag@gmail.com>
  174 +* Bugfix: DSO-2250 support, thanks to Dmitry Kolyadintsev
  175 +* Bugfix: Remove invalid divider for large buffers
openhantek/src/hantek/control.cpp
@@ -53,6 +53,8 @@ namespace Hantek { @@ -53,6 +53,8 @@ namespace Hantek {
53 this->specification.command.values.offsetLimits = (ControlValue) -1; 53 this->specification.command.values.offsetLimits = (ControlValue) -1;
54 this->specification.command.values.voltageLimits = (ControlValue) -1; 54 this->specification.command.values.voltageLimits = (ControlValue) -1;
55 55
  56 + this->specification.recordLengths << 0;
  57 +
56 this->specification.samplerate.single.base = 50e6; 58 this->specification.samplerate.single.base = 50e6;
57 this->specification.samplerate.single.max = 50e6; 59 this->specification.samplerate.single.max = 50e6;
58 this->specification.samplerate.multi.base = 100e6; 60 this->specification.samplerate.multi.base = 100e6;
@@ -127,7 +129,7 @@ namespace Hantek { @@ -127,7 +129,7 @@ namespace Hantek {
127 } 129 }
128 130
129 /// \brief Gets the physical channel count for this oscilloscope. 131 /// \brief Gets the physical channel count for this oscilloscope.
130 - /// \returns The number of physical channels. 132 + /// \return The number of physical channels.
131 unsigned int Control::getChannelCount() { 133 unsigned int Control::getChannelCount() {
132 return HANTEK_CHANNELS; 134 return HANTEK_CHANNELS;
133 } 135 }
@@ -295,11 +297,11 @@ namespace Hantek { @@ -295,11 +297,11 @@ namespace Hantek {
295 /// \brief Calculates the trigger point from the CommandGetCaptureState data. 297 /// \brief Calculates the trigger point from the CommandGetCaptureState data.
296 /// \param value The data value that contains the trigger point. 298 /// \param value The data value that contains the trigger point.
297 /// \return The calculated trigger point for the given data. 299 /// \return The calculated trigger point for the given data.
298 - unsigned short int Control::calculateTriggerPoint(unsigned short int value) {  
299 - unsigned short int result = value; 300 + unsigned long int Control::calculateTriggerPoint(unsigned long int value) {
  301 + unsigned long int result = value;
300 302
301 // Each set bit inverts all bits with a lower value 303 // Each set bit inverts all bits with a lower value
302 - for(unsigned short int bitValue = 1; bitValue; bitValue <<= 1) 304 + for(unsigned long int bitValue = 1; bitValue; bitValue <<= 1)
303 if(result & bitValue) 305 if(result & bitValue)
304 result ^= bitValue - 1; 306 result ^= bitValue - 1;
305 307
@@ -358,7 +360,7 @@ namespace Hantek { @@ -358,7 +360,7 @@ namespace Hantek {
358 this->samplesMutex.lock(); 360 this->samplesMutex.lock();
359 361
360 // Convert channel data 362 // Convert channel data
361 - if(this->settings.samplerate.limits == &this->specification.samplerate.single) { 363 + if(this->settings.samplerate.limits == &this->specification.samplerate.multi) {
362 // Fast rate mode, one channel is using all buffers 364 // Fast rate mode, one channel is using all buffers
363 int channel = 0; 365 int channel = 0;
364 for(; channel < HANTEK_CHANNELS; ++channel) { 366 for(; channel < HANTEK_CHANNELS; ++channel) {
@@ -495,25 +497,20 @@ namespace Hantek { @@ -495,25 +497,20 @@ namespace Hantek {
495 if(this->specification.command.bulk.setPretrigger == BULK_FSETBUFFER) { 497 if(this->specification.command.bulk.setPretrigger == BULK_FSETBUFFER) {
496 // Pointers to needed commands 498 // Pointers to needed commands
497 BulkSetRecordLength2250 *commandSetRecordLength2250 = static_cast<BulkSetRecordLength2250 *>(this->command[BULK_DSETBUFFER]); 499 BulkSetRecordLength2250 *commandSetRecordLength2250 = static_cast<BulkSetRecordLength2250 *>(this->command[BULK_DSETBUFFER]);
498 - BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(this->command[BULK_FSETBUFFER]);  
499 500
500 commandSetRecordLength2250->setRecordLength(bestSizeId); 501 commandSetRecordLength2250->setRecordLength(bestSizeId);
501 - commandSetBuffer2250->setUsedPre(FTRIGGERPOSITION_ON);  
502 - commandSetBuffer2250->setUsedPost(FTRIGGERPOSITION_ON);  
503 - commandSetBuffer2250->setLargeBuffer(bestSizeId == RECORDLENGTHID_LARGE);  
504 - commandSetBuffer2250->setSlowBuffer(bestSizeId != RECORDLENGTHID_SMALL);  
505 -  
506 - this->commandPending[BULK_DSETBUFFER] = true;  
507 - this->commandPending[BULK_FSETBUFFER] = true;  
508 } 502 }
509 else { 503 else {
510 // SetBuffer5200 bulk command for record length 504 // SetBuffer5200 bulk command for record length
511 BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(this->command[BULK_DSETBUFFER]); 505 BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(this->command[BULK_DSETBUFFER]);
  506 +
512 commandSetBuffer5200->setUsedPre(DTRIGGERPOSITION_ON); 507 commandSetBuffer5200->setUsedPre(DTRIGGERPOSITION_ON);
513 commandSetBuffer5200->setUsedPost(DTRIGGERPOSITION_ON); 508 commandSetBuffer5200->setUsedPost(DTRIGGERPOSITION_ON);
514 commandSetBuffer5200->setRecordLength(bestSizeId); 509 commandSetBuffer5200->setRecordLength(bestSizeId);
515 - this->commandPending[BULK_DSETBUFFER] = true;  
516 } 510 }
  511 +
  512 + this->commandPending[BULK_DSETBUFFER] = true;
  513 +
517 break; 514 break;
518 515
519 default: 516 default:
@@ -645,7 +642,7 @@ namespace Hantek { @@ -645,7 +642,7 @@ namespace Hantek {
645 this->specification.samplerate.single.max = 125e6; 642 this->specification.samplerate.single.max = 125e6;
646 this->specification.samplerate.multi.base = 200e6; 643 this->specification.samplerate.multi.base = 200e6;
647 this->specification.samplerate.multi.max = 250e6; 644 this->specification.samplerate.multi.max = 250e6;
648 - this->specification.bufferDividers << 1000 << 1 << 2; 645 + this->specification.bufferDividers << 1000 << 1 << 1;
649 this->specification.recordLengths << ULONG_MAX << 10240 << 14336; 646 this->specification.recordLengths << ULONG_MAX << 10240 << 14336;
650 this->specification.gainSteps 647 this->specification.gainSteps
651 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0; 648 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0;
@@ -659,11 +656,11 @@ namespace Hantek { @@ -659,11 +656,11 @@ namespace Hantek {
659 break; 656 break;
660 657
661 case MODEL_DSO2250: 658 case MODEL_DSO2250:
662 - this->specification.samplerate.single.base = 200e6;  
663 - this->specification.samplerate.single.max = 125e6; 659 + this->specification.samplerate.single.base = 100e6;
  660 + this->specification.samplerate.single.max = 100e6;
664 this->specification.samplerate.multi.base = 200e6; 661 this->specification.samplerate.multi.base = 200e6;
665 this->specification.samplerate.multi.max = 250e6; 662 this->specification.samplerate.multi.max = 250e6;
666 - this->specification.bufferDividers << 1000 << 1 << 2; 663 + this->specification.bufferDividers << 1000 << 1 << 1;
667 this->specification.recordLengths << ULONG_MAX << 10240 << 524288; 664 this->specification.recordLengths << ULONG_MAX << 10240 << 524288;
668 this->specification.gainSteps 665 this->specification.gainSteps
669 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; 666 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0;
@@ -671,7 +668,7 @@ namespace Hantek { @@ -671,7 +668,7 @@ namespace Hantek {
671 this->specification.voltageLimit[channel] 668 this->specification.voltageLimit[channel]
672 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; 669 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255;
673 this->specification.gainIndex 670 this->specification.gainIndex
674 - << 0 << 1 << 2 << 0 << 1 << 2 << 0 << 1 << 2; 671 + << 0 << 2 << 3 << 0 << 2 << 3 << 0 << 2 << 3;
675 this->specification.sampleSize = 8; 672 this->specification.sampleSize = 8;
676 break; 673 break;
677 674
@@ -680,7 +677,7 @@ namespace Hantek { @@ -680,7 +677,7 @@ namespace Hantek {
680 this->specification.samplerate.single.max = 75e6; 677 this->specification.samplerate.single.max = 75e6;
681 this->specification.samplerate.multi.base = 100e6; 678 this->specification.samplerate.multi.base = 100e6;
682 this->specification.samplerate.multi.max = 150e6; 679 this->specification.samplerate.multi.max = 150e6;
683 - this->specification.bufferDividers << 1000 << 1 << 2; 680 + this->specification.bufferDividers << 1000 << 1 << 1;
684 this->specification.recordLengths << ULONG_MAX << 10240 << 32768; 681 this->specification.recordLengths << ULONG_MAX << 10240 << 32768;
685 this->specification.gainSteps 682 this->specification.gainSteps
686 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; 683 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0;
@@ -697,7 +694,7 @@ namespace Hantek { @@ -697,7 +694,7 @@ namespace Hantek {
697 this->specification.samplerate.single.max = 50e6; 694 this->specification.samplerate.single.max = 50e6;
698 this->specification.samplerate.multi.base = 100e6; 695 this->specification.samplerate.multi.base = 100e6;
699 this->specification.samplerate.multi.max = 100e6; 696 this->specification.samplerate.multi.max = 100e6;
700 - this->specification.bufferDividers << 1000 << 1 << 2; 697 + this->specification.bufferDividers << 1000 << 1 << 1;
701 this->specification.recordLengths << ULONG_MAX << 10240 << 32768; 698 this->specification.recordLengths << ULONG_MAX << 10240 << 32768;
702 this->specification.gainSteps 699 this->specification.gainSteps
703 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; 700 << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0;
@@ -732,8 +729,8 @@ namespace Hantek { @@ -732,8 +729,8 @@ namespace Hantek {
732 729
733 this->updateRecordLength(size); 730 this->updateRecordLength(size);
734 731
735 - this->setPretriggerPosition(this->settings.trigger.position);  
736 this->setSamplerate(); 732 this->setSamplerate();
  733 + this->setPretriggerPosition(this->settings.trigger.position);
737 734
738 return this->specification.recordLengths[this->settings.recordLengthId]; 735 return this->specification.recordLengths[this->settings.recordLengthId];
739 } 736 }
@@ -774,7 +771,7 @@ namespace Hantek { @@ -774,7 +771,7 @@ namespace Hantek {
774 unsigned long int slowDownsampling = qMax(this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.recordLengthId] / samplerate, (long unsigned int) 1); 771 unsigned long int slowDownsampling = qMax(this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.recordLengthId] / samplerate, (long unsigned int) 1);
775 772
776 // Use normal mode if we need valueSlow or it would meet the rate at least as exactly as fast rate mode 773 // Use normal mode if we need valueSlow or it would meet the rate at least as exactly as fast rate mode
777 - if(this->settings.samplerate.downsampling > 4 || (qAbs((double) this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.recordLengthId] / slowDownsampling - samplerate) <= qAbs(this->settings.samplerate.current - samplerate))) { 774 + if(this->settings.samplerate.downsampling > 4 || (qAbs((double) this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.recordLengthId] / slowDownsampling - samplerate) <= qAbs((double) this->settings.samplerate.current - samplerate))) {
778 fastRate = false; 775 fastRate = false;
779 this->settings.samplerate.limits = &(this->specification.samplerate.single); 776 this->settings.samplerate.limits = &(this->specification.samplerate.single);
780 this->settings.samplerate.downsampling = slowDownsampling; 777 this->settings.samplerate.downsampling = slowDownsampling;
@@ -782,13 +779,13 @@ namespace Hantek { @@ -782,13 +779,13 @@ namespace Hantek {
782 } 779 }
783 } 780 }
784 781
785 - // Split the resulting divider into the values understood by the device  
786 - // The fast value is kept at 4 (or 3) for slow sample rates  
787 - long int valueSlow = qMax(((long int) this->settings.samplerate.downsampling - 3) / 2, (long int) 0);  
788 - unsigned char valueFast = this->settings.samplerate.downsampling - valueSlow * 2;  
789 -  
790 switch(this->specification.command.bulk.setSamplerate) { 782 switch(this->specification.command.bulk.setSamplerate) {
791 case BULK_SETTRIGGERANDSAMPLERATE: { 783 case BULK_SETTRIGGERANDSAMPLERATE: {
  784 + // Split the resulting divider into the values understood by the device
  785 + // The fast value is kept at 4 (or 3) for slow sample rates
  786 + long int valueSlow = qMax(((long int) this->settings.samplerate.downsampling - 3) / 2, (long int) 0);
  787 + unsigned char valueFast = this->settings.samplerate.downsampling - valueSlow * 2;
  788 +
792 // Pointers to needed commands 789 // Pointers to needed commands
793 BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE]); 790 BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE]);
794 791
@@ -804,6 +801,11 @@ namespace Hantek { @@ -804,6 +801,11 @@ namespace Hantek {
804 break; 801 break;
805 } 802 }
806 case BULK_CSETTRIGGERORSAMPLERATE: { 803 case BULK_CSETTRIGGERORSAMPLERATE: {
  804 + // Split the resulting divider into the values understood by the device
  805 + // The fast value is kept at 4 (or 3) for slow sample rates
  806 + long int valueSlow = qMax(((long int) this->settings.samplerate.downsampling - 3) / 2, (long int) 0);
  807 + unsigned char valueFast = this->settings.samplerate.downsampling - valueSlow * 2;
  808 +
807 // Pointers to needed commands 809 // Pointers to needed commands
808 BulkSetSamplerate5200 *commandSetSamplerate5200 = static_cast<BulkSetSamplerate5200 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE]); 810 BulkSetSamplerate5200 *commandSetSamplerate5200 = static_cast<BulkSetSamplerate5200 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE]);
809 BulkSetTrigger5200 *commandSetTrigger5200 = static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE]); 811 BulkSetTrigger5200 *commandSetTrigger5200 = static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE]);
@@ -824,10 +826,11 @@ namespace Hantek { @@ -824,10 +826,11 @@ namespace Hantek {
824 // Pointers to needed commands 826 // Pointers to needed commands
825 BulkSetSamplerate2250 *commandSetSamplerate2250 = static_cast<BulkSetSamplerate2250 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE]); 827 BulkSetSamplerate2250 *commandSetSamplerate2250 = static_cast<BulkSetSamplerate2250 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE]);
826 828
827 - // Store samplerate fast value  
828 - commandSetSamplerate2250->setSamplerateFast(4 - valueFast);  
829 - // Store samplerate slow value (two's complement)  
830 - commandSetSamplerate2250->setSamplerateSlow(valueSlow == 0 ? 0 : 0xffff - valueSlow); 829 + bool downsampling = this->settings.samplerate.downsampling > 1;
  830 + // Store downsampler state value
  831 + commandSetSamplerate2250->setDownsampling(downsampling);
  832 + // Store samplerate value
  833 + commandSetSamplerate2250->setSamplerate(downsampling ? 0x10001 - this->settings.samplerate.downsampling : 0);
831 // Set fast rate when used 834 // Set fast rate when used
832 commandSetSamplerate2250->setFastRate(fastRate); 835 commandSetSamplerate2250->setFastRate(fastRate);
833 836
@@ -1024,29 +1027,22 @@ namespace Hantek { @@ -1024,29 +1027,22 @@ namespace Hantek {
1024 if((!special && id >= HANTEK_CHANNELS) || (special && id >= HANTEK_SPECIAL_CHANNELS)) 1027 if((!special && id >= HANTEK_CHANNELS) || (special && id >= HANTEK_SPECIAL_CHANNELS))
1025 return Dso::ERROR_PARAMETER; 1028 return Dso::ERROR_PARAMETER;
1026 1029
1027 - // Generate trigger source value that will be transmitted  
1028 - int sourceValue;  
1029 - if(special)  
1030 - sourceValue = TRIGGER_EXT + id;  
1031 - else  
1032 - sourceValue = TRIGGER_CH1 - id;  
1033 -  
1034 switch(this->specification.command.bulk.setTrigger) { 1030 switch(this->specification.command.bulk.setTrigger) {
1035 case BULK_SETTRIGGERANDSAMPLERATE: 1031 case BULK_SETTRIGGERANDSAMPLERATE:
1036 // SetTriggerAndSamplerate bulk command for trigger source 1032 // SetTriggerAndSamplerate bulk command for trigger source
1037 - static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSource(sourceValue); 1033 + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSource(special ? 3 + id : 1 - id);
1038 this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; 1034 this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true;
1039 break; 1035 break;
1040 1036
1041 case BULK_CSETTRIGGERORSAMPLERATE: 1037 case BULK_CSETTRIGGERORSAMPLERATE:
1042 // SetTrigger2250 bulk command for trigger source 1038 // SetTrigger2250 bulk command for trigger source
1043 - static_cast<BulkSetTrigger2250 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); 1039 + static_cast<BulkSetTrigger2250 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSource(special ? 0 : 2 + id);
1044 this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; 1040 this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true;
1045 break; 1041 break;
1046 - 1042 +
1047 case BULK_ESETTRIGGERORSAMPLERATE: 1043 case BULK_ESETTRIGGERORSAMPLERATE:
1048 // SetTrigger5200 bulk command for trigger source 1044 // SetTrigger5200 bulk command for trigger source
1049 - static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); 1045 + static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSource(special ? 3 + id : 1 - id);
1050 this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; 1046 this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true;
1051 break; 1047 break;
1052 1048
@@ -1164,7 +1160,7 @@ namespace Hantek { @@ -1164,7 +1160,7 @@ namespace Hantek {
1164 // All trigger positions are measured in samples 1160 // All trigger positions are measured in samples
1165 unsigned long int positionSamples = position * this->settings.samplerate.current; 1161 unsigned long int positionSamples = position * this->settings.samplerate.current;
1166 // Fast rate mode uses both channels 1162 // Fast rate mode uses both channels
1167 - if(this->settings.samplerate.limits == &this->specification.samplerate.single) 1163 + if(this->settings.samplerate.limits == &this->specification.samplerate.multi)
1168 positionSamples /= HANTEK_CHANNELS; 1164 positionSamples /= HANTEK_CHANNELS;
1169 1165
1170 switch(this->specification.command.bulk.setPretrigger) { 1166 switch(this->specification.command.bulk.setPretrigger) {
@@ -1179,9 +1175,9 @@ namespace Hantek { @@ -1179,9 +1175,9 @@ namespace Hantek {
1179 break; 1175 break;
1180 } 1176 }
1181 case BULK_FSETBUFFER: { 1177 case BULK_FSETBUFFER: {
1182 - // Calculate the position values (Inverse, maximum is 0xffff)  
1183 - unsigned short int positionPre = 0xffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples;  
1184 - unsigned short int positionPost = 0xffff - positionSamples; 1178 + // Calculate the position values (Inverse, maximum is 0x7ffff)
  1179 + unsigned short int positionPre = 0x7ffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples;
  1180 + unsigned short int positionPost = 0x7ffff - positionSamples;
1185 1181
1186 // SetBuffer2250 bulk command for trigger position 1182 // SetBuffer2250 bulk command for trigger position
1187 BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(this->command[BULK_FSETBUFFER]); 1183 BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(this->command[BULK_FSETBUFFER]);
@@ -1238,7 +1234,7 @@ namespace Hantek { @@ -1238,7 +1234,7 @@ namespace Hantek {
1238 unsigned char commandCode = 0; 1234 unsigned char commandCode = 0;
1239 1235
1240 // Read command code (First byte) 1236 // Read command code (First byte)
1241 - Helper::hexParse(data, &commandCode, 1); 1237 + Helper::hexParse(commandParts[2], &commandCode, 1);
1242 if(commandCode > BULK_COUNT) 1238 if(commandCode > BULK_COUNT)
1243 return Dso::ERROR_UNSUPPORTED; 1239 return Dso::ERROR_UNSUPPORTED;
1244 1240
@@ -1248,8 +1244,10 @@ namespace Hantek { @@ -1248,8 +1244,10 @@ namespace Hantek {
1248 return Dso::ERROR_NONE; 1244 return Dso::ERROR_NONE;
1249 } 1245 }
1250 else if(commandParts[1] == "control") { 1246 else if(commandParts[1] == "control") {
1251 - // Get control code from third part  
1252 - unsigned char controlCode = commandParts[2].toUShort(); 1247 + unsigned char controlCode = 0;
  1248 +
  1249 + // Read command code (First byte)
  1250 + Helper::hexParse(commandParts[2], &controlCode, 1);
1253 int control; 1251 int control;
1254 for(control = 0; control < CONTROLINDEX_COUNT; ++control) { 1252 for(control = 0; control < CONTROLINDEX_COUNT; ++control) {
1255 if(this->controlCode[control] == controlCode) 1253 if(this->controlCode[control] == controlCode)
openhantek/src/hantek/control.h
@@ -134,7 +134,7 @@ namespace Hantek { @@ -134,7 +134,7 @@ namespace Hantek {
134 struct ControlSettingsSamplerate { 134 struct ControlSettingsSamplerate {
135 ControlSamplerateLimits *limits; ///< The samplerate limits 135 ControlSamplerateLimits *limits; ///< The samplerate limits
136 unsigned long int downsampling; ///< The variable downsampling factor 136 unsigned long int downsampling; ///< The variable downsampling factor
137 - double current; ///< The current samplerate 137 + unsigned long int current; ///< The current samplerate
138 }; 138 };
139 139
140 ////////////////////////////////////////////////////////////////////////////// 140 //////////////////////////////////////////////////////////////////////////////
@@ -186,7 +186,7 @@ namespace Hantek { @@ -186,7 +186,7 @@ namespace Hantek {
186 protected: 186 protected:
187 void run(); 187 void run();
188 188
189 - unsigned short int calculateTriggerPoint(unsigned short int value); 189 + unsigned long int calculateTriggerPoint(unsigned long int value);
190 int getCaptureState(); 190 int getCaptureState();
191 int getSamples(bool process); 191 int getSamples(bool process);
192 unsigned long int updateRecordLength(unsigned long int size); 192 unsigned long int updateRecordLength(unsigned long int size);
openhantek/src/hantek/types.cpp
@@ -282,7 +282,7 @@ namespace Hantek { @@ -282,7 +282,7 @@ namespace Hantek {
282 /// \brief Gets the trigger point. 282 /// \brief Gets the trigger point.
283 /// \return The trigger point for the captured samples. 283 /// \return The trigger point for the captured samples.
284 unsigned int BulkResponseGetCaptureState::getTriggerPoint() { 284 unsigned int BulkResponseGetCaptureState::getTriggerPoint() {
285 - return this->array[2] | (this->array[3] << 8); 285 + return this->array[2] | (this->array[3] << 8) | (this->array[1] << 16);
286 } 286 }
287 287
288 288
@@ -650,14 +650,14 @@ namespace Hantek { @@ -650,14 +650,14 @@ namespace Hantek {
650 650
651 /// \brief Sets the data bytes to the specified values. 651 /// \brief Sets the data bytes to the specified values.
652 /// \param fastRate The fastRate state (ESamplerateBits). 652 /// \param fastRate The fastRate state (ESamplerateBits).
653 - /// \param samplerateFast The SamplerateFast value (ESamplerateBits).  
654 - /// \param samplerateSlow The SamplerateSlow value.  
655 - BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, unsigned char samplerateFast, unsigned short int samplerateSlow) : Helper::DataArray<unsigned char>(8) { 653 + /// \param downsampling The downsampling state (ESamplerateBits).
  654 + /// \param samplerate The Samplerate value.
  655 + BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, bool downsampling, unsigned short int samplerate) : Helper::DataArray<unsigned char>(8) {
656 this->init(); 656 this->init();
657 657
658 this->setFastRate(fastRate); 658 this->setFastRate(fastRate);
659 - this->setSamplerateFast(samplerateFast);  
660 - this->setSamplerateSlow(samplerateSlow); 659 + this->setDownsampling(downsampling);
  660 + this->setSamplerate(samplerate);
661 } 661 }
662 662
663 /// \brief Get the fastRate state in ESamplerateBits. 663 /// \brief Get the fastRate state in ESamplerateBits.
@@ -672,27 +672,27 @@ namespace Hantek { @@ -672,27 +672,27 @@ namespace Hantek {
672 ((ESamplerateBits *) &(this->array[2]))->fastRate = fastRate ? 1 : 0; 672 ((ESamplerateBits *) &(this->array[2]))->fastRate = fastRate ? 1 : 0;
673 } 673 }
674 674
675 - /// \brief Get the samplerateFast value in ESamplerateBits.  
676 - /// \return The samplerateFast value in ESamplerateBits.  
677 - unsigned char BulkSetSamplerate2250::getSamplerateFast() {  
678 - return ((ESamplerateBits *) &(this->array[2]))->samplerateFast; 675 + /// \brief Get the downsampling state in ESamplerateBits.
  676 + /// \return The samplerateFast state.
  677 + bool BulkSetSamplerate2250::getDownsampling() {
  678 + return ((ESamplerateBits *) &(this->array[2]))->downsampling == 1;
679 } 679 }
680 680
681 /// \brief Set the samplerateFast in ESamplerateBits to the given value. 681 /// \brief Set the samplerateFast in ESamplerateBits to the given value.
682 /// \param value The new samplerateFast value. 682 /// \param value The new samplerateFast value.
683 - void BulkSetSamplerate2250::setSamplerateFast(unsigned char value) {  
684 - ((ESamplerateBits *) &(this->array[2]))->samplerateFast = value; 683 + void BulkSetSamplerate2250::setDownsampling(bool downsampling) {
  684 + ((ESamplerateBits *) &(this->array[2]))->downsampling = downsampling ? 1 : 0;
685 } 685 }
686 686
687 - /// \brief Get the SamplerateSlow value.  
688 - /// \return The SamplerateSlow value.  
689 - unsigned short int BulkSetSamplerate2250::getSamplerateSlow() { 687 + /// \brief Get the Samplerate value.
  688 + /// \return The Samplerate value.
  689 + unsigned short int BulkSetSamplerate2250::getSamplerate() {
690 return (unsigned short int) this->array[4] | ((unsigned short int) this->array[5] << 8); 690 return (unsigned short int) this->array[4] | ((unsigned short int) this->array[5] << 8);
691 } 691 }
692 692
693 - /// \brief Set the SamplerateSlow to the given value.  
694 - /// \param samplerate The new SamplerateSlow value.  
695 - void BulkSetSamplerate2250::setSamplerateSlow(unsigned short int samplerate) { 693 + /// \brief Set the Samplerate to the given value.
  694 + /// \param samplerate The new Samplerate value.
  695 + void BulkSetSamplerate2250::setSamplerate(unsigned short int samplerate) {
696 this->array[4] = (unsigned char) samplerate; 696 this->array[4] = (unsigned char) samplerate;
697 this->array[5] = (unsigned char) (samplerate >> 8); 697 this->array[5] = (unsigned char) (samplerate >> 8);
698 } 698 }
@@ -804,93 +804,39 @@ namespace Hantek { @@ -804,93 +804,39 @@ namespace Hantek {
804 /// \brief Sets the data bytes to the specified values. 804 /// \brief Sets the data bytes to the specified values.
805 /// \param triggerPositionPre The TriggerPositionPre value. 805 /// \param triggerPositionPre The TriggerPositionPre value.
806 /// \param triggerPositionPost The TriggerPositionPost value. 806 /// \param triggerPositionPost The TriggerPositionPost value.
807 - /// \param usedPre The TriggerPositionUsedPre value.  
808 - /// \param usedPost The TriggerPositionUsedPost value.  
809 - /// \param largeBuffer The largeBuffer state.  
810 - /// \param slowBuffer The slowBuffer state.  
811 - BulkSetBuffer2250::BulkSetBuffer2250(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre, unsigned char usedPost, bool largeBuffer, bool slowBuffer) : Helper::DataArray<unsigned char>(10) { 807 + BulkSetBuffer2250::BulkSetBuffer2250(unsigned long int triggerPositionPre, unsigned long int triggerPositionPost) : Helper::DataArray<unsigned char>(12) {
812 this->init(); 808 this->init();
813 809
814 this->setTriggerPositionPre(triggerPositionPre); 810 this->setTriggerPositionPre(triggerPositionPre);
815 this->setTriggerPositionPost(triggerPositionPost); 811 this->setTriggerPositionPost(triggerPositionPost);
816 - this->setUsedPre(usedPre);  
817 - this->setUsedPost(usedPost);  
818 - this->setLargeBuffer(largeBuffer);  
819 - this->setSlowBuffer(slowBuffer);  
820 - }  
821 -  
822 - /// \brief Get the TriggerPositionPre value.  
823 - /// \return The TriggerPositionPre value.  
824 - unsigned short int BulkSetBuffer2250::getTriggerPositionPre() {  
825 - return (unsigned short int) this->array[2] | ((unsigned short int) this->array[3] << 8);  
826 - }  
827 -  
828 - /// \brief Set the TriggerPositionPre to the given value.  
829 - /// \param position The new TriggerPositionPre value.  
830 - void BulkSetBuffer2250::setTriggerPositionPre(unsigned short int position) {  
831 - this->array[2] = (unsigned char) position;  
832 - this->array[3] = (unsigned char) (position >> 8);  
833 } 812 }
834 813
835 /// \brief Get the TriggerPositionPost value. 814 /// \brief Get the TriggerPositionPost value.
836 /// \return The TriggerPositionPost value. 815 /// \return The TriggerPositionPost value.
837 - unsigned short int BulkSetBuffer2250::getTriggerPositionPost() {  
838 - return (unsigned short int) this->array[6] | ((unsigned short int) this->array[7] << 8); 816 + unsigned long int BulkSetBuffer2250::getTriggerPositionPost() {
  817 + return (unsigned long int) this->array[2] | ((unsigned long int) this->array[3] << 8) | ((unsigned long int) this->array[4] << 16);
839 } 818 }
840 819
841 /// \brief Set the TriggerPositionPost to the given value. 820 /// \brief Set the TriggerPositionPost to the given value.
842 /// \param position The new TriggerPositionPost value. 821 /// \param position The new TriggerPositionPost value.
843 - void BulkSetBuffer2250::setTriggerPositionPost(unsigned short int position) {  
844 - this->array[6] = (unsigned char) position;  
845 - this->array[7] = (unsigned char) (position >> 8);  
846 - }  
847 -  
848 - /// \brief Get the TriggerPositionUsedPre value.  
849 - /// \return The ::DTriggerPositionUsed value for the pre position.  
850 - unsigned char BulkSetBuffer2250::getUsedPre() {  
851 - return ((FBuffer1Bits *) &(this->array[4]))->triggerPositionUsed;  
852 - }  
853 -  
854 - /// \brief Set the TriggerPositionUsedPre to the given value.  
855 - /// \param value The new ::DTriggerPositionUsed value for the pre position.  
856 - void BulkSetBuffer2250::setUsedPre(unsigned char value) {  
857 - ((FBuffer1Bits *) &(this->array[4]))->triggerPositionUsed = value;  
858 - }  
859 -  
860 - /// \brief Get the TriggerPositionUsedPost value.  
861 - /// \return The ::DTriggerPositionUsed value for the post position.  
862 - unsigned char BulkSetBuffer2250::getUsedPost() {  
863 - return ((FBuffer1Bits *) &(this->array[8]))->triggerPositionUsed;  
864 - }  
865 -  
866 - /// \brief Set the TriggerPositionUsedPost to the given value.  
867 - /// \param value The new ::DTriggerPositionUsed value for the post position.  
868 - void BulkSetBuffer2250::setUsedPost(unsigned char value) {  
869 - ((FBuffer1Bits *) &(this->array[8]))->triggerPositionUsed = value;  
870 - }  
871 -  
872 - /// \brief Get the largeBuffer state in FBuffer1Bits.  
873 - /// \return The largeBuffer state.  
874 - bool BulkSetBuffer2250::getLargeBuffer() {  
875 - return ((FBuffer1Bits *) &(this->array[2]))->largeBuffer == 0;  
876 - }  
877 -  
878 - /// \brief Set the largeBuffer in FBuffer1Bits to the given state.  
879 - /// \param largeBuffer The new largeBuffer state.  
880 - void BulkSetBuffer2250::setLargeBuffer(bool largeBuffer) {  
881 - ((FBuffer1Bits *) &(this->array[2]))->largeBuffer = largeBuffer ? 0 : 1; 822 + void BulkSetBuffer2250::setTriggerPositionPost(unsigned long int position) {
  823 + this->array[2] = (unsigned char) position;
  824 + this->array[3] = (unsigned char) (position >> 8);
  825 + this->array[4] = (unsigned char) (position >> 16);
882 } 826 }
883 827
884 - /// \brief Get the slowBuffer state in FBuffer2Bits.  
885 - /// \return The slowBuffer state.  
886 - bool BulkSetBuffer2250::getSlowBuffer() {  
887 - return ((FBuffer2Bits *) &(this->array[2]))->slowBuffer == 1; 828 + /// \brief Get the TriggerPositionPre value.
  829 + /// \return The TriggerPositionPre value.
  830 + unsigned long int BulkSetBuffer2250::getTriggerPositionPre() {
  831 + return (unsigned long int) this->array[6] | ((unsigned short int) this->array[7] << 8) | ((unsigned short int) this->array[8] << 16);
888 } 832 }
889 833
890 - /// \brief Set the slowBuffer in FBuffer2Bits to the given state.  
891 - /// \param slowBuffer The new slowBuffer state.  
892 - void BulkSetBuffer2250::setSlowBuffer(bool slowBuffer) {  
893 - ((FBuffer2Bits *) &(this->array[2]))->slowBuffer = slowBuffer ? 1 : 0; 834 + /// \brief Set the TriggerPositionPre to the given value.
  835 + /// \param position The new TriggerPositionPre value.
  836 + void BulkSetBuffer2250::setTriggerPositionPre(unsigned long int position) {
  837 + this->array[6] = (unsigned char) position;
  838 + this->array[7] = (unsigned char) (position >> 8);
  839 + this->array[8] = (unsigned char) (position >> 16);
894 } 840 }
895 841
896 /// \brief Initialize the array to the needed values. 842 /// \brief Initialize the array to the needed values.
openhantek/src/hantek/types.h
@@ -779,7 +779,7 @@ namespace Hantek { @@ -779,7 +779,7 @@ namespace Hantek {
779 /// \brief Samplerate bits for DSO-2250 0x0e command. 779 /// \brief Samplerate bits for DSO-2250 0x0e command.
780 struct ESamplerateBits { 780 struct ESamplerateBits {
781 unsigned char fastRate:1; ///< false, if one channels uses all buffers 781 unsigned char fastRate:1; ///< false, if one channels uses all buffers
782 - unsigned char samplerateFast:3; ///< samplerate value for fast sampling rates 782 + unsigned char downsampling:1; ///< true, if the downsampler is activated
783 unsigned char reserved:4; ///< Unused bits 783 unsigned char reserved:4; ///< Unused bits
784 }; 784 };
785 785
@@ -948,7 +948,7 @@ namespace Hantek { @@ -948,7 +948,7 @@ namespace Hantek {
948 948
949 ////////////////////////////////////////////////////////////////////////////// 949 //////////////////////////////////////////////////////////////////////////////
950 /// \class BulkSetFilter2250 hantek/types.h 950 /// \class BulkSetFilter2250 hantek/types.h
951 - /// \brief The DSO-5200/DSO-5200A BULK_BSETFILTER builder. 951 + /// \brief The DSO-2250 BULK_BSETFILTER builder.
952 class BulkSetFilter2250 : public Helper::DataArray<unsigned char> { 952 class BulkSetFilter2250 : public Helper::DataArray<unsigned char> {
953 public: 953 public:
954 BulkSetFilter2250(); 954 BulkSetFilter2250();
@@ -1039,14 +1039,14 @@ namespace Hantek { @@ -1039,14 +1039,14 @@ namespace Hantek {
1039 class BulkSetSamplerate2250 : public Helper::DataArray<unsigned char> { 1039 class BulkSetSamplerate2250 : public Helper::DataArray<unsigned char> {
1040 public: 1040 public:
1041 BulkSetSamplerate2250(); 1041 BulkSetSamplerate2250();
1042 - BulkSetSamplerate2250(bool fastRate, unsigned char samplerateFast = 0, unsigned short int samplerateSlow = 0); 1042 + BulkSetSamplerate2250(bool fastRate, bool downsampling = false, unsigned short int samplerate = 0);
1043 1043
1044 bool getFastRate(); 1044 bool getFastRate();
1045 void setFastRate(bool fastRate); 1045 void setFastRate(bool fastRate);
1046 - unsigned char getSamplerateFast();  
1047 - void setSamplerateFast(unsigned char value);  
1048 - unsigned short int getSamplerateSlow();  
1049 - void setSamplerateSlow(unsigned short int samplerate); 1046 + bool getDownsampling();
  1047 + void setDownsampling(bool downsampling);
  1048 + unsigned short int getSamplerate();
  1049 + void setSamplerate(unsigned short int samplerate);
1050 1050
1051 private: 1051 private:
1052 void init(); 1052 void init();
@@ -1081,20 +1081,12 @@ namespace Hantek { @@ -1081,20 +1081,12 @@ namespace Hantek {
1081 class BulkSetBuffer2250 : public Helper::DataArray<unsigned char> { 1081 class BulkSetBuffer2250 : public Helper::DataArray<unsigned char> {
1082 public: 1082 public:
1083 BulkSetBuffer2250(); 1083 BulkSetBuffer2250();
1084 - BulkSetBuffer2250(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre = 0, unsigned char usedPost = 0, bool largeBuffer = false, bool slowBuffer = false); 1084 + BulkSetBuffer2250(unsigned long int triggerPositionPre, unsigned long int triggerPositionPost);
1085 1085
1086 - unsigned short int getTriggerPositionPre();  
1087 - void setTriggerPositionPre(unsigned short int value);  
1088 - unsigned short int getTriggerPositionPost();  
1089 - void setTriggerPositionPost(unsigned short int value);  
1090 - unsigned char getUsedPre();  
1091 - void setUsedPre(unsigned char value);  
1092 - unsigned char getUsedPost();  
1093 - void setUsedPost(unsigned char value);  
1094 - bool getLargeBuffer();  
1095 - void setLargeBuffer(bool largeBuffer);  
1096 - bool getSlowBuffer();  
1097 - void setSlowBuffer(bool slowBuffer); 1086 + unsigned long int getTriggerPositionPost();
  1087 + void setTriggerPositionPost(unsigned long int value);
  1088 + unsigned long int getTriggerPositionPre();
  1089 + void setTriggerPositionPre(unsigned long int value);
1098 1090
1099 private: 1091 private:
1100 void init(); 1092 void init();