# uncomment the line to below include support local CW keyer
LOCALCW_INCLUDE=LOCALCW
-# uncomment the line below for SoapySDR
-#SOAPYSDR_INCLUDE=SOAPYSDR
-
# uncomment the line to below include support for sx1509 i2c expander
#SX1509_INCLUDE=sx1509
endif
-ifeq ($(SOAPYSDR_INCLUDE),SOAPYSDR)
-SOAPYSDR_OPTIONS=-D SOAPYSDR
-SOAPYSDRLIBS=-lSoapySDR
-SOAPYSDR_SOURCES= \
-soapy_discovery.c \
-soapy_protocol.c
-SOAPYSDR_HEADERS= \
-soapy_discovery.h \
-soapy_protocol.h
-SOAPYSDR_OBJS= \
-soapy_discovery.o \
-soapy_protocol.o
-endif
-
-
ifeq ($(LOCALCW_INCLUDE),LOCALCW)
LOCALCW_OPTIONS=-D LOCALCW
LOCALCW_SOURCES= iambic.c
//CFLAGS= -g -Wno-deprecated-declarations -O3
CFLAGS= -g -Wno-deprecated-declarations
OPTIONS=$(SMALL_SCREEN_OPTIONS) $(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \
- $(GPIO_OPTIONS) $(GPIOD_OPTIONS) $(SOAPYSDR_OPTIONS) $(LOCALCW_OPTIONS) \
+ $(GPIO_OPTIONS) $(GPIOD_OPTIONS) $(LOCALCW_OPTIONS) \
$(PTT_OPTIONS) \
$(SERVER_OPTIONS) \
$(AUDIO_OPTIONS) \
RT_OPTION=-lrt
endif
-LIBS=$(RT_OPTION) -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(MIDI_LIBS)
+LIBS=$(RT_OPTION) -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(GPIO_LIBS) $(MIDI_LIBS)
INCLUDES=$(GTKINCLUDES)
COMPILE=$(CC) $(CFLAGS) $(OPTIONS) $(INCLUDES)
switch_menu.o \
toolbar_menu.o
-$(PROGRAM): $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \
+$(PROGRAM): $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \
$(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \
$(MIDI_OBJS) $(SERVER_OBJS)
$(LINK) -o $(PROGRAM) $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \
- $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \
+ $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \
$(MIDI_OBJS) $(SERVER_OBJS) $(LIBS)
.PHONY: all
-all: prebuild $(PROGRAM) $(HEADERS) $(AUDIO_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \
+all: prebuild $(PROGRAM) $(HEADERS) $(AUDIO_HEADERS) $(USBOZY_HEADERS) \
$(LOCALCW_HEADERS) \
$(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(SERVER_HEADERS) \
$(AUDIO_SOURCES) $(SOURCES) \
- $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(LOCALCW_SOURCE) \
+ $(USBOZY_SOURCES) $(LOCALCW_SOURCE) \
$(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(SERVER_SOURCES)
.PHONY: prebuild
.PHONY: cppcheck
cppcheck:
cppcheck $(CPPOPTIONS) $(OPTIONS) $(CPPINCLUDES) $(AUDIO_SOURCES) $(SOURCES) $(REMOTE_SOURCES) \
- $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) \
+ $(USBOZY_SOURCES) \
$(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(LOCALCW_SOURCES) \
$(SERVER_SOURCES)
vfo_band_changed(active_receiver->id,band12);
}
break;
-#ifdef SOAPYSDR
- case BAND_1240:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,band1240);
- }
- break;
- case BAND_144:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,band144);
- }
- break;
-#endif
case BAND_15:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band15);
vfo_band_changed(active_receiver->id,band20);
}
break;
-#ifdef SOAPYSDR
- case BAND_220:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,band220);
- }
- break;
- case BAND_2300:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,band2300);
- }
- break;
-#endif
case BAND_30:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band30);
}
break;
-#ifdef SOAPYSDR
- case BAND_3400:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,band3400);
- }
- break;
-#endif
case BAND_40:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band40);
}
break;
-#ifdef SOAPYSDR
- case BAND_430:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,band430);
- }
- break;
-#endif
case BAND_6:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band6);
vfo_band_changed(active_receiver->id,band60);
}
break;
-#ifdef SOAPYSDR
- case BAND_70:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,band70);
- }
- break;
-#endif
case BAND_80:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band80);
}
break;
-#ifdef SOAPYSDR
- case BAND_902:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,band902);
- }
- break;
- case BAND_AIR:
- if(a->mode==PRESSED) {
- vfo_band_changed(active_receiver->id,bandAIR);
- }
- break;
-#endif
case BAND_GEN:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,bandGen);
gdouble gain;
gdouble min_gain;
gdouble max_gain;
-#ifdef SOAPYSDR
- gboolean agc;
-#endif
} ADC;
#endif
#include "band.h"
#include "radio.h"
#include "new_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
-
static GtkWidget *parent_window=NULL;
static GtkWidget *menu_b=NULL;
adc->antenna=gtk_combo_box_get_active(widget);
if(radio->protocol==NEW_PROTOCOL) {
schedule_high_priority();
-#ifdef SOAPYSDR
- } else if(radio->device==SOAPYSDR_USB_DEVICE) {
- soapy_protocol_set_rx_antenna(receiver[0],adc[0].antenna);
-#endif
}
}
dac->antenna=gtk_combo_box_get_active(widget);
if(radio->protocol==NEW_PROTOCOL) {
schedule_high_priority();
-#ifdef SOAPYSDR
- } else if(radio->device==SOAPYSDR_USB_DEVICE) {
- soapy_protocol_set_tx_antenna(transmitter,dac->antenna);
-#endif
}
}
g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
-#ifdef SOAPYSDR
- if(radio->device!=SOAPYSDR_USB_DEVICE) {
-#endif
GtkWidget *hf_rb=gtk_radio_button_new_with_label(NULL,"HF");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hf_rb),TRUE);
g_signal_connect(hf_rb,"toggled",G_CALLBACK(hf_rb_cb),NULL);
g_signal_connect(xvtr_rb,"toggled",G_CALLBACK(xvtr_rb_cb),NULL);
gtk_grid_attach(GTK_GRID(grid),xvtr_rb,2,0,1,1);
-#ifdef SOAPYSDR
- }
-#endif
-
if ((protocol == NEW_PROTOCOL && (device == NEW_DEVICE_HERMES || device == NEW_DEVICE_ANGELIA || device == NEW_DEVICE_ORION)) ||
(protocol == ORIGINAL_PROTOCOL && (device == DEVICE_HERMES || device == DEVICE_ANGELIA || device == DEVICE_ORION))) {
show_hf();
}
-#ifdef SOAPYSDR
- if(radio->device==SOAPYSDR_USB_DEVICE) {
- int i;
-
-g_print("rx_antennas=%ld\n",radio->info.soapy.rx_antennas);
- if(radio->info.soapy.rx_antennas>0) {
- GtkWidget *antenna_label=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(antenna_label), "<b>RX Antenna:</b>");
- gtk_grid_attach(GTK_GRID(grid),antenna_label,0,1,1,1);
- adc0_antenna_combo_box=gtk_combo_box_text_new();
-
- for(i=0;i<radio->info.soapy.rx_antennas;i++) {
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(adc0_antenna_combo_box),NULL,radio->info.soapy.rx_antenna[i]);
- }
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(adc0_antenna_combo_box),adc[0].antenna);
- g_signal_connect(adc0_antenna_combo_box,"changed",G_CALLBACK(adc0_antenna_cb),&adc[0]);
- gtk_grid_attach(GTK_GRID(grid),adc0_antenna_combo_box,1,1,1,1);
- }
-
- if(can_transmit) {
- g_print("tx_antennas=%ld\n",radio->info.soapy.tx_antennas);
- if(radio->info.soapy.tx_antennas>0) {
- GtkWidget *antenna_label=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(antenna_label), "<b>TX Antenna:</b>");
- gtk_grid_attach(GTK_GRID(grid),antenna_label,0,2,1,1);
- dac0_antenna_combo_box=gtk_combo_box_text_new();
-
- for(i=0;i<radio->info.soapy.tx_antennas;i++) {
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(dac0_antenna_combo_box),NULL,radio->info.soapy.tx_antenna[i]);
- }
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(dac0_antenna_combo_box),dac[0].antenna);
- g_signal_connect(dac0_antenna_combo_box,"changed",G_CALLBACK(dac0_antenna_cb),&dac[0]);
- gtk_grid_attach(GTK_GRID(grid),dac0_antenna_combo_box,1,2,1,1);
- }
- }
-
- }
-#endif
-
gtk_container_add(GTK_CONTAINER(content),grid);
sub_menu=dialog;
#include "mode.h"
#include "new_protocol.h"
#include "old_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "vfo.h"
int audio = 0;
switch(protocol) {
case ORIGINAL_PROTOCOL:
case NEW_PROTOCOL:
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
-#endif
//
// put sample into ring buffer
//
{50125000LL,modeUSB,filterF5,200,2800,200,2800},
{50200000LL,modeUSB,filterF5,200,2800,200,2800}};
-#ifdef SOAPYSDR
-BANDSTACK_ENTRY bandstack_entries70[] =
- {{70010000LL,modeCWU,filterF6,200,2800,200,2800},
- {70200000LL,modeUSB,filterF5,200,2800,200,2800},
- {70250000LL,modeUSB,filterF5,200,2800,200,2800}};
-
-BANDSTACK_ENTRY bandstack_entries144[] =
- {{144010000LL,modeCWU,filterF6,200,2800,200,2800},
- {144200000LL,modeUSB,filterF5,200,2800,200,2800},
- {144250000LL,modeUSB,filterF5,200,2800,200,2800},
- {145600000LL,modeFMN,filterF1,200,2800,200,2800},
- {145725000LL,modeFMN,filterF1,200,2800,200,2800},
- {145900000LL,modeFMN,filterF1,200,2800,200,2800}};
-
-BANDSTACK_ENTRY bandstack_entries220[] =
- {{220010000LL,modeCWU,filterF6,200,2800,200,2800},
- {220200000LL,modeUSB,filterF5,200,2800,200,2800},
- {220250000LL,modeUSB,filterF5,200,2800,200,2800}};
-
-BANDSTACK_ENTRY bandstack_entries430[] =
- {{430010000LL,modeCWU,filterF6,200,2800,200,2800},
- {432100000LL,modeUSB,filterF5,200,2800,200,2800},
- {432300000LL,modeUSB,filterF5,200,2800,200,2800}};
-
-BANDSTACK_ENTRY bandstack_entries902[] =
- {{902010000LL,modeCWU,filterF6,200,2800,200,2800},
- {902100000LL,modeUSB,filterF5,200,2800,200,2800},
- {902300000LL,modeUSB,filterF5,200,2800,200,2800}};
-
-BANDSTACK_ENTRY bandstack_entries1240[] =
- {{1240010000LL,modeCWU,filterF6,200,2800,200,2800},
- {1240100000LL,modeUSB,filterF5,200,2800,200,2800},
- {1240300000LL,modeUSB,filterF5,200,2800,200,2800}};
-
-BANDSTACK_ENTRY bandstack_entries2300[] =
- {{2300010000LL,modeCWU,filterF6,200,2800,200,2800},
- {2300100000LL,modeUSB,filterF5,200,2800,200,2800},
- {2300300000LL,modeUSB,filterF5,200,2800,200,2800}};
-
-BANDSTACK_ENTRY bandstack_entries3400[] =
- {{3400010000LL,modeCWU,filterF6,200,2800,200,2800},
- {3400100000LL,modeUSB,filterF5,200,2800,200,2800},
- {3400300000LL,modeUSB,filterF5,200,2800,200,2800}};
-
-BANDSTACK_ENTRY bandstack_entriesAIR[] =
- {{118800000LL,modeAM,filterF3,200,2800,200,2800},
- {120000000LL,modeAM,filterF3,200,2800,200,2800},
- {121700000LL,modeAM,filterF3,200,2800,200,2800},
- {124100000LL,modeAM,filterF3,200,2800,200,2800},
- {126600000LL,modeAM,filterF3,200,2800,200,2800},
- {136500000LL,modeAM,filterF3,200,2800,200,2800}};
-#endif
-
BANDSTACK_ENTRY bandstack_entriesGEN[] =
{{909000LL,modeAM,filterF3,-6000,6000,-6000,60000},
{5975000LL,modeAM,filterF3,-6000,6000,-6000,60000},
BANDSTACK bandstack12={3,1,bandstack_entries12};
BANDSTACK bandstack10={3,1,bandstack_entries10};
BANDSTACK bandstack6={3,1,bandstack_entries6};
-#ifdef SOAPYSDR
-BANDSTACK bandstack70={3,1,bandstack_entries70};
-BANDSTACK bandstack144={6,1,bandstack_entries144};
-BANDSTACK bandstack220={3,1,bandstack_entries220};
-BANDSTACK bandstack430={3,1,bandstack_entries430};
-BANDSTACK bandstack902={3,1,bandstack_entries902};
-BANDSTACK bandstack1240={3,1,bandstack_entries1240};
-BANDSTACK bandstack2300={3,1,bandstack_entries2300};
-BANDSTACK bandstack3400={3,1,bandstack_entries3400};
-BANDSTACK bandstackAIR={6,1,bandstack_entriesAIR};
-#endif
BANDSTACK bandstackGEN={3,1,bandstack_entriesGEN};
BANDSTACK bandstackWWV={5,1,bandstack_entriesWWV};
BANDSTACK bandstack136={2,0,bandstack_entries136};
{"12",&bandstack12,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,24890000LL,24990000LL,0LL,0LL,0},
{"10",&bandstack10,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,28000000LL,29700000LL,0LL,0LL,0},
{"6",&bandstack6,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,50000000LL,54000000LL,0LL,0LL,0},
-#ifdef SOAPYSDR
- {"4",&bandstack144,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,70000000LL,70500000LL,0LL,0LL,0},
- {"144",&bandstack144,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,144000000LL,148000000LL,0LL,0LL,0},
- {"220",&bandstack144,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,222000000LL,224980000LL,0LL,0LL,0},
- {"430",&bandstack430,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,420000000LL,450000000LL,0LL,0LL,0},
- {"902",&bandstack430,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,902000000LL,928000000LL,0LL,0LL,0},
- {"1240",&bandstack1240,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,1240000000LL,1300000000LL,0LL,0LL,0},
- {"2300",&bandstack2300,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,2300000000LL,2450000000LL,0LL,0LL,0},
- {"3400",&bandstack3400,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,3400000000LL,3410000000LL,0LL,0LL,0},
- {"AIR",&bandstack3400,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,108000000LL,137000000LL,0LL,0LL,0},
-#endif
{"WWV",&bandstackWWV,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
{"GEN",&bandstackGEN,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0},
// XVTRS
//
if(info_band!=bandGen
&& info_band!=bandWWV
-#ifdef SOAPYSDR
- && info_band!=bandAIR
-#endif
) {
result=TRUE;
}
if (txb == bandGen
|| txb ==bandWWV
-#ifdef SOAPYSDR
- || txb ==bandAIR
-#endif
) return 0;
//
if (tx_out_of_band) return TRUE;
if(info_band!=bandGen
&& info_band!=bandWWV
-#ifdef SOAPYSDR
- && info_band!=bandAIR
-#endif
) {
result=TRUE;
}
band12,
band10,
band6,
-#ifdef SOAPYSDR
- band70,
- band144,
- band220,
- band430,
- band902,
- band1240,
- band2300,
- band3400,
- bandAIR,
-#endif
bandWWV,
bandGen,
BANDS
radio->supported_receivers=ntohs(radio_data.supported_receivers);
temp=ntohll(radio_data.sample_rate);
radio_sample_rate=(int)temp;
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- radio->info.soapy.sample_rate=(int)temp;
- }
-#endif
display_filled=radio_data.display_filled;
locked=radio_data.locked;
receivers=ntohs(radio_data.receivers);
#define _DISCOVERED_H
#include <netinet/in.h>
-#ifdef SOAPYSDR
-#include <SoapySDR/Device.h>
-#endif
#define MAX_DEVICES 16
#define NEW_DEVICE_HERMES_LITE 6
#define NEW_DEVICE_HERMES_LITE2 1006
-#ifdef SOAPYSDR
-#define SOAPYSDR_USB_DEVICE 2000
-#endif
-
#define STATE_AVAILABLE 2
#define STATE_SENDING 3
#define ORIGINAL_PROTOCOL 0
#define NEW_PROTOCOL 1
-#ifdef SOAPYSDR
-#define SOAPYSDR_PROTOCOL 2
-#endif
struct _DISCOVERED {
int protocol;
struct sockaddr_in interface_netmask;
char interface_name[64];
} network;
-#ifdef SOAPYSDR
- struct soapy {
- char version[128];
- char hardware_key[64];
- char driver_key[64];
- int rtlsdr_count;
- int sdrplay_count;
- int sample_rate;
- size_t rx_channels;
- size_t rx_gains;
- char **rx_gain;
- SoapySDRRange *rx_range;
- gboolean rx_has_automatic_gain;
- gboolean rx_has_automatic_dc_offset_correction;
- size_t rx_antennas;
- char **rx_antenna;
- size_t tx_channels;
- size_t tx_gains;
- char **tx_gain;
- SoapySDRRange *tx_range;
- size_t tx_antennas;
- char **tx_antenna;
- size_t sensors;
- char **sensor;
- gboolean has_temp;
- char address[64];
- } soapy;
-#endif
} info;
};
#include "discovered.h"
#include "old_discovery.h"
#include "new_discovery.h"
-#ifdef SOAPYSDR
-#include "soapy_discovery.h"
-#endif
#include "main.h"
#include "radio.h"
#ifdef USBOZY
/* new_discovery(); */
/* } */
-#ifdef SOAPYSDR
- if(enable_soapy_protocol) {
- status_text("SoapySDR ... Discovering Devices");
- soapy_discovery();
- }
-#endif
-
status_text("Discovery");
fprintf(stderr,"discovery: found %d devices\n", devices);
}
#endif
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- sprintf(text,"%s (Protocol SOAPY_SDR %s) on %s",d->name,d->info.soapy.version,d->info.soapy.address);
- break;
-
-#endif
}
GtkWidget *label=gtk_label_new(text);
gtk_widget_set_sensitive(start_button, FALSE);
}
-#ifdef SOAPYSDR
- if(d->device!=SOAPYSDR_USB_DEVICE) {
-#endif
// if not on the same subnet then cannot start it
if((d->info.network.interface_address.sin_addr.s_addr&d->info.network.interface_netmask.sin_addr.s_addr) != (d->info.network.address.sin_addr.s_addr&d->info.network.interface_netmask.sin_addr.s_addr)) {
gtk_button_set_label(GTK_BUTTON(start_button),"Subnet!");
gtk_widget_set_sensitive(start_button, FALSE);
}
-#ifdef SOAPYSDR
- }
-#endif
}
}
#include "radio.h"
#include "new_protocol.h"
#include "old_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "actions.h"
#ifdef GPIO
#include "gpio.h"
case NEW_PROTOCOL:
new_protocol_stop();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_stop();
- break;
-#endif
}
radioSaveState();
radio_stop();
case NEW_PROTOCOL:
new_protocol_stop();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_stop();
- break;
-#endif
}
#ifdef CLIENT_SERVER
}
case NEW_PROTOCOL:
new_protocol_stop();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_stop();
- break;
-#endif
}
radioSaveState();
int rc=system("reboot");
case NEW_PROTOCOL:
new_protocol_stop();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_stop();
- break;
-#endif
}
radioSaveState();
int rc=system("shutdown -h -P now");
}
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- GtkWidget *sample_rate_1M=gtk_radio_button_new_with_label(NULL,"1000000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_1M), sample_rate==1000000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_1M,0,2,1,1);
- g_signal_connect(sample_rate_1M,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)1000000);
-
- GtkWidget *sample_rate_2M=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_1M),"2000000");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_2M), sample_rate==2000000);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_2M,0,3,1,1);
- g_signal_connect(sample_rate_2M,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)2000000);
-
- }
-#endif
-
GtkWidget *rit_label=gtk_label_new("RIT step: ");
gtk_grid_attach(GTK_GRID(grid),rit_label,5,1,1,1);
#include "discovery.h"
#include "new_protocol.h"
#include "old_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "css.h"
#include "ext.h"
#include "vfo.h"
case NEW_PROTOCOL:
new_protocol_stop();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_stop();
- break;
-#endif
}
#ifdef CLIENT_SERVER
}
} else {
level=value + (double)adc[rx->adc].attenuation;
}
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- //level-=rx->rf_gain;
- level-=adc[rx->id].gain;
- }
-#endif
if (filter_board == CHARLY25) {
// preamp/dither encodes the preamp level
if (rx->preamp) level -= 18.0;
} else {
level=value+(double)adc[rx->adc].attenuation;
}
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- //level-=rx->rf_gain;
- level-=adc[rx->id].gain;
- }
-#endif
if (filter_board == CHARLY25) {
// preamp/dither encodes the preamp level
if (rx->preamp) level -= 18.0;
case NEW_PROTOCOL:
new_protocol_restart();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- // dunno how to do this for soapy
- break;
-#endif
}
return TRUE;
}
#include "mode.h"
#include "portaudio.h"
#include "audio.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
static PaStream *record_handle=NULL;
}
}
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- // Note that this call ends up deeply in the TX engine
- soapy_protocol_process_local_mic(sample);
- break;
-#endif
default:
break;
}
gboolean enable_protocol_1;
gboolean enable_protocol_2;
-#ifdef SOAPYSDR
-gboolean enable_soapy_protocol;
-#endif
gboolean autostart;
void protocols_save_state() {
setProperty("enable_protocol_1",value);
sprintf(value,"%d",enable_protocol_2);
setProperty("enable_protocol_2",value);
-#ifdef SOAPYSDR
- sprintf(value,"%d",enable_soapy_protocol);
- setProperty("enable_soapy_protocol",value);
-#endif
sprintf(value,"%d",autostart);
setProperty("autostart",value);
enable_protocol_2=TRUE;
value=getProperty("enable_protocol_2");
if(value) enable_protocol_2=atoi(value);
-#ifdef SOAPYSDR
- enable_soapy_protocol=TRUE;
- value=getProperty("enable_soapy_protocol");
- if(value) enable_soapy_protocol=atoi(value);
-#endif
autostart=TRUE;
value=getProperty("autostart");
if(value) autostart=atoi(value);
enable_protocol_2=gtk_toggle_button_get_active(widget);
}
-#ifdef SOAPYSDR
-static void soapy_protocol_cb(GtkToggleButton *widget, gpointer data) {
- enable_soapy_protocol=gtk_toggle_button_get_active(widget);
-}
-#endif
static void autostart_cb(GtkToggleButton *widget, gpointer data) {
autostart=gtk_toggle_button_get_active(widget);
gtk_grid_attach(GTK_GRID(grid),b_enable_protocol_2,0,row,1,1);
row++;
-#ifdef SOAPYSDR
- GtkWidget *b_enable_soapy_protocol=gtk_check_button_new_with_label("Enable SoapySDR Protocol");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_soapy_protocol), enable_soapy_protocol);
- gtk_widget_show(b_enable_soapy_protocol);
- g_signal_connect(b_enable_soapy_protocol,"toggled",G_CALLBACK(soapy_protocol_cb),NULL);
- gtk_grid_attach(GTK_GRID(grid),b_enable_soapy_protocol,0,row,1,1);
- row++;
-#endif
GtkWidget *b_autostart=gtk_check_button_new_with_label("Auto start if only one device");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_autostart), autostart);
extern gboolean enable_protocol_1;
extern gboolean enable_protocol_2;
-#ifdef SOAPYSDR
-extern gboolean enable_soapy_protocol;
-#endif
extern gboolean autostart;
extern void protocols_save_state();
#include "mode.h"
#include "new_protocol.h"
#include "old_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
int n_input_devices;
AUDIO_DEVICE input_devices[MAX_AUDIO_DEVICES];
switch(protocol) {
case ORIGINAL_PROTOCOL:
case NEW_PROTOCOL:
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
-#endif
//
// put sample into ring buffer
//
#include "receiver.h"
#include "store.h"
#include "transmitter.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "actions.h"
#include "ext.h"
#include "gpio.h"
case NEW_PROTOCOL:
new_protocol_init(display_width);
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_init(FALSE);
- break;
-#endif
}
#ifdef CLIENT_SERVER
}
break;
}
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- if (strcmp(radio->name, "lime") == 0) {
- drive_max = 64.0;
- } else if (strcmp(radio->name, "plutosdr") == 0) {
- drive_max = 89.0;
- }
- pa_power = PA_1W;
- break;
-#endif
}
switch (pa_power) {
break;
}
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- have_rx_gain = 1;
- rx_gain_calibration = 10;
- break;
-#endif
default:
have_rx_gain = 0;
break;
case NEW_PROTOCOL:
can_transmit = 1;
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- can_transmit = (radio->info.soapy.tx_channels != 0);
- g_print("start_radio: can_transmit=%d tx_channels=%d\n", can_transmit,
- (int)radio->info.soapy.tx_channels);
- break;
-#endif
}
//
sprintf(ip, "%s", inet_ntoa(radio->info.network.address.sin_addr));
sprintf(iface, "%s", radio->info.network.interface_name);
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- strcpy(p, "SoapySDR");
- sprintf(version, "v%d.%d.%d)", radio->software_version / 100,
- (radio->software_version % 100) / 10, radio->software_version % 10);
- strcpy(mac, "");
- strcpy(ip, "");
- strcpy(iface, "");
- break;
-#endif
}
switch (protocol) {
}
#endif
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- sprintf(text, "Starting %s (%s %s)", radio->name, "SoapySDR", version);
- break;
-#endif
}
status_text(text);
break;
}
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- sprintf(property_path, "%s.props", radio->name);
- break;
-#endif
}
switch (protocol) {
break;
}
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- if (strcmp(radio->name, "lime") == 0) {
- n_adc = 2;
- } else {
- n_adc = 1;
- }
- break;
-#endif
default:
break;
}
iqswap = 0;
-#ifdef SOAPYSDR
- if (device == SOAPYSDR_USB_DEVICE) {
- iqswap = 1;
- receivers = 1;
- filter_board = NONE;
- }
-#endif
-
/*
adc_attenuation[0]=0;
adc_attenuation[1]=0;
adc[0].attenuation = 0;
}
-#ifdef SOAPYSDR
- adc[0].antenna = 0;
- if (device == SOAPYSDR_USB_DEVICE) {
- adc[0].gain = 0;
- if (radio->info.soapy.rx_gains > 0) {
- adc[0].min_gain = radio->info.soapy.rx_range[0].minimum;
- adc[0].max_gain = radio->info.soapy.rx_range[0].maximum;
- ;
- } else {
- adc[0].min_gain = 0.0;
- adc[0].max_gain = 100.0;
- }
- adc[0].agc = FALSE;
- dac[0].antenna = 1;
- dac[0].gain = 0;
- }
-#endif
adc[1].antenna = ANTENNA_1;
adc[1].filters = AUTOMATIC;
} else {
adc[1].attenuation = 0;
}
-#ifdef SOAPYSDR
- adc[1].antenna = 0;
- if (device == SOAPYSDR_USB_DEVICE) {
- adc[1].gain = 0;
- if (radio->info.soapy.rx_gains > 0) {
- adc[1].min_gain = radio->info.soapy.rx_range[0].minimum;
- adc[1].max_gain = radio->info.soapy.rx_range[0].maximum;
- ;
- } else {
- adc[1].min_gain = 0.0;
- adc[1].max_gain = 100.0;
- }
- adc[1].max_gain = 0;
- adc[1].agc = FALSE;
- dac[1].antenna = 1;
- dac[1].gain = 0;
- }
-
- radio_sample_rate = radio->info.soapy.sample_rate;
-#endif
// g_print("meter_calibration=%f display_calibration=%f\n", meter_calibration,
// display_calibration);
g_print("%s: setup RECEIVERS protocol=%d\n", __FUNCTION__, protocol);
switch (protocol) {
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- g_print("%s: setup RECEIVERS SOAPYSDR\n", __FUNCTION__);
- RECEIVERS = 1;
- MAX_RECEIVERS = RECEIVERS;
-#ifdef PURESIGNAL
- PS_TX_FEEDBACK = 0;
- PS_RX_FEEDBACK = 0;
-#endif
- MAX_DDC = 1;
- break;
-#endif
default:
g_print("%s: setup RECEIVERS default\n", __FUNCTION__);
RECEIVERS = 2;
if (buffer_size > 512)
buffer_size = 512;
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- if (buffer_size > 2048)
- buffer_size = 2048;
- break;
-#endif
}
//
// Sanity Check #2: enable diversity only if there are two RX and two ADCs
schedule_high_priority();
}
-#ifdef SOAPYSDR
- if (protocol == SOAPYSDR_PROTOCOL) {
- RECEIVER *rx = receiver[0];
- soapy_protocol_create_receiver(rx);
- if (can_transmit) {
- soapy_protocol_create_transmitter(transmitter);
- soapy_protocol_set_tx_antenna(transmitter, dac[0].antenna);
- soapy_protocol_set_tx_gain(transmitter, transmitter->drive);
- soapy_protocol_set_tx_frequency(transmitter);
- soapy_protocol_start_transmitter(transmitter);
- }
-
- soapy_protocol_set_rx_antenna(rx, adc[0].antenna);
- soapy_protocol_set_rx_frequency(rx, VFO_A);
- soapy_protocol_set_automatic_gain(rx, adc[0].agc);
- soapy_protocol_set_gain(rx);
-
- if (vfo[0].ctun) {
- setFrequency(vfo[0].ctun_frequency);
- }
- soapy_protocol_start_receiver(rx);
-
- // g_print("radio: set rf_gain=%f\n",rx->rf_gain);
- soapy_protocol_set_gain(rx);
- }
-#endif
g_idle_add(ext_vfo_update, (gpointer)NULL);
tx_set_ps_sample_rate(transmitter, rate);
}
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_change_sample_rate(receiver[0]);
- soapy_protocol_set_mic_sample_rate(rate);
- break;
-#endif
}
}
SetChannelState(transmitter->id, 1, 0);
tx_set_displaying(transmitter, 1);
switch (protocol) {
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_set_tx_frequency(transmitter);
- // soapy_protocol_start_transmitter(transmitter);
- break;
-#endif
}
} else {
// switch to rx
switch (protocol) {
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- // soapy_protocol_stop_transmitter(transmitter);
- break;
-#endif
}
SetChannelState(transmitter->id, 0, 1);
tx_set_displaying(transmitter, 0);
void setMox(int state) {
if (!can_transmit)
return;
-#ifdef SOAPYSDR
- if (protocol == SOAPYSDR_PROTOCOL && !transmitter->local_microphone)
- return;
-#endif
vox_cancel(); // remove time-out
if (mox != state) {
if (state && vox) {
if (vfo[0].ctun) {
SetRXAShiftFreq(rx->id, (double)vfo[0].offset);
RXANBPSetShiftFrequency(rx->id, (double)vfo[0].offset);
-#ifdef SOAPYSDR
- if (protocol == SOAPYSDR_PROTOCOL) {
- /*
- if(radio->can_transmit) {
- if(radio->transmitter!=NULL && radio->transmitter->rx==rx) {
- //soapy_protocol_set_tx_frequency(radio->transmitter);
- }
- }
- */
- }
-#endif
} else {
if (protocol == NEW_PROTOCOL) {
schedule_high_priority();
-#ifdef SOAPYSDR
- } else if (protocol == SOAPYSDR_PROTOCOL) {
- soapy_protocol_set_rx_frequency(rx, VFO_A);
-/*
- if(radio->can_transmit) {
- if(radio->transmitter!=NULL && radio->transmitter->rx==rx) {
- soapy_protocol_set_tx_frequency(radio->transmitter);
- }
- }
-*/
-#endif
}
vfo[0].band = get_band_from_frequency(vfo[0].frequency);
}
switch (protocol) {
case NEW_PROTOCOL:
case ORIGINAL_PROTOCOL:
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
-#endif
if (vfo[v].ctun) {
long long minf =
vfo[v].frequency - (long long)(active_receiver->sample_rate / 2);
break;
case ORIGINAL_PROTOCOL:
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- if (!vfo[v].ctun) {
- soapy_protocol_set_rx_frequency(active_receiver, v);
- vfo[v].offset = 0;
- }
- break;
-#endif
}
}
case NEW_PROTOCOL:
calcDriveLevel();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_set_tx_gain(transmitter, transmitter->drive);
- break;
-#endif
}
}
}
void radio_set_rf_gain(RECEIVER *rx) {
-#ifdef SOAPYSDR
- soapy_protocol_set_gain_element(rx, radio->info.soapy.rx_gain[rx->adc],
- (int)adc[rx->adc].gain);
-#endif
}
void set_attenuation(int value) {
case NEW_PROTOCOL:
schedule_high_priority();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_set_gain_element(
- active_receiver, radio->info.soapy.rx_gain[0], (int)adc[0].gain);
- break;
-#endif
}
}
schedule_high_priority();
}
}
-#ifdef SOAPYSDR
- if (protocol == SOAPYSDR_PROTOCOL) {
- soapy_protocol_set_rx_antenna(active_receiver, v);
- }
-#endif
}
void set_alex_tx_antenna(int v) {
if (value)
adc[0].max_gain = atof(value);
-#ifdef SOAPYSDR
- if (device == SOAPYSDR_USB_DEVICE) {
- value = getProperty("radio.adc[0].agc");
- }
-#endif
value = getProperty("radio.dac[0].antenna");
if (value)
if (value)
adc[1].max_gain = atof(value);
-#ifdef SOAPYSDR
- if (device == SOAPYSDR_USB_DEVICE) {
- value = getProperty("radio.adc[1].agc");
- }
-#endif
value = getProperty("radio.dac[1].antenna");
if (value)
sprintf(value, "%f", adc[0].max_gain);
setProperty("radio.adc[0].max_gain", value);
-#ifdef SOAPYSDR
- if (device == SOAPYSDR_USB_DEVICE) {
- sprintf(value, "%d", soapy_protocol_get_automatic_gain(receiver[0]));
- setProperty("radio.adc[0].agc", value);
- }
-#endif
sprintf(value, "%d", dac[0].antenna);
setProperty("radio.dac[0].antenna", value);
sprintf(value, "%f", adc[1].max_gain);
setProperty("radio.adc[1].max_gain", value);
-#ifdef SOAPYSDR
- if (device == SOAPYSDR_USB_DEVICE) {
- sprintf(value, "%d", soapy_protocol_get_automatic_gain(receiver[1]));
- setProperty("radio.adc[1].agc", value);
- }
-#endif
sprintf(value, "%d", dac[1].antenna);
setProperty("radio.dac[1].antenna", value);
#include "sliders.h"
#include "new_protocol.h"
#include "old_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "actions.h"
#ifdef GPIO
#include "gpio.h"
return FALSE;
}
-#ifdef SOAPYSDR
-static void rf_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
- ADC *adc=(ADC *)data;
- adc->gain=gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
-
- if(radio->device==SOAPYSDR_USB_DEVICE) {
- soapy_protocol_set_gain(receiver[0]);
- }
-}
-
-static void rx_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
- ADC *adc=(ADC *)data;
- if(radio->device==SOAPYSDR_USB_DEVICE) {
- adc->gain=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
- soapy_protocol_set_gain_element(receiver[0],(char *)gtk_widget_get_name(widget),adc->gain);
-/*
- for(int i=0;i<radio->info.soapy.rx_gains;i++) {
- if(strcmp(radio->info.soapy.rx_gain[i],(char *)gtk_widget_get_name(widget))==0) {
- adc[0].rx_gain[i]=gain;
- soapy_protocol_set_gain_element(receiver[0],(char *)gtk_widget_get_name(widget),gain);
- break;
- }
- }
-*/
- }
-}
-
-static void drive_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
- DAC *dac=(DAC *)data;
- if(radio->device==SOAPYSDR_USB_DEVICE) {
- transmitter->drive=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
- soapy_protocol_set_tx_gain(transmitter,(double)transmitter->drive);
-/*
- for(int i=0;i<radio->info.soapy.tx_gains;i++) {
- int value=soapy_protocol_get_tx_gain_element(transmitter,radio->info.soapy.tx_gain[i]);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gains[i]),(double)value);
- }
-*/
- }
-}
-
-static void tx_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
- DAC *dac=(DAC *)data;
- int gain;
- if(radio->device==SOAPYSDR_USB_DEVICE) {
- gain=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
- soapy_protocol_set_tx_gain_element(transmitter,(char *)gtk_widget_get_name(widget),gain);
-/*
- for(int i=0;i<radio->info.soapy.tx_gains;i++) {
- if(strcmp(radio->info.soapy.tx_gain[i],(char *)gtk_widget_get_name(widget))==0) {
- dac[0].tx_gain[i]=gain;
- break;
- }
- }
-*/
- }
-}
-
-
-static void agc_changed_cb(GtkWidget *widget, gpointer data) {
- ADC *adc=(ADC *)data;
- gboolean agc=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- soapy_protocol_set_automatic_gain(active_receiver,agc);
- if(!agc) {
- soapy_protocol_set_gain(active_receiver);
- }
-}
-
-/*
-static void dac0_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
- DAC *dac=(DAC *)data;
- int gain;
- if(radio->device==SOAPYSDR_USB_DEVICE) {
- gain=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
- soapy_protocol_set_tx_gain_element(radio->transmitter,(char *)gtk_widget_get_name(widget),gain);
- for(int i=0;i<radio->discovered->info.soapy.tx_gains;i++) {
- if(strcmp(radio->discovered->info.soapy.tx_gain[i],(char *)gtk_widget_get_name(widget))==0) {
- radio->dac[0].tx_gain[i]=gain;
- break;
- }
- }
- }
-}
-*/
-#endif
static void calibration_value_changed_cb(GtkWidget *widget, gpointer data) {
calibration=(long long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
}
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- if(strcmp(radio->name,"sdrplay")==0) {
- GtkWidget *sample_rate_combo_box=gtk_combo_box_text_new();
-// gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(sample_rate_combo_box),NULL,"96000");
-// gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(sample_rate_combo_box),NULL,"192000");
-// gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(sample_rate_combo_box),NULL,"384000");
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(sample_rate_combo_box),NULL,"768000");
- switch(radio_sample_rate) {
- case 96000:
- gtk_combo_box_set_active(GTK_COMBO_BOX(sample_rate_combo_box),0);
- break;
- case 192000:
- gtk_combo_box_set_active(GTK_COMBO_BOX(sample_rate_combo_box),1);
- break;
- case 384000:
- gtk_combo_box_set_active(GTK_COMBO_BOX(sample_rate_combo_box),2);
- break;
- case 768000:
- gtk_combo_box_set_active(GTK_COMBO_BOX(sample_rate_combo_box),3);
- break;
- }
- g_signal_connect(sample_rate_combo_box,"changed",G_CALLBACK(sample_rate_cb),radio);
- gtk_grid_attach(GTK_GRID(grid),sample_rate_combo_box,col,row,1,1);
- row++;
- } else {
- GtkWidget *sample_rate_label=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(sample_rate_label), "<b>Sample Rate:</b>");
- gtk_grid_attach(GTK_GRID(grid),sample_rate_label,col,row,1,1);
- row++;
-
- char rate[16];
- sprintf(rate,"%d",radio->info.soapy.sample_rate);
-
- GtkWidget *sample_rate=gtk_radio_button_new_with_label(NULL,rate);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate), radio->info.soapy.sample_rate);
- gtk_grid_attach(GTK_GRID(grid),sample_rate,col,row,1,1);
- g_signal_connect(sample_rate,"toggled",G_CALLBACK(sample_rate_cb),GINT_TO_POINTER(radio->info.soapy.sample_rate));
-
- col++;
- }
- break;
-#endif
}
row++;
if(row>temp_row) temp_row=row;
-#ifdef SOAPYSDR
- col=0;
- if(radio->device==SOAPYSDR_USB_DEVICE) {
- int i;
- if(radio->info.soapy.rx_gains>0) {
- GtkWidget *rx_gain=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(rx_gain), "<b>RX Gains:</b>");
- gtk_label_set_justify(GTK_LABEL(rx_gain),GTK_JUSTIFY_LEFT);
- gtk_grid_attach(GTK_GRID(grid),rx_gain,col,row,1,1);
- }
-
- if(can_transmit) {
- if(radio->info.soapy.tx_gains>0) {
- col=2;
- GtkWidget *tx_gain=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(tx_gain), "<b>TX Gains:</b>");
- gtk_grid_attach(GTK_GRID(grid),tx_gain,col,row,1,1);
- }
- }
-
- row++;
- temp_row=row;
- col=0;
- if(strcmp(radio->name,"sdrplay")==0 || strcmp(radio->name,"rtlsdr")==0) {
- for(i=0;i<radio->info.soapy.rx_gains;i++) {
- col=0;
- GtkWidget *rx_gain_label=gtk_label_new(radio->info.soapy.rx_gain[i]);
- gtk_grid_attach(GTK_GRID(grid),rx_gain_label,col,row,1,1);
- col++;
- SoapySDRRange range=radio->info.soapy.rx_range[i];
- if(range.step==0.0) {
- range.step=1.0;
- }
- rx_gains[i]=gtk_spin_button_new_with_range(range.minimum,range.maximum,range.step);
- gtk_widget_set_name (rx_gains[i], radio->info.soapy.rx_gain[i]);
- int value=soapy_protocol_get_gain_element(active_receiver,radio->info.soapy.rx_gain[i]);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(rx_gains[i]),(double)value);
- gtk_grid_attach(GTK_GRID(grid),rx_gains[i],col,row,1,1);
- g_signal_connect(rx_gains[i],"value_changed",G_CALLBACK(rx_gain_value_changed_cb),&adc[0]);
-
- row++;
- }
- } else {
- // used single gain control - LimeSDR works out best setting for the 3 rx gains
- col=0;
- GtkWidget *rf_gain_label=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(rf_gain_label), "<b>RF Gain</b>");
- gtk_grid_attach(GTK_GRID(grid),rf_gain_label,col,row,1,1);
- col++;
- double max=100;
- if(strcmp(radio->name,"lime")==0) {
- max=60.0;
- } else if(strcmp(radio->name,"plutosdr")==0) {
- max=73.0;
- }
- GtkWidget *rf_gain_b=gtk_spin_button_new_with_range(0.0,max,1.0);
- //gtk_spin_button_set_value(GTK_SPIN_BUTTON(rf_gain_b),active_receiver->rf_gain);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(rf_gain_b),adc[active_receiver->id].gain);
- gtk_grid_attach(GTK_GRID(grid),rf_gain_b,col,row,1,1);
- g_signal_connect(rf_gain_b,"value_changed",G_CALLBACK(rf_gain_value_changed_cb),&adc[0]);
-
- row++;
- }
-
- if(radio->info.soapy.rx_has_automatic_gain) {
- GtkWidget *agc=gtk_check_button_new_with_label("Hardware AGC: ");
- gtk_grid_attach(GTK_GRID(grid),agc,col,row,1,1);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(agc),adc[0].agc);
- g_signal_connect(agc,"toggled",G_CALLBACK(agc_changed_cb),&adc[0]);
- row++;
- }
-
- row=temp_row;
-
- if(can_transmit) {
-/*
- //tx_gains=g_new(GtkWidget*,radio->info.soapy.tx_gains);
- for(i=0;i<radio->info.soapy.tx_gains;i++) {
- col=2;
- GtkWidget *tx_gain_label=gtk_label_new(radio->info.soapy.tx_gain[i]);
- gtk_grid_attach(GTK_GRID(grid),tx_gain_label,col,row,1,1);
- col++;
- SoapySDRRange range=radio->info.soapy.tx_range[i];
- if(range.step==0.0) {
- range.step=1.0;
- }
- tx_gains[i]=gtk_spin_button_new_with_range(range.minimum,range.maximum,range.step);
- gtk_widget_set_name (tx_gains[i], radio->info.soapy.tx_gain[i]);
- int value=soapy_protocol_get_tx_gain_element(transmitter,radio->info.soapy.tx_gain[i]);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gains[i]),(double)value);
- //gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gains[i]),(double)dac[0].tx_gain[i]);
- gtk_grid_attach(GTK_GRID(grid),tx_gains[i],col,row,1,1);
- g_signal_connect(tx_gains[i],"value_changed",G_CALLBACK(tx_gain_value_changed_cb),&dac[0]);
-
- gtk_widget_set_sensitive(tx_gains[i], FALSE);
-
- row++;
- }
-*/
- // used single gain control - LimeSDR works out best setting for the 3 rx gains
- col=2;
- GtkWidget *tx_gain_label=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(tx_gain_label), "<b>TX Gain</b>");
- gtk_grid_attach(GTK_GRID(grid),tx_gain_label,col,row,1,1);
- col++;
- double max=100;
- if(strcmp(radio->name,"lime")==0) {
- max=64.0;
- } else if(strcmp(radio->name,"plutosdr")==0) {
- max=89.0;
- }
- tx_gain=gtk_spin_button_new_with_range(0.0,max,1.0);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gain),transmitter->drive);
- gtk_grid_attach(GTK_GRID(grid),tx_gain,col,row,1,1);
- g_signal_connect(tx_gain,"value_changed",G_CALLBACK(drive_gain_value_changed_cb),&adc[0]);
- }
- }
-#endif
gtk_container_add(GTK_CONTAINER(content),grid);
#include "waterfall.h"
#include "new_protocol.h"
#include "old_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "ext.h"
#include "new_menu.h"
#ifdef CLIENT_SERVER
// and then return quickly.
//
if (rx->id == PS_RX_FEEDBACK
-#ifdef SOAPYSDR
- && protocol!=SOAPYSDR_PROTOCOL
-#endif
) return;
#endif
// and then return quickly
//
if (rx->id == PS_RX_FEEDBACK
-#ifdef SOAPYSDR
- && protocol!=SOAPYSDR_PROTOCOL
-#endif
) return;
#endif
}
}
g_print("%s: id=%d default adc=%d\n",__FUNCTION__,rx->id, rx->adc);
-#ifdef SOAPYSDR
- if(radio->device==SOAPYSDR_USB_DEVICE) {
- rx->sample_rate=radio->info.soapy.sample_rate;
- rx->resampler=NULL;
- rx->resample_buffer=NULL;
-g_print("%s: id=%d sample_rate=%d\n",__FUNCTION__,rx->id, rx->sample_rate);
- } else {
-#endif
rx->sample_rate=48000;
-#ifdef SOAPYSDR
- }
-#endif
rx->buffer_size=buffer_size;
rx->fft_size=fft_size;
rx->fps=fps;
SetInputSamplerate(rx->id, sample_rate);
SetEXTANBSamplerate (rx->id, sample_rate);
SetEXTNOBSamplerate (rx->id, sample_rate);
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- soapy_protocol_change_sample_rate(rx);
- soapy_protocol_set_mic_sample_rate(rx->sample_rate);
- }
-#endif
SetChannelState(rx->id,1,0);
case NEW_PROTOCOL:
schedule_high_priority(); // send new frequency
break;
-#if SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_set_rx_frequency(rx,id);
- break;
-#endif
}
}
}
}
}
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- break;
-#endif
}
#ifdef AUDIO_WATERFALL
}
x++;
break;
-
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- {
- int row=1;
- GtkWidget *sample_rate_label=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(sample_rate_label), "<b>Sample Rate</b>");
- gtk_grid_attach(GTK_GRID(grid),sample_rate_label,x,row,1,1);
- row++;
-
-
- char rate_string[16];
- sprintf(rate_string,"%d",radio->info.soapy.sample_rate);
- GtkWidget *sample_rate=gtk_radio_button_new_with_label(NULL,rate_string);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate), radio->info.soapy.sample_rate);
- gtk_grid_attach(GTK_GRID(grid),sample_rate,x,row,1,1);
- g_signal_connect(sample_rate,"toggled",G_CALLBACK(sample_rate_cb),GINT_TO_POINTER(radio->info.soapy.sample_rate));
- row++;
-
- int rate=radio->info.soapy.sample_rate/2;
- while(rate>=48000) {
- sprintf(rate_string,"%d",rate);
- GtkWidget *next_sample_rate=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate),rate_string);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (next_sample_rate), active_receiver->sample_rate==rate);
- gtk_grid_attach(GTK_GRID(grid),next_sample_rate,x,row,1,1);
- g_signal_connect(next_sample_rate,"toggled",G_CALLBACK(sample_rate_cb),GINT_TO_POINTER(rate));
- rate=rate/2;
- row++;
- }
- }
- x++;
- break;
-#endif
-
}
//
if (rx->preamp) s1 -= 18.0;
if (rx->dither) s1 -= 18.0;
}
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- //s1-=rx->rf_gain;
- s1-=adc[rx->id].gain;
- }
-#endif
s1 = floor((rx->panadapter_high - s1)
* (double) display_height
if (rx->preamp) s2 -= 18.0;
if (rx->dither) s2 -= 18.0;
}
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- //s2-=rx->rf_gain;
- s2-=adc[rx->id].gain;
- }
-#endif
s2 = floor((rx->panadapter_high - s2)
* (double) display_height
/ (rx->panadapter_high - rx->panadapter_low));
#include "band.h"
#include "discovered.h"
#include "new_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "vfo.h"
#include "alex.h"
#include "agc.h"
static void rf_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
adc[active_receiver->adc].gain=gtk_range_get_value(GTK_RANGE(rf_gain_scale));
switch(protocol) {
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_set_gain(active_receiver);
- break;
-#endif
default:
break;
}
void set_rf_gain(int rx,double value) {
g_print("%s\n",__FUNCTION__);
adc[receiver[rx]->id].gain=value;
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- soapy_protocol_set_gain(receiver[rx]);
- }
-#endif
if(display_sliders) {
//gtk_range_set_value (GTK_RANGE(attenuation_scale),receiver[rx]->rf_gain);
gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[receiver[rx]->id].gain);
gtk_widget_override_font(rf_gain_label, pango_font_description_from_string("Sans 10"));
gtk_widget_show(rf_gain_label);
gtk_grid_attach(GTK_GRID(sliders),rf_gain_label,6,0,1,1);
-#ifdef SOAPYSDR
- if(protocol==SOAPYSDR_PROTOCOL) {
- rf_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,adc[0].min_gain, adc[0].max_gain, 1.0);
- gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[0].gain);
- } else {
-#endif
rf_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, -12.0, 48.0, 1.0);
gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[active_receiver->adc].gain);
-#ifdef SOAPYSDR
- }
-#endif
gtk_widget_override_font(rf_gain_scale, pango_font_description_from_string("Sans 10"));
gtk_range_set_increments (GTK_RANGE(rf_gain_scale),1.0,1.0);
gtk_widget_show(rf_gain_scale);
+++ /dev/null
-/* Copyright (C)
-* 2019 - John Melton, G0ORX/N6LYT
-*
-* 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 2
-* 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, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*
-*/
-
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <SoapySDR/Device.h>
-#include <SoapySDR/Formats.h>
-#include "discovered.h"
-#include "soapy_discovery.h"
-
-static int rtlsdr_count=0;
-static int sdrplay_count=0;
-
-static void get_info(char *driver) {
- size_t rx_rates_length, tx_rates_length, rx_gains_length, tx_gains_length, ranges_length, rx_antennas_length, tx_antennas_length, rx_bandwidth_length, tx_bandwidth_length;
- int i;
- SoapySDRKwargs args={};
- int software_version=0;
- char *version;
- char *address=NULL;
- int rtlsdr_val=0;
- int sdrplay_val=0;
- char fw_version[16];
- char gw_version[16];
- char hw_version[16];
- char p_version[16];
- char** tx_antennas;
- char** tx_gains;
-
- fprintf(stderr,"soapy_discovery: get_info: %s\n", driver);
-
- strcpy(fw_version,"");
- strcpy(gw_version,"");
- strcpy(hw_version,"");
- strcpy(p_version,"");
-
- SoapySDRKwargs_set(&args, "driver", driver);
- if(strcmp(driver,"rtlsdr")==0) {
- char count[16];
- sprintf(count,"%d",rtlsdr_count);
- SoapySDRKwargs_set(&args, "rtl", count);
- rtlsdr_val=rtlsdr_count;
- rtlsdr_count++;
- } else if(strcmp(driver,"sdrplay")==0) {
- char label[16];
- sprintf(label,"SDRplay Dev%d",sdrplay_count);
- SoapySDRKwargs_set(&args, "label", label);
- sdrplay_val=sdrplay_count;
- sdrplay_count++;
- }
- SoapySDRDevice *sdr = SoapySDRDevice_make(&args);
- SoapySDRKwargs_clear(&args);
- software_version=0;
-
- char *driverkey=SoapySDRDevice_getDriverKey(sdr);
- fprintf(stderr,"DriverKey=%s\n",driverkey);
-
- char *hardwarekey=SoapySDRDevice_getHardwareKey(sdr);
- fprintf(stderr,"HardwareKey=%s\n",hardwarekey);
- if(strcmp(driver,"sdrplay")==0) {
- address=hardwarekey;
- }
-
- SoapySDRKwargs info=SoapySDRDevice_getHardwareInfo(sdr);
- for(i=0;i<info.size;i++) {
- fprintf(stderr,"soapy_discovery: hardware info key=%s val=%s\n",info.keys[i], info.vals[i]);
- if(strcmp(info.keys[i],"firmwareVersion")==0) {
- strcpy(fw_version,info.vals[i]);
- }
- if(strcmp(info.keys[i],"fw_version")==0) {
- version=info.vals[i];
- }
- if(strcmp(info.keys[i],"gatewareVersion")==0) {
- strcpy(gw_version,info.vals[i]);
- software_version=(int)(atof(info.vals[i])*100.0);
- }
- if(strcmp(info.keys[i],"sdrplay_api_api_version")==0) {
- /* take just the first 4 characters here */
- info.vals[i][4]='\0';
- version=info.vals[i];
- }
- if(strcmp(info.keys[i],"hardwareVersion")==0) {
- strcpy(hw_version,info.vals[i]);
- }
- if(strcmp(info.keys[i],"protocolVersion")==0) {
- strcpy(p_version,info.vals[i]);
- }
- }
-
- size_t rx_channels=SoapySDRDevice_getNumChannels(sdr, SOAPY_SDR_RX);
- fprintf(stderr,"Rx channels: %ld\n",rx_channels);
- for(int i=0;i<rx_channels;i++) {
- fprintf(stderr,"Rx channel full duplex: channel=%d fullduplex=%d\n",i,SoapySDRDevice_getFullDuplex(sdr, SOAPY_SDR_RX, i));
- }
-
- size_t tx_channels=SoapySDRDevice_getNumChannels(sdr, SOAPY_SDR_TX);
- fprintf(stderr,"Tx channels: %ld\n",tx_channels);
- for(int i=0;i<tx_channels;i++) {
- fprintf(stderr,"Tx channel full duplex: channel=%d fullduplex=%d\n",i,SoapySDRDevice_getFullDuplex(sdr, SOAPY_SDR_TX, i));
- }
-
-
- int sample_rate=768000;
- SoapySDRRange *rx_rates=SoapySDRDevice_getSampleRateRange(sdr, SOAPY_SDR_RX, 0, &rx_rates_length);
- fprintf(stderr,"Rx sample rates: ");
- for (size_t i = 0; i < rx_rates_length; i++) {
- fprintf(stderr,"%f -> %f (%f),", rx_rates[i].minimum, rx_rates[i].maximum, rx_rates[i].minimum/48000.0);
- }
- if(strcmp(driver,"rtlsdr")==0) {
- sample_rate=1536000;
- }
-
- fprintf(stderr,"\n");
- free(rx_rates);
- fprintf(stderr,"sample_rate selected %d\n",sample_rate);
-
- if(tx_channels>0) {
- SoapySDRRange *tx_rates=SoapySDRDevice_getSampleRateRange(sdr, SOAPY_SDR_TX, 1, &tx_rates_length);
- fprintf(stderr,"Tx sample rates: ");
- for (size_t i = 0; i < tx_rates_length; i++) {
- fprintf(stderr,"%f -> %f (%f),", tx_rates[i].minimum, tx_rates[i].maximum, tx_rates[i].minimum/48000.0);
- }
- fprintf(stderr,"\n");
- free(tx_rates);
- }
-
- double *bandwidths=SoapySDRDevice_listBandwidths(sdr, SOAPY_SDR_RX, 0, &rx_bandwidth_length);
- fprintf(stderr,"Rx bandwidths: ");
- for (size_t i = 0; i < rx_bandwidth_length; i++) {
- fprintf(stderr,"%f, ", bandwidths[i]);
- }
- fprintf(stderr,"\n");
- free(bandwidths);
-
- if(tx_channels>0) {
- bandwidths=SoapySDRDevice_listBandwidths(sdr, SOAPY_SDR_TX, 0, &tx_bandwidth_length);
- fprintf(stderr,"Tx bandwidths: ");
- for (size_t i = 0; i < tx_bandwidth_length; i++) {
- fprintf(stderr,"%f, ", bandwidths[i]);
- }
- fprintf(stderr,"\n");
- free(bandwidths);
- }
-
- double bandwidth=SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_RX, 0);
- fprintf(stderr,"RX0: bandwidth=%f\n",bandwidth);
-
- if(tx_channels>0) {
- bandwidth=SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_TX, 0);
- fprintf(stderr,"TX0: bandwidth=%f\n",bandwidth);
- }
-
- SoapySDRRange *ranges = SoapySDRDevice_getFrequencyRange(sdr, SOAPY_SDR_RX, 0, &ranges_length);
- fprintf(stderr,"Rx freq ranges: ");
- for (size_t i = 0; i < ranges_length; i++) fprintf(stderr,"[%f Hz -> %f Hz step=%f], ", ranges[i].minimum, ranges[i].maximum,ranges[i].step);
- fprintf(stderr,"\n");
-
- char** rx_antennas = SoapySDRDevice_listAntennas(sdr, SOAPY_SDR_RX, 0, &rx_antennas_length);
- fprintf(stderr, "Rx antennas: ");
- for (size_t i = 0; i < rx_antennas_length; i++) fprintf(stderr, "%s, ", rx_antennas[i]);
- fprintf(stderr,"\n");
-
-
- if(tx_channels>0) {
- tx_antennas = SoapySDRDevice_listAntennas(sdr, SOAPY_SDR_TX, 0, &tx_antennas_length);
- fprintf(stderr, "Tx antennas: ");
- for (size_t i = 0; i < tx_antennas_length; i++) fprintf(stderr, "%s, ", tx_antennas[i]);
- fprintf(stderr,"\n");
- }
-
- char **rx_gains = SoapySDRDevice_listGains(sdr, SOAPY_SDR_RX, 0, &rx_gains_length);
-
- gboolean has_automatic_gain=SoapySDRDevice_hasGainMode(sdr, SOAPY_SDR_RX, 0);
- fprintf(stderr,"has_automaic_gain=%d\n",has_automatic_gain);
-
- gboolean has_automatic_dc_offset_correction=SoapySDRDevice_hasDCOffsetMode(sdr, SOAPY_SDR_RX, 0);
- fprintf(stderr,"has_automaic_dc_offset_correction=%d\n",has_automatic_dc_offset_correction);
-
- if(tx_channels>0) {
- tx_gains = SoapySDRDevice_listGains(sdr, SOAPY_SDR_TX, 1, &tx_gains_length);
- }
-
- size_t formats_length;
- char **formats = SoapySDRDevice_getStreamFormats(sdr,SOAPY_SDR_RX,0,&formats_length);
- fprintf(stderr, "Rx formats: ");
- for (size_t i = 0; i < formats_length; i++) fprintf(stderr, "%s, ", formats[i]);
- fprintf(stderr,"\n");
-
- size_t sensors;
- char **sensor = SoapySDRDevice_listSensors(sdr, &sensors);
- gboolean has_temp=FALSE;
- char *ptr;
- fprintf(stderr, "Sensors:\n");
- for (size_t i = 0; i < sensors; i++) {
- char *value=SoapySDRDevice_readSensor(sdr, sensor[i]);
- fprintf(stderr, " %s=%s\n", sensor[i],value);
- if((ptr=strstr(sensor[i],"temp"))!=NULL) {
- has_temp=TRUE;
- }
- }
-
- if(devices<MAX_DEVICES) {
- discovered[devices].device=SOAPYSDR_USB_DEVICE;
- discovered[devices].protocol=SOAPYSDR_PROTOCOL;
- strcpy(discovered[devices].name,driver);
- discovered[devices].supported_receivers=rx_channels;
- discovered[devices].supported_transmitters=tx_channels;
- discovered[devices].adcs=rx_channels;
- discovered[devices].dacs=tx_channels;
- discovered[devices].status=STATE_AVAILABLE;
- discovered[devices].software_version=software_version;
- discovered[devices].frequency_min=ranges[0].minimum;
- discovered[devices].frequency_max=ranges[0].maximum;
- strcpy(discovered[devices].info.soapy.driver_key,driverkey);
- strcpy(discovered[devices].info.soapy.hardware_key,hardwarekey);
- discovered[devices].info.soapy.sample_rate=sample_rate;
- if(strcmp(driver,"rtlsdr")==0) {
- discovered[devices].info.soapy.rtlsdr_count=rtlsdr_val;
- discovered[devices].info.soapy.sdrplay_count=0;
- } else if(strcmp(driver,"sdrplay")==0) {
- discovered[devices].info.soapy.rtlsdr_count=0;
- discovered[devices].info.soapy.sdrplay_count=sdrplay_val;
- } else {
- discovered[devices].info.soapy.rtlsdr_count=0;
- discovered[devices].info.soapy.sdrplay_count=0;
- }
- if(strcmp(driver,"lime")==0) {
- sprintf(discovered[devices].info.soapy.version,"fw=%s gw=%s hw=%s p=%s", fw_version, gw_version, hw_version, p_version);
- } else {
- strcpy(discovered[devices].info.soapy.version,"");
- }
- discovered[devices].info.soapy.rx_channels=rx_channels;
- discovered[devices].info.soapy.rx_gains=rx_gains_length;
- discovered[devices].info.soapy.rx_gain=rx_gains;
- discovered[devices].info.soapy.rx_range=malloc(rx_gains_length*sizeof(SoapySDRRange));
-fprintf(stderr,"Rx gains: \n");
- for (size_t i = 0; i < rx_gains_length; i++) {
- fprintf(stderr,"%s ", rx_gains[i]);
- SoapySDRRange rx_range=SoapySDRDevice_getGainElementRange(sdr, SOAPY_SDR_RX, 0, rx_gains[i]);
- fprintf(stderr,"%f -> %f step=%f\n",rx_range.minimum,rx_range.maximum,rx_range.step);
- discovered[devices].info.soapy.rx_range[i]=rx_range;
- }
- discovered[devices].info.soapy.rx_has_automatic_gain=has_automatic_gain;
- discovered[devices].info.soapy.rx_has_automatic_dc_offset_correction=has_automatic_dc_offset_correction;
- discovered[devices].info.soapy.rx_antennas=rx_antennas_length;
- discovered[devices].info.soapy.rx_antenna=rx_antennas;
-
- discovered[devices].info.soapy.tx_channels=tx_channels;
- if(tx_channels>0) {
- discovered[devices].info.soapy.tx_gains=tx_gains_length;
- discovered[devices].info.soapy.tx_gain=tx_gains;
- discovered[devices].info.soapy.tx_range=malloc(tx_gains_length*sizeof(SoapySDRRange));
- fprintf(stderr,"Tx gains: \n");
- for (size_t i = 0; i < tx_gains_length; i++) {
- fprintf(stderr,"%s ", tx_gains[i]);
- SoapySDRRange tx_range=SoapySDRDevice_getGainElementRange(sdr, SOAPY_SDR_TX, 1, tx_gains[i]);
- fprintf(stderr,"%f -> %f step=%f\n",tx_range.minimum,tx_range.maximum,tx_range.step);
- discovered[devices].info.soapy.tx_range[i]=tx_range;
- }
- discovered[devices].info.soapy.tx_antennas=tx_antennas_length;
- discovered[devices].info.soapy.tx_antenna=tx_antennas;
- }
- discovered[devices].info.soapy.sensors=sensors;
- discovered[devices].info.soapy.sensor=sensor;
- discovered[devices].info.soapy.has_temp=has_temp;
-
-
- if(address!=NULL) {
- strcpy(discovered[devices].info.soapy.address,address);
- } else {
- strcpy(discovered[devices].info.soapy.address,"USB");
- }
-
- devices++;
- }
-
- SoapySDRDevice_unmake(sdr);
-
- free(ranges);
-}
-
-void soapy_discovery() {
- size_t length;
- int i,j;
- SoapySDRKwargs input_args={};
- SoapySDRKwargs args={};
-
-fprintf(stderr,"soapy_discovery\n");
- rtlsdr_count=0;
- SoapySDRKwargs_set(&input_args, "hostname", "pluto.local");
- SoapySDRKwargs *results = SoapySDRDevice_enumerate(&input_args, &length);
-fprintf(stderr,"soapy_discovery: length=%d\n",(int)length);
- for (i = 0; i < length; i++) {
- for (size_t j = 0; j < results[i].size; j++) {
- if(strcmp(results[i].keys[j],"driver")==0 && strcmp(results[i].vals[j],"audio")!=0) {
- get_info(results[i].vals[j]);
- }
- }
- }
- SoapySDRKwargsList_clear(results, length);
-}
+++ /dev/null
-/* Copyright (C)
-* 2019 - John Melton, G0ORX/N6LYT
-*
-* 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 2
-* 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, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*
-*/
-
-#ifndef _SOAPY_DISCOVERY_H
-#define _SOAPY_DISCOVERY_H
-
-void soapy_discovery();
-
-#endif
+++ /dev/null
-/* Copyright (C)
-* 2019 - John Melton, G0ORX/N6LYT
-*
-* 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 2
-* 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, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <wdsp.h>
-
-#include "SoapySDR/Constants.h"
-#include "SoapySDR/Device.h"
-#include "SoapySDR/Formats.h"
-#include "SoapySDR/Version.h"
-#include "SoapySDR/Logger.h"
-
-//#define TIMING
-#ifdef TIMING
-#include <sys/time.h>
-#endif
-
-#include "band.h"
-#include "channel.h"
-#include "discovered.h"
-#include "mode.h"
-#include "filter.h"
-#include "receiver.h"
-#include "transmitter.h"
-#include "radio.h"
-#include "main.h"
-#include "soapy_protocol.h"
-#include "audio.h"
-#include "signal.h"
-#include "vfo.h"
-#include "ext.h"
-#include "error_handler.h"
-
-
-#define MAX_CHANNELS 2
-static SoapySDRStream *rx_stream[MAX_CHANNELS];
-static SoapySDRStream *tx_stream;
-static SoapySDRDevice *soapy_device;
-static int max_samples;
-
-static int samples=0;
-
-static double bandwidth=2000000.0;
-
-static GThread *receive_thread_id;
-static gpointer receive_thread(gpointer data);
-
-static int actual_rate;
-
-#ifdef TIMING
-static int rate_samples;
-#endif
-
-static gboolean running;
-
-static int mic_samples=0;
-static int mic_sample_divisor=1;
-
-static int max_tx_samples;
-static float *output_buffer;
-static int output_buffer_index;
-
-SoapySDRDevice *get_soapy_device() {
- return soapy_device;
-}
-
-void soapy_protocol_set_mic_sample_rate(int rate) {
- mic_sample_divisor=rate/48000;
-}
-
-void soapy_protocol_change_sample_rate(RECEIVER *rx) {
- int rc;
-
-// rx->mutex already locked
- if(strcmp(radio->name,"sdrplay")==0) {
- g_print("%s: setting samplerate=%f\n",__FUNCTION__,(double)rx->sample_rate);
- rc=SoapySDRDevice_setSampleRate(soapy_device,SOAPY_SDR_RX,rx->adc,(double)rx->sample_rate);
- if(rc!=0) {
- g_print("%s: SoapySDRDevice_setSampleRate(%f) failed: %s\n",__FUNCTION__,(double)rx->sample_rate,SoapySDR_errToStr(rc));
- }
- } else if(rx->sample_rate==radio_sample_rate) {
- if(rx->resample_buffer!=NULL) {
- g_free(rx->resample_buffer);
- rx->resample_buffer=NULL;
- rx->resample_buffer_size=0;
- }
- if(rx->resampler!=NULL) {
- destroy_resample(rx->resampler);
- rx->resampler=NULL;
- }
- } else {
- if(rx->resample_buffer!=NULL) {
- g_free(rx->resample_buffer);
- rx->resample_buffer=NULL;
- }
- if(rx->resampler!=NULL) {
- destroy_resample(rx->resampler);
- rx->resampler=NULL;
- }
- rx->resample_buffer_size=2*max_samples/(radio_sample_rate/rx->sample_rate);
- rx->resample_buffer=g_new(double,rx->resample_buffer_size);
- rx->resampler=create_resample (1,max_samples,rx->buffer,rx->resample_buffer,radio_sample_rate,rx->sample_rate,0.0,0,1.0);
-
- }
-
-}
-
-void soapy_protocol_create_receiver(RECEIVER *rx) {
- int rc;
-
- mic_sample_divisor=rx->sample_rate/48000;
-
- g_print("%s: device=%p adc=%d setting bandwidth=%f\n",__FUNCTION__,soapy_device,rx->adc,bandwidth);
- rc=SoapySDRDevice_setBandwidth(soapy_device,SOAPY_SDR_RX,rx->adc,bandwidth);
- if(rc!=0) {
- g_print("%s: SoapySDRDevice_setBandwidth(%f) failed: %s\n",__FUNCTION__,(double)bandwidth,SoapySDR_errToStr(rc));
- }
-
- g_print("%s: setting samplerate=%f device=%p adc=%d mic_sample_divisor=%d\n",__FUNCTION__,(double)radio_sample_rate,soapy_device,rx->adc,mic_sample_divisor);
- rc=SoapySDRDevice_setSampleRate(soapy_device,SOAPY_SDR_RX,rx->adc,(double)radio_sample_rate);
- if(rc!=0) {
- g_print("%s: SoapySDRDevice_setSampleRate(%f) failed: %s\n",__FUNCTION__,(double)radio_sample_rate,SoapySDR_errToStr(rc));
- }
-
- size_t channel=rx->adc;
-#if defined(SOAPY_SDR_API_VERSION) && (SOAPY_SDR_API_VERSION < 0x00080000)
- g_print("%s: SoapySDRDevice_setupStream(version<0x00080000): channel=%ld\n",__FUNCTION__,channel);
- rc=SoapySDRDevice_setupStream(soapy_device,&rx_stream[channel],SOAPY_SDR_RX,SOAPY_SDR_CF32,&channel,1,NULL);
- if(rc!=0) {
- g_print("%s: SoapySDRDevice_setupStream (RX) failed: %s\n",__FUNCTION__,SoapySDR_errToStr(rc));
- _exit(-1);
- }
-#else
- g_print("%s: SoapySDRDevice_setupStream(version>=0x00080000): channel=%ld\n",__FUNCTION__,channel);
- rx_stream[channel]=SoapySDRDevice_setupStream(soapy_device,SOAPY_SDR_RX,SOAPY_SDR_CF32,&channel,1,NULL);
- if(rx_stream[channel]==NULL) {
- g_print("%s: SoapySDRDevice_setupStream (RX) failed (rx_stream is NULL)\n",__FUNCTION__);
- _exit(-1);
- }
-#endif
-
- g_print("%s: id=%d soapy_device=%p rx_stream=%p\n",__FUNCTION__,rx->id,soapy_device,rx_stream);
-
- max_samples=SoapySDRDevice_getStreamMTU(soapy_device,rx_stream[channel]);
- g_print("%s: max_samples=%d\n",__FUNCTION__,max_samples);
- if(max_samples>(2*rx->fft_size)) {
- max_samples=2*rx->fft_size;
- }
- rx->buffer=g_new(double,max_samples*2);
-
- if(rx->sample_rate==radio_sample_rate) {
- rx->resample_buffer=NULL;
- rx->resampler=NULL;
- rx->resample_buffer_size=0;
- } else {
- rx->resample_buffer_size=2*max_samples/(radio_sample_rate/rx->sample_rate);
- rx->resample_buffer=g_new(double,rx->resample_buffer_size);
- rx->resampler=create_resample (1,max_samples,rx->buffer,rx->resample_buffer,radio_sample_rate,rx->sample_rate,0.0,0,1.0);
- }
-
-
-g_print("%s: max_samples=%d buffer=%p\n",__FUNCTION__,max_samples,rx->buffer);
-
-}
-
-void soapy_protocol_start_receiver(RECEIVER *rx) {
- int rc;
-
- g_print("%s: id=%d soapy_device=%p rx_stream=%p\n",__FUNCTION__,rx->id,soapy_device,rx_stream);
-
- size_t channel=rx->adc;
- double rate=SoapySDRDevice_getSampleRate(soapy_device,SOAPY_SDR_RX,rx->adc);
- g_print("%s: rate=%f\n",__FUNCTION__,rate);
-
- g_print("%s: activate Stream\n",__FUNCTION__);
- rc=SoapySDRDevice_activateStream(soapy_device, rx_stream[channel], 0, 0LL, 0);
- if(rc!=0) {
- g_print("%s: SoapySDRDevice_activateStream failed: %s\n",__FUNCTION__,SoapySDR_errToStr(rc));
- _exit(-1);
- }
-
- g_print("%s: create receiver_thread\n",__FUNCTION__);
- receive_thread_id = g_thread_new( "soapy_rx", receive_thread, rx);
- if( ! receive_thread_id )
- {
- g_print("%s: g_thread_new failed for receive_thread\n",__FUNCTION__);
- exit( -1 );
- }
- g_print("%s: receiver_thread_id=%p\n",__FUNCTION__,receive_thread_id);
-}
-
-void soapy_protocol_create_transmitter(TRANSMITTER *tx) {
- int rc;
-
- g_print("%s: setting samplerate=%f\n",__FUNCTION__,(double)tx->iq_output_rate);
- rc=SoapySDRDevice_setSampleRate(soapy_device,SOAPY_SDR_TX,tx->dac,(double)tx->iq_output_rate);
- if(rc!=0) {
- g_print("%s: SoapySDRDevice_setSampleRate(%f) failed: %s\n",__FUNCTION__,(double)tx->iq_output_rate,SoapySDR_errToStr(rc));
- }
-
-
- size_t channel=tx->dac;
- g_print("%s: SoapySDRDevice_setupStream: channel=%ld\n",__FUNCTION__,channel);
-#if defined(SOAPY_SDR_API_VERSION) && (SOAPY_SDR_API_VERSION < 0x00080000)
- rc=SoapySDRDevice_setupStream(soapy_device,&tx_stream,SOAPY_SDR_TX,SOAPY_SDR_CF32,&channel,1,NULL);
- if(rc!=0) {
- g_print("%s: SoapySDRDevice_setupStream (RX) failed: %s\n",__FUNCTION__,SoapySDR_errToStr(rc));
- _exit(-1);
- }
-#else
- tx_stream=SoapySDRDevice_setupStream(soapy_device,SOAPY_SDR_TX,SOAPY_SDR_CF32,&channel,1,NULL);
- if(tx_stream==NULL) {
- g_print("%s: SoapySDRDevice_setupStream (TX) failed: %s\n",__FUNCTION__,SoapySDR_errToStr(rc));
- _exit(-1);
- }
-#endif
-
- max_tx_samples=SoapySDRDevice_getStreamMTU(soapy_device,tx_stream);
- if(max_tx_samples>(2*tx->fft_size)) {
- max_tx_samples=2*tx->fft_size;
- }
- g_print("%s: max_tx_samples=%d\n",__FUNCTION__,max_tx_samples);
- output_buffer=(float *)malloc(max_tx_samples*sizeof(float)*2);
-
-}
-
-void soapy_protocol_start_transmitter(TRANSMITTER *tx) {
- int rc;
-
-double rate=SoapySDRDevice_getSampleRate(soapy_device,SOAPY_SDR_TX,tx->dac);
-fprintf(stderr,"soapy_protocol_start_transmitter: activateStream rate=%f\n",rate);
- rc=SoapySDRDevice_activateStream(soapy_device, tx_stream, 0, 0LL, 0);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol_start_transmitter: SoapySDRDevice_activateStream failed: %s\n",SoapySDR_errToStr(rc));
- _exit(-1);
- }
-}
-
-void soapy_protocol_stop_transmitter(TRANSMITTER *tx) {
- int rc;
-
-fprintf(stderr,"soapy_protocol_stop_transmitter: deactivateStream\n");
- rc=SoapySDRDevice_deactivateStream(soapy_device, tx_stream, 0, 0LL);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol_stop_transmitter: SoapySDRDevice_deactivateStream failed: %s\n",SoapySDR_errToStr(rc));
- _exit(-1);
- }
-}
-
-void soapy_protocol_init(gboolean hf) {
- SoapySDRKwargs args={};
- char temp[32];
- int rc;
- int i;
-
-
- SoapySDR_setLogLevel(SOAPY_SDR_TRACE);
-
-g_print("%s: hf=%d driver=%s\n",__FUNCTION__,hf,radio->name);
-
- // initialize the radio
- SoapySDRKwargs_set(&args, "driver", radio->name);
- if(strcmp(radio->name,"rtlsdr")==0) {
- sprintf(temp,"%d",radio->info.soapy.rtlsdr_count);
- SoapySDRKwargs_set(&args, "rtl", temp);
-
- if(hf) {
- SoapySDRKwargs_set(&args, "direct_samp", "2");
- } else {
- SoapySDRKwargs_set(&args, "direct_samp", "0");
- }
- } else if(strcmp(radio->name,"sdrplay")==0) {
- sprintf(temp,"SDRplay Dev%d",radio->info.soapy.sdrplay_count);
- g_print("%s: label=%s\n",__FUNCTION__,temp);
- SoapySDRKwargs_set(&args, "label", temp);
- }
- soapy_device=SoapySDRDevice_make(&args);
- if(soapy_device==NULL) {
- g_print("%s: SoapySDRDevice_make failed: %s\n",__FUNCTION__,SoapySDRDevice_lastError());
- _exit(-1);
- }
- SoapySDRKwargs_clear(&args);
-
- g_print("%s: soapy_device=%p\n",__FUNCTION__,soapy_device);
-
- if(can_transmit) {
- if(transmitter->local_microphone) {
- if(audio_open_input()!=0) {
- g_print("%s: audio_open_input failed\n",__FUNCTION__);
- transmitter->local_microphone=0;
- }
- }
- }
-
-}
-
-static void *receive_thread(void *arg) {
- double isample;
- double qsample;
- int elements;
- int flags=0;
- long long timeNs=0;
- long timeoutUs=100000L;
- int i;
- RECEIVER *rx=(RECEIVER *)arg;
- float *buffer=g_new(float,max_samples*2);
- void *buffs[]={buffer};
- float fsample;
- running=TRUE;
-fprintf(stderr,"soapy_protocol: receive_thread\n");
- size_t channel=rx->adc;
- while(running) {
- elements=SoapySDRDevice_readStream(soapy_device,rx_stream[channel],buffs,max_samples,&flags,&timeNs,timeoutUs);
- //fprintf(stderr,"soapy_protocol_receive_thread: SoapySDRDevice_readStream failed: max_samples=%d read=%d\n",max_samples,elements);
- if(elements<0) {
- continue;
- }
-
- for(i=0;i<elements;i++) {
- rx->buffer[i*2]=(double)buffer[i*2];
- rx->buffer[(i*2)+1]=(double)buffer[(i*2)+1];
- }
-
- if(rx->resampler!=NULL) {
- int samples=xresample(rx->resampler);
- for(i=0;i<samples;i++) {
- isample=rx->resample_buffer[i*2];
- qsample=rx->resample_buffer[(i*2)+1];
- if(iqswap) {
- add_iq_samples(rx,qsample,isample);
- } else {
- add_iq_samples(rx,isample,qsample);
- }
- if(can_transmit) {
- mic_samples++;
- if(mic_samples>=mic_sample_divisor) { // reduce to 48000
- if(transmitter!=NULL) {
- fsample = transmitter->local_microphone ? audio_get_next_mic_sample() : 0.0F;
- } else {
- fsample=0.0F;
- }
- add_mic_sample(transmitter,fsample);
- mic_samples=0;
- }
- }
- }
- } else {
- for(i=0;i<elements;i++) {
- isample=rx->buffer[i*2];
- qsample=rx->buffer[(i*2)+1];
- if(iqswap) {
- add_iq_samples(rx,qsample,isample);
- } else {
- add_iq_samples(rx,isample,qsample);
- }
- if(can_transmit) {
- mic_samples++;
- if(mic_samples>=mic_sample_divisor) { // reduce to 48000
- if(transmitter!=NULL) {
- fsample = transmitter->local_microphone ? audio_get_next_mic_sample() : 0.0F;
- } else {
- fsample=0.0F;
- }
- add_mic_sample(transmitter,fsample);
- mic_samples=0;
- }
- }
- }
- }
- }
-
-fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_deactivateStream\n");
- SoapySDRDevice_deactivateStream(soapy_device,rx_stream[channel],0,0LL);
- /*
-fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_closeStream\n");
- SoapySDRDevice_closeStream(soapy_device,rx_stream[channel]);
-fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_unmake\n");
- SoapySDRDevice_unmake(soapy_device);
- */
- return NULL;
-}
-
-void soapy_protocol_process_local_mic(float sample) {
- add_mic_sample(transmitter,sample);
-}
-
-void soapy_protocol_iq_samples(float isample,float qsample) {
- const void *tx_buffs[]={output_buffer};
- int flags=0;
- long long timeNs=0;
- long timeoutUs=100000L;
- if(isTransmitting()) {
- output_buffer[(output_buffer_index*2)]=isample;
- output_buffer[(output_buffer_index*2)+1]=qsample;
- output_buffer_index++;
- if(output_buffer_index>=max_tx_samples) {
- int elements=SoapySDRDevice_writeStream(soapy_device,tx_stream,tx_buffs,max_tx_samples,&flags,timeNs,timeoutUs);
- if(elements!=max_tx_samples) {
- g_print("soapy_protocol_iq_samples: writeStream returned %d for %d elements\n",elements,max_tx_samples);
- }
- output_buffer_index=0;
- }
- }
-}
-
-
-
-void soapy_protocol_stop() {
-fprintf(stderr,"soapy_protocol_stop\n");
- running=FALSE;
-}
-
-void soapy_protocol_set_rx_frequency(RECEIVER *rx,int v) {
- int rc;
-
- if(soapy_device!=NULL) {
- double f=(double)(vfo[v].frequency-vfo[v].lo);
- rc=SoapySDRDevice_setFrequency(soapy_device,SOAPY_SDR_RX,rx->adc,f,NULL);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol: SoapySDRDevice_setFrequency(RX) failed: %s\n",SoapySDR_errToStr(rc));
- }
- }
-}
-
-void soapy_protocol_set_tx_frequency(TRANSMITTER *tx) {
- int v;
- int rc;
- double f;
-
- v=get_tx_vfo();
- if(soapy_device!=NULL) {
- if(vfo[v].ctun) {
- f=(double)(vfo[v].ctun_frequency);
- } else {
- f=(double)(vfo[v].frequency);
- }
-
- if(transmitter->xit_enabled) {
- f+=(double)(transmitter->xit);
- }
-
-//fprintf(stderr,"soapy_protocol_set_tx_frequency: %f\n",f);
- rc=SoapySDRDevice_setFrequency(soapy_device,SOAPY_SDR_TX,tx->dac,f,NULL);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol: SoapySDRDevice_setFrequency(TX) failed: %s\n",SoapySDR_errToStr(rc));
- }
- }
-}
-
-void soapy_protocol_set_rx_antenna(RECEIVER *rx,int ant) {
- int rc;
- if(soapy_device!=NULL) {
- if (ant >= radio->info.soapy.rx_antennas) ant=radio->info.soapy.rx_antennas -1;
- g_print("soapy_protocol: set_rx_antenna: %s\n",radio->info.soapy.rx_antenna[ant]);
- rc=SoapySDRDevice_setAntenna(soapy_device,SOAPY_SDR_RX,rx->adc,radio->info.soapy.rx_antenna[ant]);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol: SoapySDRDevice_setAntenna RX failed: %s\n",SoapySDR_errToStr(rc));
- }
- }
-}
-
-void soapy_protocol_set_tx_antenna(TRANSMITTER *tx,int ant) {
- int rc;
- if(soapy_device!=NULL) {
- if (ant >= radio->info.soapy.tx_antennas) ant=radio->info.soapy.tx_antennas -1;
- g_print("soapy_protocol: set_tx_antenna: %s\n",radio->info.soapy.tx_antenna[ant]);
- rc=SoapySDRDevice_setAntenna(soapy_device,SOAPY_SDR_TX,tx->dac,radio->info.soapy.tx_antenna[ant]);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol: SoapySDRDevice_setAntenna TX failed: %s\n",SoapySDR_errToStr(rc));
- }
- }
-}
-
-void soapy_protocol_set_gain(RECEIVER *rx) {
- int rc;
-//fprintf(stderr,"soapy_protocol_set_gain: adc=%d gain=%f\n",gain);
- rc=SoapySDRDevice_setGain(soapy_device,SOAPY_SDR_RX,rx->adc,adc[rx->adc].gain);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol: SoapySDRDevice_setGain failed: %s\n",SoapySDR_errToStr(rc));
- }
-}
-
-void soapy_protocol_set_gain_element(RECEIVER *rx,char *name,int gain) {
- int rc;
-g_print("%s: adc=%d %s=%d\n",__FUNCTION__,rx->adc,name,gain);
- rc=SoapySDRDevice_setGainElement(soapy_device,SOAPY_SDR_RX,rx->adc,name,(double)gain);
- if(rc!=0) {
- g_print("%s: SoapySDRDevice_setGainElement %s failed: %s\n",__FUNCTION__,name,SoapySDR_errToStr(rc));
- }
-}
-
-void soapy_protocol_set_tx_gain(TRANSMITTER *tx,int gain) {
- int rc;
- rc=SoapySDRDevice_setGain(soapy_device,SOAPY_SDR_TX,tx->dac,(double)gain);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol: SoapySDRDevice_setGain failed: %s\n",SoapySDR_errToStr(rc));
- }
-}
-
-void soapy_protocol_set_tx_gain_element(TRANSMITTER *tx,char *name,int gain) {
- int rc;
- rc=SoapySDRDevice_setGainElement(soapy_device,SOAPY_SDR_TX,tx->dac,name,(double)gain);
- if(rc!=0) {
- fprintf(stderr,"soapy_protocol: SoapySDRDevice_setGainElement %s failed: %s\n",name,SoapySDR_errToStr(rc));
- }
-}
-
-int soapy_protocol_get_gain_element(RECEIVER *rx,char *name) {
- double gain;
- gain=SoapySDRDevice_getGainElement(soapy_device,SOAPY_SDR_RX,rx->adc,name);
- return (int)gain;
-}
-
-int soapy_protocol_get_tx_gain_element(TRANSMITTER *tx,char *name) {
- double gain;
- gain=SoapySDRDevice_getGainElement(soapy_device,SOAPY_SDR_TX,tx->dac,name);
- return (int)gain;
-}
-
-gboolean soapy_protocol_get_automatic_gain(RECEIVER *rx) {
- gboolean mode=SoapySDRDevice_getGainMode(soapy_device, SOAPY_SDR_RX, rx->adc);
- return mode;
-}
-
-void soapy_protocol_set_automatic_gain(RECEIVER *rx,gboolean mode) {
- int rc;
- rc=SoapySDRDevice_setGainMode(soapy_device, SOAPY_SDR_RX, rx->adc,mode);
- if(rc!=0) {
-
- fprintf(stderr,"soapy_protocol: SoapySDRDevice_getGainMode failed: %s\n", SoapySDR_errToStr(rc));
- }
-}
+++ /dev/null
-/* Copyright (C)
-* 2015 - John Melton, G0ORX/N6LYT
-*
-* 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 2
-* 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, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*
-*/
-
-#ifndef _SOAPY_PROTOCOL_H
-#define _SOAPY_PROTOCOL_H
-
-#define BUFFER_SIZE 1024
-
-SoapySDRDevice *get_soapy_device();
-
-void soapy_protocol_create_receiver(RECEIVER *rx);
-void soapy_protocol_start_receiver(RECEIVER *rx);
-
-void soapy_protocol_init(gboolean hf);
-void soapy_protocol_stop();
-void soapy_protocol_set_rx_frequency(RECEIVER *rx,int v);
-void soapy_protocol_set_rx_antenna(RECEIVER *rx,int ant);
-void soapy_protocol_set_lna_gain(RECEIVER *rx,int gain);
-void soapy_protocol_set_gain(RECEIVER *rx);
-void soapy_protocol_set_gain_element(RECEIVER *rx,char *name,int gain);
-int soapy_protocol_get_gain_element(RECEIVER *rx,char *name);
-void soapy_protocol_change_sample_rate(RECEIVER *rx);
-gboolean soapy_protocol_get_automatic_gain(RECEIVER *rx);
-void soapy_protocol_set_automatic_gain(RECEIVER *rx,gboolean mode);
-void soapy_protocol_create_transmitter(TRANSMITTER *tx);
-void soapy_protocol_start_transmitter(TRANSMITTER *tx);
-void soapy_protocol_stop_transmitter(TRANSMITTER *tx);
-void soapy_protocol_set_tx_frequency(TRANSMITTER *tx);
-void soapy_protocol_set_tx_antenna(TRANSMITTER *tx,int ant);
-void soapy_protocol_set_tx_gain(TRANSMITTER *tx,int gain);
-void soapy_protocol_set_tx_gain_element(TRANSMITTER *tx,char *name,int gain);
-int soapy_protocol_get_tx_gain_element(TRANSMITTER *tx,char *name);
-void soapy_protocol_process_local_mic(float sample);
-void soapy_protocol_iq_samples(float isample,float qsample);
-void soapy_protocol_set_mic_sample_rate(int rate);
-#endif
#include "transmitter.h"
#include "new_protocol.h"
#include "old_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "audio.h"
#include "ext.h"
}
break;
-#ifdef SOAPY_SDR
- case SOAPY_PROTOCOL:
- transmitter->fwd=0.0;
- transmitter->exciter=0.0;
- transmitter->rev=0.0;
- break;
-#endif
}
double fwd=compute_power(transmitter->fwd);
tx->mic_dsp_rate=96000;
tx->iq_output_rate=192000;
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- tx->mic_sample_rate=48000;
- tx->mic_dsp_rate=96000;
- tx->iq_output_rate=radio_sample_rate;
- break;
-#endif
}
int ratio=tx->iq_output_rate/tx->mic_sample_rate;
case NEW_PROTOCOL:
gain=8388607.0; // 24 bit
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- gain=32767.0; // 16 bit
- break;
-#endif
}
if (cwmode) {
case NEW_PROTOCOL:
new_protocol_iq_samples(isample,qsample);
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_iq_samples((float)isample,(float)qsample);
- break;
-#endif
}
}
}
tx->puresignal = state ? 1 : 0;
schedule_high_priority();
schedule_receive_specific();
-#ifdef SOAPY_SDR
- case SOAPY_PROTOCOL:
- // are there feedback channels in SOAPY?
- break;
-#endif
}
if(state) {
// if switching on: wait a while to get the feedback
char build_version[]=GIT_VERSION;
char version[]=GIT_VERSION
-#if defined(GPIO) || defined(PURESIGNAL) || defined(SOAPYSDR) || defined(MIDI)
+#if defined(GPIO) || defined(PURESIGNAL) || defined(MIDI)
" includes"
#endif
#ifdef GPIO
#ifdef PURESIGNAL
" PURESIGNAL"
#endif
-#ifdef SOAPYSDR
-" SOAPYSDR"
-#endif
#ifdef MIDI
" MIDI"
#endif
#include "receiver.h"
#include "transmitter.h"
#include "new_protocol.h"
-#ifdef SOAPYSDR
-#include "soapy_protocol.h"
-#endif
#include "vfo.h"
#include "channel.h"
#include "toolbar.h"
vfo[i].band=band20;
vfo[i].bandstack=0;
vfo[i].frequency=14010000;
-#ifdef SOAPYSDR
- if(radio->protocol==SOAPYSDR_PROTOCOL) {
- vfo[i].band=band144;
- vfo[i].bandstack=0;
- vfo[i].frequency=144010000;
- }
-#endif
vfo[i].mode=modeCWU;
vfo[i].filter=filterF6;
vfo[i].lo=0;
case NEW_PROTOCOL:
schedule_general();
break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- soapy_protocol_set_rx_frequency(active_receiver,id);
- break;
-#endif
}
g_idle_add(ext_vfo_update,NULL);
}