]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
a) save/restore DIVERSITY settings
authorc vw <dl1ycf@darc.de>
Mon, 4 Nov 2019 15:53:20 +0000 (16:53 +0100)
committerc vw <dl1ycf@darc.de>
Mon, 4 Nov 2019 15:53:20 +0000 (16:53 +0100)
b) upon startup, do not activate DIVERSITY unless there are two ADCs.

radio.c

diff --git a/radio.c b/radio.c
index d7a2e10aeef5fa710db55decf68cba7b91bbae95..f3457ec7c49b88e9ed5b99b1e1d6647d46dc00d2 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -725,7 +725,9 @@ void start_radio() {
 // It is possible that an option has been read in
 // which is not compatible with the hardware.
 // Change setting to reasonable value then.
+// This could possibly be moved to radioRestoreState().
 // 
+// Sanity Check #1: restrict buffer size in new protocol
 //
   switch (protocol) {
     case ORIGINAL_PROTOCOL:
@@ -740,6 +742,12 @@ void start_radio() {
       break;
 #endif
   }
+//
+// Sanity Check #2: enable diversity only if there are two RX and two ADCs
+//
+   if (RECEIVERS < 2 || n_adc < 2) {
+     diversity_enabled=0;
+   }
 
   radio_change_region(region);
 
@@ -1459,6 +1467,16 @@ fprintf(stderr,"sem_wait\n");
 fprintf(stderr,"sem_wait: returner\n");
     loadProperties(property_path);
 
+    value=getProperty("diversity_enabled");
+    if (value) diversity_enabled=atoi(value);
+    value=getProperty("diversity_gain");
+    if (value) div_gain=atof(value);
+    value=getProperty("diversity_phase");
+    if (value) div_phase=atof(value);
+    value=getProperty("diversity_cos");
+    if (value) div_cos=atof(value);
+    value=getProperty("diversity_sin");
+    if (value) div_sin=atof(value);
     value=getProperty("new_pa_board");
     if (value) new_pa_board=atoi(value);
     value=getProperty("region");
@@ -1698,6 +1716,16 @@ fprintf(stderr,"sem_wait\n");
     sem_wait(&property_sem);
 #endif
 fprintf(stderr,"sem_wait: returned\n");
+    sprintf(value,"%d",diversity_enabled);
+    setProperty("diversity_enabled",value);
+    sprintf(value,"%f",div_gain);
+    setProperty("diversity_gain",value);
+    sprintf(value,"%f",div_phase);
+    setProperty("diversity_phase",value);
+    sprintf(value,"%f",div_cos);
+    setProperty("diversity_cos",value);
+    sprintf(value,"%f",div_sin);
+    setProperty("diversity_sin",value);
     sprintf(value,"%d",new_pa_board);
     setProperty("new_pa_board",value);
     sprintf(value,"%d",region);