]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
No essential change, but reduce differences between versions
authorc vw <dl1ycf@darc.de>
Fri, 28 May 2021 11:54:52 +0000 (13:54 +0200)
committerc vw <dl1ycf@darc.de>
Fri, 28 May 2021 11:54:52 +0000 (13:54 +0200)
to prepeare for merging them

Makefile
cw_menu.c
exit_menu.c
ext.c
iambic.h
new_protocol.c
old_protocol.c
receiver.c
rigctl.c
step_menu.c

index 1410a009e1ed7ac1613a253ab8bbd1e873a53579..7e811bfaa9384b6a7163bdb7e97450fff212f027 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,6 @@ MIDI_INCLUDE=MIDI
 # uncomment to get ALSA audio module on Linux (default is now to use pulseaudio)
 #AUDIO_MODULE=ALSA
 
-
 # uncomment the line below for various debug facilities
 #DEBUG_OPTION=-D DEBUG
 
@@ -466,7 +465,7 @@ $(PROGRAM):  $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS
 all:    prebuild  $(PROGRAM) $(HEADERS) $(AUDIO_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \
        $(LOCALCW_HEADERS) $(GPIO_HEADERS) \
        $(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(STEMLAB_HEADERS) $(SERVER_HEADERS) \
-       $(AUDIO_SOURCES) $(GPIO_SOURCES) $(SOURCES) \
+       $(AUDIO_SOURCES) $(SOURCES) $(GPIO_SOURCES) \
        $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(LOCALCW_SOURCE) \
        $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(SERVER_SOURCES)
 
@@ -569,13 +568,11 @@ debian:
 #############################################################################
 
 .PHONY: app
-app:   $(OBJS) $(REMOTE_OBJS) $(AUDIO_OBJS) $(GPIO_OBJS) \
-               $(USBOZY_OBJS)  $(SOAPYSDR_OBJS) \
-               $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \
+app:   $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS)  $(SOAPYSDR_OBJS) \
+               $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) $(GPIO_OBJS) \
                $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS)
-       $(CC)   -headerpad_max_install_names -o $(PROGRAM) \
-               $(OBJS) $(AUDIO_OBJS) $(GPIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \
-               $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \
+       $(CC)   -headerpad_max_install_names -o $(PROGRAM) $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS)  $(USBOZY_OBJS)  \
+               $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) $(GPIO_OBJS) \
                $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS) $(LIBS) $(LDFLAGS)
        @rm -rf pihpsdr.app
        @mkdir -p pihpsdr.app/Contents/MacOS
index 335f66a431f62648cf53145bc9384b154ed6dd11..54d0e47389471da204c9f9feb2b0e822709374e0 100644 (file)
--- a/cw_menu.c
+++ b/cw_menu.c
@@ -33,9 +33,7 @@
 #include "receiver.h"
 #include "new_protocol.h"
 #include "old_protocol.h"
-#ifdef LOCALCW
 #include "iambic.h"
-#endif
 #include "ext.h"
 
 static GtkWidget *parent_window=NULL;
index ece8880dca6c0248bdf0712fed57fef2f9673aeb..0ba81a3a7e5481f9cb52d3220aff4b4bf9678af0 100644 (file)
@@ -32,9 +32,7 @@
 #ifdef SOAPYSDR
 #include "soapy_protocol.h"
 #endif
-#ifdef GPIO
 #include "gpio.h"
-#endif
 
 static GtkWidget *parent_window=NULL;
 
diff --git a/ext.c b/ext.c
index 366b2df676aae71c1f7e41bca18f422fc2a09ba1..f0b798b3701cc8c0da65b5519d6b0c339409f7a0 100644 (file)
--- a/ext.c
+++ b/ext.c
 //
 // Re-structuring of the rigctl, MIDI, and gpio code
 // eliminates the need for many "ext" functions
-// defined here. For the time being, they are
-// moved to the end of the file, and the whole block is
-// deactivated with #if0/#endif
+// defined here.
 //
 
 //
-// Furthermore, some "helper" functions defined here
+// Some "helper" functions defined in this file
 // are moved to the top of the file, since they
 // eventually are moved elsewhere.
 //
