}
}
-#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
#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");
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;
+ }
+ }
+
}
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:
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__
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__
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);
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;
// 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));
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);
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)) {
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)) {
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)) {
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)) {
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);
if(bytesread<0) {
g_print("recvfrom socket failed for new_protocol_thread");
- abort();
+ exit(-1);
}
sourceport=ntohs(addr.sin_port);
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++;
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++;
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);
}
if( ! ozy_EP6_rx_thread_id )
{
g_print("g_thread_new failed for ozy_ep6_rx_thread\n");
- abort();
+ exit( -1 );
}
}
{
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
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;
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);
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) {
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);
}
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
int tmp;
unsigned char buffer[1032];
+ g_print("%s: %d\n",__FUNCTION__,command);
#ifdef USBOZY
if(device!=DEVICE_OZY)
{
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");
} else {
// This should not happen
g_print("METIS send: neither UDP nor TCP socket available!\n");
- abort();
+ exit(-1);
}
}
}
#endif
+/*
#ifdef CLIENT_SERVER
if(!radio_is_remote) {
#endif
#ifdef CLIENT_SERVER
}
#endif
+*/
if(display_zoompan) {
zoompan = zoompan_init(display_width,ZOOMPAN_HEIGHT);
//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() {
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
}
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) {
}
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);
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;
}
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) {
}
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) {
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);
}
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);