]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
turned on hardware timer in new protocol, fixed segfault when exiting and using GPIO
authorJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Tue, 23 Aug 2016 14:46:25 +0000 (14:46 +0000)
committerJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Tue, 23 Aug 2016 14:46:25 +0000 (14:46 +0000)
gpio.c
main.c
new_discovery.c
new_protocol.c
pihpsdr
release/pihpsdr.tar
release/pihpsdr/pihpsdr
vfo.c

diff --git a/gpio.c b/gpio.c
index 3faacac093f60c9dd107194b26161346c73d1e50..0bf2b9aa7728e6a3f091457fcfa43932108a9115 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -116,6 +116,8 @@ static int previous_mox_button=0;
 static int lock_button=0;
 static int previous_lock_button=0;
 
+static int running=1;
+
 static void afFunctionAlert(int gpio, int level, uint32_t tick) {
     afFunction=(level==0);
 }
@@ -613,12 +615,7 @@ fprintf(stderr,"encoder_init\n");
 }
 
 void gpio_close() {
-//  if(strcmp(unameData.nodename,"raspberrypi")==0) {
-#ifdef raspberrypi
-    gpioTerminate();
-#endif
-//  }
-//  if(strcmp(unameData.nodename,"odroid")==0) {
+    running=0;
 #ifdef odroid
     FILE *fp;
     fp = popen("echo 97 > /sys/class/gpio/unexport\n", "r");
@@ -626,7 +623,6 @@ void gpio_close() {
     fp = popen("echo 108 > /sys/class/gpio/unexport\n", "r");
     pclose(fp);
 #endif
-//  }
 }
 
 int vfo_encoder_get_pos() {
@@ -869,7 +865,8 @@ static int agc_pressed(void *data) {
 
 static void* rotary_encoder_thread(void *arg) {
     int pos;
-    while(1) {
+    running=1;
+    while(running) {
 
         int function_button=function_get_state();
         if(function_button!=previous_function_button) {
@@ -984,15 +981,15 @@ static void* rotary_encoder_thread(void *arg) {
             }
         }
 
-//        if(strcmp(unameData.nodename,"raspberrypi")==0) {
 #ifdef raspberrypi
-          gpioDelay(100000); // 10 per second
+          if(running) gpioDelay(100000); // 10 per second
 #endif
-//        } else if(strcmp(unameData.nodename,"odroid")==0) {
 #ifdef odroid
-          usleep(100000);
+          if(runnig) usleep(100000);
 #endif
-//        }
     }
+#ifdef raspberrypi
+    gpioTerminate();
+#endif
 }
 #endif
diff --git a/main.c b/main.c
index df10b25b9e9a99b189b71a9c5e600cfed50ca1f6..4142cc11cd6793200bd441a0da5ae06521fc22bd 100644 (file)
--- a/main.c
+++ b/main.c
@@ -270,8 +270,8 @@ static gint save_cb(gpointer data) {
 }
 
 static void start_cb(GtkWidget *widget, gpointer data) {
-    selected_device=(int)data;
-fprintf(stderr,"start_cb: %d\n",selected_device);
+fprintf(stderr,"start_cb: %p\n",data);
+    radio=(DISCOVERED *)data;
     start=1;
     gtk_widget_destroy(discovery_dialog);
 }
@@ -399,20 +399,28 @@ gint init(void* arg) {
           gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
 
           int i;
+          char version[16];
           char text[128];
           for(i=0;i<devices;i++) {
               d=&discovered[i];
-fprintf(stderr,"protocol=%d name=%s\n",d->protocol,d->name);
+fprintf(stderr,"%p protocol=%d name=%s\n",d,d->protocol,d->name);
+              if(d->protocol==ORIGINAL_PROTOCOL) {
+                  sprintf(version,"%d.%d",
+                        d->software_version/10,
+                        d->software_version%10);
+              } else {
+                  sprintf(version,"%d.%d.%d",
+                        d->software_version/100,
+                        (d->software_version%100)/10,
+                        d->software_version%10);
+              }
               switch(d->protocol) {
                 case ORIGINAL_PROTOCOL:
                 case NEW_PROTOCOL:
-                  sprintf(text,"%s (%s %d.%d) %s (%02X:%02X:%02X:%02X:%02X:%02X) on %s\n",
+                  sprintf(text,"%s (%s %s) %s (%02X:%02X:%02X:%02X:%02X:%02X) on %s\n",
                         d->name,
                         d->protocol==ORIGINAL_PROTOCOL?"old":"new",
-                        //d->protocol==ORIGINAL_PROTOCOL?d->software_version/10:d->software_version/100,
-                        //d->protocol==ORIGINAL_PROTOCOL?d->software_version%10:d->software_version%100,
-                        d->software_version/10,
-                        d->software_version%10,
+                        version,
                         inet_ntoa(d->info.network.address.sin_addr),
                         d->info.network.mac_address[0],
                         d->info.network.mac_address[1],
@@ -425,12 +433,10 @@ fprintf(stderr,"protocol=%d name=%s\n",d->protocol,d->name);
 #ifdef LIMESDR
                 case LIMESDR_PROTOCOL:
 /*
-                  sprintf(text,"%s (%s %d.%d.%d)\n",
+                  sprintf(text,"%s (%s %s)\n",
                         d->name,
                         "lime",
-                        d->software_version/100,
-                        (d->software_version%100)/10,
-                        d->software_version%10);
+                        version);
 */
                   sprintf(text,"%s\n",
                         d->name);
@@ -447,7 +453,7 @@ fprintf(stderr,"protocol=%d name=%s\n",d->protocol,d->name);
               gtk_widget_override_font(start_button, pango_font_description_from_string("Arial 18"));
               gtk_widget_show(start_button);
               gtk_grid_attach(GTK_GRID(grid),start_button,3,i,1,1);
-              g_signal_connect(start_button,"pressed",G_CALLBACK(start_cb),(gpointer *)i);
+              g_signal_connect(start_button,"pressed",G_CALLBACK(start_cb),(gpointer)d);
 
               // if not available then cannot start it
               if(d->status!=STATE_AVAILABLE) {
@@ -471,7 +477,9 @@ fprintf(stderr,"protocol=%d name=%s\n",d->protocol,d->name);
               _exit(0);
           }
          
-          gtk_widget_destroy(discovery_dialog);
+          if(!start) {
+            gtk_widget_destroy(discovery_dialog);
+          }
 #ifdef GPIO
           if(result==GTK_RESPONSE_YES) {
               configure_gpio(splash_window);
@@ -484,11 +492,11 @@ fprintf(stderr,"protocol=%d name=%s\n",d->protocol,d->name);
 
   splash_status("Initializing wdsp ...");
 
-  radio=&d[selected_device];
+fprintf(stderr,"selected radio=%p device=%d\n",radio,radio->device);
+
   protocol=radio->protocol;
   device=radio->device;
 
-fprintf(stderr,"radio: %p\n",radio);
 
   switch(radio->protocol) {
     case ORIGINAL_PROTOCOL:
index 1d3658aafe87091f544a738f898d2c908f4c00d6..b8a21cab49027e92caa2cddd81e08a43c680310e 100644 (file)
@@ -249,7 +249,8 @@ void* new_discover_receive_thread(void* arg) {
                     memcpy((void*)&discovered[devices].info.network.interface_netmask,(void*)&interface_netmask,sizeof(interface_netmask));
                     discovered[devices].info.network.interface_length=sizeof(interface_addr);
                     strcpy(discovered[devices].info.network.interface_name,interface_name);
-                    fprintf(stderr,"new_discover: found protocol=%d device=%d software_version=%d status=%d address=%s (%02X:%02X:%02X:%02X:%02X:%02X) on %s\n", 
+                    fprintf(stderr,"new_discover: found %d protocol=%d device=%d software_version=%d status=%d address=%s (%02X:%02X:%02X:%02X:%02X:%02X) on %s\n", 
+                            devices,
                             discovered[devices].protocol,
                             discovered[devices].device,
                             discovered[devices].software_version,
index 9a200029bbf180c1214e49f224645c129f0b1a95..ea7ee55c1af972836d6635b37a9946ecf9c0fa74 100644 (file)
@@ -263,9 +263,11 @@ fprintf(stderr,"new_protocol_general: receiver=%d\n", receiver);
 
     // use defaults apart from
     buffer[37]=0x08;  //  phase word (not frequency)
+    buffer[38]=0x01;  //  enable hardware timer
     //buffer[58]=pa;  // enable PA 0x01
     buffer[58]=0x01;  // enable PA 0x01
-    if((filter_board==APOLLO) && tune) {
+    //if((filter_board==APOLLO) && tune) {
+    if(filter_board==APOLLO) {
         buffer[58]|=0x02;
     }
 
diff --git a/pihpsdr b/pihpsdr
index 6de2da4f0629ecf2572f8b93aa1e87729c3024d1..80cf3d02762919339176f7b8d720f060a7113f3b 100755 (executable)
Binary files a/pihpsdr and b/pihpsdr differ
index 50fa1b929c9a5540a7e34a29e8658d2e4afb1ae4..a1389ff6aaa45daace41b04c8bd71e264fa73c3e 100644 (file)
Binary files a/release/pihpsdr.tar and b/release/pihpsdr.tar differ
index 6de2da4f0629ecf2572f8b93aa1e87729c3024d1..80cf3d02762919339176f7b8d720f060a7113f3b 100755 (executable)
Binary files a/release/pihpsdr/pihpsdr and b/release/pihpsdr/pihpsdr differ
diff --git a/vfo.c b/vfo.c
index c461a616f57af019204688aaf260455583fce3a4..2f55319f366e3e52aad64878a0884059e9c8207a 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -193,21 +193,32 @@ int vfo_update(void *data) {
             CAIRO_FONT_SLANT_NORMAL,
             CAIRO_FONT_WEIGHT_BOLD);
 
+        char version[16];
         char text[128];
-        switch(discovered->protocol) {
+        if(radio->protocol==ORIGINAL_PROTOCOL) {
+            sprintf(version,"%d.%d",
+                radio->software_version/10,
+                radio->software_version%10);
+        } else {
+            sprintf(version,"%d.%d.%d",
+                radio->software_version/100,
+                (radio->software_version%100)/10,
+                radio->software_version%10);
+        }
+
+        switch(radio->protocol) {
             case ORIGINAL_PROTOCOL:
             case NEW_PROTOCOL:
-              sprintf(text,"%s (%s %d.%d) %s",
-                    discovered->name,
-                    discovered->protocol==ORIGINAL_PROTOCOL?"old":"new",
-                    discovered->software_version/10,
-                    discovered->software_version%10,
-                    inet_ntoa(discovered->info.network.address.sin_addr));
+              sprintf(text,"%s (%s %s) %s",
+                    radio->name,
+                    radio->protocol==ORIGINAL_PROTOCOL?"old":"new",
+                    version,
+                    inet_ntoa(radio->info.network.address.sin_addr));
               break;
 #ifdef LIMESDR
             case LIMESDR_PROTOCOL:
               sprintf(text,"%s\n",
-                    discovered->name);
+                    radio->name);
               break;
 #endif
         }