Skip to content

Commit

Permalink
#52 Add sdrplay tuner support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Sheirer committed Jan 15, 2023
1 parent 8be4e78 commit 2cb1ee6
Show file tree
Hide file tree
Showing 350 changed files with 30,898 additions and 280 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ out/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Gradle template
.gradle
/build/
/jsdrplay/build/
/sdrplay-api/build/

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 30 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.text.SimpleDateFormat

/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
Expand Down Expand Up @@ -29,7 +31,13 @@ repositories {
}

version = '0.6.0-alpha1'
sourceCompatibility = '17'

//Java 19 is required for this version of the Project Panama preview/incubator feature
java {
toolchain {
languageVersion = JavaLanguageVersion.of(19)
}
}

sourceSets {
main.java.srcDirs 'src/main'
Expand All @@ -42,6 +50,9 @@ test {

dependencies {

implementation project('sdrplay-api')
implementation project('jsdrplay')

// JUnit Tests
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.assertj:assertj-core:3.23.1'
Expand Down Expand Up @@ -91,18 +102,33 @@ dependencies {
}

/**
* This is needed for the JDK17 vector API ... until it moves out of incubation
* This is needed for the JDK19 panama and vector API ... until it moves out of incubation or preview
*/
tasks.withType(JavaCompile) {
options.compilerArgs.add("--add-modules=jdk.incubator.vector") //Needed while Panama Vector API remains in incubator
options.compilerArgs.add("--enable-preview") //Panama Foreign Function/Memory is preview in JDK 19
}

application {
mainClassName = "io.github.dsheirer.gui.SDRTrunk"
applicationDefaultJvmArgs =
['--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED', //Needed for controls-fx.jar
'--add-modules=jdk.incubator.vector', //Needed while Panama Vector API remains in incubator
'--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED'] //Windows Swing - jide-oss library
'--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED', //Windows Swing - jide-oss library
'--enable-preview',
'--enable-native-access=ALL-UNNAMED'] //Panama Foreign Function access
}

//Adds the SDRPlay native API library to the java system path for runtime
run {
OperatingSystem os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;

if(os.isWindows()) {
systemProperty "java.library.path", "c:\\Program Files\\SDRplay\\API\\x64"
}
else {
systemProperty "java.library.path", "/usr/local/lib"
}
}

jar {
Expand All @@ -111,7 +137,7 @@ jar {
'Implementation-Title' : 'sdrtrunk project',
'Implementation-Version' : archiveVersion,
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Timestamp' : new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-Timestamp' : new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-JDK' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']}",
'Build-OS' : "${System.properties['os.name']} (${System.properties['os.arch']} ${System.properties['os.version']}"
)
Expand Down
85 changes: 85 additions & 0 deletions jsdrplay/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform

plugins {
id 'java'
id 'maven-publish'
}

group 'com.github.DSheirer'
version '3.11.0.0'

repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}

//Java 19 is required for this version of the Project Panama preview/incubator feature
java {
toolchain {
languageVersion = JavaLanguageVersion.of(19)
}
}

/**
* This is needed for the JDK19 panama until it moves out of preview
*/
tasks.withType(JavaCompile) {
options.compilerArgs.add("--enable-preview") //Panama Foreign Function/Memory is preview in JDK 19
}

var incubatorArguments = ["-Djava.library.path=" + getJavaLibraryPath()]

tasks.withType(JavaExec) {
jvmArgs += incubatorArguments
}
tasks.withType(Test) {
jvmArgs += incubatorArguments
}

dependencies {
implementation project(':sdrplay-api')
implementation 'ch.qos.logback:logback-classic:1.4.4'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'org.slf4j:slf4j-api:2.0.3'

testImplementation 'com.github.wendykierp:JTransforms:3.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
}

test {
useJUnitPlatform()

//Exclude all tests by default. Comment out this line to run tests.
// exclude '**/*'
}

