From: John Melton - G0ORX/N6LYT Date: Tue, 23 Aug 2016 14:46:25 +0000 (+0000) Subject: turned on hardware timer in new protocol, fixed segfault when exiting and using GPIO X-Git-Url: https://git.rkrishnan.org/pf/frontends/...?a=commitdiff_plain;h=657f909d5f76d70480c545bfeedb2f236f8197e9;p=pihpsdr.git turned on hardware timer in new protocol, fixed segfault when exiting and using GPIO --- diff --git a/gpio.c b/gpio.c index 3faacac..0bf2b9a 100644 --- 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 df10b25..4142cc1 100644 --- 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;iprotocol,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: diff --git a/new_discovery.c b/new_discovery.c index 1d3658a..b8a21ca 100644 --- a/new_discovery.c +++ b/new_discovery.c @@ -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, diff --git a/new_protocol.c b/new_protocol.c index 9a20002..ea7ee55 100644 --- a/new_protocol.c +++ b/new_protocol.c @@ -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 6de2da4..80cf3d0 100755 Binary files a/pihpsdr and b/pihpsdr differ diff --git a/release/pihpsdr.tar b/release/pihpsdr.tar index 50fa1b9..a1389ff 100644 Binary files a/release/pihpsdr.tar and b/release/pihpsdr.tar differ diff --git a/release/pihpsdr/pihpsdr b/release/pihpsdr/pihpsdr index 6de2da4..80cf3d0 100755 Binary files a/release/pihpsdr/pihpsdr and b/release/pihpsdr/pihpsdr differ diff --git a/vfo.c b/vfo.c index c461a61..2f55319 100644 --- 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 }