]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Manual merge with John's updates, made both repos as close as possible.
authorDL1YCF <dl1ycf@darc.de>
Sat, 25 Jul 2020 14:40:26 +0000 (16:40 +0200)
committerDL1YCF <dl1ycf@darc.de>
Sat, 25 Jul 2020 14:40:26 +0000 (16:40 +0200)
discovery.c
gpio.c
new_protocol.c
old_protocol.c
radio.c
zoompan.c

index cfc7e0f600d1ab7c1f4e11d013999e3f020f1bf4..2dc024c517a81137c9092860fe6426a273339115 100644 (file)
@@ -532,20 +532,6 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name);
       }
     }
 
-#ifdef GPIO
-    controller=CONTROLLER2_V2;
-    gpio_set_defaults(controller);
-    gpio_restore_state();
-#endif
-
-    g_print("%s: devices=%d autostart=%d\n",__FUNCTION__,devices,autostart);
-
-    if(devices==1 && autostart) {
-        d=&discovered[0];
-       if(d->status==STATE_AVAILABLE) {
-          if(start_cb(NULL,NULL,(gpointer)d)) return;
-       }
-    }
 
 #ifdef CLIENT_SERVER
 
@@ -579,6 +565,10 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name);
 #endif
 
 #ifdef GPIO
+    controller=CONTROLLER2_V2;
+    gpio_set_defaults(controller);
+    gpio_restore_state();
+
     GtkWidget *gpio=gtk_combo_box_text_new();
     gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"No Controller");
     gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Controller1");
@@ -629,6 +619,16 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name);
     gtk_widget_show_all(discovery_dialog);
 fprintf(stderr,"showing device dialog\n");
 
+    // autostart if enabled and only one device
+    g_print("%s: devices=%d autostart=%d\n",__FUNCTION__,devices,autostart);
+
+    if(devices==1 && autostart) {
+        d=&discovered[0];
+       if(d->status==STATE_AVAILABLE) {
+          if(start_cb(NULL,NULL,(gpointer)d)) return;
+       }
+    }
+
 }
 
 