/**
* Determine library path for the current operating system and architecture
*/
static String getJavaLibraryPath() {
OperatingSystem os = DefaultNativePlatform.currentOperatingSystem

if(os.isLinux() || os.isMacOsX()) {
return "/usr/local/lib"
}

if(os.isWindows()) {
if(System.getProperty("sun.arch.data.model").contentEquals("64")) {
return "c:\\Program Files\\SDRplay\\API\\x64"
}
else {
return "c:\\Program Files\\SDRplay\\API\\x86"
}
}

return ""
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2023 Dennis Sheirer
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/

package com.github.dsheirer.sdrplay;

import com.github.dsheirer.sdrplay.device.RspDuoMode;
import com.github.dsheirer.sdrplay.device.TunerSelect;
import java.util.EnumSet;

/**
* Enumeration of modes that indicate how each SDRplay RSP device can be selected
*/
public enum DeviceSelectionMode
{
//All RSP devices
SINGLE_TUNER_1("Single Tuner 1", RspDuoMode.SINGLE_TUNER, TunerSelect.TUNER_1),
SINGLE_TUNER_2("Single Tuner 2", RspDuoMode.SINGLE_TUNER, TunerSelect.TUNER_2),
MASTER_TUNER_1("Master - Tuner 1", RspDuoMode.MASTER, TunerSelect.TUNER_1),
SLAVE_TUNER_2("Slave - Tuner 2", RspDuoMode.SLAVE, TunerSelect.TUNER_2);

private String mDescription;
private RspDuoMode mRspDuoMode;
private TunerSelect mTunerSelect;

/**
* Private constructor
* @param description of the mode
* @param rspDuoMode that corresponds to the mode
* @param tunerSelect tuner(s) that correspond to the mode
*/
DeviceSelectionMode(String description, RspDuoMode rspDuoMode, TunerSelect tunerSelect)
{
mDescription = description;
mRspDuoMode = rspDuoMode;
mTunerSelect = tunerSelect;
}

/**
* Set of all selection modes available for the RSPduo
*/
public static final EnumSet<DeviceSelectionMode> MASTER_MODES = EnumSet.of(MASTER_TUNER_1);
public static final EnumSet<DeviceSelectionMode> SLAVE_MODES = EnumSet.of(SLAVE_TUNER_2);
public static final EnumSet<DeviceSelectionMode> SINGLE_TUNER_MODES = EnumSet.of(SINGLE_TUNER_1, SINGLE_TUNER_2);

/**
* RSPduo mode associated with the selection mode
*/
public RspDuoMode getRspDuoMode()
{
return mRspDuoMode;
}

/**
* Indicates if this mode is designated as a master mode.
*/
public boolean isMasterMode()
{
return MASTER_MODES.contains(this);
}

/**
* Indicates if this mode is designated as a slave mode.
*/
public boolean isSlaveMode()
{
return SLAVE_MODES.contains(this);
}

/**
* Indicates if this is a single-tuner mode
*/
public boolean isSingleTunerMode()
{
return SINGLE_TUNER_MODES.contains(this);
}

/**
* Tuner(s) associated with the selection mode
*/
public TunerSelect getTunerSelect()
{
return mTunerSelect;
}

@Override
public String toString()
{
return mDescription;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/

package com.github.dsheirer.sdrplay;

/**
* SDRplay checked exception.
*/
public class SDRPlayException extends Exception
{
private Status mStatus = Status.UNKNOWN;

/**
* Creates an exception
* @param message for the exception
*/
public SDRPlayException(String message)
{
super(message);
}

/**
* Creates an operation exception
* @param message for the exception
* @param status of the operation
*/
public SDRPlayException(String message, Status status)
{
super(message + " Status:" + status);
mStatus = status;
}

/**
* Creates an exception
* @param message for the exception
* @param throwable nested exception
*/
public SDRPlayException(String message, Throwable throwable)
{
super(message, throwable);
}

public Status getStatus()
{
return mStatus;
}
}
Loading

0 comments on commit 2cb1ee6

Please sign in to comment.