#include "icons/icons.h"
#include "babel.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
-#include <glib.h>
+#include <glib/gstdio.h>
#include <glib/gprintf.h>
#include <glib/gi18n.h>
#ifdef VIK_CONFIG_REALTIME_GPS_TRACKING
static void vik_gps_layer_realize ( VikGpsLayer *val, VikTreeview *vt, GtkTreeIter *layer_iter );
static void vik_gps_layer_free ( VikGpsLayer *val );
static void vik_gps_layer_draw ( VikGpsLayer *val, gpointer data );
-VikGpsLayer *vik_gps_layer_new ();
+static VikGpsLayer *vik_gps_layer_new ( VikViewport *vp );
static void gps_layer_marshall( VikGpsLayer *val, guint8 **data, gint *len );
static VikGpsLayer *gps_layer_unmarshall( guint8 *data, gint len, VikViewport *vvp );
#else
static gchar * params_ports[] = {"/dev/ttyS0", "/dev/ttyS1", "/dev/ttyUSB0", "/dev/ttyUSB1", "usb:", NULL};
#endif
-#define NUM_PORTS (sizeof(params_ports)/sizeof(params_ports[0]) - 1)
+/* NUM_PORTS not actually used */
+/* #define NUM_PORTS (sizeof(params_ports)/sizeof(params_ports[0]) - 1) */
/* Compatibility with previous versions */
#ifdef WINDOWS
static gchar * old_params_ports[] = {"com1", "usb:", NULL};
params_groups,
sizeof(params_groups)/sizeof(params_groups[0]),
- VIK_MENU_ITEM_ALL & ~(VIK_MENU_ITEM_CUT|VIK_MENU_ITEM_COPY),
+ VIK_MENU_ITEM_ALL,
(VikLayerFuncCreate) vik_gps_layer_create,
(VikLayerFuncRealize) vik_gps_layer_realize,
len -= sizeof(gint) + alm_size; \
data += sizeof(gint) + alm_size;
- VikGpsLayer *rv = vik_gps_layer_new();
+ VikGpsLayer *rv = vik_gps_layer_new(vvp);
VikLayer *child_layer;
gint i;
vgl->protocol_id = 0;
vgl->serial_port = NULL;
+#ifndef WINDOWS
+ /* Attempt to auto set default USB serial port entry */
+ /* Ordered to make lowest device favourite if available */
+ if (g_access ("/dev/ttyUSB1", R_OK) == 0) {
+ if (vgl->serial_port != NULL)
+ g_free (vgl->serial_port);
+ vgl->serial_port = g_strdup ("/dev/ttyUSB1");
+ }
+ if (g_access ("/dev/ttyUSB0", R_OK) == 0) {
+ if (vgl->serial_port != NULL)
+ g_free (vgl->serial_port);
+ vgl->serial_port = g_strdup ("/dev/ttyUSB0");
+ }
+#endif
+
return vgl;
}
static void disconnect_layer_signal ( VikLayer *vl, VikGpsLayer *vgl )
{
- g_assert(DISCONNECT_UPDATE_SIGNAL(vl,vgl)==1);
+ guint number_handlers = DISCONNECT_UPDATE_SIGNAL(vl,vgl);
+ if ( number_handlers != 1 ) {
+ /*
+ NB It's not fatal if this gives 2 for example! Hence removal of the g_assert
+ This happens when copied GPS layer is deleted (not sure why the number_handlers would be 2)
+ I don't think there's any side effects and certainly better than the program just aborting
+ */
+ g_warning(_("Unexpected number of disconnected handlers: %d"), number_handlers);
+ }
}
static void vik_gps_layer_free ( VikGpsLayer *vgl )
}
g_strfreev(tokens);
}
+ /* eg: "Unit:\teTrex Legend HCx Software Version 2.90\n" */
+ if (strstr(line, "Unit:")) {
+ gchar **tokens = g_strsplit(line, "\t", 0);
+ int n_tokens = 0;
+ while (tokens[n_tokens])
+ n_tokens++;
+
+ if (n_tokens > 1) {
+ set_gps_info(tokens[1], sess);
+ }
+ g_strfreev(tokens);
+ }
if (strstr(line, "RECORD")) {
int lsb, msb, cnt;