int on_eof;
#ifdef _WIN32
int no_data_count;
- struct event_timeout * timeout;\r
- struct callback *timeout_callback;\r
+ struct event_timeout * timeout;
+ struct callback *timeout_callback;
#else
- enum file_type file_type;\r
- FILE *file;\r
- struct event_watch *watch;\r
+ enum file_type file_type;
+ FILE *file;
+ struct event_watch *watch;
#endif
speed_t baudrate;
struct attr ** attrs;
int valid;
};
-//***************************************************************************\r
-/** @fn static int vehicle_win32_serial_track(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Callback of the plugin\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @return always 1\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
#ifdef _WIN32
static int vehicle_win32_serial_track(struct vehicle_priv *priv)
{
static int current_index = 0;
const int chunk_size = 1024;
int rc = 0;
-\r
- dbg(1, "enter, *priv='%x', priv->source='%s'\n", priv, priv->source);\r
+
+ dbg(1, "enter, *priv='%x', priv->source='%s'\n", priv, priv->source);
if ( priv->no_data_count > 5 )
{
vehicle_file_close( priv );
priv->no_data_count = 0;
- vehicle_file_open( priv );\r
- vehicle_file_enable_watch(priv);\r
+ vehicle_file_open( priv );
+ vehicle_file_enable_watch(priv);
}
//if ( priv->fd <= 0 )
char return_buffer[1024];
int bytes_to_copy = return_pos - buffer + 1;
memcpy( return_buffer, buffer, bytes_to_copy );
- return_buffer[ bytes_to_copy + 1 ] = '\0';\r
- return_buffer[ bytes_to_copy ] = '\0';\r
+ return_buffer[ bytes_to_copy + 1 ] = '\0';
+ return_buffer[ bytes_to_copy ] = '\0';
// printf( "received %d : '%s' bytes to copy\n", bytes_to_copy, return_buffer );
rc += vehicle_file_parse( priv, return_buffer );
current_index -= bytes_to_copy;
memmove( buffer, &buffer[ bytes_to_copy ] , sizeof( buffer ) - bytes_to_copy );
}
- if (rc) {\r
+ if (rc) {
priv->no_data_count = 0;
callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
if (rc > 1)
- dbg(0, "Can not keep with gps data delay is %d seconds\n", rc - 1);\r
+ dbg(0, "Can not keep with gps data delay is %d seconds\n", rc - 1);
}
}
{
priv->no_data_count++;
}
- dbg(2, "leave, return '1', priv->no_data_count='%d'\n", priv->no_data_count);\r
+ dbg(2, "leave, return '1', priv->no_data_count='%d'\n", priv->no_data_count);
return 1;
}
#endif
-//***************************************************************************\r
-/** @fn static int vehicle_file_open(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: open dialogue with the GPS\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @return 1 if ok\r
-* 0 if error\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
static int
vehicle_file_open(struct vehicle_priv *priv)
{
priv->fd=serial_io_init( strport, strsettings );
}
- g_free( raw_setting_str );\r
-\r
- // Add the callback\r
- dbg(2, "Add the callback ...\n", priv->source);\r
- priv->timeout_callback=callback_new_1(callback_cast(vehicle_win32_serial_track), priv);\r
- }\r
+ g_free( raw_setting_str );
+
+ // Add the callback
+ dbg(2, "Add the callback ...\n", priv->source);
+ priv->timeout_callback=callback_new_1(callback_cast(vehicle_win32_serial_track), priv);
+ }
#else
char *name;
struct stat st;
priv->file_type = file_type_pipe;
}
#endif
- return(priv->fd != -1);\r
+ return(priv->fd != -1);
}
-//***************************************************************************\r
-/** @fn static void vehicle_file_close(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: close dialogue with the GPS\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
static void
vehicle_file_close(struct vehicle_priv *priv)
{
- dbg(1, "enter, priv->fd='%d'\n", priv->fd);\r
- vehicle_file_disable_watch(priv);\r
-#ifdef _WIN32\r
- if (priv->timeout_callback) {\r
- callback_destroy(priv->timeout_callback);\r
- priv->timeout_callback=NULL; // dangling pointer! prevent double freeing.\r
+ dbg(1, "enter, priv->fd='%d'\n", priv->fd);
+ vehicle_file_disable_watch(priv);
+#ifdef _WIN32
+ if (priv->timeout_callback) {
+ callback_destroy(priv->timeout_callback);
+ priv->timeout_callback=NULL; // dangling pointer! prevent double freeing.
}
serial_io_shutdown( priv->fd );
#else
pclose(priv->file);
else if (priv->fd >= 0)
close(priv->fd);
- priv->file = NULL;\r
+ priv->file = NULL;
#endif
priv->fd = -1;
}
-//***************************************************************************\r
-/** @fn static int vehicle_file_enable_watch_timer(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Enable watch timer to get GPS data\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @return always 0\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
static int
vehicle_file_enable_watch_timer(struct vehicle_priv *priv)
{
}
-//***************************************************************************\r
-/** @fn static int vehicle_file_parse( struct vehicle_priv *priv,\r
-* char *buffer)\r
-*****************************************************************************\r
-* @b Description: Parse the buffer\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-* @param buffer : data buffer (null terminated)\r
-*****************************************************************************\r
-* @return 1 if The GPRMC Sentence is found\r
-* 0 if not found\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
static int
vehicle_file_parse(struct vehicle_priv *priv, char *buffer)
{
}
if (buffer[len - 1] == '\r' || buffer[len - 1] == '\n') {
buffer[--len] = '\0';
- if (buffer[len - 1] == '\r')\r
- buffer[--len] = '\0';\r
- } else\r
+ if (buffer[len - 1] == '\r')
+ buffer[--len] = '\0';
+ } else
break;
}
if (buffer[0] != '$') {
if (!strcasecmp(item[5],"W"))
priv->geo.lng=-priv->geo.lng;
- priv->valid=attr_position_valid_valid;\r
- dbg(2, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng);\r
+ priv->valid=attr_position_valid_valid;
+ dbg(2, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng);
} else
priv->valid=attr_position_valid_invalid;
if (valid) {
priv->direction = g_ascii_strtod( item[1], NULL );
priv->speed = g_ascii_strtod( item[7], NULL );
- dbg(2,"direction %lf, speed %2.1lf\n", priv->direction, priv->speed);\r
+ dbg(2,"direction %lf, speed %2.1lf\n", priv->direction, priv->speed);
}
}
if (!strncmp(buffer, "$GPRMC", 6)) {
return ret;
}
-//***************************************************************************\r
-/** @fn static void vehicle_file_io(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: function to get data from GPS\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @remarks Not used on WIN32 operating system\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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 Not used on WIN32 operating system
+*****************************************************************************
+**/
static void
vehicle_file_io(struct vehicle_priv *priv)
{
- dbg(1, "vehicle_file_io : enter\n");\r
-#ifndef _WIN32\r
+ dbg(1, "vehicle_file_io : enter\n");
+#ifndef _WIN32
int size, rc = 0;
char *str, *tok;
}
if (rc)
callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
-#endif\r
+#endif
}
-//***************************************************************************\r
-/** @fn static void vehicle_file_enable_watch(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Enable watch\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
static void
vehicle_file_enable_watch(struct vehicle_priv *priv)
{
- dbg(1, "enter\n");\r
-#ifdef _WIN32\r
- // add an event : don't use glib timers and g_timeout_add\r
+ dbg(1, "enter\n");
+#ifdef _WIN32
+ // add an event : don't use glib timers and g_timeout_add
if (priv->timeout_callback != NULL)
- priv->timeout = event_add_timeout(500, 1, priv->timeout_callback);\r
+ priv->timeout = event_add_timeout(500, 1, priv->timeout_callback);
else
- dbg(1, "error : watch not enabled : priv->timeout_callback is null\n");\r
+ dbg(1, "error : watch not enabled : priv->timeout_callback is null\n");
#else
if (! priv->watch)
priv->watch = event_add_watch((void *)priv->fd, event_watch_cond_read, priv->cb);
#endif
}
-//***************************************************************************\r
-/** @fn static void vehicle_file_disable_watch(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Disable watch\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
static void
vehicle_file_disable_watch(struct vehicle_priv *priv)
{
- dbg(1, "vehicle_file_disable_watch : enter\n");\r
-#ifdef _WIN32\r
- if (priv->timeout) {\r
- event_remove_timeout(priv->timeout);\r
- priv->timeout=NULL; // dangling pointer! prevent double freeing.\r
- }\r
+ dbg(1, "vehicle_file_disable_watch : enter\n");
+#ifdef _WIN32
+ if (priv->timeout) {
+ event_remove_timeout(priv->timeout);
+ priv->timeout=NULL; // dangling pointer! prevent double freeing.
+ }
#else
if (priv->watch)
event_remove_watch(priv->watch);
#endif
}
-//***************************************************************************\r
-/** @fn static void vehicle_priv vehicle_file_destroy(struct vehicle_priv *priv)\r
-*****************************************************************************\r
-* @b Description: Function called to uninitialize the plugin\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @remarks private data is freed by this function (g_free)\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+* @remarks private data is freed by this function (g_free)
+*****************************************************************************
+**/
static void
vehicle_file_destroy(struct vehicle_priv *priv)
{
g_free(priv);
}
-//***************************************************************************\r
-/** @fn static int vehicle_file_position_attr_get(struct vehicle_priv *priv,\r
-* enum attr_type type,\r
-* struct attr *attr)\r
-*****************************************************************************\r
-* @b Description: Function called to get attribute\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-* @param type : attribute type called\r
-* @param attr : structure to return the attribute value\r
-*****************************************************************************\r
-* @return 1 if ok\r
-* 0 for unkown or invalid attribute\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
static int
vehicle_file_position_attr_get(struct vehicle_priv *priv,
enum attr_type type, struct attr *attr)
return 1;
}
-//***************************************************************************\r
-/** @fn static int vehicle_file_sat_attr_get(struct vehicle_priv *priv,\r
-* enum attr_type type,\r
-* struct attr *attr)\r
-*****************************************************************************\r
-* @b Description: Function called to get satellite attribute\r
-*****************************************************************************\r
-* @param priv : pointer on the private data of the plugin\r
-* @param type : attribute type called\r
-* @param attr : structure to return the attribute value\r
-*****************************************************************************\r
-* @return 1 if ok\r
-* 0 for unkown attribute\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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
+*****************************************************************************
+**/
static int
vehicle_file_sat_attr_get(void *priv_data, enum attr_type type, struct attr *attr)
{
vehicle_file_position_attr_get,
};
-//***************************************************************************\r
-/** @fn static struct vehicle_priv * vehicle_file_new_file(\r
-* struct vehicle_methods *meth,\r
-* struct callback_list *cbl,\r
-* struct attr **attrs)\r
-*****************************************************************************\r
-* @b Description: Function called to initialize the plugin\r
-*****************************************************************************\r
-* @param meth : ?\r
-* @param cbl : ?\r
-* @param attrs : ?\r
-*****************************************************************************\r
-* @return pointer on the private data of the plugin\r
-*****************************************************************************\r
-* @remarks private data is allocated by this function (g_new0)\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @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)
+*****************************************************************************
+**/
static struct vehicle_priv *
vehicle_file_new_file(struct vehicle_methods
*meth, struct callback_list
struct attr *baudrate;
struct attr *checksum_ignore;
- dbg(1, "enter\n");\r
+ dbg(1, "enter\n");
source = attr_search(attrs, NULL, attr_source);
if(source == NULL){
dbg(0,"Missing source attribute");
return NULL;
}
- ret = g_new0(struct vehicle_priv, 1); // allocate and initialize to 0\r
+ ret = g_new0(struct vehicle_priv, 1); // allocate and initialize to 0
ret->fd = -1;
ret->cbl = cbl;
ret->source = g_strdup(source->u.str);
ret->sat_item.id_hi=ret->sat_item.id_lo=0;
ret->sat_item.priv_data=ret;
ret->sat_item.meth=&vehicle_file_sat_methods;
-#ifdef _WIN32\r
- ret->no_data_count = 0;\r
-#endif\r
-\r
- dbg(1, "vehicle_file_new_file:open\n");\r
+#ifdef _WIN32
+ ret->no_data_count = 0;
+#endif
+
+ dbg(1, "vehicle_file_new_file:open\n");
if (!vehicle_file_open(ret)) {
- dbg(0, "Failed to open '%s'\n", ret->source);\r
+ dbg(0, "Failed to open '%s'\n", ret->source);
}
-\r
- vehicle_file_enable_watch(ret);\r
+
+ vehicle_file_enable_watch(ret);
// vehicle_file_destroy(ret);
- // return NULL;\r
- dbg(1, "leave\n");\r
- return ret;\r
+ // return NULL;
+ dbg(1, "leave\n");
+ return ret;
}
-//***************************************************************************\r
-/** @fn void plugin_init(void)\r
-*****************************************************************************\r
-* @b Description: Initialisation of vehicle_file plugin\r
-*****************************************************************************\r
-**/\r
+//***************************************************************************
+/** @fn void plugin_init(void)
+*****************************************************************************
+* @b Description: Initialisation of vehicle_file plugin
+*****************************************************************************
+**/
void plugin_init(void)
{
dbg(1, "vehicle_file:plugin_init:enter\n");