Fix:core: Fix for vehicles not routing until position is set with the GUI. |
authorsteven_s <steven_s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 1 Nov 2008 02:48:32 +0000 (02:48 +0000)
committersteven_s <steven_s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 1 Nov 2008 02:48:32 +0000 (02:48 +0000)
If navit was started before the gps daemon was running vehicle_gpsd would
report the vehicle as active=0 so navit->vehcile would be null.
We now report the active status based on the attribute value not the
current status of the gps link.
Same applies to vehicle_file and vehicle_gypsy

git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@1626 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/vehicle/file/vehicle_file.c
navit/vehicle/gpsd/vehicle_gpsd.c
navit/vehicle/gypsy/vehicle_gypsy.c

index 6b124d7..43859c1 100644 (file)
@@ -75,6 +75,7 @@ struct vehicle_priv {
        int no_data_count;
 #endif
        speed_t baudrate;
+       struct attr ** attrs;
 };
 
 #ifdef _WIN32
@@ -438,6 +439,8 @@ static int
 vehicle_file_position_attr_get(struct vehicle_priv *priv,
                               enum attr_type type, struct attr *attr)
 {
+       struct attr * active=NULL;
+
        switch (type) {
        case attr_position_height:
                attr->u.numd = &priv->height;
@@ -460,11 +463,11 @@ vehicle_file_position_attr_get(struct vehicle_priv *priv,
                        return 0;
                break;
        case attr_active:
-              if(priv->watch)
-                attr->u.num=1;
-              else
-                attr->u.num=0;
-         break;
+                 if(active != NULL && active->u.num == 1)
+                   return 1;
+                 else
+                   return 0;
+                 break;
        default:
                return 0;
        }
@@ -513,6 +516,7 @@ vehicle_file_new_file(struct vehicle_methods
 #endif
                }
        }
+       ret->attrs = attrs;
        on_eof = attr_search(attrs, NULL, attr_on_eof);
        if (on_eof && !strcasecmp(on_eof->u.str, "stop"))
                ret->on_eof=1;
index 4e972d0..2cb661f 100644 (file)
@@ -47,6 +47,7 @@ static struct vehicle_priv {
        char *nmea_data;
         char *nmea_data_buf;
        guint retry_timer;
+       struct attr ** attrs;
 } *vehicle_last;
 
 #define DEFAULT_RETRY_INTERVAL 10 // seconds
@@ -224,6 +225,7 @@ static int
 vehicle_gpsd_position_attr_get(struct vehicle_priv *priv,
                               enum attr_type type, struct attr *attr)
 {
+       struct attr * active=NULL;
        switch (type) {
        case attr_position_height:
                attr->u.numd = &priv->height;
@@ -249,10 +251,11 @@ vehicle_gpsd_position_attr_get(struct vehicle_priv *priv,
                        return 0;
                break;
        case attr_active:
-              if ( priv->watch)
-                attr->u.num=1;
-              else
-                attr->u.num=0;
+         active = attr_search(priv->attrs,NULL,attr_active);
+         if(active != NULL && active->u.num == 1)
+           return 1;
+         else
+           return 0;
               break;
        default:
                return 0;
@@ -298,6 +301,7 @@ vehicle_gpsd_new_gpsd(struct vehicle_methods
        }
        ret->cbl = cbl;
        *meth = vehicle_gpsd_methods;
+       ret->attrs = attrs;
        vehicle_gpsd_open(ret);
        return ret;
 }
index fa7250a..0abd193 100644 (file)
@@ -51,6 +51,7 @@ static struct vehicle_priv {
        int sats;
        int sats_used;
        guint retry_timer;
+       struct attr ** attrs;
 } *vehicle_last;
 
 #define DEFAULT_RETRY_INTERVAL 10 // seconds
@@ -246,6 +247,7 @@ static int
 vehicle_gypsy_position_attr_get(struct vehicle_priv *priv,
                               enum attr_type type, struct attr *attr)
 {
+       struct attr * active=NULL;
        switch (type) {
        case attr_position_height:
                attr->u.numd = &priv->height;
@@ -265,6 +267,14 @@ vehicle_gypsy_position_attr_get(struct vehicle_priv *priv,
        case attr_position_coord_geo:
                attr->u.coord_geo = &priv->geo;
                break;
+       case attr_active:
+         active = attr_search(priv->attrs,NULL,attr_active);
+         if(active != NULL && active->u.num == 1)
+           return 1;
+         else
+           return 0;
+              break;
+
        default:
                return 0;
        }
@@ -289,6 +299,7 @@ vehicle_gypsy_new_gypsy(struct vehicle_methods
        source = attr_search(attrs, NULL, attr_source);
        ret = g_new0(struct vehicle_priv, 1);
        ret->source = g_strdup(source->u.str);
+       ret->attrs = attrs;
        retry_int = attr_search(attrs, NULL, attr_retry_interval);
        if (retry_int) {
                ret->retry_interval = retry_int->u.num;