Thread: [Gpredict-svn] SF.net SVN: gpredict:[623] trunk/src/gtk-rig-ctrl.c (Page 2)
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <cs...@us...> - 2010-07-09 09:31:23
|
Revision: 623 http://gpredict.svn.sourceforge.net/gpredict/?rev=623&view=rev Author: csete Date: 2010-07-09 09:31:17 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Fix indentation Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-06-18 10:08:48 UTC (rev 622) +++ trunk/src/gtk-rig-ctrl.c 2010-07-09 09:31:17 UTC (rev 623) @@ -11,7 +11,7 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -135,7 +135,7 @@ GType -gtk_rig_ctrl_get_type () + gtk_rig_ctrl_get_type () { static GType gtk_rig_ctrl_type = 0; @@ -156,7 +156,7 @@ gtk_rig_ctrl_type = g_type_register_static (GTK_TYPE_VBOX, "GtkRigCtrl", >k_rig_ctrl_info, - 0); + 0); } return gtk_rig_ctrl_type; @@ -164,7 +164,7 @@ static void -gtk_rig_ctrl_class_init (GtkRigCtrlClass *class) + gtk_rig_ctrl_class_init (GtkRigCtrlClass *class) { GObjectClass *gobject_class; GtkObjectClass *object_class; @@ -179,13 +179,13 @@ parent_class = g_type_class_peek_parent (class); object_class->destroy = gtk_rig_ctrl_destroy; - + } static void -gtk_rig_ctrl_init (GtkRigCtrl *ctrl) + gtk_rig_ctrl_init (GtkRigCtrl *ctrl) { ctrl->sats = NULL; ctrl->target = NULL; @@ -197,7 +197,7 @@ ctrl->trsplist = NULL; ctrl->trsplock = FALSE; ctrl->tracking = FALSE; - g_static_mutex_init(&(ctrl->busy)); + g_static_mutex_init(&(ctrl->busy)); ctrl->engaged = FALSE; ctrl->delay = 1000; ctrl->timerid = 0; @@ -207,10 +207,10 @@ } static void -gtk_rig_ctrl_destroy (GtkObject *object) + gtk_rig_ctrl_destroy (GtkObject *object) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (object); - + /* stop timer */ if (ctrl->timerid > 0) g_source_remove (ctrl->timerid); @@ -245,7 +245,7 @@ * */ GtkWidget * -gtk_rig_ctrl_new (GtkSatModule *module) + gtk_rig_ctrl_new (GtkSatModule *module) { GtkWidget *widget; GtkWidget *table; @@ -265,11 +265,11 @@ /* store QTH */ GTK_RIG_CTRL (widget)->qth = module->qth; - if (GTK_RIG_CTRL(widget)->target !=NULL) { - /* get next pass for target satellite */ - GTK_RIG_CTRL (widget)->pass = get_next_pass (GTK_RIG_CTRL (widget)->target, - GTK_RIG_CTRL (widget)->qth, - 3.0); + if (GTK_RIG_CTRL(widget)->target !=NULL) { + /* get next pass for target satellite */ + GTK_RIG_CTRL (widget)->pass = get_next_pass (GTK_RIG_CTRL (widget)->target, + GTK_RIG_CTRL (widget)->qth, + 3.0); } /* initialise custom colors */ gdk_rgb_find_color (gtk_widget_get_colormap (widget), &ColBlack); @@ -299,7 +299,7 @@ rig_ctrl_timeout_cb, GTK_RIG_CTRL (widget)); - return widget; + return widget; } @@ -311,7 +311,7 @@ * of the controller and the rigator. */ void -gtk_rig_ctrl_update (GtkRigCtrl *ctrl, gdouble t) + gtk_rig_ctrl_update (GtkRigCtrl *ctrl, gdouble t) { gdouble satfreq; gchar *buff; @@ -387,7 +387,7 @@ * */ static -GtkWidget *create_downlink_widgets (GtkRigCtrl *ctrl) + GtkWidget *create_downlink_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame; GtkWidget *vbox; @@ -452,7 +452,7 @@ * uplink frequency of the satellite and the radio. */ static -GtkWidget *create_uplink_widgets (GtkRigCtrl *ctrl) + GtkWidget *create_uplink_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame; GtkWidget *vbox; @@ -501,7 +501,7 @@ ctrl->RigFreqUp = gtk_freq_knob_new (145890000.0, FALSE); gtk_box_pack_start_defaults (GTK_BOX (hbox2), ctrl->RigFreqUp); - + gtk_box_pack_start_defaults (GTK_BOX (vbox), hbox1); gtk_box_pack_start_defaults (GTK_BOX (vbox), hbox2); gtk_container_add (GTK_CONTAINER (frame), vbox); @@ -514,7 +514,7 @@ * \param ctrl Pointer to the GtkRigCtrl widget. */ static -GtkWidget *create_target_widgets (GtkRigCtrl *ctrl) + GtkWidget *create_target_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame,*table,*label,*satsel,*track; GtkWidget *tune,*trsplock,*hbox; @@ -563,24 +563,24 @@ /* buttons */ tune = gtk_button_new_with_label (_("T")); gtk_widget_set_tooltip_text (tune, - _("Tune the radio to this transponder. "\ - "The uplink and downlink will be set to the center of "\ - "the transponder passband. In case of beacons, only the "\ - "downlink will be tuned to the beacon frequency.")); + _("Tune the radio to this transponder. "\ + "The uplink and downlink will be set to the center of "\ + "the transponder passband. In case of beacons, only the "\ + "downlink will be tuned to the beacon frequency.")); g_signal_connect (tune, "clicked", G_CALLBACK (trsp_tune_cb), ctrl); trsplock = gtk_toggle_button_new_with_label (_("L")); gtk_widget_set_tooltip_text (trsplock, - _("Lock the uplink and the downlink to each other. "\ - "Whenever you change the downlink (in the controller "\ - "or on the dial, the uplink will track it according "\ - "to whether the transponder is inverting or not. "\ - "Similarly, if you change the uplink the downlink "\ - "will track it automatically.\n\n"\ - "If the downlink and uplink are initially out of sync "\ - "when you enable this function, "\ - "the current downlink frequency will be used as "\ - "baseline for setting the new uplink frequency.")); + _("Lock the uplink and the downlink to each other. "\ + "Whenever you change the downlink (in the controller "\ + "or on the dial, the uplink will track it according "\ + "to whether the transponder is inverting or not. "\ + "Similarly, if you change the uplink the downlink "\ + "will track it automatically.\n\n"\ + "If the downlink and uplink are initially out of sync "\ + "when you enable this function, "\ + "the current downlink frequency will be used as "\ + "baseline for setting the new uplink frequency.")); g_signal_connect (trsplock, "toggled", G_CALLBACK (trsp_lock_cb), ctrl); /* box for packing buttons */ @@ -646,7 +646,7 @@ static GtkWidget * -create_conf_widgets (GtkRigCtrl *ctrl) + create_conf_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame,*table,*label,*timer; GDir *dir = NULL; /* directory handle */ @@ -691,7 +691,7 @@ else { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: Failed to open hwconf dir (%s)"), - __FILE__, __LINE__, error->message); + __FILE__, __LINE__, error->message); g_clear_error (&error); } @@ -734,7 +734,7 @@ else { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: Failed to open hwconf dir (%s)"), - __FILE__, __LINE__, error->message); + __FILE__, __LINE__, error->message); g_clear_error (&error); } @@ -784,7 +784,7 @@ /** \brief Create count down widget */ static GtkWidget * -create_count_down_widgets (GtkRigCtrl *ctrl) + create_count_down_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame; @@ -808,7 +808,7 @@ /** \brief Copy satellite from hash table to singly linked list. */ static void -store_sats (gpointer key, gpointer value, gpointer user_data) + store_sats (gpointer key, gpointer value, gpointer user_data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL( user_data); sat_t *sat = SAT (value); @@ -824,7 +824,7 @@ * This function is called when the user selects a new satellite. */ static void -sat_selected_cb (GtkComboBox *satsel, gpointer data) + sat_selected_cb (GtkComboBox *satsel, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); gint i; @@ -880,8 +880,8 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Inconsistency detected in internal transponder data (%d,%d)"), - __FUNCTION__, i, n); + _("%s: Inconsistency detected in internal transponder data (%d,%d)"), + __FUNCTION__, i, n); } } @@ -959,7 +959,7 @@ * \param data Pointer to the GtkRigCtrl widget. */ static void -track_toggle_cb (GtkToggleButton *button, gpointer data) + track_toggle_cb (GtkToggleButton *button, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); @@ -979,7 +979,7 @@ * cycle delay. */ static void -delay_changed_cb (GtkSpinButton *spin, gpointer data) + delay_changed_cb (GtkSpinButton *spin, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); @@ -1005,7 +1005,7 @@ * BUG Doesn't prevent user to select same radio as in the secondary conf. */ static void -primary_rig_selected_cb (GtkComboBox *box, gpointer data) + primary_rig_selected_cb (GtkComboBox *box, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); gchar *buff; @@ -1071,7 +1071,7 @@ * device for the secondary radio. This radio is used for uplink only. */ static void -secondary_rig_selected_cb (GtkComboBox *box, gpointer data) + secondary_rig_selected_cb (GtkComboBox *box, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); gchar *buff; @@ -1166,7 +1166,7 @@ * This function is called when the user toggles the "Engage" button. */ static void -rig_engaged_cb (GtkToggleButton *button, gpointer data) + rig_engaged_cb (GtkToggleButton *button, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); @@ -1178,20 +1178,20 @@ ctrl->engaged = FALSE; ctrl->lasttxf = 0.0; ctrl->lastrxf = 0.0; - switch (ctrl->conf->type) { - case RIG_TYPE_TOGGLE: - unset_toggle (ctrl,ctrl->conf); - break; - default: - break; - } + switch (ctrl->conf->type) { + case RIG_TYPE_TOGGLE: + unset_toggle (ctrl,ctrl->conf); + break; + default: + break; + } } else { if (ctrl->conf == NULL) { /* we don't have a working configuration */ sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Controller does not have a valid configuration"), - __FUNCTION__); + __FUNCTION__); return; } @@ -1208,32 +1208,32 @@ else { switch (ctrl->conf->type) { - case RIG_TYPE_RX: - exec_rx_cycle (ctrl); - break; - - case RIG_TYPE_TX: - exec_tx_cycle (ctrl); - break; - - case RIG_TYPE_TRX: - exec_trx_cycle (ctrl); - break; - - case RIG_TYPE_DUPLEX: - exec_duplex_cycle (ctrl); - break; + case RIG_TYPE_RX: + exec_rx_cycle (ctrl); + break; - case RIG_TYPE_TOGGLE: - set_toggle (ctrl,ctrl->conf); - exec_toggle_cycle (ctrl); - break; - - default: - /* this is an error! */ - ctrl->conf->type = RIG_TYPE_RX; - exec_rx_cycle (ctrl); - break; + case RIG_TYPE_TX: + exec_tx_cycle (ctrl); + break; + + case RIG_TYPE_TRX: + exec_trx_cycle (ctrl); + break; + + case RIG_TYPE_DUPLEX: + exec_duplex_cycle (ctrl); + break; + + case RIG_TYPE_TOGGLE: + set_toggle (ctrl,ctrl->conf); + exec_toggle_cycle (ctrl); + break; + + default: + /* this is an error! */ + ctrl->conf->type = RIG_TYPE_RX; + exec_rx_cycle (ctrl); + break; } } } @@ -1279,48 +1279,48 @@ * \return Always TRUE to let the timer continue. */ static gboolean -rig_ctrl_timeout_cb (gpointer data) + rig_ctrl_timeout_cb (gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); - if (g_static_mutex_trylock(&(ctrl->busy))==FALSE) { + if (g_static_mutex_trylock(&(ctrl->busy))==FALSE) { sat_log_log (SAT_LOG_LEVEL_ERROR,_("%s missed the deadline"),__FUNCTION__); return TRUE; } - if (ctrl->conf2 != NULL) { + if (ctrl->conf2 != NULL) { exec_dual_rig_cycle (ctrl); } else { /* Execute controller cycle depending on primary radio type */ switch (ctrl->conf->type) { - - case RIG_TYPE_RX: - exec_rx_cycle (ctrl); - break; + + case RIG_TYPE_RX: + exec_rx_cycle (ctrl); + break; - case RIG_TYPE_TX: - exec_tx_cycle (ctrl); - break; + case RIG_TYPE_TX: + exec_tx_cycle (ctrl); + break; - case RIG_TYPE_TRX: - exec_trx_cycle (ctrl); - break; + case RIG_TYPE_TRX: + exec_trx_cycle (ctrl); + break; - case RIG_TYPE_DUPLEX: - exec_duplex_cycle (ctrl); - break; - - case RIG_TYPE_TOGGLE: - exec_toggle_cycle (ctrl); - break; + case RIG_TYPE_DUPLEX: + exec_duplex_cycle (ctrl); + break; + + case RIG_TYPE_TOGGLE: + exec_toggle_cycle (ctrl); + break; - default: - /* invalid mode */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Invalid radio type %d. Setting type to RIG_TYPE_RX"), - __FUNCTION__, ctrl->conf->type); - ctrl->conf->type = RIG_TYPE_RX; + default: + /* invalid mode */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Invalid radio type %d. Setting type to RIG_TYPE_RX"), + __FUNCTION__, ctrl->conf->type); + ctrl->conf->type = RIG_TYPE_RX; } } @@ -1332,8 +1332,8 @@ ctrl->engaged = FALSE; ctrl->errcnt = 0; sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: MAX_ERROR_COUNT (%d) reached. Disengaging device!"), - __FUNCTION__, MAX_ERROR_COUNT); + _("%s: MAX_ERROR_COUNT (%d) reached. Disengaging device!"), + __FUNCTION__, MAX_ERROR_COUNT); //g_print ("ERROR. WROPS = %d\n", ctrl->wrops); } @@ -1422,16 +1422,16 @@ if (ctrl->tracking) { /* downlink */ gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqDown), - satfreqd + ctrl->dd - ctrl->conf->lo); + satfreqd + ctrl->dd - ctrl->conf->lo); /* uplink */ gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqUp), - satfrequ + ctrl->du - ctrl->conf->loup); + satfrequ + ctrl->du - ctrl->conf->loup); } else { gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqDown), - satfreqd - ctrl->conf->lo); + satfreqd - ctrl->conf->lo); gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqUp), - satfrequ - ctrl->conf->loup ); + satfrequ - ctrl->conf->loup ); } tmpfreq = gtk_freq_knob_get_value(GTK_FREQ_KNOB(ctrl->RigFreqDown)); @@ -1536,16 +1536,16 @@ if (ctrl->tracking) { /* downlink */ gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqDown), - satfreqd + ctrl->dd - ctrl->conf->lo); + satfreqd + ctrl->dd - ctrl->conf->lo); /* uplink */ gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqUp), - satfrequ + ctrl->du - ctrl->conf->loup); + satfrequ + ctrl->du - ctrl->conf->loup); } else { gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqDown), - satfreqd - ctrl->conf->lo); + satfreqd - ctrl->conf->lo); gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqUp), - satfrequ - ctrl->conf->loup); + satfrequ - ctrl->conf->loup); } tmpfreq = gtk_freq_knob_get_value(GTK_FREQ_KNOB(ctrl->RigFreqUp)); @@ -1594,8 +1594,8 @@ */ static void exec_toggle_cycle (GtkRigCtrl *ctrl) { - exec_rx_cycle (ctrl); - exec_toggle_tx_cycle (ctrl); + exec_rx_cycle (ctrl); + exec_toggle_tx_cycle (ctrl); } /** \brief Execute TX mode cycle. @@ -1618,21 +1618,21 @@ Note: If ctrl->lasttxf = 0.0 the sync has been invalidated (e.g. user pressed "tune") and no need to execute the dial feedback. */ - if (ctrl->engaged && ctrl->conf->ptt) { + if (ctrl->engaged && ctrl->conf->ptt) { ptt = get_ptt (ctrl, ctrl->conf); } if ((ctrl->engaged) && (ctrl->lasttxf > 0.0)) { - if (ptt == TRUE) { - printf("PTT TRUE\n"); + if (ptt == TRUE) { + printf("PTT TRUE\n"); if (!get_freq_toggle (ctrl, ctrl->conf, &readfreq)) { - /* error => use a passive value */ - readfreq = ctrl->lasttxf; - ctrl->errcnt++; - } - } else { - readfreq = ctrl->lasttxf; - } + /* error => use a passive value */ + readfreq = ctrl->lasttxf; + ctrl->errcnt++; + } + } else { + readfreq = ctrl->lasttxf; + } if (fabs (readfreq - ctrl->lasttxf) >= 1.0) { dialchanged = TRUE; @@ -1673,16 +1673,16 @@ if (ctrl->tracking) { /* downlink */ gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqDown), - satfreqd + ctrl->dd - ctrl->conf->lo); + satfreqd + ctrl->dd - ctrl->conf->lo); /* uplink */ gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqUp), - satfrequ + ctrl->du - ctrl->conf->loup); + satfrequ + ctrl->du - ctrl->conf->loup); } else { gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqDown), - satfreqd - ctrl->conf->lo); + satfreqd - ctrl->conf->lo); gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqUp), - satfrequ - ctrl->conf->loup); + satfrequ - ctrl->conf->loup); } tmpfreq = gtk_freq_knob_get_value(GTK_FREQ_KNOB(ctrl->RigFreqUp)); @@ -1702,8 +1702,8 @@ frequency from the rig. */ if (ptt){ get_freq_toggle (ctrl, ctrl->conf, &tmpfreq); - } - ctrl->lasttxf = tmpfreq; + } + ctrl->lasttxf = tmpfreq; } else { ctrl->errcnt++; @@ -1720,14 +1720,14 @@ */ static void exec_duplex_cycle (GtkRigCtrl *ctrl) { - if (ctrl->engaged) { - /* Downlink */ - set_vfo (ctrl, ctrl->conf->vfoDown); - exec_rx_cycle (ctrl); - - /* Uplink */ - set_vfo (ctrl, ctrl->conf->vfoUp); - exec_tx_cycle (ctrl); + if (ctrl->engaged) { + /* Downlink */ + set_vfo (ctrl, ctrl->conf->vfoDown); + exec_rx_cycle (ctrl); + + /* Uplink */ + set_vfo (ctrl, ctrl->conf->vfoUp); + exec_tx_cycle (ctrl); } else { /* still execute cycles to update UI widgets @@ -1818,7 +1818,7 @@ /* if no dial change on downlink perform forward tracking on downlink and execute uplink controller too. */ - + satfreqd = gtk_freq_knob_get_value (GTK_FREQ_KNOB (ctrl->SatFreqDown)); if (ctrl->tracking) { /* downlink */ @@ -1854,19 +1854,19 @@ /* check if uplink dial has changed */ if ((ctrl->engaged) && (ctrl->lasttxf > 0.0)) { - + if (!get_freq_simplex (ctrl, ctrl->conf2, &readfreq)) { /* error => use a passive value */ readfreq = ctrl->lasttxf; ctrl->errcnt++; } - + if (fabs (readfreq - ctrl->lasttxf) >= 1.0) { dialchanged = TRUE; - + gtk_freq_knob_set_value (GTK_FREQ_KNOB (ctrl->RigFreqUp), readfreq); ctrl->lasttxf = readfreq; - + /* doppler shift; only if we are tracking */ if (ctrl->tracking) { satfrequ = readfreq - ctrl->du + ctrl->conf2->loup; @@ -1896,7 +1896,7 @@ } tmpfreq = gtk_freq_knob_get_value(GTK_FREQ_KNOB(ctrl->RigFreqDown)); - + /* if device is engaged, send freq command to radio */ if ((ctrl->engaged) && (fabs(ctrl->lastrxf - tmpfreq) >= 1.0)) { if (set_freq_simplex (ctrl, ctrl->conf, tmpfreq)) { @@ -1975,15 +1975,15 @@ if (sock < 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: Failed to create socket"), - __FILE__, __LINE__); + __FILE__, __LINE__); return FALSE; } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s:%d Network socket created successfully"), - __FILE__, __LINE__); + __FILE__, __LINE__); } - + memset(&ServAddr, 0, sizeof(ServAddr)); /* Zero out structure */ ServAddr.sin_family = AF_INET; /* Internet address family */ h = gethostbyname(conf->host); @@ -1995,13 +1995,13 @@ if (status < 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: Failed to connect to %s:%d"), - __FILE__, __LINE__, conf->host, conf->port); + __FILE__, __LINE__, conf->host, conf->port); return FALSE; } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s:%d: Connection opened to %s:%d"), - __FILE__, __LINE__, conf->host, conf->port); + __FILE__, __LINE__, conf->host, conf->port); } if (conf->ptt == PTT_TYPE_CAT) { @@ -2019,7 +2019,7 @@ if (written != size) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: SIZE ERROR %d / %d"), - __FILE__, __LINE__, written, size); + __FILE__, __LINE__, written, size); } g_free (buff); @@ -2029,33 +2029,33 @@ if (buff == NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%s: Failed to allocate 128 bytes (yes, this means trouble)"), - __FILE__, __FUNCTION__); + __FILE__, __FUNCTION__); #ifndef WIN32 shutdown (sock, SHUT_RDWR); #else shutdown (sock, SD_BOTH); #endif - + close (sock); return FALSE; } - + size = read (sock, buff, 127); if (size == 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%s: Got 0 bytes from rigctld"), - __FILE__, __FUNCTION__); + __FILE__, __FUNCTION__); } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s:%s: Read %d bytes from rigctld"), - __FILE__, __FUNCTION__, size); + __FILE__, __FUNCTION__, size); buff[size] = 0; vbuff = g_strsplit (buff, "\n", 3); pttstat = g_ascii_strtoull (vbuff[0], NULL, 0); //FIXME base = 0 ok? - + g_free (buff); g_strfreev (vbuff); } @@ -2092,21 +2092,21 @@ struct hostent *h; struct sockaddr_in ServAddr; gint sock; /*!< Network socket */ - + /* create socket */ sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create socket"), - __FUNCTION__); + __FUNCTION__); return FALSE; } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Network socket created successfully"), - __FUNCTION__); + __FUNCTION__); } - + memset(&ServAddr, 0, sizeof(ServAddr)); /* Zero out structure */ ServAddr.sin_family = AF_INET; /* Internet address family */ h = gethostbyname(conf->host); @@ -2118,13 +2118,13 @@ if (status < 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to connect to %s:%d"), - __FUNCTION__, conf->host, conf->port); + __FUNCTION__, conf->host, conf->port); return FALSE; } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Connection opened to %s:%d"), - __FUNCTION__, conf->host, conf->port); + __FUNCTION__, conf->host, conf->port); } /* send command */ @@ -2135,7 +2135,7 @@ if (written != size) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: SIZE ERROR %d / %d"), - __FUNCTION__, written, size); + __FUNCTION__, written, size); } g_free (buff); @@ -2172,21 +2172,21 @@ struct hostent *h; struct sockaddr_in ServAddr; gint sock; /*!< Network socket */ - + /* create socket */ sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create socket"), - __FUNCTION__); + __FUNCTION__); return FALSE; } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Network socket created successfully"), - __FUNCTION__); + __FUNCTION__); } - + memset(&ServAddr, 0, sizeof(ServAddr)); /* Zero out structure */ ServAddr.sin_family = AF_INET; /* Internet address family */ h = gethostbyname(conf->host); @@ -2198,13 +2198,13 @@ if (status < 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to connect to %s:%d"), - __FUNCTION__, conf->host, conf->port); + __FUNCTION__, conf->host, conf->port); return FALSE; } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Connection opened to %s:%d"), - __FUNCTION__, conf->host, conf->port); + __FUNCTION__, conf->host, conf->port); } /* send command */ @@ -2215,7 +2215,7 @@ if (written != size) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: SIZE ERROR %d / %d"), - __FUNCTION__, written, size); + __FUNCTION__, written, size); } g_free (buff); @@ -2247,21 +2247,21 @@ struct hostent *h; struct sockaddr_in ServAddr; gint sock; /*!< Network socket */ - + /* create socket */ sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create socket"), - __FUNCTION__); + __FUNCTION__); return FALSE; } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Network socket created successfully"), - __FUNCTION__); + __FUNCTION__); } - + memset(&ServAddr, 0, sizeof(ServAddr)); /* Zero out structure */ ServAddr.sin_family = AF_INET; /* Internet address family */ h = gethostbyname(conf->host); @@ -2273,13 +2273,13 @@ if (status < 0) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to connect to %s:%d"), - ... [truncated message content] |
From: <cs...@us...> - 2010-07-09 10:36:19
|
Revision: 625 http://gpredict.svn.sourceforge.net/gpredict/?rev=625&view=rev Author: csete Date: 2010-07-09 10:36:13 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Clean up formatting of function names. Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-07-09 09:49:40 UTC (rev 624) +++ trunk/src/gtk-rig-ctrl.c 2010-07-09 10:36:13 UTC (rev 625) @@ -134,8 +134,7 @@ static GdkColor ColGreen = {0, 0, 0xFFFF, 0}; -GType - gtk_rig_ctrl_get_type () +GType gtk_rig_ctrl_get_type () { static GType gtk_rig_ctrl_type = 0; @@ -163,8 +162,7 @@ } -static void - gtk_rig_ctrl_class_init (GtkRigCtrlClass *class) +static void gtk_rig_ctrl_class_init (GtkRigCtrlClass *class) { GObjectClass *gobject_class; GtkObjectClass *object_class; @@ -184,8 +182,7 @@ -static void - gtk_rig_ctrl_init (GtkRigCtrl *ctrl) +static void gtk_rig_ctrl_init (GtkRigCtrl *ctrl) { ctrl->sats = NULL; ctrl->target = NULL; @@ -206,8 +203,7 @@ ctrl->lasttxf = 0.0; } -static void - gtk_rig_ctrl_destroy (GtkObject *object) +static void gtk_rig_ctrl_destroy (GtkObject *object) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (object); @@ -244,8 +240,7 @@ * \return A new rig control window. * */ -GtkWidget * - gtk_rig_ctrl_new (GtkSatModule *module) +GtkWidget *gtk_rig_ctrl_new (GtkSatModule *module) { GtkWidget *widget; GtkWidget *table; @@ -310,8 +305,7 @@ * the satellite data has been updated. The function updates the internal state * of the controller and the rigator. */ -void - gtk_rig_ctrl_update (GtkRigCtrl *ctrl, gdouble t) +void gtk_rig_ctrl_update (GtkRigCtrl *ctrl, gdouble t) { gdouble satfreq; gchar *buff; @@ -386,8 +380,7 @@ * satellite frequency with the radio frequency below it. * */ -static - GtkWidget *create_downlink_widgets (GtkRigCtrl *ctrl) +static GtkWidget *create_downlink_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame; GtkWidget *vbox; @@ -451,8 +444,7 @@ * This function creates and initialises the widgets for displaying the * uplink frequency of the satellite and the radio. */ -static - GtkWidget *create_uplink_widgets (GtkRigCtrl *ctrl) +static GtkWidget *create_uplink_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame; GtkWidget *vbox; @@ -513,8 +505,7 @@ /** \brief Create target widgets. * \param ctrl Pointer to the GtkRigCtrl widget. */ -static - GtkWidget *create_target_widgets (GtkRigCtrl *ctrl) +static GtkWidget *create_target_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame,*table,*label,*satsel,*track; GtkWidget *tune,*trsplock,*hbox; @@ -645,8 +636,7 @@ } -static GtkWidget * - create_conf_widgets (GtkRigCtrl *ctrl) +static GtkWidget *create_conf_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame,*table,*label,*timer; GDir *dir = NULL; /* directory handle */ @@ -783,8 +773,7 @@ /** \brief Create count down widget */ -static GtkWidget * - create_count_down_widgets (GtkRigCtrl *ctrl) +static GtkWidget *create_count_down_widgets (GtkRigCtrl *ctrl) { GtkWidget *frame; @@ -807,8 +796,7 @@ /** \brief Copy satellite from hash table to singly linked list. */ -static void - store_sats (gpointer key, gpointer value, gpointer user_data) +static void store_sats (gpointer key, gpointer value, gpointer user_data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL( user_data); sat_t *sat = SAT (value); @@ -823,8 +811,7 @@ * * This function is called when the user selects a new satellite. */ -static void - sat_selected_cb (GtkComboBox *satsel, gpointer data) +static void sat_selected_cb (GtkComboBox *satsel, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); gint i; @@ -958,8 +945,7 @@ * \param button Pointer to the GtkToggle button. * \param data Pointer to the GtkRigCtrl widget. */ -static void - track_toggle_cb (GtkToggleButton *button, gpointer data) +static void track_toggle_cb (GtkToggleButton *button, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); @@ -978,8 +964,7 @@ * This function is called when the user changes the value of the * cycle delay. */ -static void - delay_changed_cb (GtkSpinButton *spin, gpointer data) +static void delay_changed_cb (GtkSpinButton *spin, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); @@ -1004,8 +989,7 @@ * * BUG Doesn't prevent user to select same radio as in the secondary conf. */ -static void - primary_rig_selected_cb (GtkComboBox *box, gpointer data) +static void primary_rig_selected_cb (GtkComboBox *box, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); gchar *buff; @@ -1070,8 +1054,7 @@ * This function is called when the user selects a new rig controller * device for the secondary radio. This radio is used for uplink only. */ -static void - secondary_rig_selected_cb (GtkComboBox *box, gpointer data) +static void secondary_rig_selected_cb (GtkComboBox *box, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); gchar *buff; @@ -1284,8 +1267,7 @@ * \param data Pointer to the GtkRigCtrl widget. * \return Always TRUE to let the timer continue. */ -static gboolean - rig_ctrl_timeout_cb (gpointer data) +static gboolean rig_ctrl_timeout_cb (gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-07-09 13:02:33
|
Revision: 626 http://gpredict.svn.sourceforge.net/gpredict/?rev=626&view=rev Author: csete Date: 2010-07-09 13:02:26 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Added function to capture key press events. Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-07-09 10:36:13 UTC (rev 625) +++ trunk/src/gtk-rig-ctrl.c 2010-07-09 13:02:26 UTC (rev 626) @@ -39,6 +39,7 @@ * */ #include <gtk/gtk.h> +#include <gdk/gdkkeysyms.h> #include <glib/gi18n.h> #include <math.h> #include <glib.h> @@ -97,6 +98,7 @@ static gboolean rig_ctrl_timeout_cb (gpointer data); static void downlink_changed_cb (GtkFreqKnob *knob, gpointer data); static void uplink_changed_cb (GtkFreqKnob *knob, gpointer data); +static gboolean key_press_cb (GtkWidget *widget, GdkEventKey *pKey, gpointer data); /* radio control functions */ @@ -251,6 +253,10 @@ } widget = g_object_new (GTK_TYPE_RIG_CTRL, NULL); + + /* connect calback to catch key press events */ + g_signal_connect (widget, "key-press-event", + G_CALLBACK(key_press_cb), NULL); // controller widget will be passed as primary param /* store satellites */ g_hash_table_foreach (module->satellites, store_sats, widget); @@ -3066,3 +3072,44 @@ return TRUE; } + + +/** \brief Manage key press event on the controller widget + * \param widget Pointer to the GtkRigCtrl widget that received the event + * \param pKey Pointer to the event that has happened + * \param data User data (always NULL) + * \return TRUE if the event is known and managed by this callback, FALSE otherwise + * + * This function is used to catch events when the user presses the SPACE key on the keyboard. + * This is used to toggle betweer RX/TX when using FT817/857/897 in manual mode. + */ +static gboolean key_press_cb (GtkWidget *widget, GdkEventKey *pKey, gpointer data) +{ + GtkRigCtrl *ctrl = GTK_RIG_CTRL(widget); + gboolean event_managed = FALSE; + + + /* filter GDK_KEY_PRESS events */ + if (pKey->type == GDK_KEY_PRESS) { + + switch (pKey->keyval) { + /* keyvals not in API docs. See <gdk/gdkkeysyms.h> for a complete list */ + case GDK_space: + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Detected SPACEBAR pressed event"), + __FUNCTION__); + + event_managed = TRUE; + break; + + default: + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Keypress value %i not managed by this function"), + __FUNCTION__, pKey->keyval); + break; + + } + } + + return event_managed; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-09-17 11:05:33
|
Revision: 651 http://gpredict.svn.sourceforge.net/gpredict/?rev=651&view=rev Author: aa1vs Date: 2010-09-17 11:05:26 +0000 (Fri, 17 Sep 2010) Log Message: ----------- Fix potential memory leak gtk-rig-ctrl.c Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-09-14 19:54:09 UTC (rev 650) +++ trunk/src/gtk-rig-ctrl.c 2010-09-17 11:05:26 UTC (rev 651) @@ -2004,10 +2004,11 @@ vbuff = g_strsplit (buff, "\n", 3); pttstat = g_ascii_strtoull (vbuff[0], NULL, 0); //FIXME base = 0 ok? - g_free (buff); g_strfreev (vbuff); } + g_free (buff); + #ifndef WIN32 shutdown (sock, SHUT_RDWR); #else @@ -2517,9 +2518,10 @@ vbuff = g_strsplit (buff, "\n", 3); *freq = g_ascii_strtod (vbuff[0], NULL); - g_free (buff); g_strfreev (vbuff); } + g_free (buff); + #ifndef WIN32 shutdown (sock, SHUT_RDWR); @@ -2636,9 +2638,9 @@ vbuff = g_strsplit (buff, "\n", 3); *freq = g_ascii_strtod (vbuff[0], NULL); - g_free (buff); g_strfreev (vbuff); } + g_free (buff); #ifndef WIN32 shutdown (sock, SHUT_RDWR); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-10-02 14:23:51
|
Revision: 658 http://gpredict.svn.sourceforge.net/gpredict/?rev=658&view=rev Author: aa1vs Date: 2010-10-02 14:23:44 +0000 (Sat, 02 Oct 2010) Log Message: ----------- Fix bug with set and unset toggle buffer size being incorrect causing junk to be sent to rigctld. Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-09-26 20:23:08 UTC (rev 657) +++ trunk/src/gtk-rig-ctrl.c 2010-10-02 14:23:44 UTC (rev 658) @@ -2315,7 +2315,7 @@ /* send command */ buff = g_strdup_printf ("S 1 %d\x0aq\x0a",ctrl->conf->vfoDown); - size = 15; + size = strlen(buff); written = send(sock, buff, size, 0); if (written != size) { sat_log_log (SAT_LOG_LEVEL_ERROR, @@ -2390,7 +2390,7 @@ /* send command */ buff = g_strdup_printf ("S 0 %d\x0aq\x0a",ctrl->conf->vfoDown); - size = 15; + size = strlen(buff); written = send(sock, buff, size, 0); if (written != size) { sat_log_log (SAT_LOG_LEVEL_ERROR, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-10-02 16:38:15
|
Revision: 661 http://gpredict.svn.sourceforge.net/gpredict/?rev=661&view=rev Author: aa1vs Date: 2010-10-02 16:38:08 +0000 (Sat, 02 Oct 2010) Log Message: ----------- Trap NULL values in rig_ctrl_timeout_cb that caused crash Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-10-02 16:36:25 UTC (rev 660) +++ trunk/src/gtk-rig-ctrl.c 2010-10-02 16:38:08 UTC (rev 661) @@ -1168,14 +1168,16 @@ ctrl->engaged = FALSE; ctrl->lasttxf = 0.0; ctrl->lastrxf = 0.0; - switch (ctrl->conf->type) { - case RIG_TYPE_TOGGLE_AUTO: - case RIG_TYPE_TOGGLE_MAN: - unset_toggle (ctrl,ctrl->conf); - break; - default: - break; - } + if (ctrl->conf->type != NULL) { + switch (ctrl->conf->type) { + case RIG_TYPE_TOGGLE_AUTO: + case RIG_TYPE_TOGGLE_MAN: + unset_toggle (ctrl,ctrl->conf); + break; + default: + break; + } + } } else { if (ctrl->conf == NULL) { @@ -1274,7 +1276,15 @@ static gboolean rig_ctrl_timeout_cb (gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); - + if (ctrl->conf == NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Controller does not have a valid configuration"), + __FUNCTION__); + return (TRUE); + + } + + if (g_static_mutex_trylock(&(ctrl->busy))==FALSE) { sat_log_log (SAT_LOG_LEVEL_ERROR,_("%s missed the deadline"),__FUNCTION__); return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-10-02 19:57:06
|
Revision: 662 http://gpredict.svn.sourceforge.net/gpredict/?rev=662&view=rev Author: aa1vs Date: 2010-10-02 19:57:00 +0000 (Sat, 02 Oct 2010) Log Message: ----------- Fixing rig_ctrl_timeout_cb for NULL ctrl->conf Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-10-02 16:38:08 UTC (rev 661) +++ trunk/src/gtk-rig-ctrl.c 2010-10-02 19:57:00 UTC (rev 662) @@ -1160,6 +1160,15 @@ { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); + if (ctrl->conf == NULL) { + /* we don't have a working configuration */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Controller does not have a valid configuration"), + __FUNCTION__); + return; + } + + if (!gtk_toggle_button_get_active (button)) { /* close socket */ @@ -1168,6 +1177,7 @@ ctrl->engaged = FALSE; ctrl->lasttxf = 0.0; ctrl->lastrxf = 0.0; + if (ctrl->conf->type != NULL) { switch (ctrl->conf->type) { case RIG_TYPE_TOGGLE_AUTO: @@ -1180,14 +1190,7 @@ } } else { - if (ctrl->conf == NULL) { - /* we don't have a working configuration */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Controller does not have a valid configuration"), - __FUNCTION__); - return; - } - + gtk_widget_set_sensitive (ctrl->DevSel, FALSE); gtk_widget_set_sensitive (ctrl->DevSel2, FALSE); ctrl->engaged = TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-10-12 10:45:57
|
Revision: 676 http://gpredict.svn.sourceforge.net/gpredict/?rev=676&view=rev Author: csete Date: 2010-10-12 10:45:51 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Not sure what 'NULL' was supposed to mean here, but the rewritten code is equivalent and gives no warnings. Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-10-12 10:36:56 UTC (rev 675) +++ trunk/src/gtk-rig-ctrl.c 2010-10-12 10:45:51 UTC (rev 676) @@ -1178,16 +1178,11 @@ ctrl->lasttxf = 0.0; ctrl->lastrxf = 0.0; - if (ctrl->conf->type != NULL) { - switch (ctrl->conf->type) { - case RIG_TYPE_TOGGLE_AUTO: - case RIG_TYPE_TOGGLE_MAN: - unset_toggle (ctrl,ctrl->conf); - break; - default: - break; - } - } + if ((ctrl->conf->type == RIG_TYPE_TOGGLE_AUTO) || + (ctrl->conf->type == RIG_TYPE_TOGGLE_MAN)) { + + unset_toggle (ctrl,ctrl->conf); + } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-11-01 19:54:31
|
Revision: 704 http://gpredict.svn.sourceforge.net/gpredict/?rev=704&view=rev Author: aa1vs Date: 2010-11-01 19:54:24 +0000 (Mon, 01 Nov 2010) Log Message: ----------- Add checks to g_strsplit calls in gtk-rig-ctrl.c Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-11-01 19:51:23 UTC (rev 703) +++ trunk/src/gtk-rig-ctrl.c 2010-11-01 19:54:24 UTC (rev 704) @@ -1965,8 +1965,8 @@ retcode=send_rigctld_command(ctrl,sock,buff,buffback,128); if (retcode) { vbuff = g_strsplit (buffback, "\n", 3); - pttstat = g_ascii_strtoull (vbuff[0], NULL, 0); //FIXME base = 0 ok? - + if (vbuff[0]) + pttstat = g_ascii_strtoull (vbuff[0], NULL, 0); //FIXME base = 0 ok? g_strfreev (vbuff); } g_free (buff); @@ -2120,6 +2120,7 @@ gchar *buff,**vbuff; gchar buffback[128]; gboolean retcode; + gboolean retval = TRUE; buff = g_strdup_printf ("f\x0a"); @@ -2127,10 +2128,15 @@ retcode=check_get_response(buffback,retcode,__FUNCTION__); if (retcode) { vbuff = g_strsplit (buffback, "\n", 3); - *freq = g_ascii_strtod (vbuff[0], NULL); + if (vbuff[0]) + *freq = g_ascii_strtod (vbuff[0], NULL); + else + retval = FALSE; g_strfreev (vbuff); + } else { + retval = FALSE; } - return TRUE; + return retval; } /** \brief Get frequency when the radio is working toggle @@ -2145,6 +2151,7 @@ gchar *buff,**vbuff; gchar buffback[128]; gboolean retcode; + gboolean retval=TRUE; if (freq == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, @@ -2160,10 +2167,16 @@ retcode=check_get_response(buffback,retcode,__FUNCTION__); if (retcode) { vbuff = g_strsplit (buffback, "\n", 3); - *freq = g_ascii_strtod (vbuff[0], NULL); + if (vbuff[0]) + *freq = g_ascii_strtod (vbuff[0], NULL); + else + retval = FALSE; + g_strfreev (vbuff); + } else { + retval = FALSE; } - return TRUE; + return retval; } /** \brief Select target VFO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-11-23 14:31:27
|
Revision: 718 http://gpredict.svn.sourceforge.net/gpredict/?rev=718&view=rev Author: aa1vs Date: 2010-11-23 14:31:21 +0000 (Tue, 23 Nov 2010) Log Message: ----------- Close socket in gtk-rig-ctrl when window closes if applicable Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-11-23 13:23:27 UTC (rev 717) +++ trunk/src/gtk-rig-ctrl.c 2010-11-23 14:31:21 UTC (rev 718) @@ -120,7 +120,7 @@ static gboolean set_vfo (GtkRigCtrl *ctrl, vfo_t vfo); static void update_count_down (GtkRigCtrl *ctrl, gdouble t); static gboolean open_rigctld_socket(radio_conf_t *conf, gint *sock); -static gboolean close_rigctld_socket(gint sock); +static gboolean close_rigctld_socket(gint *sock); /* misc utility functions */ static void load_trsp_list (GtkRigCtrl *ctrl); @@ -205,6 +205,8 @@ ctrl->trsplist = NULL; ctrl->trsplock = FALSE; ctrl->tracking = FALSE; + ctrl->sock = 0; + ctrl->sock2 = 0; g_static_mutex_init(&(ctrl->busy)); ctrl->engaged = FALSE; ctrl->delay = 1000; @@ -243,6 +245,11 @@ ctrl->trsplist = NULL; /* destroy might be called twice (?) so we need to NULL it */ } + /* close sockets if they are open*/ + if (ctrl->sock) + close_rigctld_socket(&(ctrl->sock)); + if (ctrl->sock2) + close_rigctld_socket(&(ctrl->sock2)); (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -1204,9 +1211,9 @@ if (ctrl->conf2 != NULL) { - close_rigctld_socket(ctrl->sock2); + close_rigctld_socket(&(ctrl->sock2)); } - close_rigctld_socket(ctrl->sock); + close_rigctld_socket(&(ctrl->sock)); } @@ -2692,6 +2699,7 @@ sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create socket"), __FUNCTION__); + *sock = 0; return FALSE; } else { @@ -2712,6 +2720,7 @@ sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to connect to %s:%d"), __FUNCTION__, conf->host, conf->port); + *sock = 0; return FALSE; } else { @@ -2723,18 +2732,18 @@ return TRUE; } -static gboolean close_rigctld_socket (gint sock) { +static gboolean close_rigctld_socket (gint *sock) { gint written; /*shutdown the rigctld connect*/ - written = send(sock, "q\x0a", 2, 0); + written = send(*sock, "q\x0a", 2, 0); #ifndef WIN32 - shutdown (sock, SHUT_RDWR); + shutdown (*sock, SHUT_RDWR); #else - shutdown (sock, SD_BOTH); + shutdown (*sock, SD_BOTH); #endif - close (sock); + close (*sock); return TRUE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2010-11-24 03:18:10
|
Revision: 720 http://gpredict.svn.sourceforge.net/gpredict/?rev=720&view=rev Author: aa1vs Date: 2010-11-24 03:17:59 +0000 (Wed, 24 Nov 2010) Log Message: ----------- Finish socket closing in gtk-rig-ctrl.c Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2010-11-23 14:39:01 UTC (rev 719) +++ trunk/src/gtk-rig-ctrl.c 2010-11-24 03:17:59 UTC (rev 720) @@ -2744,7 +2744,9 @@ #endif close (*sock); - + + *sock = 0; + return TRUE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-07-14 04:03:39
|
Revision: 857 http://gpredict.svn.sourceforge.net/gpredict/?rev=857&view=rev Author: aa1vs Date: 2011-07-14 04:03:33 +0000 (Thu, 14 Jul 2011) Log Message: ----------- Clean pendantic compiler warning. Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2011-07-14 03:48:30 UTC (rev 856) +++ trunk/src/gtk-rig-ctrl.c 2011-07-14 04:03:33 UTC (rev 857) @@ -118,7 +118,9 @@ static gboolean get_freq_toggle (GtkRigCtrl *ctrl, gint sock, gdouble *freq); static gboolean get_ptt (GtkRigCtrl *ctrl, gint sock); static gboolean set_ptt (GtkRigCtrl *ctrl, gint sock, gboolean ptt); +#if 0 static gboolean set_vfo (GtkRigCtrl *ctrl, vfo_t vfo); +#endif static gboolean setup_split(GtkRigCtrl *ctrl); static void update_count_down (GtkRigCtrl *ctrl, gdouble t); static gboolean open_rigctld_socket(radio_conf_t *conf, gint *sock); @@ -163,6 +165,7 @@ sizeof (GtkRigCtrl), 2, /* n_preallocs */ (GInstanceInitFunc) gtk_rig_ctrl_init, + NULL }; gtk_rig_ctrl_type = g_type_register_static (GTK_TYPE_VBOX, @@ -837,6 +840,7 @@ GtkRigCtrl *ctrl = GTK_RIG_CTRL( user_data); sat_t *sat = SAT (value); + (void) key; /* avoid unused parameter compiler warning */ //ctrl->sats = g_slist_append (ctrl->sats, sat); ctrl->sats = g_slist_insert_sorted (ctrl->sats, sat, (GCompareFunc)sat_name_compare); } @@ -927,6 +931,8 @@ GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); gdouble freq; + (void) button; /* avoid unused parameter compiler warning */ + if (ctrl->trsp == NULL) return; @@ -1330,6 +1336,7 @@ static void downlink_changed_cb (GtkFreqKnob *knob, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); + (void) knob; /* avoid unused parameter compiler warning */ if (ctrl->trsplock) { track_downlink (ctrl); @@ -1346,6 +1353,7 @@ static void uplink_changed_cb (GtkFreqKnob *knob, gpointer data) { GtkRigCtrl *ctrl = GTK_RIG_CTRL (data); + (void) knob; /* avoid unused parameter compiler warning */ if (ctrl->trsplock) { track_uplink (ctrl); @@ -2337,6 +2345,7 @@ * occurred. * */ +#if 0 static gboolean set_vfo (GtkRigCtrl *ctrl, vfo_t vfo) { gchar *buff; @@ -2373,8 +2382,8 @@ return(check_set_response(buffback,retcode,__FUNCTION__)); } +#endif - /** \brief Update count down label. * \param[in] ctrl Pointer to the RigCtrl widget. * \param[in] t The current time. @@ -2662,7 +2671,7 @@ return FALSE; } /* try to read answer */ - size = recv (sock, buffout, 127, 0); + size = recv (sock, buffout, sizeout - 1, 0); if (size == -1) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: rigctld port closed"), @@ -2702,6 +2711,7 @@ GtkRigCtrl *ctrl = GTK_RIG_CTRL(widget); gboolean event_managed = FALSE; + (void) data; /* avoid unused parameter compiler warning */ /* filter GDK_KEY_PRESS events */ if (pKey->type == GDK_KEY_PRESS) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |