From 3c53f864c4fa612d024ad10c6b58ee5cf2376f00 Mon Sep 17 00:00:00 2001 From: Denny Date: Mon, 30 May 2016 08:58:00 -0400 Subject: [PATCH] Closes #70 - airspy mini sample rates. Change code to no longer assume that 10 MHz is an available default sample rate. The mini is only capable of 6 and 3 MHz. Note: only the 6 MHz sample rate option should be used at this time. 6 MHz can be decimated to 48 kHz using an integer decimator. sdrtrunk doesn't support the 3 MHz option, because it can't decimate that rate to 48 kHz until the new channelizer is developed. --- .../tuner/airspy/AirspyTunerController.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/source/tuner/airspy/AirspyTunerController.java b/src/source/tuner/airspy/AirspyTunerController.java index 558d0752..7e8165a9 100644 --- a/src/source/tuner/airspy/AirspyTunerController.java +++ b/src/source/tuner/airspy/AirspyTunerController.java @@ -298,7 +298,14 @@ public class AirspyTunerController extends TunerController if( rate == null ) { - rate = DEFAULT_SAMPLE_RATE; + if( !mSampleRates.isEmpty() ) + { + rate = mSampleRates.get( 0 ); + } + else + { + rate = DEFAULT_SAMPLE_RATE; + } } try @@ -359,6 +366,7 @@ public class AirspyTunerController extends TunerController @Override public void setTunedFrequency( long frequency ) throws SourceException { + mLog.debug("Setting tuned frequency to: " + frequency ); if( FREQUENCY_MIN <= frequency && frequency <= FREQUENCY_MAX ) { ByteBuffer buffer = ByteBuffer.allocateDirect( 4 ); @@ -635,8 +643,6 @@ public class AirspyTunerController extends TunerController { mSampleRates.clear(); - mSampleRates.add( DEFAULT_SAMPLE_RATE ); - //Get a count of available sample rates. If we get an exception, then //we're using an older firmware revision and only the default 10 MHz //rate is supported @@ -644,18 +650,17 @@ public class AirspyTunerController extends TunerController { byte[] rawCount = readArray( Command.GET_SAMPLE_RATES, 0, 0, 4 ); - if( rawCount != null ) { int count = EndianUtils.readSwappedInteger( rawCount, 0 ); - - byte[] rawRates = readArray( Command.GET_SAMPLE_RATES, 0, + + byte[] rawRates = readArray( Command.GET_SAMPLE_RATES, 0, count, ( count * 4 ) ); for( int x = 0; x < count; x++ ) { int rate = EndianUtils.readSwappedInteger( rawRates, ( x * 4 ) ); - + if( rate != DEFAULT_SAMPLE_RATE.getRate() ) { mSampleRates.add( new AirspySampleRate( x, rate, @@ -668,6 +673,11 @@ public class AirspyTunerController extends TunerController { //Press on, nothing else to do here .. } + + if( mSampleRates.isEmpty()) + { + mSampleRates.add( DEFAULT_SAMPLE_RATE ); + } } /**