mirror of
https://github.com/JvanKatwijk/javaDab
synced 2018-12-22 06:18:52 +01:00
93 lines
2.9 KiB
Java
Executable File
93 lines
2.9 KiB
Java
Executable File
/*
|
|
* Copyright (C) 2017
|
|
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
|
* Lazy Chair Computing
|
|
*
|
|
* This file is part of the javaDab program
|
|
* javaDab is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* javaDab is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with javaDab; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
package devices;
|
|
|
|
public class airspyDevice implements Device {
|
|
|
|
private long handle = 0;
|
|
private native long airspyInit (int freq,
|
|
int gain, boolean ag);
|
|
@Override
|
|
public void restartReader () {
|
|
airspy_restartReader (handle);
|
|
}
|
|
@Override
|
|
public void stopReader () {
|
|
airspy_stopReader (handle);
|
|
}
|
|
@Override
|
|
public void setVFOFrequency (int v) {
|
|
airspy_setVFOFrequency (handle, v);
|
|
}
|
|
@Override
|
|
public int getVFOFrequency () {
|
|
return airspy_getVFOFrequency (handle);
|
|
}
|
|
@Override
|
|
public void resetBuffer () {
|
|
airspy_resetBuffer (handle);
|
|
}
|
|
@Override
|
|
public int bitDepth () {return 12; }
|
|
@Override
|
|
public int samples () {
|
|
return airspy_samples (handle);
|
|
}
|
|
@Override
|
|
public int getSamples (float [] v, int amount) {
|
|
return airspy_getSamples (handle, v, amount);
|
|
}
|
|
@Override
|
|
public void setGain (int g) {
|
|
airspy_setGain (handle, g);
|
|
}
|
|
|
|
@Override
|
|
public void autoGain (boolean b) {
|
|
}
|
|
|
|
public airspyDevice (int frequency,
|
|
int gain,
|
|
boolean autogain) throws Exception {
|
|
handle = 0;
|
|
try {
|
|
System. load ("/usr/local/lib/libairspy-wrapper.so");
|
|
handle = airspyInit (frequency, gain, autogain);
|
|
} catch (Exception e) {}
|
|
catch (Error e) {}
|
|
if (handle == 0)
|
|
throw (new Exception ());
|
|
}
|
|
|
|
@Override
|
|
public boolean is_nullDevice () { return false; }
|
|
|
|
private native int airspy_getSamples (long handle, float [] v,
|
|
int amount);
|
|
private native int airspy_samples (long handle);
|
|
private native void airspy_resetBuffer (long handle);
|
|
private native void airspy_restartReader (long handle);
|
|
private native void airspy_stopReader (long handle);
|
|
private native void airspy_setVFOFrequency (long handle, int freq);
|
|
private native int airspy_getVFOFrequency (long handle);
|
|
private native void airspy_setGain (long handle, int g);
|
|
}
|