#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
#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};
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;
}
}
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;