diff --git a/gpio.c b/gpio.c
index 4a48aad472fe58bba4b37994a5ff9a1695d9284d..9fb48e12e05cb42618be39f97e7cf1708c5e31c6 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -2198,7 +2198,6 @@ static void encoder_changed(int action,int pos) {
       update_diversity_phase((double)pos*0.1);
       break;
     case ENCODER_ZOOM:
-g_print("GPIO: ENCODER_ZOOM: update_zoom: pos=%d\n",pos);
       update_zoom((double)pos);
       break;
     case ENCODER_PAN:
index 6341f5fd32195b104afd33ab2f140144480036f8..9fe58e6873864691bbf21fd524971573c15a9d02 100644 (file)
@@ -520,7 +520,7 @@ void new_protocol_init(int pixels) {
     command_response_thread_id = g_thread_new( "command_response thread",command_response_thread, NULL);
     if( ! command_response_thread_id ) {
       g_print("g_thread_new failed on command_response_thread\n");
-      abort();
+      exit( -1 );
     }
     g_print( "command_response_thread: id=%p\n",command_response_thread_id);
 #ifdef __APPLE__
@@ -537,7 +537,7 @@ void new_protocol_init(int pixels) {
     high_priority_thread_id = g_thread_new( "high_priority thread", high_priority_thread, NULL);
     if( ! high_priority_thread_id ) {
       g_print("g_thread_new failed on high_priority_thread\n");
-      abort();
+      exit( -1 );
     }
     g_print( "high_priority_thread: id=%p\n",high_priority_thread_id);
 #ifdef __APPLE__
@@ -554,7 +554,7 @@ void new_protocol_init(int pixels) {
     mic_line_thread_id = g_thread_new( "mic_line thread", mic_line_thread, NULL);
     if( ! mic_line_thread_id ) {
       g_print("g_thread_new failed on mic_line_thread\n");
-      abort();
+      exit( -1 );
     }
     g_print( "mic_line_thread: id=%p\n",mic_line_thread_id);
 
@@ -590,7 +590,7 @@ void new_protocol_init(int pixels) {
     data_socket=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
     if(data_socket<0) {
         g_print("NewProtocol: create socket failed for data_socket\n");
-        abort();
+        exit(-1);
     }
 
     int optval = 1;
@@ -600,7 +600,7 @@ void new_protocol_init(int pixels) {
     // bind to the interface
     if(bind(data_socket,(struct sockaddr*)&radio->info.network.interface_address,radio->info.network.interface_length)<0) {
         g_print("metis: bind socket failed for data_socket\n");
-        abort();
+        exit(-1);
     }
 
 g_print("new_protocol_init: data_socket %d bound to interface %s:%d\n",data_socket,inet_ntoa(radio->info.network.interface_address.sin_addr),ntohs(radio->info.network.interface_address.sin_port));
@@ -654,7 +654,7 @@ g_print("new_protocol_init: data_socket %d bound to interface %s:%d\n",data_sock
     if( ! new_protocol_thread_id )
     {
         g_print("g_thread_new failed on new_protocol_thread\n");
-        abort();
+        exit( -1 );
     }
     g_print( "new_protocol_thread: id=%p\n",new_protocol_thread_id);
 
@@ -707,7 +707,7 @@ static void new_protocol_general() {
 
     if((rc=sendto(data_socket,general_buffer,sizeof(general_buffer),0,(struct sockaddr*)&base_addr,base_addr_length))<0) {
         g_print("sendto socket failed for general: rc=%d errno=%d\n",rc,errno);
-        abort();
+        exit(1);
     }
 
     if(rc!=sizeof(general_buffer)) {
@@ -1197,6 +1197,7 @@ static void new_protocol_high_priority() {
     if((rc=sendto(data_socket,high_priority_buffer_to_radio,sizeof(high_priority_buffer_to_radio),0,(struct sockaddr*)&high_priority_addr,high_priority_addr_length))<0) {
         g_print("sendto socket failed for high priority: rc=%d errno=%d\n",rc,errno);
         abort();
+        //exit(1);
     }
  
     if(rc!=sizeof(high_priority_buffer_to_radio)) {
@@ -1291,7 +1292,7 @@ static void new_protocol_transmit_specific() {
 
     if((rc=sendto(data_socket,transmit_specific_buffer,sizeof(transmit_specific_buffer),0,(struct sockaddr*)&transmitter_addr,transmitter_addr_length))<0) {
         g_print("sendto socket failed for tx specific: rc=%d errno=%d\n",rc,errno);
-       abort();
+       exit(1);
     }
 
     if(rc!=sizeof(transmit_specific_buffer)) {
@@ -1391,7 +1392,7 @@ static void new_protocol_receive_specific() {
 
     if((rc=sendto(data_socket,receive_specific_buffer,sizeof(receive_specific_buffer),0,(struct sockaddr*)&receiver_addr,receiver_addr_length))<0) {
       g_print("sendto socket failed for receive specific: rc=%d errno=%d\n",rc,errno);
-      abort();
+      exit(1);
     }
  
     if(rc!=sizeof(receive_specific_buffer)) {
@@ -1410,7 +1411,7 @@ static void new_protocol_start() {
     if( ! new_protocol_timer_thread_id )
     {
         g_print("g_thread_new failed on new_protocol_timer_thread\n");
-       abort();
+       exit( -1 );
     }
     g_print( "new_protocol_timer_thread: id=%p\n",new_protocol_timer_thread_id);
 
@@ -1519,7 +1520,7 @@ g_print("new_protocol_thread\n");
 
         if(bytesread<0) {
             g_print("recvfrom socket failed for new_protocol_thread");
-           abort();
+            exit(-1);
         }
 
         sourceport=ntohs(addr.sin_port);
@@ -2052,7 +2053,7 @@ void new_protocol_flush_iq_samples() {
   rc=sendto(data_socket,iqbuffer,sizeof(iqbuffer),0,(struct sockaddr*)&iq_addr,iq_addr_length);
   if(rc<0) {
     g_print("sendto socket failed for iq-flush, rc=%d errno=%d\n",rc,errno);
-    abort();
+    exit(1);
   }
   iqindex=4;
   tx_iq_sequence++;
@@ -2078,7 +2079,7 @@ void new_protocol_iq_samples(int isample,int qsample) {
     rc=sendto(data_socket,iqbuffer,sizeof(iqbuffer),0,(struct sockaddr*)&iq_addr,iq_addr_length);
     if(rc<0) {
       g_print("sendto socket failed for iq, rc=%d errno=%d\n",rc,errno);
-      abort();
+      exit(1);
     }
     iqindex=4;
     tx_iq_sequence++;
index 94f9436fc2d7aa24189ead88563444a52ffb1609..ffabfb80e20194b8fe5fa91d7de49f2cea7eb925 100644 (file)
@@ -288,7 +288,7 @@ void old_protocol_init(int rx,int pixels,int rate) {
     if( ! receive_thread_id )
     {
       g_print("g_thread_new failed on receive_thread\n");
-      abort();
+      exit( -1 );
     }
     g_print( "receive_thread: id=%p\n",receive_thread_id);
   }
@@ -317,7 +317,7 @@ static void start_usb_receive_threads()
   if( ! ozy_EP6_rx_thread_id )
   {
     g_print("g_thread_new failed for ozy_ep6_rx_thread\n");
-    abort();
+    exit( -1 );
   }
 }
 
@@ -353,6 +353,7 @@ static gpointer ozy_ep6_rx_thread(gpointer arg) {
     {
       g_print("old_protocol_ep6_read: OzyBulkRead failed %d bytes\n",bytes);
       perror("ozy_read(EP6 read failed");
+      //exit(1);
     }
     else
 // process the received data normally
@@ -380,7 +381,7 @@ static void open_udp_socket() {
     tmp=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
     if(tmp<0) {
       perror("old_protocol: create socket failed for data_socket\n");
-      abort();
+      exit(-1);
     }
 
     int optval = 1;
@@ -415,7 +416,7 @@ static void open_udp_socket() {
 g_print("binding UDP socket to %s:%d\n",inet_ntoa(radio->info.network.interface_address.sin_addr),ntohs(radio->info.network.interface_address.sin_port));
     if(bind(tmp,(struct sockaddr*)&radio->info.network.interface_address,radio->info.network.interface_length)<0) {
       perror("old_protocol: bind socket failed for data_socket\n");
-      abort();
+      exit(-1);
     }
 
     memcpy(&data_addr,&radio->info.network.address,radio->info.network.address_length);
@@ -441,7 +442,7 @@ static void open_tcp_socket() {
     tmp=socket(AF_INET, SOCK_STREAM, 0);
     if (tmp < 0) {
       perror("tcp_socket: create socket failed for TCP socket");
-      abort();
+      exit(-1);
     }
     int optval = 1;
     if(setsockopt(tmp, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))<0) {
@@ -1465,10 +1466,10 @@ static int last_power=0;
           if (isTransmitting()) {
            //
            // Set the preamp to (19-TXatt) dB (+19 ... –12 dB)
-           // temporary change: use +31 ... 0 dB to allow PURESIGNAL on
+           // temporary change: use more amplification to allow PURESIGNAL on
             // a barefoot HL2 with "cross talk" feedback from the TRX relay
             //
-           output_buffer[C4] = 0x40 | (43 - (transmitter->attenuation & 0x1F));
+           output_buffer[C4] = 0x40 | (45 - (transmitter->attenuation & 0x1F));
           } else { 
            output_buffer[C4] = 0x40 | (rxgain & 0x3F);
           }
@@ -1706,6 +1707,8 @@ static int metis_write(unsigned char ep,unsigned char* buffer,int length) {
 
 static void metis_restart() {
   int i;
+
+  g_print("%s\n",__FUNCTION__);
   //
   // In TCP-ONLY mode, we possibly need to re-connect
   // since if we come from a METIS-stop, the server
@@ -1749,6 +1752,7 @@ static void metis_start_stop(int command) {
   int tmp;
   unsigned char buffer[1032];
     
+  g_print("%s: %d\n",__FUNCTION__,command);
 #ifdef USBOZY
   if(device!=DEVICE_OZY)
   {
@@ -1808,7 +1812,7 @@ static void metis_send_buffer(unsigned char* buffer,int length) {
   if (tcp_socket >= 0) {
     if (length != 1032) {
        g_print("PROGRAMMING ERROR: TCP LENGTH != 1032\n");
-       abort();
+       exit(-1);
     }
     if(sendto(tcp_socket,buffer,length,0,NULL, 0) != length) {
       perror("sendto socket failed for TCP metis_send_data\n");
@@ -1820,7 +1824,7 @@ static void metis_send_buffer(unsigned char* buffer,int length) {
   } else {
     // This should not happen
     g_print("METIS send: neither UDP nor TCP socket available!\n");
-    abort();
+    exit(-1);
   }
 }
 
diff --git a/radio.c b/radio.c
index 2209b81c6edb2b197a65c0d14232198c63f5da79..b5fc393f60cd920fe1b265fb7c5f1ba5e9dc6d16 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -604,6 +604,7 @@ if(!radio_is_remote) {
   }
 #endif
   
+/*
 #ifdef CLIENT_SERVER
   if(!radio_is_remote) {
 #endif
@@ -623,6 +624,7 @@ if(!radio_is_remote) {
 #ifdef CLIENT_SERVER
   }
 #endif
+*/
 
   if(display_zoompan) {
     zoompan = zoompan_init(display_width,ZOOMPAN_HEIGHT);
@@ -661,6 +663,26 @@ g_print("create_visual: calling radio_change_receivers: receivers=%d r=%d\n",rec
   //gtk_widget_show_all (fixed);
   gtk_widget_show_all (top_window);
 
+#ifdef CLIENT_SERVER
+  if(!radio_is_remote) {
+#endif
+  switch(protocol) {
+    case ORIGINAL_PROTOCOL:
+      old_protocol_init(0,display_width,receiver[0]->sample_rate);
+      break;
+    case NEW_PROTOCOL:
+      new_protocol_init(display_width);
+      break;
+#ifdef SOAPYSDR
+    case SOAPYSDR_PROTOCOL:
+      soapy_protocol_init(0,false);
+      break;
+#endif
+  }
+#ifdef CLIENT_SERVER
+  }
+#endif
+
 }
   
 void start_radio() {
index 3de8fb32ee0f0e9c4ed7108e6ebdf0905b402967..868c1514476fb359146892b633e4658346530139 100644 (file)
--- a/zoompan.c
+++ b/zoompan.c
@@ -51,19 +51,22 @@ static GdkRGBA gray;
 int zoompan_active_receiver_changed(void *data) {
   if(display_zoompan) {
     //g_mutex_lock(&pan_zoom_mutex);
+    //g_signal_handler_block(G_OBJECT(zoom_scale),zoom_signal_id);
+    //g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id);
     gtk_range_set_value(GTK_RANGE(zoom_scale),active_receiver->zoom);
     gtk_range_set_range(GTK_RANGE(pan_scale),0.0,(double)(active_receiver->zoom==1?active_receiver->pixels:active_receiver->pixels-active_receiver->width));
     gtk_range_set_value (GTK_RANGE(pan_scale),active_receiver->pan);
     if(active_receiver->zoom == 1) {
       gtk_widget_set_sensitive(pan_scale, FALSE);
     }
+    //g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id);
+    //g_signal_handler_unblock(G_OBJECT(zoom_scale),zoom_signal_id);
     //g_mutex_unlock(&pan_zoom_mutex);
   }
   return FALSE;
 }
 
 static void zoom_value_changed_cb(GtkWidget *widget, gpointer data) {
-g_print("zoom_value_changed_cb\n");
   g_mutex_lock(&pan_zoom_mutex);
   g_mutex_lock(&active_receiver->display_mutex);
 #ifdef CLIENT_SERVER
@@ -92,14 +95,25 @@ g_print("zoom_value_changed_cb\n");
 }
 
 void set_zoom(int rx,double value) {
-g_print("set_zoom: %f\n",value);
   g_mutex_lock(&pan_zoom_mutex);
   g_mutex_lock(&active_receiver->display_mutex);
-  receiver_change_zoom(receiver[rx], value);
+  receiver[rx]->zoom=value;
+  receiver_change_zoom(receiver[rx],value);
   g_mutex_unlock(&active_receiver->display_mutex);
   g_mutex_unlock(&pan_zoom_mutex);
   if(display_zoompan) {
+    g_signal_handler_block(G_OBJECT(zoom_scale),zoom_signal_id);
     gtk_range_set_value (GTK_RANGE(zoom_scale),receiver[rx]->zoom);
+    g_signal_handler_unblock(G_OBJECT(zoom_scale),zoom_signal_id);
+    g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id);
+    gtk_range_set_range(GTK_RANGE(pan_scale),0.0,(double)(active_receiver->zoom==1?active_receiver->pixels:active_receiver->pixels-active_receiver->width));
+    gtk_range_set_value (GTK_RANGE(pan_scale),active_receiver->pan);
+    g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id);
+    if(active_receiver->zoom==1) {
+      gtk_widget_set_sensitive(pan_scale, FALSE);
+    } else {
+      gtk_widget_set_sensitive(pan_scale, TRUE);
+    }
   } else {
     if(scale_status!=ZOOM || scale_rx!=rx) {
       if(scale_status!=NO_FUNCTION) {
@@ -132,7 +146,6 @@ g_print("set_zoom: %f\n",value);
 }
 
 void remote_set_zoom(int rx,double value) {
-g_print("remote_set_zoom: rx=%d zoom=%f\n",rx,value);
   g_mutex_lock(&pan_zoom_mutex);
   g_signal_handler_block(G_OBJECT(zoom_scale),zoom_signal_id);
   g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id);
@@ -140,11 +153,9 @@ g_print("remote_set_zoom: rx=%d zoom=%f\n",rx,value);
   g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id);
   g_signal_handler_unblock(G_OBJECT(zoom_scale),zoom_signal_id);
   g_mutex_unlock(&pan_zoom_mutex);
-g_print("remote_set_zoom: EXIT\n");
 }
 
 void update_zoom(double zoom) {
-g_print("update_zoom: %f\n",zoom);
   int z=active_receiver->zoom+(int)zoom;
   if(z>MAX_ZOOM) z=MAX_ZOOM;
   if(z<1) z=1;
@@ -152,7 +163,6 @@ g_print("update_zoom: %f\n",zoom);
 }
 
 static void pan_value_changed_cb(GtkWidget *widget, gpointer data) {
-g_print("pan_value_changed_cb\n");
   g_mutex_lock(&pan_zoom_mutex);
 #ifdef CLIENT_SERVER
   if(radio_is_remote) {
@@ -167,12 +177,13 @@ g_print("pan_value_changed_cb\n");
 }
 
 void set_pan(int rx,double value) {
-g_print("set_pan: %f\n",value);
   g_mutex_lock(&pan_zoom_mutex);
   receiver_change_pan(receiver[rx],value);
   g_mutex_unlock(&pan_zoom_mutex);
   if(display_zoompan) {
+    g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id);
     gtk_range_set_value (GTK_RANGE(pan_scale),receiver[rx]->pan);
+    g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id);
   } else {
     if(scale_status!=PAN || scale_rx!=rx) {
       if(scale_status!=NO_FUNCTION) {
@@ -190,7 +201,7 @@ g_print("set_pan: %f\n",value);
       GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog));
       pan_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, receiver[rx]->zoom==1?receiver[rx]->pixels:receiver[rx]->pixels-receiver[rx]->width, 1.00);
       gtk_widget_set_size_request (pan_scale, 400, 30);
-      gtk_range_set_value (GTK_RANGE(pan_scale),(double) receiver[rx]->pan);
+      gtk_range_set_value (GTK_RANGE(pan_scale),receiver[rx]->pan);
       gtk_widget_show(pan_scale);
       gtk_container_add(GTK_CONTAINER(content),pan_scale);
       scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL);
@@ -204,32 +215,28 @@ g_print("set_pan: %f\n",value);
 }
 
 void remote_set_pan(int rx,double value) {
-g_print("remote_set_pan: rx=%d pan=%f\n",rx,value);
   g_mutex_lock(&pan_zoom_mutex);
   g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id);
   gtk_range_set_range(GTK_RANGE(pan_scale),0.0,(double)(receiver[rx]->zoom==1?receiver[rx]->pixels:receiver[rx]->pixels-receiver[rx]->width));
   set_pan(rx,value);
   g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id);
   g_mutex_unlock(&pan_zoom_mutex);
-g_print("remote_set_pan: EXIT\n");
 }
 
 void update_pan(double pan) {
-//  g_mutex_lock(&pan_zoom_mutex);
   if(active_receiver->zoom>1) {
     int p=active_receiver->pan+(int)pan;
     if(p<0) p=0;
     if(p>(active_receiver->pixels-active_receiver->width)) p=active_receiver->pixels-active_receiver->width;
     set_pan(active_receiver->id,(double)p);
   }
-//  g_mutex_unlock(&pan_zoom_mutex);
 }
 
 GtkWidget *zoompan_init(int my_width, int my_height) {
   width=my_width;
   height=my_height;
 
-fprintf(stderr,"zoompan_init: width=%d height=%d\n", width,height);
+g_print("%s: width=%d height=%d\n",__FUNCTION__,width,height);
 
   zoompan=gtk_grid_new();
   gtk_widget_set_size_request (zoompan, width, height);