diff options
Diffstat (limited to 'navit/vehicle')
-rw-r--r-- | navit/vehicle/android/vehicle_android.c | 17 | ||||
-rw-r--r-- | navit/vehicle/demo/vehicle_demo.c | 12 | ||||
-rw-r--r-- | navit/vehicle/file/vehicle_file.c | 330 | ||||
-rw-r--r-- | navit/vehicle/gpsd/vehicle_gpsd.c | 14 | ||||
-rw-r--r-- | navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c | 10 | ||||
-rw-r--r-- | navit/vehicle/gypsy/vehicle_gypsy.c | 16 | ||||
-rw-r--r-- | navit/vehicle/iphone/vehicle_iphone.c | 10 | ||||
-rw-r--r-- | navit/vehicle/maemo/vehicle_maemo.c | 23 | ||||
-rw-r--r-- | navit/vehicle/null/vehicle_null.c | 10 | ||||
-rw-r--r-- | navit/vehicle/qt5/vehicle_qt5.cpp | 12 | ||||
-rw-r--r-- | navit/vehicle/webos/vehicle_webos.c | 10 | ||||
-rw-r--r-- | navit/vehicle/wince/vehicle_wince.c | 114 |
12 files changed, 388 insertions, 190 deletions
diff --git a/navit/vehicle/android/vehicle_android.c b/navit/vehicle/android/vehicle_android.c index 89882d048..4165b9b31 100644 --- a/navit/vehicle/android/vehicle_android.c +++ b/navit/vehicle/android/vehicle_android.c @@ -1,6 +1,4 @@ -/** @file vehicle_android.c - * @brief android uses dbus signals - * +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -18,8 +16,6 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * - * @Author Tim Niemeyer <reddog@mastersword.de> - * @date 2008-2009 */ #include <config.h> @@ -35,6 +31,15 @@ #include "android.h" #include "vehicle.h" +/** + * @defgroup vehicle-android Vehicle Android + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from android. Android uses dbus signals + * @author Tim Niemeyer <reddog@mastersword.de> + * @date 2008-2009 + * + */ + struct vehicle_priv { struct callback_list *cbl; struct coord_geo geo; /**< The last known position of the vehicle **/ @@ -294,3 +299,5 @@ plugin_init(void) dbg(lvl_debug, "enter\n"); plugin_register_category_vehicle("android", vehicle_android_new_android); } + +/** @} */ diff --git a/navit/vehicle/demo/vehicle_demo.c b/navit/vehicle/demo/vehicle_demo.c index 4a47c1476..1e2991300 100644 --- a/navit/vehicle/demo/vehicle_demo.c +++ b/navit/vehicle/demo/vehicle_demo.c @@ -1,4 +1,4 @@ -/** +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -34,6 +34,13 @@ #include "event.h" #include "util.h" +/** + * @defgroup vehicle-demo Vehicle Demo + * @ingroup vehicle-plugins + * @brief The Vehicle for a demo. It followes the route automatically + * + */ + struct vehicle_priv { int interval; int position_set; @@ -302,3 +309,6 @@ plugin_init(void) dbg(lvl_debug, "enter\n"); plugin_register_category_vehicle("demo", vehicle_demo_new); } + + +/** @} */ diff --git a/navit/vehicle/file/vehicle_file.c b/navit/vehicle/file/vehicle_file.c index 10bce942b..81b99f829 100644 --- a/navit/vehicle/file/vehicle_file.c +++ b/navit/vehicle/file/vehicle_file.c @@ -1,4 +1,4 @@ -/** +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -59,6 +59,14 @@ int inet_aton(const char *cp, struct in_addr *inp) } #endif +/** + * @defgroup vehicle-file Vehicle File + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from a file, pipe, serial interface or a socket + * + * @{ + */ + static void vehicle_file_disable_watch(struct vehicle_priv *priv); static void vehicle_file_enable_watch(struct vehicle_priv *priv); static int vehicle_file_parse(struct vehicle_priv *priv, char *buffer); @@ -84,7 +92,7 @@ struct vehicle_priv { char *source; struct callback_list *cbl; int fd; - struct callback *cb,*cbt; + struct callback *cb,*cbt,*cb_fix_timeout; char *buffer; int buffer_pos; char *nmea_data; @@ -114,6 +122,7 @@ struct vehicle_priv { enum file_type file_type; FILE *file; struct event_watch *watch; + struct event_timeout *ev_fix_timeout; speed_t baudrate; struct attr ** attrs; char fixiso8601[128]; @@ -129,16 +138,13 @@ struct vehicle_priv { int process_statefile; }; -//*************************************************************************** -/** @fn static int vehicle_win32_serial_track(struct vehicle_priv *priv) -***************************************************************************** -* @b Description: Callback of the plugin -***************************************************************************** -* @param priv : pointer on the private data of the plugin -***************************************************************************** -* @return always 1 -***************************************************************************** -**/ +/** +* @brief Callback of the plugin +* +* @param priv Pointer on the private data of the plugin +* +* @return Always 1 +*/ #ifdef _WIN32 static int vehicle_win32_serial_track(struct vehicle_priv *priv) { @@ -207,17 +213,13 @@ static int vehicle_win32_serial_track(struct vehicle_priv *priv) } #endif -//*************************************************************************** -/** @fn static int vehicle_file_open(struct vehicle_priv *priv) -***************************************************************************** -* @b Description: open dialogue with the GPS -***************************************************************************** -* @param priv : pointer on the private data of the plugin -***************************************************************************** -* @return 1 if ok -* 0 if error -***************************************************************************** -**/ +/** +* @brief Open dialogue with the GPS +* +* @param priv Pointer on the private data of the plugin +* +* @return 1 if ok, 0 if error +*/ static int vehicle_file_open(struct vehicle_priv *priv) { @@ -318,14 +320,11 @@ vehicle_file_open(struct vehicle_priv *priv) return(priv->fd != -1); } -//*************************************************************************** -/** @fn static void vehicle_file_close(struct vehicle_priv *priv) -***************************************************************************** -* @b Description: close dialogue with the GPS -***************************************************************************** -* @param priv : pointer on the private data of the plugin -***************************************************************************** -**/ +/** +* @brief Close dialogue with the GPS +* +* @param priv Pointer on the private data of the plugin +*/ static void vehicle_file_close(struct vehicle_priv *priv) { @@ -356,16 +355,13 @@ vehicle_file_close(struct vehicle_priv *priv) } } -//*************************************************************************** -/** @fn static int vehicle_file_enable_watch_timer(struct vehicle_priv *priv) -***************************************************************************** -* @b Description: Enable watch timer to get GPS data -***************************************************************************** -* @param priv : pointer on the private data of the plugin -***************************************************************************** -* @return always 0 -***************************************************************************** -**/ +/** +* @brief Enable watch timer to get GPS data +* +* @param priv Pointer on the private data of the plugin +* +* @return Always 0 +*/ static int vehicle_file_enable_watch_timer(struct vehicle_priv *priv) { @@ -376,19 +372,44 @@ vehicle_file_enable_watch_timer(struct vehicle_priv *priv) } -//*************************************************************************** -/** @fn static int vehicle_file_parse( struct vehicle_priv *priv, -* char *buffer) -***************************************************************************** -* @b Description: Parse the buffer -***************************************************************************** -* @param priv : pointer on the private data of the plugin -* @param buffer : data buffer (null terminated) -***************************************************************************** -* @return 1 if The GPRMC Sentence is found -* 0 if not found -***************************************************************************** -**/ +/** +* @brief This is a callback function, called when the fix timeout +* is done. Set the position to invalid. +* +* @param priv Pointer on the private data of the plugin +*/ +static void +vehicle_file_fix_timeout_cb(struct vehicle_priv *priv) +{ + priv->valid = attr_position_valid_invalid; + priv->ev_fix_timeout = NULL; + callback_list_call_attr_0(priv->cbl, attr_position_coord_geo); +} + + +/** +* @brief Cancel previous fix timeout event and add a new one +* +* @param priv Pointer on the private data of the plugin +*/ +static void +vehicle_file_restart_fix_timeout(struct vehicle_priv *priv) +{ + if (priv->ev_fix_timeout != NULL) + event_remove_timeout(priv->ev_fix_timeout); + priv->ev_fix_timeout = event_add_timeout(10000, 0, priv->cb_fix_timeout); +} + + +/** +* @brief Parse the buffer +* +* @param priv Pointer on the private data of the plugin +* @param buffer Data buffer (null terminated) +* +* @return 1 if new coords were received (fixtime changed) or changed to invalid, +* 0 if not found +*/ static int vehicle_file_parse(struct vehicle_priv *priv, char *buffer) { @@ -458,7 +479,7 @@ vehicle_file_parse(struct vehicle_priv *priv, char *buffer) UTC of Fix[1],Latitude[2],N/S[3],Longitude[4],E/W[5],Quality(0=inv,1=gps,2=dgps)[6],Satelites used[7], HDOP[8],Altitude[9],"M"[10],height of geoid[11], "M"[12], time since dgps update[13], dgps ref station [14] */ - if (*item[2] && *item[3] && *item[4] && *item[5]) { + if (*item[2] && *item[3] && *item[4] && *item[5] && *item[6] > 0) { lat = g_ascii_strtod(item[2], NULL); priv->geo.lat = floor(lat / 100); lat -= priv->geo.lat * 100; @@ -474,20 +495,31 @@ vehicle_file_parse(struct vehicle_priv *priv, char *buffer) if (!g_ascii_strcasecmp(item[5],"W")) priv->geo.lng=-priv->geo.lng; - priv->valid=attr_position_valid_valid; + + if (priv->valid == attr_position_valid_invalid) + ret = 1; + priv->valid = attr_position_valid_valid; + vehicle_file_restart_fix_timeout(priv); + + if (*item[1] && strncmp(priv->fixtime, item[1], sizeof(priv->fixtime))) { + ret = 1; + strncpy(priv->fixtime, item[1], sizeof(priv->fixtime)); + } dbg(lvl_info, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng); - } else + } else { + if (priv->valid == attr_position_valid_valid) + ret = 1; priv->valid=attr_position_valid_invalid; + } + if (*item[6]) sscanf(item[6], "%d", &priv->status); if (*item[7]) sscanf(item[7], "%d", &priv->sats_used); if (*item[8]) sscanf(item[8], "%lf", &priv->hdop); - if (*item[1]) - strncpy(priv->fixtime, item[1], sizeof(priv->fixtime)); if (*item[9]) sscanf(item[9], "%lf", &priv->height); @@ -537,8 +569,40 @@ vehicle_file_parse(struct vehicle_priv *priv, char *buffer) &priv->fixmonth, &priv->fixyear); priv->fixyear += 2000; + + lat = g_ascii_strtod(item[3], NULL); + priv->geo.lat = floor(lat / 100); + lat -= priv->geo.lat * 100; + priv->geo.lat += lat / 60; + + if (!g_ascii_strcasecmp(item[4],"S")) + priv->geo.lat=-priv->geo.lat; + + lng = g_ascii_strtod(item[5], NULL); + priv->geo.lng = floor(lng / 100); + lng -= priv->geo.lng * 100; + priv->geo.lng += lng / 60; + + if (!g_ascii_strcasecmp(item[6],"W")) + priv->geo.lng=-priv->geo.lng; + + if (priv->valid == attr_position_valid_invalid) + ret = 1; + priv->valid=attr_position_valid_valid; + vehicle_file_restart_fix_timeout(priv); + + if (*item[1] && strncmp(priv->fixtime, item[1], sizeof(priv->fixtime))) { + ret = 1; + strncpy(priv->fixtime, item[1], sizeof(priv->fixtime)); + } + + dbg(lvl_info, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng); + + } else { + if (priv->valid == attr_position_valid_valid) + ret = 1; + priv->valid=attr_position_valid_invalid; } - ret = 1; } if (!strncmp(buffer, "$GPGSV", 6) && i >= 4) { /* @@ -610,16 +674,11 @@ vehicle_file_parse(struct vehicle_priv *priv, char *buffer) return ret; } -//*************************************************************************** -/** @fn static void vehicle_file_io(struct vehicle_priv *priv) -***************************************************************************** -* @b Description: function to get data from GPS -***************************************************************************** -* @param priv : pointer on the private data of the plugin -***************************************************************************** -* @remarks -***************************************************************************** -**/ +/** +* @brief Function to get data from GPS +* +* @param priv Pointer on the private data of the plugin +*/ static void vehicle_file_io(struct vehicle_priv *priv) { @@ -685,14 +744,11 @@ vehicle_file_io(struct vehicle_priv *priv) callback_list_call_attr_0(priv->cbl, attr_position_coord_geo); } -//*************************************************************************** -/** @fn static void vehicle_file_enable_watch(struct vehicle_priv *priv) -***************************************************************************** -* @b Description: Enable watch -***************************************************************************** -* @param priv : pointer on the private data of the plugin -***************************************************************************** -**/ +/** +* @brief Enable watch +* +* @param priv Pointer on the private data of the plugin +*/ static void vehicle_file_enable_watch(struct vehicle_priv *priv) { @@ -713,14 +769,11 @@ vehicle_file_enable_watch(struct vehicle_priv *priv) } } -//*************************************************************************** -/** @fn static void vehicle_file_disable_watch(struct vehicle_priv *priv) -***************************************************************************** -* @b Description: Disable watch -***************************************************************************** -* @param priv : pointer on the private data of the plugin -***************************************************************************** -**/ +/** +* @brief Disable watch +* +* @param priv Pointer on the private data of the plugin +*/ static void vehicle_file_disable_watch(struct vehicle_priv *priv) { @@ -742,16 +795,13 @@ vehicle_file_disable_watch(struct vehicle_priv *priv) } } -//*************************************************************************** -/** @fn static void vehicle_priv vehicle_file_destroy(struct vehicle_priv *priv) -***************************************************************************** -* @b Description: Function called to uninitialize the plugin -***************************************************************************** -* @param priv : pointer on the private data of the plugin -***************************************************************************** +/** +* @brief Function called to uninitialize the plugin +* +* @param priv Pointer on the private data of the plugin +* * @remarks private data is freed by this function (g_free) -***************************************************************************** -**/ +*/ static void vehicle_file_destroy(struct vehicle_priv *priv) { @@ -781,21 +831,15 @@ vehicle_file_destroy(struct vehicle_priv *priv) g_free(priv); } -//*************************************************************************** -/** @fn static int vehicle_file_position_attr_get(struct vehicle_priv *priv, -* enum attr_type type, -* struct attr *attr) -***************************************************************************** -* @b Description: Function called to get attribute -***************************************************************************** -* @param priv : pointer on the private data of the plugin -* @param type : attribute type called -* @param attr : structure to return the attribute value -***************************************************************************** -* @return 1 if ok -* 0 for unkown or invalid attribute -***************************************************************************** -**/ +/** +* @brief Function called to get attribute +* +* @param priv Pointer on the private data of the plugin +* @param type Attribute type called +* @param attr Structure to return the attribute value +* +* @return 1 if ok, 0 for unkown or invalid attribute +*/ static int vehicle_file_position_attr_get(struct vehicle_priv *priv, enum attr_type type, struct attr *attr) @@ -865,21 +909,15 @@ vehicle_file_position_attr_get(struct vehicle_priv *priv, return 1; } -//*************************************************************************** -/** @fn static int vehicle_file_sat_attr_get(struct vehicle_priv *priv, -* enum attr_type type, -* struct attr *attr) -***************************************************************************** -* @b Description: Function called to get satellite attribute -***************************************************************************** -* @param priv : pointer on the private data of the plugin -* @param type : attribute type called -* @param attr : structure to return the attribute value -***************************************************************************** -* @return 1 if ok -* 0 for unkown attribute -***************************************************************************** -**/ +/** +* @brief Function called to get satellite attribute +* +* @param priv Pointer on the private data of the plugin +* @param type Attribute type called +* @param attr Structure to return the attribute value +* +* @return 1 if ok, 0 for unkown attribute +*/ static int vehicle_file_sat_attr_get(void *priv_data, enum attr_type type, struct attr *attr) { @@ -922,23 +960,17 @@ static struct vehicle_methods vehicle_file_methods = { vehicle_file_position_attr_get, }; -//*************************************************************************** -/** @fn static struct vehicle_priv * vehicle_file_new_file( -* struct vehicle_methods *meth, -* struct callback_list *cbl, -* struct attr **attrs) -***************************************************************************** -* @b Description: Function called to initialize the plugin -***************************************************************************** -* @param meth : ? -* @param cbl : ? -* @param attrs : ? -***************************************************************************** -* @return pointer on the private data of the plugin -***************************************************************************** -* @remarks private data is allocated by this function (g_new0) -***************************************************************************** -**/ +/** +* @brief Function called to initialize the plugin +* +* @param meth ? +* @param cbl ? +* @param attrs ? +* +* @return Pointer on the private data of the plugin +* +* @remarks Private data is allocated by this function (g_new0) +*/ static struct vehicle_priv * vehicle_file_new_file(struct vehicle_methods *meth, struct callback_list @@ -958,7 +990,7 @@ vehicle_file_new_file(struct vehicle_methods if(source == NULL){ dbg(lvl_error,"Missing source attribute"); return NULL; - } + } ret = g_new0(struct vehicle_priv, 1); // allocate and initialize to 0 ret->fd = -1; ret->cbl = cbl; @@ -966,6 +998,8 @@ vehicle_file_new_file(struct vehicle_methods ret->buffer = g_malloc(buffer_size); ret->time=1000; ret->baudrate=B4800; + ret->fixtime[0] = '\0'; + ret->ev_fix_timeout = NULL; state_file=attr_search(attrs, NULL, attr_state_file); if (state_file) ret->statefile=g_strdup(state_file->u.str); @@ -1014,6 +1048,7 @@ vehicle_file_new_file(struct vehicle_methods *meth = vehicle_file_methods; ret->cb=callback_new_1(callback_cast(vehicle_file_io), ret); ret->cbt=callback_new_1(callback_cast(vehicle_file_enable_watch_timer), ret); + ret->cb_fix_timeout=callback_new_1(callback_cast(vehicle_file_fix_timeout_cb), ret); if (ret->statefile && file_exists(ret->statefile)) { ret->process_statefile=1; event_add_timeout(1000, 0, ret->cb); @@ -1038,12 +1073,9 @@ vehicle_file_new_file(struct vehicle_methods return ret; } -//*************************************************************************** -/** @fn void plugin_init(void) -***************************************************************************** -* @b Description: Initialisation of vehicle_file plugin -***************************************************************************** -**/ +/** +* @brief Initialisation of vehicle_file plugin +*/ void plugin_init(void) { dbg(lvl_debug, "vehicle_file:plugin_init:enter\n"); diff --git a/navit/vehicle/gpsd/vehicle_gpsd.c b/navit/vehicle/gpsd/vehicle_gpsd.c index a8c29cd97..975d9c68a 100644 --- a/navit/vehicle/gpsd/vehicle_gpsd.c +++ b/navit/vehicle/gpsd/vehicle_gpsd.c @@ -1,4 +1,4 @@ -/** +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -35,6 +35,14 @@ #include "event.h" #include "types.h" +/** + * @defgroup vehicle-gpsd Vehicle Gpsd + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from the gpsd service + * + * @{ + */ + static struct vehicle_priv { char *source; char *gpsd_query; @@ -101,13 +109,15 @@ vehicle_gpsd_callback(struct gps_data_t *data, const char *buf, size_t len, } } } + dbg(lvl_debug,"data->set="LONGLONG_HEX_FMT"\n", (unsigned long long)data->set); if (data->set & SPEED_SET) { - priv->speed = data->fix.speed * 3.6; + priv->speed = data->fix.speed * MPS_TO_KPH; if(!isnan(data->fix.speed)) callback_list_call_attr_0(priv->cbl, attr_position_speed); data->set &= ~SPEED_SET; } + if (data->set & TRACK_SET) { priv->direction = data->fix.track; data->set &= ~TRACK_SET; diff --git a/navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c b/navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c index fa5eb8780..ebdf08707 100644 --- a/navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c +++ b/navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c @@ -1,4 +1,4 @@ -/** +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -34,6 +34,14 @@ #include "vehicle.h" #include "event.h" +/** + * @defgroup vehicle-gpsd-dbus Vehicle Gpsd DBus + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from Gpsd over DBus + * + * @{ + */ + static char *vehicle_gpsd_dbus_prefix="gpsd_dbus:"; struct vehicle_priv { diff --git a/navit/vehicle/gypsy/vehicle_gypsy.c b/navit/vehicle/gypsy/vehicle_gypsy.c index 589e53a3f..16175f2e8 100644 --- a/navit/vehicle/gypsy/vehicle_gypsy.c +++ b/navit/vehicle/gypsy/vehicle_gypsy.c @@ -1,6 +1,4 @@ -/** @file vehicle_gypsy.c - * @brief gypsy uses dbus signals - * +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -18,8 +16,6 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * - * @Author Tim Niemeyer <reddog@mastersword.de> - * @date 2008-2009 */ #include <config.h> @@ -47,6 +43,16 @@ #include "item.h" #include "vehicle.h" +/** + * @defgroup vehicle-gypsy Vehicle gypsy + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from gypsy. gypsy uses dbus signals + * @Author Tim Niemeyer <reddog@mastersword.de> + * @date 2008-2009 + * + * @{ + */ + static struct vehicle_priv { char *source; GypsyControl *control; diff --git a/navit/vehicle/iphone/vehicle_iphone.c b/navit/vehicle/iphone/vehicle_iphone.c index 94fec114a..f8ce5b644 100644 --- a/navit/vehicle/iphone/vehicle_iphone.c +++ b/navit/vehicle/iphone/vehicle_iphone.c @@ -1,4 +1,4 @@ -/** +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -33,6 +33,14 @@ #include "event.h" #include "corelocation.h" +/** + * @defgroup vehicle-iphone Vehicle iPhone + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from iPhone. + * + * @{ + */ + struct vehicle_priv { int interval; int position_set; diff --git a/navit/vehicle/maemo/vehicle_maemo.c b/navit/vehicle/maemo/vehicle_maemo.c index d686a6a03..015f1c8e3 100644 --- a/navit/vehicle/maemo/vehicle_maemo.c +++ b/navit/vehicle/maemo/vehicle_maemo.c @@ -1,4 +1,4 @@ -/** +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -18,14 +18,6 @@ */ -/* - Plugin for new Maemo's liblocation API. - - <vehicle source="maemo://any" retry_interval="1"/> - source cound be on of "any","cwp","acwp","gnss","agnss" - retry_interval could be one of "1","2","5","10","20","30","60","120" measured in seconds -*/ - #include <config.h> #include <string.h> #include <glib.h> @@ -40,6 +32,19 @@ #include "vehicle.h" #include "event.h" +/** + * @defgroup vehicle-iphone Vehicle Maemo + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from Maemo. + * + * Plugin for new Maemo's liblocation API. + * <vehicle source="maemo://any" retry_interval="1"/> + * source cound be on of "any","cwp","acwp","gnss","agnss" + * retry_interval could be one of "1","2","5","10","20","30","60","120" measured in seconds + * + * @{ + */ + static struct vehicle_priv { LocationGPSDControl *control; LocationGPSDevice *device; diff --git a/navit/vehicle/null/vehicle_null.c b/navit/vehicle/null/vehicle_null.c index 643945c71..6b723f9ff 100644 --- a/navit/vehicle/null/vehicle_null.c +++ b/navit/vehicle/null/vehicle_null.c @@ -1,4 +1,4 @@ -/** @file vehicle_null.c +/* * @brief null uses dbus signals * * Navit, a modular navigation system. @@ -34,6 +34,14 @@ #include "item.h" #include "vehicle.h" +/** + * @defgroup vehicle-null Vehicle Null + * @ingroup vehicle-plugins + * @brief A dummy Vehicle to have a null movement. + * + * @{ + */ + struct vehicle_priv { struct callback_list *cbl; struct coord_geo geo; diff --git a/navit/vehicle/qt5/vehicle_qt5.cpp b/navit/vehicle/qt5/vehicle_qt5.cpp index 2a2b6f5cf..fc8a6635a 100644 --- a/navit/vehicle/qt5/vehicle_qt5.cpp +++ b/navit/vehicle/qt5/vehicle_qt5.cpp @@ -1,5 +1,4 @@ -/** @file vehicle_null.c - * @brief null uses dbus signals +/* * * Navit, a modular navigation system. * Copyright (C) 2005-2017 Navit Team @@ -41,6 +40,15 @@ extern "C" { #include "vehicle_qt5.h" #include "vehicle_qt5.moc" #include <QDateTime> + +/** + * @defgroup vehicle-qt5 Vehicle QT5 + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from qt5 + * + * @{ + */ + QNavitGeoReceiver::QNavitGeoReceiver(QObject* parent, struct vehicle_priv* c) : QObject(parent) { diff --git a/navit/vehicle/webos/vehicle_webos.c b/navit/vehicle/webos/vehicle_webos.c index a5bba4bce..c4bdcbaf2 100644 --- a/navit/vehicle/webos/vehicle_webos.c +++ b/navit/vehicle/webos/vehicle_webos.c @@ -1,4 +1,4 @@ -/** +/* * vim: sw=3 ts=3 * * Navit, a modular navigation system. @@ -37,6 +37,14 @@ #include "vehicle_webos.h" #include "bluetooth.h" +/** + * @defgroup vehicle-webos Vehicle WebOS + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from WebOS + * + * @{ + */ + static char *vehicle_webos_prefix="webos:"; /*******************************************************************/ diff --git a/navit/vehicle/wince/vehicle_wince.c b/navit/vehicle/wince/vehicle_wince.c index d43c516f7..49f90b1f5 100644 --- a/navit/vehicle/wince/vehicle_wince.c +++ b/navit/vehicle/wince/vehicle_wince.c @@ -1,4 +1,4 @@ -/** +/* * Navit, a modular navigation system. * Copyright (C) 2005-2008 Navit Team * @@ -44,6 +44,14 @@ #include <wchar.h> #include "support/win32/ConvertUTF.h" +/** + * @defgroup vehicle-wince Vehicle WinCE + * @ingroup vehicle-plugins + * @brief The Vehicle to gain position data from WinCE + * + * @{ + */ + #define SwitchToThread() Sleep(0) typedef int (WINAPI *PFN_BthSetMode)(DWORD pBthMode); @@ -83,6 +91,8 @@ struct vehicle_priv { char *source; struct callback_list *cbl; struct callback_list *priv_cbl; + struct callback *cb_fix_timeout; + struct event_timeout *ev_fix_timeout; int is_running; int thread_up; int fd; @@ -365,6 +375,36 @@ vehicle_wince_available_ports(void) } +/** +* @brief This is a callback function, called when the fix timeout +* is done. Set the position to invalid. +* +* @param priv Pointer on the private data of the plugin +*/ +static void +vehicle_wince_fix_timeout_cb(struct vehicle_priv *priv) +{ + priv->valid = attr_position_valid_invalid; + priv->ev_fix_timeout = NULL; + callback_list_call_attr_0(priv->cbl, attr_position_coord_geo); +} + + +/** +* @brief Cancel previous fix timeout event and add a new one +* +* @param priv Pointer on the private data of the plugin +*/ +static void +vehicle_wince_restart_fix_timeout(struct vehicle_priv *priv) +{ + if (priv->ev_fix_timeout != NULL) + event_remove_timeout(priv->ev_fix_timeout); + priv->ev_fix_timeout = event_add_timeout(10000, 0, priv->cb_fix_timeout); +} + + + static int vehicle_wince_open(struct vehicle_priv *priv) { @@ -474,7 +514,7 @@ vehicle_wince_parse(struct vehicle_priv *priv, char *buffer) UTC of Fix[1],Latitude[2],N/S[3],Longitude[4],E/W[5],Quality(0=inv,1=gps,2=dgps)[6],Satelites used[7], HDOP[8],Altitude[9],"M"[10],height of geoid[11], "M"[12], time since dgps update[13], dgps ref station [14] */ - if (*item[2] && *item[3] && *item[4] && *item[5]) { + if (*item[2] && *item[3] && *item[4] && *item[5] && *item[6] > 0) { lat = g_ascii_strtod(item[2], NULL); priv->geo.lat = floor(lat / 100); lat -= priv->geo.lat * 100; @@ -490,20 +530,31 @@ vehicle_wince_parse(struct vehicle_priv *priv, char *buffer) if (!g_strcasecmp(item[5],"W")) priv->geo.lng=-priv->geo.lng; - priv->valid=attr_position_valid_valid; + + if (priv->valid == attr_position_valid_invalid) + ret = 1; + priv->valid = attr_position_valid_valid; + vehicle_wince_restart_fix_timeout(priv); + + if (*item[1] && strncmp(priv->fixtime, item[1], sizeof(priv->fixtime))) { + ret = 1; + strncpy(priv->fixtime, item[1], sizeof(priv->fixtime)); + } dbg(lvl_info, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng); - } else + } else { + if (priv->valid == attr_position_valid_valid) + ret = 1; priv->valid=attr_position_valid_invalid; + } + if (*item[6]) sscanf(item[6], "%d", &priv->status); if (*item[7]) - sscanf(item[7], "%d", &priv->sats_used); + sscanf(item[7], "%d", &priv->sats_used); if (*item[8]) sscanf(item[8], "%lf", &priv->hdop); - if (*item[1]) - strncpy(priv->fixtime, item[1], sizeof(priv->fixtime)); if (*item[9]) sscanf(item[9], "%lf", &priv->height); @@ -547,8 +598,40 @@ vehicle_wince_parse(struct vehicle_priv *priv, char *buffer) &priv->fixmonth, &priv->fixyear); priv->fixyear += 2000; + + lat = g_ascii_strtod(item[3], NULL); + priv->geo.lat = floor(lat / 100); + lat -= priv->geo.lat * 100; + priv->geo.lat += lat / 60; + + if (!g_ascii_strcasecmp(item[4],"S")) + priv->geo.lat=-priv->geo.lat; + + lng = g_ascii_strtod(item[5], NULL); + priv->geo.lng = floor(lng / 100); + lng -= priv->geo.lng * 100; + priv->geo.lng += lng / 60; + + if (!g_ascii_strcasecmp(item[6],"W")) + priv->geo.lng=-priv->geo.lng; + + if (priv->valid == attr_position_valid_invalid) + ret = 1; + priv->valid=attr_position_valid_valid; + vehicle_wince_restart_fix_timeout(priv); + + if (*item[1] && strncmp(priv->fixtime, item[1], sizeof(priv->fixtime))) { + ret = 1; + strncpy(priv->fixtime, item[1], sizeof(priv->fixtime)); + } + + dbg(lvl_info, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng); + + } else { + if (priv->valid == attr_position_valid_valid) + ret = 1; + priv->valid=attr_position_valid_invalid; } - ret = 1; } if (!strncmp(buffer, "$GPGSV", 6) && i >= 4) { /* @@ -741,7 +824,8 @@ vehicle_wince_destroy(struct vehicle_priv *priv) * @param priv vehicle_priv structure for the vehicle * @param type The attribute type to retrieve * @param attr Points to an attr structure that will receive the attribute data - * @returns True for success, false for failure + * + * @return True for success, false for failure */ static int vehicle_wince_position_attr_get(struct vehicle_priv *priv, @@ -863,10 +947,11 @@ struct vehicle_methods vehicle_wince_methods = { /** * @brief Creates a new wince_vehicle * - * @param meth - * @param cbl - * @param attrs - * @returns vehicle_priv + * @param meth ? + * @param cbl ? + * @param attrs ? + * + * @return vehicle_priv */ static struct vehicle_priv * vehicle_wince_new(struct vehicle_methods @@ -902,6 +987,8 @@ vehicle_wince_new(struct vehicle_methods ret->buffer = g_malloc(buffer_size); ret->time=1000; ret->baudrate=0; // do not change the rate if not configured + ret->fixtime[0] = '\0'; + ret->ev_fix_timeout = NULL; time = attr_search(attrs, NULL, attr_time); if (time) @@ -923,6 +1010,7 @@ vehicle_wince_new(struct vehicle_methods *meth = vehicle_wince_methods; ret->priv_cbl = callback_list_new(); callback_list_add(ret->priv_cbl, callback_new_1(callback_cast(vehicle_wince_io), ret)); + ret->cb_fix_timeout=callback_new_1(callback_cast(vehicle_wince_fix_timeout_cb), ret); ret->sat_item.type=type_position_sat; ret->sat_item.id_hi=ret->sat_item.id_lo=0; ret->sat_item.priv_data=ret; |