Thread: [Gpredict-svn] SF.net SVN: gpredict:[139] trunk/src/tle-update.c
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <cs...@us...> - 2008-09-20 13:21:30
|
Revision: 139 http://gpredict.svn.sourceforge.net/gpredict/?rev=139&view=rev Author: csete Date: 2008-09-20 13:21:28 +0000 (Sat, 20 Sep 2008) Log Message: ----------- Changed connection timeout from system default to 10 seconds. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2008-09-18 19:04:42 UTC (rev 138) +++ trunk/src/tle-update.c 2008-09-20 13:21:28 UTC (rev 139) @@ -473,6 +473,7 @@ curl_easy_setopt (curl, CURLOPT_PROXY, proxy); curl_easy_setopt (curl, CURLOPT_USERAGENT, "gpredict/curl"); + curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 10); /* get files */ for (i = 0; i < numfiles; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fi...@us...> - 2009-03-20 14:06:32
|
Revision: 202 http://gpredict.svn.sourceforge.net/gpredict/?rev=202&view=rev Author: fillods Date: 2009-03-20 14:06:21 +0000 (Fri, 20 Mar 2009) Log Message: ----------- proper error checking when downloading tle files Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2009-03-18 10:05:03 UTC (rev 201) +++ trunk/src/tle-update.c 2009-03-20 14:06:21 UTC (rev 202) @@ -418,7 +418,6 @@ gchar *curfile; gchar *locfile; GFile *file; - gboolean error = FALSE; gdouble fraction,start=0; GFile *outfile; GDir *dir; @@ -491,11 +490,12 @@ g_file_copy (file, outfile, G_FILE_COPY_NONE, NULL, NULL, NULL, &err); - if (error) { + if (err != NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Error fetching %s (%s)"), __FUNCTION__, curfile, err->message); - g_clear_error (&err); + g_clear_error (&err); + err = NULL; } else { sat_log_log (SAT_LOG_LEVEL_MSG, @@ -552,8 +552,9 @@ /* send an error message */ sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Error opening %s (%s)"), - __FUNCTION__, dir, err->message); + __FUNCTION__, cache, err->message); g_clear_error (&err); + err = NULL; } else { /* delete files in cache one by one */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-05-13 20:39:26
|
Revision: 308 http://gpredict.svn.sourceforge.net/gpredict/?rev=308&view=rev Author: csete Date: 2009-05-13 20:39:23 +0000 (Wed, 13 May 2009) Log Message: ----------- Fixed compile warnings. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2009-05-13 20:11:07 UTC (rev 307) +++ trunk/src/tle-update.c 2009-05-13 20:39:23 UTC (rev 308) @@ -629,6 +629,7 @@ gchar *path; gchar tle_str[3][80]; gchar catstr[6]; + gchar *b; FILE *fp; gint retcode = 0; guint catnr,i; @@ -644,8 +645,8 @@ /* read 3 lines at a time */ while (fgets (tle_str[0], 80, fp)) { /* read second and third lines */ - fgets (tle_str[1], 80, fp); - fgets (tle_str[2], 80, fp); + b = fgets (tle_str[1], 80, fp); + b = fgets (tle_str[2], 80, fp); /* copy catnum and convert to integer */ for (i = 2; i < 7; i++) { @@ -746,6 +747,7 @@ guint total = 0; /* total no. of sats in gpredict tle file */ gchar tle_str[3][80]; gchar catstr[6]; + gchar *b; FILE *fp; FILE *tmp; guint catnr,i; @@ -770,8 +772,8 @@ /* read 3 lines at a time */ while (fgets (tle_str[0], 80, fp)) { /* read second and third lines */ - fgets (tle_str[1], 80, fp); - fgets (tle_str[2], 80, fp); + b = fgets (tle_str[1], 80, fp); + b = fgets (tle_str[2], 80, fp); /* stats */ total++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-15 12:50:31
|
Revision: 418 http://gpredict.svn.sourceforge.net/gpredict/?rev=418&view=rev Author: csete Date: 2009-08-15 12:50:23 +0000 (Sat, 15 Aug 2009) Log Message: ----------- Adding new satellites appears to work. Cleaned for debug comments. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2009-08-14 11:25:24 UTC (rev 417) +++ trunk/src/tle-update.c 2009-08-15 12:50:23 UTC (rev 418) @@ -343,6 +343,9 @@ sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: TLE elements updated."), __FUNCTION__); + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: FIXME: Sync of categories not implemented!"), + __FUNCTION__); } /* destroy hash tables */ @@ -364,13 +367,9 @@ GError *err = NULL; - g_print ("==> Add new sat %d?\n", ntle->catnum); - /* check if sat is new */ if (ntle->isnew) { - g_print ("-----> YES!\n"); - /* create config data */ satdata = g_key_file_new (); @@ -412,7 +411,7 @@ } else { sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Satellite data written for %d."), + _("%s: Data for new sat %d successfully added."), __FUNCTION__, ntle->catnum); *num += 1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-09-28 15:44:02
|
Revision: 456 http://gpredict.svn.sourceforge.net/gpredict/?rev=456&view=rev Author: csete Date: 2009-09-28 15:43:55 +0000 (Mon, 28 Sep 2009) Log Message: ----------- Removed obsolete log message. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2009-09-28 15:41:01 UTC (rev 455) +++ trunk/src/tle-update.c 2009-09-28 15:43:55 UTC (rev 456) @@ -343,9 +343,6 @@ sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: TLE elements updated."), __FUNCTION__); - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: FIXME: Sync of categories not implemented!"), - __FUNCTION__); } /* destroy hash tables */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-10-13 18:29:17
|
Revision: 493 http://gpredict.svn.sourceforge.net/gpredict/?rev=493&view=rev Author: csete Date: 2009-10-13 18:29:03 +0000 (Tue, 13 Oct 2009) Log Message: ----------- Applied patch 2877878 and 2877918 from Charles Suprin AA1VS. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2009-10-12 22:20:05 UTC (rev 492) +++ trunk/src/tle-update.c 2009-10-13 18:29:03 UTC (rev 493) @@ -3,6 +3,7 @@ Gpredict: Real-time satellite tracking and orbit prediction program Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC. + Copyright (C) 2009 Charles Suprin AA1VS. Authors: Alexandru Csete <oz...@gm...> @@ -45,7 +46,10 @@ e.g. user starts update from menubar while automatic update is in progress */ -static gboolean tle_in_progress = FALSE; +/* static gboolean tle_in_progress = FALSE; */ +/* Replace flag with lock */ +/* http://library.gnome.org/devel/glib/unstable/glib-Threads.html */ +static GStaticMutex tle_in_progress = G_STATIC_MUTEX_INIT ; /* private function prototypes */ @@ -118,15 +122,16 @@ gdouble fraction = 0.0; gdouble start = 0.0; + if (g_static_mutex_trylock(&tle_in_progress)==FALSE) + return; - /* create hash table */ data = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, free_new_tle); /* open directory and read files one by one */ cache_dir = g_dir_open (dir, 0, &err); - + if (err != NULL) { /* send an error message */ @@ -348,6 +353,7 @@ /* destroy hash tables */ g_hash_table_destroy (data); + g_static_mutex_unlock(&tle_in_progress); } @@ -509,13 +515,13 @@ GError *err = NULL; guint success = 0; /* no. of successfull downloads */ - /* bail out if we are already in an update process */ - if (tle_in_progress) + /*if (tle_in_progress)*/ + if (g_static_mutex_trylock(&tle_in_progress)==FALSE) return; - tle_in_progress = TRUE; + /*tle_in_progress = TRUE;*/ /* get server, proxy, and list of files */ server = sat_cfg_get_str (SAT_CFG_STR_TLE_SERVER); @@ -570,7 +576,7 @@ while (g_main_context_iteration (NULL, FALSE)); } - /* creae local cache file */ + /* create local cache file */ userconfdir = get_user_conf_dir (); locfile = g_strconcat (userconfdir, G_DIR_SEPARATOR_S, "satdata", G_DIR_SEPARATOR_S, @@ -664,7 +670,8 @@ g_free (cache); /* clear busy flag */ - tle_in_progress = FALSE; + /* tle_in_progress = FALSE; */ + g_static_mutex_unlock(&tle_in_progress); } @@ -728,83 +735,101 @@ /* read category name for catfile */ catfile = g_fopen (catpath, "r"); - b = fgets (category, 80, catfile); - fclose (catfile); + if (catfile!=NULL) { + b = fgets (category, 80, catfile); + fclose (catfile); + } + else { + /* FIXME not sure what goes here AA1VS */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%s: Failed to open %s"), + __FILE__, __FUNCTION__, catpath); + return (retcode); + } /* reopen a new catfile and write category name */ catfile = g_fopen (catpath, "w"); - g_free (catpath); - fputs (category, catfile); + if (catfile!=NULL) { - /* .cat file now contains the category name; - satellite catnums will be added during update in the while loop */ + fputs (category, catfile); + + /* .cat file now contains the category name; + satellite catnums will be added during update in the while loop */ - /* read 3 lines at a time */ - while (fgets (tle_str[0], 80, fp)) { - /* read second and third lines */ - b = fgets (tle_str[1], 80, fp); - b = fgets (tle_str[2], 80, fp); + /* read 3 lines at a time */ + while (fgets (tle_str[0], 80, fp)) { + /* read second and third lines */ + b = fgets (tle_str[1], 80, fp); + b = fgets (tle_str[2], 80, fp); + + tle_str[1][69] = '\0'; + tle_str[2][69] = '\0'; + + /* copy catnum and convert to integer */ + for (i = 2; i < 7; i++) { + catstr[i-2] = tle_str[1][i]; + } + catstr[5] = '\0'; + catnr = (guint) g_ascii_strtod (catstr, NULL); + + + if (Get_Next_Tle_Set (tle_str, &tle) != 1) { + /* TLE data not good */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%s: Invalid data for %d"), + __FILE__, __FUNCTION__, catnr); + } + else { + /* DATA OK, phew... */ + /* sat_log_log (SAT_LOG_LEVEL_DEBUG, */ + /* _("%s: Good data for %d"), */ + /* __FUNCTION__, */ + /* catnr); */ + + /* store catalog number in catfile */ + buff = g_strdup_printf ("%d\n", catnr); + fputs (buff, catfile); + g_free (buff); + + /* add data to hash table */ + key = g_try_new0 (guint, 1); + *key = catnr; + + /* check if satellite already in hash table */ + if (g_hash_table_lookup (data, key) == NULL) { + + /* create new_tle structure */ + ntle = g_try_new (new_tle_t, 1); + ntle->catnum = catnr; + ntle->epoch = tle.epoch; + ntle->satname = g_strdup (tle_str[0]); + ntle->line1 = g_strdup (tle_str[1]); + ntle->line2 = g_strdup (tle_str[2]); + ntle->srcfile = g_strdup (fnam); + ntle->isnew = TRUE; /* flag will be reset when using data */ + + + g_hash_table_insert (data, key, ntle); + retcode++; + } + else { + g_free (key); + } + } + + } + + /* close category file */ + fclose (catfile); + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%s: Failed to open %s"), + __FILE__, __FUNCTION__, catpath); + } - tle_str[1][69] = '\0'; - tle_str[2][69] = '\0'; + g_free (catpath); - /* copy catnum and convert to integer */ - for (i = 2; i < 7; i++) { - catstr[i-2] = tle_str[1][i]; - } - catstr[5] = '\0'; - catnr = (guint) g_ascii_strtod (catstr, NULL); - - - if (Get_Next_Tle_Set (tle_str, &tle) != 1) { - /* TLE data not good */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%s: Invalid data for %d"), - __FILE__, __FUNCTION__, catnr); - } - else { - /* DATA OK, phew... */ - /* sat_log_log (SAT_LOG_LEVEL_DEBUG, */ - /* _("%s: Good data for %d"), */ - /* __FUNCTION__, */ - /* catnr); */ - - /* store catalog number in catfile */ - buff = g_strdup_printf ("%d\n", catnr); - fputs (buff, catfile); - g_free (buff); - - /* add data to hash table */ - key = g_try_new0 (guint, 1); - *key = catnr; - - /* check if satellite already in hash table */ - if (g_hash_table_lookup (data, key) == NULL) { - - /* create new_tle structure */ - ntle = g_try_new (new_tle_t, 1); - ntle->catnum = catnr; - ntle->epoch = tle.epoch; - ntle->satname = g_strdup (tle_str[0]); - ntle->line1 = g_strdup (tle_str[1]); - ntle->line2 = g_strdup (tle_str[2]); - ntle->srcfile = g_strdup (fnam); - ntle->isnew = TRUE; /* flag will be reset when using data */ - - - g_hash_table_insert (data, key, ntle); - retcode++; - } - else { - g_free (key); - } - } - - } - - /* close category file */ - fclose (catfile); - /* close input TLE file */ fclose (fp); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2011-02-28 03:30:38
|
Revision: 774 http://gpredict.svn.sourceforge.net/gpredict/?rev=774&view=rev Author: csete Date: 2011-02-28 03:30:30 +0000 (Mon, 28 Feb 2011) Log Message: ----------- Fixed spelling error. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2011-02-22 16:02:56 UTC (rev 773) +++ trunk/src/tle-update.c 2011-02-28 03:30:30 UTC (rev 774) @@ -815,7 +815,7 @@ else { catsync = FALSE; sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%s: Could not reopne .cat file while reading TLE from %s"), + _("%s:%s: Could not reopen .cat file while reading TLE from %s"), __FILE__, __FUNCTION__, fnam); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-07-14 00:02:25
|
Revision: 847 http://gpredict.svn.sourceforge.net/gpredict/?rev=847&view=rev Author: aa1vs Date: 2011-07-14 00:02:17 +0000 (Thu, 14 Jul 2011) Log Message: ----------- Clean pendantic compiler warning. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2011-07-14 00:01:34 UTC (rev 846) +++ trunk/src/tle-update.c 2011-07-14 00:02:17 UTC (rev 847) @@ -123,6 +123,8 @@ guint total,total_tmp; gdouble fraction = 0.0; gdouble start = 0.0; + + (void) filter; /* avoid unused parameter compiler warning */ if (g_static_mutex_trylock(&tle_file_in_progress)==FALSE) { sat_log_log (SAT_LOG_LEVEL_ERROR, @@ -380,6 +382,7 @@ gsize length, written; GError *err = NULL; + (void) key; /* avoid unused parameter compiler warning */ /* check if sat is new */ if (ntle->isnew) { @@ -1100,7 +1103,7 @@ const gchar * tle_update_freq_to_str (tle_auto_upd_freq_t freq) { - if ((freq < TLE_AUTO_UPDATE_NEVER) || + if ((freq <= TLE_AUTO_UPDATE_NEVER) || (freq >= TLE_AUTO_UPDATE_NUM)) { freq = TLE_AUTO_UPDATE_NEVER; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-08-21 14:00:25
|
Revision: 890 http://gpredict.svn.sourceforge.net/gpredict/?rev=890&view=rev Author: aa1vs Date: 2011-08-21 14:00:19 +0000 (Sun, 21 Aug 2011) Log Message: ----------- Fix cut and paste error. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2011-08-21 13:43:29 UTC (rev 889) +++ trunk/src/tle-update.c 2011-08-21 14:00:19 UTC (rev 890) @@ -1063,6 +1063,9 @@ if (!g_regex_match_simple ("\\d{4,}-\\d{3,}",ntle->satname,0,0)) { if (g_regex_match_simple ("\\d{4,}-\\d{3,}",satname,0,0)) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Data for %d updated for name."), + __FUNCTION__, catnr); g_key_file_set_string (satdata, "Satellite", "NAME", ntle->satname); updateddata = TRUE; } @@ -1072,6 +1075,9 @@ /* clobber if nickname and name were same before */ /* clobber if international designator */ if (g_regex_match_simple ("\\d{4,}-\\d{3,}",satnickname,0,0)) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Data for %d updated for nickname."), + __FUNCTION__, catnr); g_key_file_set_string (satdata, "Satellite", "NICKNAME", ntle->satname); updateddata = TRUE; } @@ -1084,9 +1090,12 @@ if (tle.epoch < ntle->epoch) { /* new data is newer than what we already have */ /* store new data */ + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Data for %d updated for tle."), + __FUNCTION__, catnr); g_key_file_set_string (satdata, "Satellite", "TLE1", ntle->line1); g_key_file_set_string (satdata, "Satellite", "TLE2", ntle->line2); - updated = TRUE; + updateddata = TRUE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-09-24 12:02:36
|
Revision: 906 http://gpredict.svn.sourceforge.net/gpredict/?rev=906&view=rev Author: aa1vs Date: 2011-09-24 12:02:30 +0000 (Sat, 24 Sep 2011) Log Message: ----------- Fix another logic error in name merges. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2011-09-23 00:37:27 UTC (rev 905) +++ trunk/src/tle-update.c 2011-09-24 12:02:30 UTC (rev 906) @@ -1018,7 +1018,7 @@ } /* merge based on name */ - if ((!g_regex_match_simple ("\\d{4,}-\\d{3,}",ntle->satname,0,0)) && + if ((g_regex_match_simple ("\\d{4,}-\\d{3,}",ntle->satname,0,0)) && (!g_regex_match_simple ("\\d{4,}-\\d{3,}",tle_str[0],0,0))) { g_free (ntle->satname); ntle->satname = g_strdup (g_strchomp(tle_str[0])); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-10-09 13:36:19
|
Revision: 923 http://gpredict.svn.sourceforge.net/gpredict/?rev=923&view=rev Author: aa1vs Date: 2011-10-09 13:36:13 +0000 (Sun, 09 Oct 2011) Log Message: ----------- Eliminate compiler warning. Modified Paths: -------------- trunk/src/tle-update.c Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2011-10-09 13:34:42 UTC (rev 922) +++ trunk/src/tle-update.c 2011-10-09 13:36:13 UTC (rev 923) @@ -860,7 +860,7 @@ } /* set b to non-null as a flag */ - b = 1; + b = path; /* read lines from tle file */ while (fgets (linetmp, 80, fp)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |