]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
fixes for DUPLEX
authorc vw <dl1ycf@darc.de>
Thu, 16 Jan 2020 10:30:05 +0000 (11:30 +0100)
committerc vw <dl1ycf@darc.de>
Thu, 16 Jan 2020 10:30:05 +0000 (11:30 +0100)
new_protocol.c
old_protocol.c

index c66098618b8d16d7685dd4339f1a9a00f1535e4d..c8f1954e187aa0f6ed45f84d54dabc0f63a1e8dd 100644 (file)
@@ -314,15 +314,36 @@ void update_action_table() {
   // Depending on the values of mox, puresignal, and diversity,
   // determine the actions to be taken when a DDC packet arrives
   //
-  int flag;
-  flag=0;
-  if (device==NEW_DEVICE_ANGELIA || device==NEW_DEVICE_ORION || device == NEW_DEVICE_ORION2) flag +=1000;
-  if (isTransmitting())                                                                      flag +=100;
-  if (transmitter->puresignal)                                                               flag +=10;
-  if (diversity_enabled)                                                                     flag +=1;
 
+  int flag=0;
+  int xmit=isTransmitting();  // store such that it cannot change while building the flag
+  int newdev=(device==NEW_DEVICE_ANGELIA || device==NEW_DEVICE_ORION || device == NEW_DEVICE_ORION2);
+
+  if (duplex && xmit)                  flag +=10000;
+  if (newdev)                          flag +=1000;
+  if (xmit)                            flag +=100;
+  if (transmitter->puresignal && xmit) flag +=10;
+  if (diversity_enabled && !xmit)      flag +=1;
+
+  // Note that the PURESIGNAL and DUPLEX flags are only set in the TX cases, since they
+  // make no difference upon RXing
+  // Note further, we do not use the diversity mixer upon transmitting.
   //
-  // Set up rxcase and rxid for each of the 16 possible cases
+  // Therefore, the following 12 values for flag are possible:
+  // flag=     0
+  // flag=     1
+  // flag=   100
+  // flag=   110
+  // flag=  1000
+  // flag=  1001
+  // flag=  1100
+  // flag=  1110
+  // flag= 10100
+  // flag= 10110
+  // flag= 11100
+  // flag= 11110
+  //
+  // Set up rxcase and rxid for each of the 12 cases
   // note that rxid[i] can be left unspecified if rxcase[i] == RXACTION_SKIP
   //
   rxcase[0] = RXACTION_SKIP;
@@ -330,8 +351,8 @@ void update_action_table() {
   rxcase[2] = RXACTION_SKIP;
   rxcase[3] = RXACTION_SKIP;
   switch (flag) {
-    case    0:                                                         // HERMES, RX, no DIVERSITY
-    case   10:
+    case       0:                                                      // HERMES, RX, no DIVERSITY
+    case   10100:                                                      // HERMES, TX, no PURESIGNAL, DUPLEX
        rxid[0]=0;
        rxcase[0] = RXACTION_NORMAL;
         if (receivers > 1) {
@@ -339,27 +360,25 @@ void update_action_table() {
          rxcase[1] = RXACTION_NORMAL;
         }
        break;
-    case    1:                                                         // HERMES, RX, DIVERSITY
-    case   11:                                                         // ORION, RX, DIVERSITY
-    case 1001:
-    case 1011:
+    case     1:                                                                // HERMES or ORION, RX, DIVERSITY
+    case  1001:
        rxid[0]=0;
        rxcase[0] = RXACTION_DIV;
        break;
-    case  100:                                                         // HERMES, TX, no PURESIGNAL
-    case  101:
-    case 1100:                                                         // ORION, TX, no PURESIGNAL
-    case 1101:                                                         // ORION, TX, no PURESIGNAL
+    case  100:                                                         // HERMES or ORION, TX, no PURESIGNAL, no DUPLEX
+    case 1100:
        // just skip samples
        break;
-    case  110:                                                         // HERMES, TX, PURESIGNAL
-    case  111:
-    case 1110:                                                         // ORION, TX, PURESIGNAL
-    case 1111:
+    case  110:                                                         // HERMES or ORION, TX, PURESIGNAL, no DUPLEX
+    case 1110:
+    case 10110:                                                                // HERMES, TX, DUPLEX, PS: duplex is ignored
        rxcase[0] = RXACTION_PS;
        break;
+    case 11110:                                                                // ORION, TX, PURESIGNAL, DUPLEX
+       rxcase[0] = RXACTION_PS;
+       /* FALLTHROUGH */
     case 1000:                                                         // ORION, RX, no DIVERSITY
-    case 1010:
+    case 11100:                                                                // ORION, TX, no PURESIGNAL, DUPLEX
        rxid[2]=0;
        rxcase[2] = RXACTION_NORMAL;
         if (receivers > 1) {
@@ -367,6 +386,9 @@ void update_action_table() {
          rxcase[3] = RXACTION_NORMAL;
         }
        break;
+    default:
+       fprintf(stderr,"ACTION TABLE: case not handled: %d\n", flag);
+       break;
   }
 }
 
@@ -662,7 +684,7 @@ static void new_protocol_high_priority() {
 //  Set DDC frequencies
 //
 
-    if (diversity_enabled) {
+    if (diversity_enabled && !isTransmitting()) {
        //
        // Use frequency of first receiver for both DDC0 and DDC1
        // This is overridden later if we do PURESIGNAL TX
@@ -1234,7 +1256,11 @@ static void new_protocol_receive_specific() {
         receive_specific_buffer[5]|=receiver[i]->dither<<ddc; // dither enable
         receive_specific_buffer[6]|=receiver[i]->random<<ddc; // random enable
        if (!isTransmitting() && !diversity_enabled) {
-         // Upon TX (with and without PURESIGNAL), and upon diversity reception, deactivate DDCs
+         // normal RX without diversity
+          receive_specific_buffer[7]|=(1<<ddc); // DDC enable
+       }
+       if (isTransmitting() && duplex) {
+         // transmitting with duplex
           receive_specific_buffer[7]|=(1<<ddc); // DDC enable
        }
         receive_specific_buffer[17+(ddc*6)]=receiver[i]->adc;
@@ -1263,7 +1289,7 @@ static void new_protocol_receive_specific() {
       receive_specific_buffer[26]=24;          // bits per sample
       receive_specific_buffer[1363]=0x02;       // sync DDC1 to DDC0
 
-      receive_specific_buffer[7]=1;            // enable  DDC0 but disable all others
+      receive_specific_buffer[7] |=1;          // enable  DDC0
     }
     if (diversity_enabled && ! isTransmitting()) {
 //
index ccb75d427d8ccfb0bcadc10ae6c27c46baea1a6e..1c20de682ff1c940ec9af7b6e679614efe27af51 100644 (file)
@@ -799,6 +799,10 @@ static void process_ozy_input_buffer(unsigned char  *buffer) {
   double right_sample_double_rx;
   double left_sample_double_tx;
   double right_sample_double_tx;
+  double left_sample_double_main;
+  double right_sample_double_main;
+  double left_sample_double_aux;
+  double right_sample_double_aux;
 
   int id=active_receiver->id;
 
@@ -913,17 +917,17 @@ static void process_ozy_input_buffer(unsigned char  *buffer) {
          // receiving with DIVERSITY. Get sample pairs and feed to diversity mixer
          //
           if (r == rx1channel) {
-            left_sample_double_rx=left_sample_double;
-            right_sample_double_rx=right_sample_double;
+            left_sample_double_main=left_sample_double;
+            right_sample_double_main=right_sample_double;
           } else if (r == rx2channel) {
-            left_sample_double_tx=left_sample_double;
-            right_sample_double_tx=right_sample_double;
+            left_sample_double_aux=left_sample_double;
+            right_sample_double_aux=right_sample_double;
           }
-         // this is pure paranoia, it allows for div_main < div_aux
+         // this is pure paranoia, it allows for rx2channel < rx1channel
           if (r+1 == num_hpsdr_receivers) {
-            add_div_iq_samples(receiver[0], left_sample_double_rx,right_sample_double_rx,left_sample_double_tx,right_sample_double_tx);
+            add_div_iq_samples(receiver[0], left_sample_double_main,right_sample_double_main,left_sample_double_aux,right_sample_double_aux);
            // if we have a second receiver, display "auxiliary" receiver as well
-            if (receivers >1) add_iq_samples(receiver[1], left_sample_double_tx,right_sample_double_tx);
+            if (receivers >1) add_iq_samples(receiver[1], left_sample_double_aux,right_sample_double_aux);
           }
        }