noise_menu.c \
agc_menu.c \
fm_menu.c \
+vox_menu.c \
test_menu.c \
rit.c \
meter.c \
vfo.c \
waterfall.c \
wdsp_init.c \
-button_text.c
+button_text.c \
+vox.c
HEADERS= \
noise_menu.h \
agc_menu.h \
fm_menu.h \
+vox_menu.h \
test_menu.h \
rit.h \
meter.h \
vfo.h \
waterfall.h \
wdsp_init.h \
-button_text.h
+button_text.h \
+vox.h
OBJS= \
noise_menu.o \
agc_menu.o \
fm_menu.o \
+vox_menu.o \
test_menu.o \
rit.o \
meter.o \
vfo.o \
waterfall.o \
wdsp_init.o \
-button_text.o
+button_text.o \
+vox.o
all: prebuild $(PROGRAM) $(HEADERS) $(LIMESDR_HEADERS) $(FREEDV_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) $(SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) $(GPIO_SOURCES) $(PSK_SOURCES)
return TRUE;
}
-static void linein_cb(GtkWidget *widget, gpointer data) {
- mic_linein=mic_linein==1?0:1;
-}
-
static void micboost_cb(GtkWidget *widget, gpointer data) {
mic_boost=mic_boost==1?0:1;
}
+static void linein_cb(GtkWidget *widget, gpointer data) {
+ mic_linein=mic_linein==1?0:1;
+}
+
static void local_audio_cb(GtkWidget *widget, gpointer data) {
if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
if(audio_open_output()==0) {
}
}
-
void audio_menu(GtkWidget *parent) {
int i;
GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
GtkWidget *grid=gtk_grid_new();
- //gtk_grid_set_column_spacing (GTK_GRID(grid),10);
- //gtk_grid_set_row_spacing (GTK_GRID(grid),10);
+ gtk_grid_set_column_spacing (GTK_GRID(grid),10);
+ gtk_grid_set_row_spacing (GTK_GRID(grid),5);
//gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
//gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
+ int row=0;
if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) {
- GtkWidget *linein_b=gtk_check_button_new_with_label("Mic Line In");
+ GtkWidget *linein_b=gtk_check_button_new_with_label("Mic Line In (ACC connector)");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (linein_b), mic_linein);
gtk_widget_show(linein_b);
- gtk_grid_attach(GTK_GRID(grid),linein_b,0,1,1,1);
+ gtk_grid_attach(GTK_GRID(grid),linein_b,0,++row,1,1);
g_signal_connect(linein_b,"toggled",G_CALLBACK(linein_cb),NULL);
- GtkWidget *micboost_b=gtk_check_button_new_with_label("Mic Boost");
+ GtkWidget *micboost_b=gtk_check_button_new_with_label("Mic Boost (radio only)");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (micboost_b), mic_boost);
gtk_widget_show(micboost_b);
- gtk_grid_attach(GTK_GRID(grid),micboost_b,0,2,1,1);
+ gtk_grid_attach(GTK_GRID(grid),micboost_b,0,++row,1,1);
g_signal_connect(micboost_b,"toggled",G_CALLBACK(micboost_cb),NULL);
}
- if(n_output_devices>0) {
- GtkWidget *local_audio_b=gtk_check_button_new_with_label("Local Audio");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (local_audio_b), local_audio);
- gtk_widget_show(local_audio_b);
- gtk_grid_attach(GTK_GRID(grid),local_audio_b,1,1,1,1);
- g_signal_connect(local_audio_b,"toggled",G_CALLBACK(local_audio_cb),NULL);
-
- if(n_selected_output_device==-1) n_selected_output_device=0;
-
- for(i=0;i<n_output_devices;i++) {
- GtkWidget *output;
- if(i==0) {
- output=gtk_radio_button_new_with_label(NULL,output_devices[i]);
- } else {
- output=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(output),output_devices[i]);
- }
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (output), n_selected_output_device==i);
- gtk_widget_show(output);
- gtk_grid_attach(GTK_GRID(grid),output,1,i+2,1,1);
- g_signal_connect(output,"pressed",G_CALLBACK(local_output_changed_cb),(gpointer *)i);
- }
- }
-
if(n_input_devices>0) {
- GtkWidget *local_microphone_b=gtk_check_button_new_with_label("Microphone Audio");
+ GtkWidget *local_microphone_b=gtk_check_button_new_with_label("Local Microphone Input");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (local_microphone_b), local_microphone);
gtk_widget_show(local_microphone_b);
- gtk_grid_attach(GTK_GRID(grid),local_microphone_b,2,1,1,1);
+ gtk_grid_attach(GTK_GRID(grid),local_microphone_b,0,++row,1,1);
g_signal_connect(local_microphone_b,"toggled",G_CALLBACK(local_microphone_cb),NULL);
if(n_selected_input_device==-1) n_selected_input_device=0;
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (input), n_selected_input_device==i);
gtk_widget_show(input);
- gtk_grid_attach(GTK_GRID(grid),input,2,i+2,1,1);
+ gtk_grid_attach(GTK_GRID(grid),input,0,++row,1,1);
g_signal_connect(input,"pressed",G_CALLBACK(local_input_changed_cb),(gpointer *)i);
}
}
+ row=0;
+
+ if(n_output_devices>0) {
+ GtkWidget *local_audio_b=gtk_check_button_new_with_label("Local Audio Output");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (local_audio_b), local_audio);
+ gtk_widget_show(local_audio_b);
+ gtk_grid_attach(GTK_GRID(grid),local_audio_b,1,++row,1,1);
+ g_signal_connect(local_audio_b,"toggled",G_CALLBACK(local_audio_cb),NULL);
+
+ if(n_selected_output_device==-1) n_selected_output_device=0;
+
+ for(i=0;i<n_output_devices;i++) {
+ GtkWidget *output;
+ if(i==0) {
+ output=gtk_radio_button_new_with_label(NULL,output_devices[i]);
+ } else {
+ output=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(output),output_devices[i]);
+ }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (output), n_selected_output_device==i);
+ gtk_widget_show(output);
+ gtk_grid_attach(GTK_GRID(grid),output,1,++row,1,1);
+ g_signal_connect(output,"pressed",G_CALLBACK(local_output_changed_cb),(gpointer *)i);
+ }
+ }
+
gtk_container_add(GTK_CONTAINER(content),grid);
sub_menu=dialog;
#include "agc_menu.h"
#include "fm_menu.h"
#include "test_menu.h"
+#include "vox_menu.h"
static GtkWidget *parent_window=NULL;
return TRUE;
}
+void start_vox() {
+ cleanup();
+ vox_menu(parent_window);
+}
+
+static gboolean vox_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
+ start_vox();
+ return TRUE;
+}
+
void start_test() {
cleanup();
test_menu(parent_window);
g_signal_connect (meter_b, "button-press-event", G_CALLBACK(meter_cb), NULL);
gtk_grid_attach(GTK_GRID(grid),meter_b,1,3,1,1);
+ GtkWidget *vox_b=gtk_button_new_with_label("VOX");
+ g_signal_connect (vox_b, "button-press-event", G_CALLBACK(vox_cb), NULL);
+ gtk_grid_attach(GTK_GRID(grid),vox_b,2,3,1,1);
+
GtkWidget *band_b=gtk_button_new_with_label("Band");
g_signal_connect (band_b, "button-press-event", G_CALLBACK(band_cb), NULL);
gtk_grid_attach(GTK_GRID(grid),band_b,0,4,1,1);
}
} else {
#endif
- if(mode==modeCWL || mode==modeCWU || tune || !isTransmitting()) {
+ if(mode==modeCWL || mode==modeCWU || tune /*|| !isTransmitting()*/) {
micinputbuffer[micsamples*2]=0.0;
micinputbuffer[(micsamples*2)+1]=0.0;
} else {
static void process_rx_buffer() {
int j;
for(j=0;j<outputsamples;j++) {
- leftaudiosample=(short)(audiooutputbuffer[j*2]*32767.0*volume);
- rightaudiosample=(short)(audiooutputbuffer[(j*2)+1]*32767.0*volume);
+ if(isTransmitting()) {
+ leftaudiosample=0;
+ rightaudiosample=0;
+ } else {
+ leftaudiosample=(short)(audiooutputbuffer[j*2]*32767.0*volume);
+ rightaudiosample=(short)(audiooutputbuffer[(j*2)+1]*32767.0*volume);
#ifdef PSK
- if(mode==modePSK) {
- if(psk_samples==0) {
- psk_demod((double)((leftaudiosample+rightaudiosample)/2));
- }
- psk_samples++;
- if(psk_samples==psk_resample) {
- psk_samples=0;
+ if(mode==modePSK) {
+ if(psk_samples==0) {
+ psk_demod((double)((leftaudiosample+rightaudiosample)/2));
+ }
+ psk_samples++;
+ if(psk_samples==psk_resample) {
+ psk_samples=0;
+ }
}
- }
#endif
+ }
+
if(local_audio) {
audio_write(leftaudiosample,rightaudiosample);
}
int j;
int error;
+ if(vox_enabled) {
+ switch(mode) {
+ case modeLSB:
+ case modeUSB:
+ case modeDSB:
+ case modeFMN:
+ case modeAM:
+ case modeSAM:
+#ifdef FREEDV
+ case modeFREEDV:
+#endif
+ update_vox(micinputbuffer,BUFFER_SIZE);
+ break;
+ }
+ }
+
fexchange0(CHANNEL_TX, micinputbuffer, iqoutputbuffer, &error);
Spectrum0(1, CHANNEL_TX, 0, 0, iqoutputbuffer);
#ifdef PSK
#include "psk.h"
#endif
+#include "vox.h"
#define min(x,y) (x<y?x:y)
int last_ptt;
int last_dot;
int last_dash;
- int left_sample[RECEIVERS];
- int right_sample[RECEIVERS];
+ int left_sample;
+ int right_sample;
int mic_sample;
double left_sample_double[RECEIVERS];
double right_sample_double[RECEIVERS];
for(i=0;i<iq_samples;i++) {
for(r=0;r<RECEIVERS;r++) {
- left_sample[r] = (int)((signed char) buffer[b++]) << 16;
- left_sample[r] += (int)((unsigned char)buffer[b++]) << 8;
- left_sample[r] += (int)((unsigned char)buffer[b++]);
- right_sample[r] = (int)((signed char) buffer[b++]) << 16;
- right_sample[r] += (int)((unsigned char)buffer[b++]) << 8;
- right_sample[r] += (int)((unsigned char)buffer[b++]);
+ left_sample = (int)((signed char) buffer[b++]) << 16;
+ left_sample += (int)((unsigned char)buffer[b++]) << 8;
+ left_sample += (int)((unsigned char)buffer[b++]);
+ right_sample = (int)((signed char) buffer[b++]) << 16;
+ right_sample += (int)((unsigned char)buffer[b++]) << 8;
+ right_sample += (int)((unsigned char)buffer[b++]);
+ left_sample_double[r]=(double)left_sample/8388607.0; // 24 bit sample 2^23-1
+ right_sample_double[r]=(double)right_sample/8388607.0; // 24 bit sample 2^23-1
}
mic_sample = (int)((signed char) buffer[b++]) << 8;
mic_sample |= (int)((unsigned char)buffer[b++]);
mic_sample_double = (1.0 / 2147483648.0) * (double)(mic_sample<<16);
- for(r=0;r<RECEIVERS;r++) {
- left_sample_double[r]=(double)left_sample[r]/8388607.0; // 24 bit sample 2^23-1
- right_sample_double[r]=(double)right_sample[r]/8388607.0; // 24 bit sample 2^23-1
- }
-
// add to buffer
if(isTransmitting() && !local_microphone) {
#ifdef FREEDV
#endif
} else {
if(!isTransmitting()) {
- micinputbuffer[samples*2]=0.0;
- micinputbuffer[(samples*2)+1]=0.0;
+ micinputbuffer[samples*2]=mic_sample_double;
+ micinputbuffer[(samples*2)+1]=mic_sample_double;
iqinputbuffer[0][samples*2]=left_sample_double[0];
iqinputbuffer[0][(samples*2)+1]=right_sample_double[0];
samples++;
int j;
int error;
+ if(vox_enabled) {
+ switch(mode) {
+ case modeLSB:
+ case modeUSB:
+ case modeDSB:
+ case modeFMN:
+ case modeAM:
+ case modeSAM:
+#ifdef FREEDV
+ case modeFREEDV:
+#endif
+ update_vox(micinputbuffer,BUFFER_SIZE);
+ break;
+ }
+ }
+
fexchange0(CHANNEL_RX0, iqinputbuffer[0], audiooutputbuffer, &error);
- //fexchange0(CHANNEL_TX, micinputbuffer, iqoutputbuffer, &error);
#ifdef PSK
if(mode!=modePSK) {
int error;
double gain=32767.0; // 2^16-1
- fexchange0(CHANNEL_TX, micinputbuffer, iqoutputbuffer, &error);
- if(error!=0) {
- fprintf(stderr,"full_tx_buffer: fexchange0: error=%d\n",error);
+ if(vox_enabled && vox) {
+ update_vox(micinputbuffer,BUFFER_SIZE);
}
- Spectrum0(1, CHANNEL_TX, 0, 0, iqoutputbuffer);
- if(radio->device==DEVICE_METIS && atlas_penelope) {
- if(tune) {
- gain=gain*tune_drive;
- } else {
- gain=gain*drive;
+ if(isTransmitting()) {
+ fexchange0(CHANNEL_TX, micinputbuffer, iqoutputbuffer, &error);
+ if(error!=0) {
+ fprintf(stderr,"full_tx_buffer: fexchange0: error=%d\n",error);
}
- }
- for(j=0;j<output_buffer_size;j++) {
- left_rx_sample=0;
- right_rx_sample=0;
- left_tx_sample=(int)(iqoutputbuffer[j*2]*gain);
- right_tx_sample=(int)(iqoutputbuffer[(j*2)+1]*gain);
-
- output_buffer[output_buffer_index++]=0;
- output_buffer[output_buffer_index++]=0;
- output_buffer[output_buffer_index++]=0;
- output_buffer[output_buffer_index++]=0;
- output_buffer[output_buffer_index++]=left_tx_sample>>8;
- output_buffer[output_buffer_index++]=left_tx_sample;
- output_buffer[output_buffer_index++]=right_tx_sample>>8;
- output_buffer[output_buffer_index++]=right_tx_sample;
- if(output_buffer_index>=OZY_BUFFER_SIZE) {
- ozy_send_buffer();
- output_buffer_index=8;
+ Spectrum0(1, CHANNEL_TX, 0, 0, iqoutputbuffer);
+
+ if(radio->device==DEVICE_METIS && atlas_penelope) {
+ if(tune) {
+ gain=gain*tune_drive;
+ } else {
+ gain=gain*drive;
+ }
+ }
+ for(j=0;j<output_buffer_size;j++) {
+ left_rx_sample=0;
+ right_rx_sample=0;
+ left_tx_sample=(int)(iqoutputbuffer[j*2]*gain);
+ right_tx_sample=(int)(iqoutputbuffer[(j*2)+1]*gain);
+
+ output_buffer[output_buffer_index++]=0;
+ output_buffer[output_buffer_index++]=0;
+ output_buffer[output_buffer_index++]=0;
+ output_buffer[output_buffer_index++]=0;
+ output_buffer[output_buffer_index++]=left_tx_sample>>8;
+ output_buffer[output_buffer_index++]=left_tx_sample;
+ output_buffer[output_buffer_index++]=right_tx_sample>>8;
+ output_buffer[output_buffer_index++]=right_tx_sample;
+ if(output_buffer_index>=OZY_BUFFER_SIZE) {
+ ozy_send_buffer();
+ output_buffer_index=8;
+ }
}
}
-
}
void old_protocol_process_local_mic(unsigned char *buffer,int le) {
}
} else {
- //fprintf(stderr,"not transmitting - ignore local mic buffer\n");
+ if(vox_enabled) {
+ }
}
}
if(mode!=modeCWU && mode!=modeCWL) {
// output_buffer[C1]|=0x00;
} else {
- if((tune==1) || (mox==1) || (cw_keyer_internal==0)) {
+ if((tune==1) || (mox==1) || (vox==1) || (cw_keyer_internal==0)) {
output_buffer[C1]|=0x00;
} else {
output_buffer[C1]|=0x01;
int deviation=2500;
int pre_emphasize=0;
+int vox_enabled=0;
+double vox_threshold=0.001;
+double vox_gain=1;
+double vox_hang=250.0;
+int vox=0;
+
void init_radio() {
int rc;
rc=sem_init(&property_sem, 0, 0);
return sample_rate;
}
-void setMox(int state) {
- if(mox!=state) {
- if(state) {
- // switch to tx
- SetChannelState(CHANNEL_RX0,0,1);
- mox=state;
- if(protocol==NEW_PROTOCOL) {
- schedule_high_priority(3);
- }
- SetChannelState(CHANNEL_TX,1,0);
-#ifdef FREEDV
- if(mode==modeFREEDV) {
- freedv_reset_tx_text_index();
- }
-#endif
- } else {
- SetChannelState(CHANNEL_TX,0,1);
- mox=state;
- if(protocol==NEW_PROTOCOL) {
- schedule_high_priority(3);
- }
- SetChannelState(CHANNEL_RX0,1,0);
- }
-/*
- mox=state;
+static void rxtx(int state) {
+ if(state) {
+ // switch to tx
+ SetChannelState(CHANNEL_RX0,0,1);
if(protocol==NEW_PROTOCOL) {
schedule_high_priority(3);
}
- if(mox) {
+ SetChannelState(CHANNEL_TX,1,0);
#ifdef FREEDV
- if(mode==modeFREEDV) {
- freedv_reset_tx_text_index();
- }
+ if(mode==modeFREEDV) {
+ freedv_reset_tx_text_index();
+ }
#endif
- SetChannelState(CHANNEL_RX0,0,1);
- SetChannelState(CHANNEL_TX,1,0);
+ } else {
+ SetChannelState(CHANNEL_TX,0,1);
+ if(protocol==NEW_PROTOCOL) {
+ schedule_high_priority(3);
+ }
+ SetChannelState(CHANNEL_RX0,1,0);
+ }
+}
+
+void setMox(int state) {
+ if(mox!=state) {
+ mox=state;
+ if(vox_enabled && vox) {
+ vox_cancel();
} else {
- SetChannelState(CHANNEL_TX,0,1);
- SetChannelState(CHANNEL_RX0,1,0);
+ rxtx(state);
}
-*/
}
}
return mox;
}
+void setVox(int state) {
+ if(vox!=state && !tune) {
+ vox=state;
+ rxtx(state);
+ }
+}
+
void setTune(int state) {
if(tune!=state) {
tune=state;
+ if(vox_enabled && vox) {
+ vox_cancel();
+ }
if(tune) {
if(OCmemory_tune_time!=0) {
struct timeval te;
}
int isTransmitting() {
- return ptt || mox || tune;
+ return ptt || mox || vox || tune;
}
void setFrequency(long long f) {
value=getProperty("pre_emphasize");
if(value) pre_emphasize=atoi(value);
+ value=getProperty("vox_enabled");
+ if(value) vox_enabled=atoi(value);
+ value=getProperty("vox_threshold");
+ if(value) vox_threshold=atof(value);
+ value=getProperty("vox_gain");
+ if(value) vox_gain=atof(value);
+ value=getProperty("vox_hang");
+ if(value) vox_hang=atof(value);
+
bandRestoreState();
sem_post(&property_sem);
sprintf(value,"%d",pre_emphasize);
setProperty("pre_emphasize",value);
+ sprintf(value,"%d",vox_enabled);
+ setProperty("vox_enabled",value);
+ sprintf(value,"%f",vox_threshold);
+ setProperty("vox_threshold",value);
+ sprintf(value,"%f",vox_gain);
+ setProperty("vox_gain",value);
+ sprintf(value,"%f",vox_hang);
+ setProperty("vox_hang",value);
+
bandSaveState();
saveProperties(property_path);
extern int deviation;
extern int pre_emphasize;
+extern int vox_enabled;
+extern double vox_threshold;
+extern double vox_gain;
+extern double vox_hang;
+extern int vox;
+
extern void init_radio();
extern void setSampleRate(int rate);
extern int getSampleRate();
#include "vfo.h"
#include "sliders.h"
#include <pthread.h>
+#include <wdsp.h>
// IP stuff below
#include<sys/socket.h>
#undef RIGCTL_DEBUG
// the port client will be connecting to
-#define PORT 19090 // This is the HAMLIB port
+#define TELNET_PORT 19090 // This is the HAMLIB port
// max number of bytes we can get at once
#define MAXDATASIZE 300
}
static void * rigctl (void * arg) {
-
+ int work_int;
int len;
init_server();
double meter;
strcpy(cmd_save,cmd_input); // And save a copy of it till next time through
save_flag = 1;
#ifdef RIGCTL_DEBUG
- fprintf(stderr,"RIGCTL: *** CMD_SAVE=%s\n",cmd_save);
+ fprintf(stderr,"RIGCTL: CMD_SAVE=%s LEN=%d\n",cmd_save,numbytes);
#endif
} else if(save_flag == 1) {
save_flag = 0;
strcpy(cmd_input,cmd_save); // Cat them together and replace cmd_input
numbytes = strlen(cmd_input);
#ifdef RIGCTL_DEBUG
- fprintf(stderr,"RIGCTL: *** CMD_INPUT=%s LEN=%d\n",cmd_input,numbytes);
+ fprintf(stderr,"RIGCTL: CMD_INPUT=%s LEN=%d\n",cmd_input,numbytes);
+ #endif
+ } else {
+ #ifdef RIGCTL_DEBUG
+ fprintf(stderr,"RIGCTL: CMD_NORM=%s NUMBYTES=%d\n",cmd_input,numbytes);
#endif
}
cmd_input[numbytes-1] = '\0'; // Turn it into a C string.
len = strlen(cmd_input);
+ #ifdef RIGCTL_DEBUG
+ fprintf(stderr,"RIGCTL: CMD_AFTER=%s LEN=%d\n",cmd_input,len);
+ #endif
#ifdef RIGCTL_DEBUG
- fprintf(stderr,"RIGCTL: RCVD=%s LENGTH=%d\n",cmd_input,len);
+ fprintf(stderr,"RIGCTL: RCVD=%s LENGTH=%d\n",cmd_input,len);
#endif
// Parse the cmd_input
//int space = command.indexOf(' ');
send_resp("FD00000000;");
}
else if(strcmp(cmd_str,"FR")==0) { // Set/reads the extension menu
- if(len <2) {
+ if(len <=2) {
send_resp("FR0;");
}
}
else if(strcmp(cmd_str,"FS")==0) { // Set/reads fine funct status
- if(len <2) {
+ if(len <=2) {
send_resp("FS0;");
}
}
else if(strcmp(cmd_str,"FT")==0) { // Sel or reads the transmitters VFO, M, ch or Call comm
- if(len <2) {
+ if(len <=2) {
send_resp("FT0;");
}
}
else if(strcmp(cmd_str,"FW")==0) { // Sets/Reas DSP receive filter width in hz 0-9999hz
- if(len <2) {
+ if(len <=2) {
send_resp("FW0000;");
}
}
else if(strcmp(cmd_str,"GT")==0) { // Sets/Reas AGC constant status
- if(len <2) {
+ if(len <=2) {
send_resp("GT000;");
}
}
send_resp(msg);
}
else if(strcmp(cmd_str,"IS")==0) { // Sets/Reas IF shift funct status
- if(len <2) {
+ if(len <=2) {
send_resp("IS00000;");
}
}
else if(strcmp(cmd_str,"KS")==0) { // Sets/Reads keying freq - 0-060 max
- if(len <2) {
+ if(len <=2) {
send_resp("KS000;");
}
}
else if(strcmp(cmd_str,"KY")==0) { // Convert char to morse code
- if(len <2) {
+ if(len <=2) {
send_resp("KY0;");
}
}
else if(strcmp(cmd_str,"LK")==0) { // Set/read key lock function status
- if(len <2) {
+ if(len <=2) {
send_resp("LK00;");
}
}
else if(strcmp(cmd_str,"LM")==0) { // Set/read DRU 3A unit or elect keyer recording status
- if(len <2) {
+ if(len <=2) {
send_resp("LM0;");
}
}
else if(strcmp(cmd_str,"LT")==0) { // Set/read Alt function
- if(len <2) {
+ if(len <=2) {
send_resp("LT0;");
}
}
else if(strcmp(cmd_str,"MC")==0) { // Recalls or reads memory channel
- if(len <2) {
+ if(len <=2) {
send_resp("MC000;"); // Link this to band stack at some point
}
}
default:
break;
#ifdef RIGCTL_DEBUG
- fprintf(stderr,"MD command Unknown");
+ fprintf(stderr,"MD command Unknown\n");
#endif
}
// Other stuff to switch modes goes here..
}
}
else if(strcmp(cmd_str,"MF")==0) { // Set/read menu A/B
- if(len <2) {
+ if(len <=2) {
send_resp("MF0;");
}
}
else if(strcmp(cmd_str,"MG")==0) { // Mike Gain - 3 digit value
- if(len <2) {
- sprintf(msg,"MG%03d",mic_gain * 100);
+ if(len <=2) {
+ work_int = (int) ((mic_gain +10.0)* 100.0/60.0);
+ sprintf(msg,"MG%03d",work_int);
send_resp(msg);
} else {
int tval = atoi(&cmd_input[2]);
- new_vol = (double) tval/2;
+ new_vol = (double) (tval * 60/100) - 10;
//set_mic_gain(new_vol);
double *p_mic_gain=malloc(sizeof(double));
*p_mic_gain=new_vol;
}
}
else if(strcmp(cmd_str,"ML")==0) { // Set/read the monitor function level
- if(len <2) {
+ if(len <=2) {
send_resp("ML000;");
}
}
else if(strcmp(cmd_str,"MO")==0) { // Set Monitor on/off
- if(len <2) {
+ if(len <=2) {
send_resp("MO0;");
}
}
else if(strcmp(cmd_str,"MR")==0) { // Read Memory Channel data
- sprintf("MR%1d%02d%02d%011d%1d%1d%1d%02d%02d%03d%1d%1d%09d%02d%1d%08d;",
+ sprintf(msg,"MR%1d%02d%02d%011d%1d%1d%1d%02d%02d%03d%1d%1d%09d%02d%1d%08d;",
0, // P1 - Rx Freq - 1 Tx Freq
0, // P2 Bankd and channel number -- see MC comment
0, // P3 - see MC comment
send_resp(msg);
}
else if(strcmp(cmd_str,"MU")==0) { // Set/Read Memory Group Data
- if(len <2) {
+ if(len <=2) {
send_resp("MU0000000000;");
}
}
else if(strcmp(cmd_str,"MW")==0) { // Store Data to Memory Channel
}
else if(strcmp(cmd_str,"NB")==0) { // Set/Read Noise Blanker func status (on/off)
- if(len <2) {
+ if(len <=2) {
send_resp("NB0;");
}
}
else if(strcmp(cmd_str,"NL")==0) { // Set/Read Noise Reduction Level
- if(len <2) {
+ if(len <=2) {
send_resp("NL000;");
}
}
else if(strcmp(cmd_str,"NR")==0) { // Set/Read Noise Reduction function status
- if(len <2) {
+ if(len <=2) {
send_resp("NR0;");
}
}
else if(strcmp(cmd_str,"NT")==0) { // Set/Read autonotch function
- if(len <2) {
+ if(len <=2) {
send_resp("NT0;");
}
}
else if(strcmp(cmd_str,"OF")==0) { // Set/Read Offset freq (9 digits - hz)
- if(len <2) {
+ if(len <=2) {
send_resp("OF000000000;");
}
}
else if(strcmp(cmd_str,"OI")==0) { // Read Memory Channel Data
- if(len <2) {
+ if(len <=2) {
sprintf(msg,"OI%011d%04d%06d%1d%1d%1d%02d%1d%1d%1d%1d%1d%1d%02d%1d;",
getFrequency(),
0, // P2 - Freq Step size
}
}
else if(strcmp(cmd_str,"OS")==0) { // Set/Read Offset freq (9 digits - hz)
- if(len <2) {
+ if(len <=2) {
send_resp("OS0;");
}
}
else if(strcmp(cmd_str,"PA")==0) { // Set/Read Preamp function status
- if(len <2) {
+ if(len <=2) {
send_resp("PA00;");
}
}
else if(strcmp(cmd_str,"PB")==0) { // Set/Read DRU-3A Playback status
- if(len <2) {
+ if(len <=2) {
send_resp("PB0;");
}
}
else if(strcmp(cmd_str,"PC")==0) { // Set/Read Drive Power output
- if(len==2) {
- sprintf(msg,"PC%03d;",drive*100);
+ if(len<=2) {
+ sprintf(msg,"PC%03d;",(int) drive);
send_resp(msg);
} else {
// Power Control - 3 digit number- 0 to 100
else if(strcmp(cmd_str,"PL")==0) { // Set/Read Speech processor level
// P1 000 - min-100 max
// P2 000 - min - 100 max
- if(len <2) {
+ if(len <=2) {
send_resp("PL000000;");
}
}
else if(strcmp(cmd_str,"PM")==0) { // Recalls the Programmable memory
- if(len <2) {
+ if(len <=2) {
send_resp("PM0;");
}
}
else if(strcmp(cmd_str,"PR")==0) { // Sets/reads the speech processor function on/off
// 0 - off, 1=on
- if(len <2) {
+ if(len <=2) {
send_resp("PR0;");
}
}
else if(strcmp(cmd_str,"PS")==0) { // Sets/reads Power on/off state
// 0 - off, 1=on
- if(len <2) {
+ if(len <=2) {
send_resp("PS1;"); // Lets pretend we're powered up ;-)
}
}
else if(strcmp(cmd_str,"PS")==0) { // Sets/reads DCS code
// Codes numbered from 000 to 103.
- if(len <2) {
+ if(len <=2) {
send_resp("QC000;"); // Lets pretend we're powered up ;-)
}
}
else if(strcmp(cmd_str,"QR")==0) { // Send the Quick memory channel data
// P1 - Quick mem off, 1 quick mem on
// P2 - Quick mem channel number
- if(len <2) {
+ if(len <=2) {
send_resp("QR00;"); // Lets pretend we're powered up ;-)
}
}
else if(strcmp(cmd_str,"RA")==0) { // Sets/reads Attenuator function status
// 00-off, 1-99 -on - Main and sub receivers reported
- if(len <2) {
+ if(len <=2) {
send_resp("RA0000;");
}
}
else if(strcmp(cmd_str,"RC")==0) { // Clears the RIT offset freq
}
else if(strcmp(cmd_str,"RD")==0) { // Move the RIT offset freq down, slow down the scan speed in scan mode
- if(len <2) {
+ if(len <=2) {
send_resp("RD0;");
}
}
*p_gain=new_gain;
g_idle_add(update_agc_gain,(gpointer)p_gain);
} else { // Read Audio Gain
- sprintf(msg,"RG%03d;",(255/140)*(agc_gain+20));
+ sprintf(msg,"RG%03d;",((256 * (int) agc_gain)/140)+36);
send_resp(msg);
}
}
else if(strcmp(cmd_str,"RL")==0) { // Set/read Noise reduction level
- if(len <2) {
+ if(len <=2) {
send_resp("RL00;");
}
}
else if(strcmp(cmd_str,"RM")==0) { // Set/read Meter function
// P1- 0, unsel, 1 SWR, 2 Comp, 3 ALC
// P2 - 4 dig - Meter value in dots - 000-0030
- if(len <2) {
+ if(len <=2) {
send_resp("RM00000;");
}
}
else if(strcmp(cmd_str,"RT")==0) { // Set/read the RIT function status
- if(len <2) {
+ if(len <=2) {
send_resp("RT0;");
}
}
else if(strcmp(cmd_str,"RU")==0) { // Set/move RIT frequency up
- if(len <2) {
+ if(len <=2) {
send_resp("RU0;");
}
}
else if(strcmp(cmd_str,"RX")==0) { // Unkey Xmitter
setMox(0);
// 0-main, 1=sub
- if(len <2) {
+ if(len <=2) {
send_resp("RX0;");
}
}
else if(strcmp(cmd_str,"SA")==0) { // Set/reads satellite mode status
// 0-main, 1=sub
- if(len <2) {
+ if(len <=2) {
send_resp("SA000000000000000;");
}
}
else if(strcmp(cmd_str,"SB")==0) { // Set/read the SUB TF-W status
- if(len <2) {
+ if(len <=2) {
send_resp("SB0;");
}
}
else if(strcmp(cmd_str,"SC")==0) { // Set/read the Scan function status
- if(len <2) {
+ if(len <=2) {
send_resp("SC0;");
}
}
else if(strcmp(cmd_str,"SD")==0) { // Set/read CW break-in time delay
// 0000-1000 ms (in steps of 50 ms) 0000 is full break in
- if(len <2) {
+ if(len <=2) {
send_resp("SD0000;");
}
}
else if(strcmp(cmd_str,"SH")==0) { // Set/read the DSP filter settings
- if(len <2) {
+ if(len <=2) {
send_resp("SH00;");
}
}
else if(strcmp(cmd_str,"SI")==0) { // Enters the satellite memory name
}
else if(strcmp(cmd_str,"SL")==0) { // Set/read the DSP filter settings - this appears twice? See SH
- if(len <2) {
+ if(len <=2) {
send_resp("SL00;");
}
}
else if(strcmp(cmd_str,"SQ")==0) { // Set/read the squelch level
// P1 - 0- main, 1=sub
// P2 - 0-255
- if(len <2) {
+ if(len <=2) {
send_resp("SQ0000;");
}
}
else if(strcmp(cmd_str,"SR")==0) { // Resets the transceiver
}
else if(strcmp(cmd_str,"SS")==0) { // Set/read Scan pause freq
- if(len <2) {
+ if(len <=2) {
send_resp("SS0;");
}
}
else if(strcmp(cmd_str,"ST")==0) { // Set/read the multi/ch control freq steps
- if(len <2) {
+ if(len <=2) {
send_resp("ST00;");
}
}
else if(strcmp(cmd_str,"SU")==0) { // Set/read the scan pause freq
- if(len <2) {
+ if(len <=2) {
send_resp("SU00000000000;");
}
}
else if(strcmp(cmd_str,"SV")==0) { // Execute the memory transfer function
}
else if(strcmp(cmd_str,"TC")==0) { // Set/read the internal TNC mode
- if(len <2) {
+ if(len <=2) {
send_resp("TC00;");
}
}
else if(strcmp(cmd_str,"TD")==0) { // Sends the DTMF memory channel
}
else if(strcmp(cmd_str,"TI")==0) { // Reads the TNC LED status
- if(len <2) {
+ if(len <=2) {
send_resp("TI00;");
}
}
else if(strcmp(cmd_str,"TN")==0) { // Set/Read sub tone freq
- if(len <2) {
+ if(len <=2) {
send_resp("TN00;");
}
}
else if(strcmp(cmd_str,"TO")==0) { // Set/Read tone function
- if(len <2) {
+ if(len <=2) {
send_resp("TO0;");
}
}
else if(strcmp(cmd_str,"TS")==0) { // Set/Read TF Set function status
- if(len <2) {
+ if(len <=2) {
send_resp("TS0;");
}
}
else if(strcmp(cmd_str,"TX")==0) { // Key Xmitter - P1 - transmit on main/sub freq
setMox(1);
- if(len <2) {
+ if(len <=2) {
send_resp("TS0;");
}
}
else if(strcmp(cmd_str,"TY")==0) { // Set/Read uP firmware type
- if(len <2) {
+ if(len <=2) {
send_resp("TY000;");
}
}
else if(strcmp(cmd_str,"UL")==0) { // Detects the PLL unlock status - this should never occur - xmit only
- if(len <2) {
+ if(len <=2) {
send_resp("UL0;");
}
}
else if(strcmp(cmd_str,"UP")==0) { // Emulates the mic up key
}
else if(strcmp(cmd_str,"VD")==0) { // Sets/Reads VOX dleay time - 0000-3000ms in steps of 150
- if(len <2) {
+ if(len <=2) {
send_resp("VD0000;");
}
}
else if(strcmp(cmd_str,"VG")==0) { // Sets/Reads VOX gain 000-009
- if(len <2) {
+ if(len <=2) {
send_resp("VG000;");
}
}
else if(strcmp(cmd_str,"VG")==0) { // Emulates the voide 1/2 key
}
else if(strcmp(cmd_str,"VX")==0) { // Sets/reads vox f(x) state
- if(len <2) {
+ if(len <=2) {
send_resp("VX0;");
}
}
else if(strcmp(cmd_str,"XT")==0) { // Sets/reads the XIT f(x) state
- if(len <2) {
+ if(len <=2) {
send_resp("XT0;");
}
}
digl_pol = (cmd_input[2]=='0') ? -1 : 1;
digl_offset = atoi(&cmd_input[3]);
#ifdef RIGCTL_DEBUG
- fprintf(stderr,"RIGCTL:RL set %d %d",digl_pol,digl_offset);
+ fprintf(stderr,"RIGCTL:RL set %d %d\n",digl_pol,digl_offset);
#endif
} else {
if(digl_pol==1) { // Nah - its a read
digl_pol = (cmd_input[2]=='0') ? -1 : 1;
digl_offset = atoi(&cmd_input[3]);
#ifdef RIGCTL_DEBUG
- fprintf(stderr,"RIGCTL:RL set %d %d",digl_pol,digl_offset);
+ fprintf(stderr,"RIGCTL:RL set %d %d\n",digl_pol,digl_offset);
#endif
} else {
if(digl_pol==1) { // Nah - its a read
//
// Telnet Server Code below:
//
- // the port client will be connecting to
- #define PORT 19090 // This is the HAMLIB port
// max number of bytes we can get at once
#define MAXDATASIZE 300
//Prepare the sockaddr_in structure
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
- server.sin_port = htons( PORT );
+ server.sin_port = htons( TELNET_PORT );
//Bind
if( bind(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
--- /dev/null
+/* Copyright (C)
+* 2016 - 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 <semaphore.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "new_menu.h"
+#include "vox_menu.h"
+#include "radio.h"
+
+static GtkWidget *parent_window=NULL;
+
+static GtkWidget *dialog=NULL;
+
+static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
+ if(dialog!=NULL) {
+ gtk_widget_destroy(dialog);
+ dialog=NULL;
+ sub_menu=NULL;
+ }
+ return TRUE;
+}
+
+static void vox_cb(GtkWidget *widget, gpointer data) {
+ vox_enabled=vox_enabled==1?0:1;
+}
+
+static void vox_value_changed_cb(GtkWidget *widget, gpointer data) {
+ vox_threshold=gtk_range_get_value(GTK_RANGE(widget))/10000.0;
+}
+
+static void vox_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
+ vox_gain=gtk_range_get_value(GTK_RANGE(widget));
+}
+
+static void vox_hang_value_changed_cb(GtkWidget *widget, gpointer data) {
+ vox_hang=gtk_range_get_value(GTK_RANGE(widget));
+}
+
+void vox_menu(GtkWidget *parent) {
+ int i;
+
+ parent_window=parent;
+
+ dialog=gtk_dialog_new();
+ gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window));
+ gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE);
+
+ GdkRGBA color;
+ color.red = 1.0;
+ color.green = 1.0;
+ color.blue = 1.0;
+ color.alpha = 1.0;
+ gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&color);
+
+ GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+
+ GtkWidget *grid=gtk_grid_new();
+ gtk_grid_set_column_spacing (GTK_GRID(grid),10);
+ gtk_grid_set_row_spacing (GTK_GRID(grid),10);
+ //gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
+ //gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
+
+ GtkWidget *close_b=gtk_button_new_with_label("Close VOX");
+ g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
+ gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
+
+ GtkWidget *vox_b=gtk_check_button_new_with_label("VOX Enable");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vox_b), vox_enabled);
+ gtk_widget_show(vox_b);
+ gtk_grid_attach(GTK_GRID(grid),vox_b,0,1,1,1);
+ g_signal_connect(vox_b,"toggled",G_CALLBACK(vox_cb),NULL);
+
+ GtkWidget *threshold_label=gtk_label_new("VOX Threshold:");
+ gtk_misc_set_alignment (GTK_MISC(threshold_label), 0, 0);
+ gtk_widget_show(threshold_label);
+ gtk_grid_attach(GTK_GRID(grid),threshold_label,0,2,1,1);
+
+ GtkWidget *vox_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0,1000.0,1.0);
+ gtk_widget_set_size_request (vox_scale, 300, 25);
+ gtk_range_set_value(GTK_RANGE(vox_scale),vox_threshold*10000.0);
+ gtk_widget_show(vox_scale);
+ gtk_grid_attach(GTK_GRID(grid),vox_scale,1,2,1,1);
+ g_signal_connect(G_OBJECT(vox_scale),"value_changed",G_CALLBACK(vox_value_changed_cb),NULL);
+
+ GtkWidget *gain_label=gtk_label_new("VOX Gain:");
+ gtk_misc_set_alignment (GTK_MISC(gain_label), 0, 0);
+ gtk_widget_show(gain_label);
+ gtk_grid_attach(GTK_GRID(grid),gain_label,0,3,1,1);
+
+ GtkWidget *gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,1.0,10.0,1.0);
+ gtk_range_set_value(GTK_RANGE(gain_scale),vox_gain*10000.0);
+ gtk_widget_show(gain_scale);
+ gtk_grid_attach(GTK_GRID(grid),gain_scale,1,3,1,1);
+ g_signal_connect(G_OBJECT(gain_scale),"value_changed",G_CALLBACK(vox_gain_value_changed_cb),NULL);
+
+ GtkWidget *hang_label=gtk_label_new("VOX Hang (ms):");
+ gtk_misc_set_alignment (GTK_MISC(hang_label), 0, 0);
+ gtk_widget_show(hang_label);
+ gtk_grid_attach(GTK_GRID(grid),hang_label,0,4,1,1);
+
+ GtkWidget *vox_hang_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0,1000.0,1.0);
+ gtk_range_set_value(GTK_RANGE(vox_hang_scale),vox_hang);
+ gtk_widget_show(vox_hang_scale);
+ gtk_grid_attach(GTK_GRID(grid),vox_hang_scale,1,4,1,1);
+ g_signal_connect(G_OBJECT(vox_hang_scale),"value_changed",G_CALLBACK(vox_hang_value_changed_cb),NULL);
+ gtk_container_add(GTK_CONTAINER(content),grid);
+
+ sub_menu=dialog;
+
+ gtk_widget_show_all(dialog);
+
+}
+
--- /dev/null
+/* Copyright (C)
+* 2016 - 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.
+*
+*/
+
+void vox_menu(GtkWidget *parent);