From: DL1YCF <dl1ycf@darc.de>
Date: Sat, 4 Jan 2020 11:37:40 +0000 (+0100)
Subject: Restart old protocol when changing the number of used HPSDR receivers.
X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/simplejson/class-simplejson.JSONEncoder-index.html?a=commitdiff_plain;h=4a449b3cf5cd5641b71c123259467d5c605b2514;p=pihpsdr.git

Restart old protocol when changing the number of used HPSDR receivers.
---

diff --git a/diversity_menu.c b/diversity_menu.c
index b42822d..eaa41bd 100644
--- a/diversity_menu.c
+++ b/diversity_menu.c
@@ -61,7 +61,18 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_d
 }
 
 static void diversity_cb(GtkWidget *widget, gpointer data) {
+  //
+  // If we have only one receiver, then changing diversity
+  // changes the number of HPSR receivers so we restart the
+  // original protocol
+  //
+  if (protocol == ORIGINAL_PROTOCOL && receivers == 1) {
+    old_protocol_stop();
+  }
   diversity_enabled=diversity_enabled==1?0:1;
+  if (protocol == ORIGINAL_PROTOCOL && receivers == 1) {
+    old_protocol_run();
+  }
   if (protocol == NEW_PROTOCOL) {
     schedule_high_priority();
     schedule_receive_specific();
diff --git a/ps_menu.c b/ps_menu.c
index e26ee5b..21682db 100644
--- a/ps_menu.c
+++ b/ps_menu.c
@@ -28,6 +28,7 @@
 #include "toolbar.h"
 #include "transmitter.h"
 #include "new_protocol.h"
+#include "old_protocol.h"
 #include "vfo.h"
 #include "ext.h"
 
@@ -286,7 +287,17 @@ static void ps_ant_cb(GtkWidget *widget, gpointer data) {
 }
 
 static void enable_cb(GtkWidget *widget, gpointer data) {
+  //
+  // Enabling/Disabling changes the number of required
+  // of HPSR receivers so we restart the original protocol
+  //
+  if (protocol == ORIGINAL_PROTOCOL) {
+    old_protocol_stop();
+  }
   g_idle_add(ext_tx_set_ps,GINT_TO_POINTER(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))));
+  if (protocol == ORIGINAL_PROTOCOL) {
+    old_protocol_run();
+  }
 }
 
 static void auto_cb(GtkWidget *widget, gpointer data) {
diff --git a/radio.c b/radio.c
index 35050db..66e3c58 100644
--- a/radio.c
+++ b/radio.c
@@ -1070,6 +1070,13 @@ void radio_change_receivers(int r) {
   // number of receivers has not changed.
   if (receivers == r) return;
   fprintf(stderr,"radio_change_receivers: from %d to %d\n",receivers,r);
+  //
+  // When changing the number of receivers, restart the
+  // old protocol
+  //
+  if (protocol == ORIGINAL_PROTOCOL) {
+    old_protocol_stop();
+  }
   switch(r) {
     case 1:
 	set_displaying(receiver[1],0);
@@ -1087,6 +1094,9 @@ void radio_change_receivers(int r) {
   if(protocol==NEW_PROTOCOL) {
     schedule_high_priority();
   }
+  if (protocol == ORIGINAL_PROTOCOL) {
+    old_protocol_run();
+  }
 }
 
 void radio_change_sample_rate(int rate) {