@@ -192,44 +190,73 @@ void num_pad(int val) {
 }
 
 void update_vfo_step(int direction) {
-  int i=0;
-  while(steps[i]!=step && steps[i]!=0) {
-    i++;
+  int i;
+  for (i=0; i<STEPS; i++) {
+    if (steps[i] == step) break;
   }
+  //
+  // This should not happen (step size not found). If it happens,
+  // take the seond-smallest one such that the step size remains
+  // small after changing it.
+  //
+  if (i >= STEPS) i=1;
 
-  if(steps[i]!=0) {
-    // current step size is in slot #i.
-    if(direction>0) {
-      // move to next slot (if it exists)
-      i++;
-      if(steps[i]!=0) {
-        step=steps[i];
-      }
-    } else {
-      // move to previous slot (if it exists)
-      i--;
-      if(i>=0) {
-        step=steps[i];
-      }
-    }
+  if (direction > 0) {
+    i++;
+  } else {
+    i--;
   }
+  if (i >= STEPS) i=STEPS;
+  if (i < 0     ) i=0;
+  step=steps[i];
+
   vfo_update();
 }
 
 //
 // Functions to be invoked through the GTK idle queue,
-// still in use
 //
 
+int ext_menu_filter(void *data) {
+  start_filter();
+  return 0;
+}
+
+int ext_menu_mode(void *data) {
+  start_mode();
+  return 0;
+}
+
+int ext_num_pad(void *data) {
+  gint val=GPOINTER_TO_INT(data);
+  num_pad(val);
+  return 0;
+}
+
+int ext_vfo_mode_changed(void * data)
+{
+  int mode=GPOINTER_TO_INT(data);
+  vfo_mode_changed(mode);
+  return 0;
+}
+
 int ext_discovery(void *data) {
   discovery();
   return 0;
 }
 
-//
-// ext_vfo_update includes a limitation to how often
-// the VFO bar is actually re-drawn (every 100 msec)
-//
+int ext_set_frequency(void *data) {
+  //
+  // If new frequency is outside of current band,
+  // behave as if the user had chosen the new band
+  // via the menu prior to changing the frequency
+  //
+  SET_FREQUENCY *SetFreq=(SET_FREQUENCY *)data;
+g_print("ext_set_frequency: vfo=%d freq=%lld\n",SetFreq->vfo,SetFreq->frequency);
+  set_frequency(SetFreq->vfo,SetFreq->frequency);
+  free(data);
+  return 0;
+}
 
 static guint vfo_timeout=0;
 
@@ -250,6 +277,11 @@ int ext_vfo_update(void *data) {
   return 0;
 }
 
+int ext_vfo_filter_changed(void *data) {
+  vfo_filter_changed(GPOINTER_TO_INT(data));
+  return 0;
+}
+
 int ext_band_update(void *data) {
   if(data==NULL) {
     start_band();
@@ -284,7 +316,13 @@ int ext_memory_update(void *data) {
   return 0;
 }
 
+int ext_noise_update(void *data) {
+  start_noise();
+  return 0;
+}
+
 int ext_mox_update(void *data) {
+g_print("%s\n",__FUNCTION__);
   mox_update(GPOINTER_TO_INT(data));
   return 0;
 }
@@ -299,6 +337,38 @@ int ext_vox_changed(void *data) {
   return 0;
 }
 
+int ext_update_agc_gain(void *data) {
+  update_agc_gain(GPOINTER_TO_INT(data));
+  free(data);
+  return 0;
+}
+
+int ext_update_af_gain(void *data) {
+  update_af_gain();
+  return 0;
+}
+
+int ext_calc_drive_level(void *data) {
+  calcDriveLevel();
+  return 0;
+}
+
+int ext_vfo_band_changed(void *data) {
+  int b=GPOINTER_TO_INT(data);
+  vfo_band_changed(active_receiver->id,b);
+  return 0;
+}
+
+int ext_radio_change_sample_rate(void *data) {
+  radio_change_sample_rate(GPOINTER_TO_INT(data));
+  return 0;
+}
+
+int ext_update_squelch(void *data) {
+  set_squelch();
+  return 0;
+}
+
 int ext_sliders_update(void *data) {
   sliders_update();
   return 0;
@@ -314,6 +384,62 @@ int ext_tx_set_ps(void *data) {
 }
 #endif
 
+int ext_update_vfo_step(void *data) {
+  int direction=GPOINTER_TO_INT(data);
+  update_vfo_step(direction);
+  return 0;
+}
+
+int ext_vfo_step(void *data) {
+  int step=GPOINTER_TO_INT(data);
+  vfo_step(step);
+  return 0;
+}
+
+int ext_vfo_id_step(void *data) {
+  int *ip=(int *) data;
+  int id=ip[0];
+  int step=ip[1];
+  vfo_id_step(id,step);
+  free(data);
+  return 0;
+}
+
+int ext_set_mic_gain(void * data) {
+  double d=*(double *)data;
+  set_mic_gain(d);
+  free(data);
+  return 0;
+}
+
+int ext_set_af_gain(void *data) {
+  double d=*(double *)data;
+  set_af_gain(active_receiver->id,d);
+  free(data);
+  return 0;
+}
+
+int ext_set_agc_gain(void *data) {
+  double d=*(double *)data;
+  set_agc_gain(active_receiver->id,d);
+  free(data);
+  return 0;
+}
+int ext_set_drive(void *data) {
+  double d=*(double *)data;
+  set_drive(d);
+  free(data);
+  return 0;
+}
+
+int ext_set_compression(void *data) {
+  if(can_transmit) {
+    set_compression(transmitter);
+  }
+  return 0;
+}
+
 int ext_vfo_a_swap_b(void *data) {
   vfo_a_swap_b();
   return 0;
@@ -329,6 +455,25 @@ int ext_vfo_b_to_a(void *data) {
   return 0;
 }
 
+int ext_update_att_preamp(void *data) {
+  update_att_preamp();
+  return 0;
+}
+
+int ext_set_alex_attenuation(void *data) {
+  int val=GPOINTER_TO_INT(data);
+  set_alex_attenuation(val);
+  return 0;
+}
+
+int ext_set_attenuation_value(void *data) {
+  double d=*(double *)data;
+  set_attenuation_value(d);
+  free(data);
+  return 0;
+}
+
+
 #ifdef PURESIGNAL
 int ext_ps_update(void *data) {
   if(can_transmit) {
@@ -404,6 +549,13 @@ int ext_snb_update(void *data) {
   return 0;
 }
 
+int ext_band_select(void *data) {
+  int b=GPOINTER_TO_INT(data);
+  g_print("%s: %d\n",__FUNCTION__,b);
+  vfo_band_changed(active_receiver->id,b);
+  return 0;
+}
+
 int ext_band_plus(void *data) {
   band_plus(active_receiver->id);
   return 0;
@@ -522,8 +674,10 @@ int ext_agc_update(void *data) {
 }
 
 int ext_split_toggle(void *data) {
-  int val = split ? 0 : 1;
-  set_split(val);
+  if(can_transmit) {
+    set_split(!split);
+    g_idle_add(ext_vfo_update, NULL);
+  }
   return 0;
 }
 
@@ -552,6 +706,20 @@ int ext_diversity_update(void *data) {
   return 0;
 }
 
+int ext_diversity_change_gain(void *data) {
+  double *dp = (double *) data;
+  update_diversity_gain(*dp);
+  free(dp);
+  return 0;
+}
+
+int ext_diversity_change_phase(void *data) {
+  double *dp = (double *) data;
+  update_diversity_phase(*dp);
+  free(dp);
+  return 0;
+}
+
 #ifdef PURESIGNAL
 int ext_start_ps(void *data) {
   start_ps();
@@ -585,6 +753,19 @@ int ext_function_update(void *data) {
   return 0;
 }
 
+int ext_set_rf_gain(void *data) {
+  int pos=GPOINTER_TO_INT(data);
+  double value;
+  value=(double)pos;
+  if(value<-12.0) {
+    value=-12.0;
+  } else if(value>48.0) {
+    value=48.0;
+  }
+  set_rf_gain(active_receiver->id,value);
+  return 0;
+}
+
 int ext_update_noise(void *data) {
   update_noise();
   return 0;
@@ -997,254 +1178,6 @@ int ext_receiver_remote_update_display(void *data) {
 }
 #endif
 
-int ext_mute_update(void *data) {
-  active_receiver->mute_radio=!active_receiver->mute_radio;
-  return 0;
-}
-
-int ext_zoom_update(void *data) {
-  update_zoom((double)GPOINTER_TO_INT(data));
-  return 0;
-}
-
-int ext_pan_update(void *data) {
-  update_pan((double)GPOINTER_TO_INT(data));
-  return 0;
-}
-
-int ext_remote_set_zoom(void *data) {
-  int zoom=GPOINTER_TO_INT(data);
-g_print("ext_remote_set_zoom: %d\n",zoom);
-  remote_set_zoom(active_receiver->id,(double)zoom);
-  return 0;
-}
-
-int ext_remote_set_pan(void *data) {
-  int pan=GPOINTER_TO_INT(data);
-g_print("ext_remote_set_pan: %d\n",pan);
-  remote_set_pan(active_receiver->id,(double)pan);
-  return 0;
-}
-
-int ext_set_title(void *data) {
-  gtk_window_set_title(GTK_WINDOW(top_window),(char *)data);
-  return 0;
-}
-
-//
-// Functions no longer used
-//
-#if 0
-int ext_recall_memory_slot(void *data) {
-  recall_memory_slot(GPOINTER_TO_INT(data));
-  return 0;
-}
-
-int ext_vfo_mode_changed(void * data)
-{
-  int mode=GPOINTER_TO_INT(data);
-  vfo_mode_changed(mode);
-  return 0;
-}
-
-int ext_set_frequency(void *data) {
-  //
-  // If new frequency is outside of current band,
-  // behave as if the user had chosen the new band
-  // via the menu prior to changing the frequency
-  //
-  SET_FREQUENCY *set_frequency=(SET_FREQUENCY *)data;
-g_print("ext_set_frequency: vfo=%d freq=%lld\n",set_frequency->vfo,set_frequency->frequency);
-  set_frequency(set_frequency->vfo,set_frequency->frequency);
-  free(data);
-  return 0;
-}
-
-int ext_vfo_filter_changed(void *data) {
-  vfo_filter_changed(GPOINTER_TO_INT(data));
-  return 0;
-}
-
-int ext_noise_update(void *data) {
-  start_noise();
-  return 0;
-}
-
-int ext_update_agc_gain(void *data) {
-  update_agc_gain(GPOINTER_TO_INT(data));
-  return 0;
-}
-
-int ext_update_af_gain(void *data) {
-  update_af_gain();
-  return 0;
-}
-
-int ext_calc_drive_level(void *data) {
-  calcDriveLevel();
-  return 0;
-}
-
-int ext_vfo_band_changed(void *data) {
-  int b=GPOINTER_TO_INT(data);
-  vfo_band_changed(active_receiver->id,b);
-  return 0;
-}
-
-int ext_radio_change_sample_rate(void *data) {
-  radio_change_sample_rate(GPOINTER_TO_INT(data));
-  return 0;
-}
-
-int ext_update_squelch(void *data) {
-  set_squelch();
-  return 0;
-}
-
-int ext_update_vfo_step(void *data) {
-  int direction=GPOINTER_TO_INT(data);
-  int i=0;
-  while(steps[i]!=step && steps[i]!=0) {
-    i++;
-  }
-
-  if(steps[i]!=0) {
-    if(direction>0) {
-      i++;
-      if(steps[i]!=0) {
-        step=steps[i];
-      }
-    } else {
-      i--;
-      if(i>=0) {
-        step=steps[i];
-      }
-    }
-  }
-  g_idle_add(ext_vfo_update, NULL);
-  return 0;
-}
-
-int ext_vfo_step(void *data) {
-  int step=GPOINTER_TO_INT(data);
-  vfo_step(step);
-  return 0;
-}
-
-int ext_vfo_id_step(void *data) {
-  //
-  // the two integer input arguments (VFO id and Step in Hz)
-  // are encoded in a single integer-type number:
-  // input = 10000*vfo_id + (step+1000);
-  //
-  // Normally vfo_id is a small number (0 or 1)
-  // and the step is in the range -100 - 100 (in units of the VFO step size)
-  //
-  int val = GPOINTER_TO_INT(data);
-  int id = val / 10000;
-  int step = (val % 10000) - 1000;
-  vfo_id_step(id,step);
-  return 0;
-}
-
-int ext_set_mic_gain(void * data) {
-  //
-  // mic gain is (input value - 1000), normally between -12 and 50
-  //
-  int val = GPOINTER_TO_INT(data);
-  double d = val - 1000;
-  set_mic_gain(d);
-  return 0;
-}
-
-int ext_set_agc_gain(void *data) {
-  //
-  // AGC is (input value - 1000), normally between -20 and +120
-  //
-  int val=GPOINTER_TO_INT(data);
-  double d=  val - 1000;
-  set_agc_gain(active_receiver->id,d);
-  return 0;
-}
-
-int ext_set_drive(void *data) {
-  //
-  // Drive is input value, normally between 0 and 100
-  //
-  int val=GPOINTER_TO_INT(data);
-  double d=(double) val;
-  set_drive(d);
-  return 0;
-}
-
-int ext_set_compression(void *data) {
-  if(can_transmit) {
-    set_compression(transmitter);
-  }
-  return 0;
-}
-
-int ext_update_att_preamp(void *data) {
-  update_att_preamp();
-  return 0;
-}
-
-int ext_set_alex_attenuation(void *data) {
-  int val=GPOINTER_TO_INT(data);
-  set_alex_attenuation(val);
-  return 0;
-}
-
-int ext_set_attenuation_value(void *data) {
-  //
-  // Att valus is (input -1000), normally between 0 and 31
-  // but HermesLite-II and others have the range -12 to 48.
-  //
-  int val=GPOINTER_TO_INT(data);
-  double d = val - 1000;
-  set_attenuation_value(d);
-  return 0;
-}
-
-int ext_set_split(void *data) {
-  val=GPOINTER_TO_INT(data),
-  set_split(val);
-  return 0;
-}
-
-int ext_diversity_change_gain(void *data) {
-  //
-  // value = (input-10000) * 0.1
-  //
-  int val=GPOINTER_TO_INT(data);
-  double d = (val - 10000) * 0.1;
-  update_diversity_gain(d);
-  return 0;
-}
-
-int ext_diversity_change_phase(void *data) {
-  //
-  // value = (input-10000) * 0.1
-  //
-  int val=GPOINTER_TO_INT(data);
-  double d = (val - 10000) * 0.1;
-  update_diversity_phase(d);
-  return 0;
-}
-
-int ext_set_rf_gain(void *data) {
-  int pos=GPOINTER_TO_INT(data);
-  double value;
-  value=(double)pos;
-  if(value<-12.0) {
-    value=-12.0;
-  } else if(value>48.0) {
-    value=48.0;
-  }
-  set_rf_gain(active_receiver->id,value);
-  return 0;
-}
-
 int ext_anf_update(void *data) {
   if(active_receiver->anf==0) {
     active_receiver->anf=1;
@@ -1258,6 +1191,16 @@ int ext_anf_update(void *data) {
   return 0;
 }
 
+int ext_mute_update(void *data) {
+  active_receiver->mute_radio=!active_receiver->mute_radio;
+  return 0;
+}
+
+int ext_zoom_update(void *data) {
+  update_zoom((double)GPOINTER_TO_INT(data));
+  return 0;
+}
+
 int ext_zoom_set(void *data) {
   int pos=GPOINTER_TO_INT(data);
   double zoom=((double)pos/(100.0/7.0))+1.0;
@@ -1267,6 +1210,11 @@ int ext_zoom_set(void *data) {
   return 0;
 }
 
+int ext_pan_update(void *data) {
+  update_pan((double)GPOINTER_TO_INT(data));
+  return 0;
+}
+
 int ext_pan_set(void *data) {
   if(active_receiver->zoom>1) {
     int pos=GPOINTER_TO_INT(data);
@@ -1276,8 +1224,21 @@ int ext_pan_set(void *data) {
   return 0;
 }
 
-int ext_store_memory_slot(void *data) {
-  store_memory_slot(GPOINTER_TO_INT(data));
+int ext_remote_set_zoom(void *data) {
+  int zoom=GPOINTER_TO_INT(data);
+g_print("ext_remote_set_zoom: %d\n",zoom);
+  remote_set_zoom(active_receiver->id,(double)zoom);
+  return 0;
+}
+
+int ext_remote_set_pan(void *data) {
+  int pan=GPOINTER_TO_INT(data);
+g_print("ext_remote_set_pan: %d\n",pan);
+  remote_set_pan(active_receiver->id,(double)pan);
+  return 0;
+}
+
+int ext_set_title(void *data) {
+  gtk_window_set_title(GTK_WINDOW(top_window),(char *)data);
   return 0;
 }
-#endif
index 91fcd4341749967df328021f905058ab728fa916..62865ad85c7c64e7b7043f0b242948c7ab8d74ca 100644 (file)
--- a/iambic.h
+++ b/iambic.h
@@ -1,6 +1,7 @@
 #ifndef _IAMBIC_H
 #define _IAMBIC_H
 
+#ifdef LOCALCW
 enum {
     CHECK = 0,
     STRAIGHT,
@@ -20,3 +21,4 @@ void keyer_close();
 int  keyer_init();
 
 #endif
+#endif
index 7f20c825ff3db42fa26ee3a6c9fbafd66855ecdf..bdac6bff3a5dafe07831765a394e12cf559fc73e 100644 (file)
@@ -59,9 +59,7 @@
 #include "toolbar.h"
 #include "vox.h"
 #include "ext.h"
-#ifdef LOCALCW
 #include "iambic.h"
-#endif
 
 #define min(x,y) (x<y?x:y)
 
@@ -478,13 +476,6 @@ void new_protocol_init(int pixels) {
 #endif
     micoutputsamples=buffer_size*4;
 
-//  if(local_audio) {
-//   if(audio_open_output()!=0) {
-//     g_print("audio_open_output failed\n");
-//     local_audio=0;
-//   }
-//  }
-
     if(transmitter->local_microphone) {
       if(audio_open_input()!=0) {
         g_print("audio_open_input failed\n");
index eece1fb667c1d10d7da0a48df7856ec76225b4ea..c4a0601b58c3fdfe192359b78107f2a683082ff0 100644 (file)
@@ -50,9 +50,7 @@
 #include "toolbar.h"
 #include "vfo.h"
 #include "ext.h"
-#ifdef LOCALCW
 #include "iambic.h"
-#endif
 #include "error_handler.h"
 
 #define min(x,y) (x<y?x:y)
index 80d44ce0d5acf468d5ad84419cfadbad113a62de..b4b6199edc18a4368dcc86af6c62ebcc9b500b27 100644 (file)
@@ -69,7 +69,7 @@ static int waterfall_resample=6;
 
 void receiver_weak_notify(gpointer data,GObject  *obj) {
   RECEIVER *rx=(RECEIVER *)data;
-  fprintf(stderr,"receiver_weak_notify: id=%d obj=%p\n",rx->id, obj);
+  g_print("%s: id=%d obj=%p\n",__FUNCTION__,rx->id, obj);
 }
 
 gboolean receiver_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) {
@@ -194,7 +194,7 @@ void receiver_save_state(RECEIVER *rx) {
   char name[128];
   char value[128];
 
-  g_print("receiver_save_state: %d\n",rx->id);
+  g_print("%s: %d\n",__FUNCTION__,rx->id);
   sprintf(name,"receiver.%d.audio_channel",rx->id);
   sprintf(value,"%d",rx->audio_channel);
   setProperty(name,value);
@@ -231,7 +231,11 @@ void receiver_save_state(RECEIVER *rx) {
     // for PS_RX_RECEIVER, *only* save the ALEX antenna setting
     // and then return quickly.
     //
-    if (rx->id == PS_RX_FEEDBACK) return;
+    if (rx->id == PS_RX_FEEDBACK
+#ifdef SOAPYSDR
+        && protocol!=SOAPYSDR_PROTOCOL
+#endif
+       ) return;
 #endif
 
     sprintf(name,"receiver.%d.sample_rate",rx->id);
@@ -363,7 +367,7 @@ void receiver_restore_state(RECEIVER *rx) {
   char name[128];
   char *value;
 
-fprintf(stderr,"receiver_restore_state: id=%d\n",rx->id);
+g_print("%s: id=%d\n",__FUNCTION__,rx->id);
 
   sprintf(name,"receiver.%d.audio_channel",rx->id);
   value=getProperty(name);
@@ -404,7 +408,11 @@ fprintf(stderr,"receiver_restore_state: id=%d\n",rx->id);
     // for PS_RX_RECEIVER, *only* restore the ALEX antenna and setting
     // and then return quickly
     //
-    if (rx->id == PS_RX_FEEDBACK) return;
+    if (rx->id == PS_RX_FEEDBACK
+#ifdef SOAPYSDR
+        && protocol!=SOAPYSDR_PROTOCOL
+#endif
+       ) return;
 #endif
 
     sprintf(name,"receiver.%d.sample_rate",rx->id);
@@ -568,12 +576,11 @@ void reconfigure_receiver(RECEIVER *rx,int height) {
 
   if(rx->display_panadapter) {
     if(rx->panadapter==NULL) {
-fprintf(stderr,"reconfigure_receiver: panadapter_init: width:%d height:%d\n",rx->width,myheight);
+g_print("%s: panadapter_init: width:%d height:%d\n",__FUNCTION__,rx->width,myheight);
       rx_panadapter_init(rx, rx->width,myheight);
       gtk_fixed_put(GTK_FIXED(rx->panel),rx->panadapter,0,y);  // y=0 here always
     } else {
        // set the size
-//fprintf(stderr,"reconfigure_receiver: panadapter set_size_request: width:%d height:%d\n",rx->width,myheight);
       gtk_widget_set_size_request(rx->panadapter, rx->width, myheight);
       // move the current one
       gtk_fixed_move(GTK_FIXED(rx->panel),rx->panadapter,0,y);
@@ -589,12 +596,12 @@ fprintf(stderr,"reconfigure_receiver: panadapter_init: width:%d height:%d\n",rx-
 
   if(rx->display_waterfall) {
     if(rx->waterfall==NULL) {
-fprintf(stderr,"reconfigure_receiver: waterfall_init: width:%d height:%d\n",rx->width,myheight);
+g_print("%s: waterfall_init: width:%d height:%d\n",__FUNCTION__,rx->width,myheight);
       waterfall_init(rx,rx->width,myheight);
       gtk_fixed_put(GTK_FIXED(rx->panel),rx->waterfall,0,y);  // y=0 if ONLY waterfall is present
     } else {
       // set the size
-fprintf(stderr,"reconfigure_receiver: waterfall set_size_request: width:%d height:%d\n",rx->width,myheight);
+g_print("%s: waterfall set_size_request: width:%d height:%d\n",__FUNCTION__,rx->width,myheight);
       gtk_widget_set_size_request(rx->waterfall, rx->width, myheight);
       // move the current one
       gtk_fixed_move(GTK_FIXED(rx->panel),rx->waterfall,0,y);
@@ -615,8 +622,6 @@ static gint update_display(gpointer data) {
   RECEIVER *rx=(RECEIVER *)data;
   int rc;
 
-//g_print("update_display: rx=%d displaying=%d\n",rx->id,rx->displaying);
-
   if(rx->displaying) {
     if(rx->pixels>0) {
       g_mutex_lock(&rx->display_mutex);
@@ -744,8 +749,6 @@ void set_agc(RECEIVER *rx, int agc) {
 }
 
 void set_offset(RECEIVER *rx,long long offset) {
-//fprintf(stderr,"set_offset: id=%d ofset=%lld\n",rx->id,offset);
-//fprintf(stderr,"set_offset: frequency=%lld ctun_freqeuncy=%lld offset=%lld\n",vfo[rx->id].frequency,vfo[rx->id].ctun_frequency,vfo[rx->id].offset);
   if(offset==0) {
     SetRXAShiftFreq(rx->id, (double)offset);
     RXANBPSetShiftFrequency(rx->id, (double)offset);
@@ -780,7 +783,7 @@ static void init_analyzer(RECEIVER *rx) {
 
     overlap = (int)fmax(0.0, ceil(fft_size - (double)rx->sample_rate / (double)rx->fps));
 
-    //g_print("SetAnalyzer id=%d buffer_size=%d overlap=%d\n",rx->id,rx->buffer_size,overlap);
+    //g_print("%s: id=%d buffer_size=%d overlap=%d\n",_FUNCTION__,rx->id,rx->buffer_size,overlap);
 
 
     SetAnalyzer(rx->id,
@@ -811,7 +814,7 @@ static void create_visual(RECEIVER *rx) {
   int y=0;
 
   rx->panel=gtk_fixed_new();
-fprintf(stderr,"receiver: create_visual: id=%d width=%d height=%d %p\n",rx->id, rx->width, rx->height, rx->panel);
+g_print("%s: id=%d width=%d height=%d %p\n",__FUNCTION__,rx->id, rx->width, rx->height, rx->panel);
   g_object_weak_ref(G_OBJECT(rx->panel),receiver_weak_notify,(gpointer)rx);
   gtk_widget_set_size_request (rx->panel, rx->width, rx->height);
 
@@ -824,14 +827,14 @@ fprintf(stderr,"receiver: create_visual: id=%d width=%d height=%d %p\n",rx->id,
   }
 
   rx_panadapter_init(rx, rx->width,height);
-fprintf(stderr,"receiver: panadapter_init: height=%d y=%d %p\n",height,y,rx->panadapter);
+g_print("%s: panadapter height=%d y=%d %p\n",__FUNCTION__,height,y,rx->panadapter);
   g_object_weak_ref(G_OBJECT(rx->panadapter),receiver_weak_notify,(gpointer)rx);
   gtk_fixed_put(GTK_FIXED(rx->panel),rx->panadapter,0,y);
   y+=height;
 
   if(rx->display_waterfall) {
     waterfall_init(rx,rx->width,height);
-fprintf(stderr,"receiver: waterfall_init: height=%d y=%d %p\n",height,y,rx->waterfall);
+g_print("%s: waterfall height=%d y=%d %p\n",__FUNCTION__,height,y,rx->waterfall);
     g_object_weak_ref(G_OBJECT(rx->waterfall),receiver_weak_notify,(gpointer)rx);
     gtk_fixed_put(GTK_FIXED(rx->panel),rx->waterfall,0,y);
   }
@@ -841,7 +844,7 @@ fprintf(stderr,"receiver: waterfall_init: height=%d y=%d %p\n",height,y,rx->wate
 
 #ifdef PURESIGNAL
 RECEIVER *create_pure_signal_receiver(int id, int buffer_size,int sample_rate,int width) {
-fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_size);
+g_print("%s: id=%d buffer_size=%d\n",__FUNCTION__,id,buffer_size);
   RECEIVER *rx=malloc(sizeof(RECEIVER));
   rx->id=id;
 
@@ -942,7 +945,7 @@ fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_s
   int result;
   XCreateAnalyzer(rx->id, &result, 262144, 1, 1, "");
   if(result != 0) {
-    fprintf(stderr, "XCreateAnalyzer id=%d failed: %d\n", rx->id, result);
+    g_print( "%s: XCreateAnalyzer id=%d failed: %d\n",__FUNCTION__, rx->id, result);
   } else {
     init_analyzer(rx);
   }
@@ -959,7 +962,7 @@ fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_s
 #endif
 
 RECEIVER *create_receiver(int id, int buffer_size, int fft_size, int pixels, int fps, int width, int height) {
-fprintf(stderr,"create_receiver: id=%d buffer_size=%d fft_size=%d pixels=%d fps=%d\n",id,buffer_size, fft_size, pixels, fps);
+g_print("%s: id=%d buffer_size=%d fft_size=%d pixels=%d fps=%d\n",__FUNCTION__,id,buffer_size, fft_size, pixels, fps);
   RECEIVER *rx=malloc(sizeof(RECEIVER));
   rx->id=id;
   g_mutex_init(&rx->mutex);
@@ -996,12 +999,13 @@ fprintf(stderr,"create_receiver: id=%d buffer_size=%d fft_size=%d pixels=%d fps=
           break;
       }
   }
-fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc);
+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;
@@ -1092,21 +1096,21 @@ fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc);
   rx->pixel_samples=g_new(float,rx->pixels);
 
 
-fprintf(stderr,"create_receiver (after restore): rx=%p id=%d audio_buffer_size=%d local_audio=%d\n",rx,rx->id,rx->audio_buffer_size,rx->local_audio);
-  //rx->audio_buffer=g_new(guchar,rx->audio_buffer_size);
+g_print("%s (after restore): rx=%p id=%d audio_buffer_size=%d local_audio=%d\n",__FUNCTION__,rx,rx->id,rx->audio_buffer_size,rx->local_audio);
   int scale=rx->sample_rate/48000;
   rx->output_samples=rx->buffer_size/scale;
   rx->audio_output_buffer=g_new(gdouble,2*rx->output_samples);
 
-fprintf(stderr,"create_receiver: id=%d output_samples=%d\n",rx->id,rx->output_samples);
+g_print("%s: id=%d output_samples=%d audio_output_buffer=%p\n",__FUNCTION__,rx->id,rx->output_samples,rx->audio_output_buffer);
 
   rx->hz_per_pixel=(double)rx->sample_rate/(double)rx->pixels;
 
   // setup wdsp for this receiver
 
-fprintf(stderr,"create_receiver: id=%d after restore adc=%d\n",rx->id, rx->adc);
+g_print("%s: id=%d after restore adc=%d\n",__FUNCTION__,rx->id, rx->adc);
 
-fprintf(stderr,"create_receiver: OpenChannel id=%d buffer_size=%d fft_size=%d sample_rate=%d\n",
+g_print("%s: OpenChannel id=%d buffer_size=%d fft_size=%d sample_rate=%d\n",
+        __FUNCTION__,
         rx->id,
         rx->buffer_size,
         rx->fft_size,
@@ -1138,9 +1142,7 @@ fprintf(stderr,"create_receiver: OpenChannel id=%d buffer_size=%d fft_size=%d sa
   create_anbEXT(rx->id,1,  rx->buffer_size,rx->sample_rate,0.00001,0.00001,0.00001,0.05, 4.95);
   create_nobEXT(rx->id,1,0,rx->buffer_size,rx->sample_rate,0.00001,0.00001,0.00001,0.05, 4.95);
   
-fprintf(stderr,"RXASetNC %d\n",rx->fft_size);
   RXASetNC(rx->id, rx->fft_size);
-fprintf(stderr,"RXASetMP %d\n",rx->low_latency);
   RXASetMP(rx->id, rx->low_latency);
 
   set_agc(rx, rx->agc);
@@ -1179,7 +1181,7 @@ fprintf(stderr,"RXASetMP %d\n",rx->low_latency);
   int result;
   XCreateAnalyzer(rx->id, &result, 262144, 1, 1, "");
   if(result != 0) {
-    fprintf(stderr, "XCreateAnalyzer id=%d failed: %d\n", rx->id, result);
+    g_print( "%s: XCreateAnalyzer id=%d failed: %d\n",__FUNCTION__,rx->id, result);
   } else {
     init_analyzer(rx);
   }
@@ -1191,11 +1193,12 @@ fprintf(stderr,"RXASetMP %d\n",rx->low_latency);
 
   create_visual(rx);
 
-fprintf(stderr,"create_receiver: rx=%p id=%d local_audio=%d\n",rx,rx->id,rx->local_audio);
+g_print("%s: rx=%p id=%d local_audio=%d\n",__FUNCTION__,rx,rx->id,rx->local_audio);
   if(rx->local_audio) {
-    if (audio_open_output(rx) < 0) rx->local_audio=0;
+    if(audio_open_output(rx)<0) {
+      rx->local_audio=0;
+    }
   }
-
   return rx;
 }
 
@@ -1212,14 +1215,14 @@ void receiver_change_sample_rate(RECEIVER *rx,int sample_rate) {
   rx->output_samples=rx->buffer_size/scale;
   rx->hz_per_pixel=(double)rx->sample_rate/(double)rx->width;
 
-g_print("receiver_change_sample_rate: id=%d rate=%d scale=%d buffer_size=%d output_samples=%d\n",rx->id,sample_rate,scale,rx->buffer_size,rx->output_samples);
+g_print("%s: id=%d rate=%d scale=%d buffer_size=%d output_samples=%d\n",__FUNCTION__,rx->id,sample_rate,scale,rx->buffer_size,rx->output_samples);
 
 #ifdef PURESIGNAL
   //
   // In the old protocol, the RX_FEEDBACK sample rate is tied
   // to the radio's sample rate and therefore may vary.
   // Since there is no downstream WDSP receiver her, the only thing
-  // we have to do here is to adapt the spectrum display of the 
+  // we have to do here is to adapt the spectrum display of the
   // feedback and must then return (rx->id is not a WDSP channel!)
   // 
   if (rx->id == PS_RX_FEEDBACK && protocol == ORIGINAL_PROTOCOL) {
@@ -1264,7 +1267,7 @@ g_print("receiver_change_sample_rate: id=%d rate=%d scale=%d buffer_size=%d outp
 
   g_mutex_unlock(&rx->mutex);
 
-fprintf(stderr,"receiver_change_sample_rate: id=%d rate=%d buffer_size=%d output_samples=%d\n",rx->id, rx->sample_rate, rx->buffer_size, rx->output_samples);
+g_print("%s: id=%d rate=%d buffer_size=%d output_samples=%d\n",__FUNCTION__,rx->id, rx->sample_rate, rx->buffer_size, rx->output_samples);
 }
 
 void receiver_frequency_changed(RECEIVER *rx) {
@@ -1353,6 +1356,9 @@ static void process_rx_buffer(RECEIVER *rx) {
   gdouble left_sample,right_sample;
   short left_audio_sample,right_audio_sample;
   int i;
+
+  //g_print("%s: rx=%p id=%d output_samples=%d audio_output_buffer=%p\n",__FUNCTION__,rx,rx->id,rx->output_samples,rx->audio_output_buffer);
+
   for(i=0;i<rx->output_samples;i++) {
     if(isTransmitting() && (!duplex || mute_rx_while_transmitting)) {
       left_sample=0.0;
@@ -1440,6 +1446,7 @@ static void process_rx_buffer(RECEIVER *rx) {
 void full_rx_buffer(RECEIVER *rx) {
   int error;
 
+  //g_print("%s: rx=%p\n",__FUNCTION__,rx);
   g_mutex_lock(&rx->mutex);
 
   // noise blanker works on original IQ samples
@@ -1452,7 +1459,6 @@ void full_rx_buffer(RECEIVER *rx) {
 
   fexchange0(rx->id, rx->iq_input_buffer, rx->audio_output_buffer, &error);
   if(error!=0) {
-    //fprintf(stderr,"full_rx_buffer: id=%d fexchange0: error=%d\n",rx->id,error);
     rx->fexchange_errors++;
   }
 
@@ -1462,7 +1468,6 @@ void full_rx_buffer(RECEIVER *rx) {
     g_mutex_unlock(&rx->display_mutex);
   }
 
-//g_print("full_rx_buffer: rx=%d buffer_size=%d samples=%d\n",rx->id,rx->buffer_size,rx->samples);
   process_rx_buffer(rx);
   g_mutex_unlock(&rx->mutex);
 }
@@ -1494,7 +1499,6 @@ void add_div_iq_samples(RECEIVER *rx, double i0, double q0, double i1, double q1
 }
 
 void receiver_change_zoom(RECEIVER *rx,double zoom) {
-g_print("receiver_change_zoom: %d %f\n",rx->id,zoom);
   rx->zoom=(int)zoom;
   rx->pixels=rx->width*rx->zoom;
   rx->hz_per_pixel=(double)rx->sample_rate/(double)rx->pixels;
@@ -1521,7 +1525,6 @@ g_print("receiver_change_zoom: %d %f\n",rx->id,zoom);
 #ifdef CLIENT_SERVER
   }
 #endif
-g_print("receiver_change_zoom: pixels=%d zoom=%d pan=%d\n",rx->pixels,rx->zoom,rx->pan);
 }
 
 void receiver_change_pan(RECEIVER *rx,double pan) {
index d9496f743961769f3b399a3aee7f47258ed4fb4b..d29aa9df44105ed5719210c42a70145ec7605e3c 100644 (file)
--- a/rigctl.c
+++ b/rigctl.c
 #include "rigctl_menu.h"
 #include "noise_menu.h"
 #include "new_protocol.h"
-#ifdef LOCALCW
 #include "iambic.h"              // declare keyer_update()
-#endif
 #include <math.h>
 
+#define NEW_PARSER
+
 // IP stuff below
 #include <sys/socket.h>
 #include <arpa/inet.h> //inet_addr
@@ -799,7 +799,7 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) {
           if(command[4]==';') {
             // read the step size
             int i=0;
-            for(i=0;i<=14;i++) {
+            for(i=0;i<STEPS;i++) {
               if(steps[i]==step) break;
             }
             if(i<=14) {
@@ -810,7 +810,7 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) {
           } else if(command[6]==';') {
             // set the step size
             int i=atoi(&command[4]) ;
-            if(i>=0 && i<=14) {
+            if(i>=0 && i<STEPS) {
               step=steps[i];
               vfo_update();
             }
@@ -822,7 +822,7 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) {
           if(command[6]==';') {
             int step_index=atoi(&command[4]);
             long long hz=0;
-            if(step_index>=0 && step_index<=14) {
+            if(step_index>=0 && step_index<STEPS) {
               hz=(long long)steps[step_index];
             }
             if(hz!=0LL) {
@@ -895,7 +895,7 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) {
           if(command[6]==';') {
             int step_index=atoi(&command[4]);
             long long hz=0;
-            if(step_index>=0 && step_index<=14) {
+            if(step_index>=0 && step_index<STEPS) {
               hz=(long long)steps[step_index];
             }
             if(hz!=0LL) {
@@ -959,7 +959,7 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) {
           if(command[6]==';') {
             int step_index=atoi(&command[4]);
             long long hz=0;
-            if(step_index>=0 && step_index<=14) {
+            if(step_index>=0 && step_index<STEPS) {
               hz=(long long)steps[step_index];
             }
             if(hz!=0LL) {
@@ -974,7 +974,7 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) {
           if(command[6]==';') {
             int step_index=atoi(&command[4]);
             long long hz=0;
-            if(step_index>=0 && step_index<=14) {
+            if(step_index>=0 && step_index<STEPS) {
               hz=(long long)steps[step_index];
             }
             if(hz!=0LL) {
index 64d46506a92076dc0213fa386c69fc388e7404a6..10380fb0212c2784f8f169914a9b1d49696700fe 100644 (file)
@@ -51,7 +51,8 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_d
 }
 
 static void step_select_cb (GtkToggleButton *widget, gpointer        data) {
-  if(gtk_toggle_button_get_active(widget)) {
+  int val=GPOINTER_TO_INT(data);
+  if(gtk_toggle_button_get_active(widget) && val >= 0 && val<STEPS) {
     step=steps[GPOINTER_TO_INT(data)];
     g_idle_add(ext_vfo_update,NULL);
   }
@@ -86,8 +87,7 @@ void step_menu(GtkWidget *parent) {
   gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
 
   GtkWidget *step_rb=NULL;
-  int i=0;
-  while(steps[i]!=0) {
+  for (int i=0; i<STEPS; i++) {
     if(i==0) {
       step_rb=gtk_radio_button_new_with_label(NULL,step_labels[i]);
     } else {
@@ -98,7 +98,6 @@ void step_menu(GtkWidget *parent) {
     gtk_widget_show(step_rb);
     gtk_grid_attach(GTK_GRID(grid),step_rb,i%5,1+(i/5),1,1);
     g_signal_connect(step_rb,"toggled",G_CALLBACK(step_select_cb),(gpointer)(long)i);
-    i++;
   }
 
   gtk_container_add(GTK_CONTAINER(content),grid);