X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/2b756ea0f81ebe3ef92ba3d40b67b9ad0d2e19e6..43e8b799d298705a645376a567b89faa20d55a87:/src/datasource_gps.c?ds=sidebyside diff --git a/src/datasource_gps.c b/src/datasource_gps.c index e7de72e2..3e6ccced 100644 --- a/src/datasource_gps.c +++ b/src/datasource_gps.c @@ -2,6 +2,8 @@ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager * * Copyright (C) 2003-2005, Evan Battaglia + * Copyright (C) 2006, Alex Foobarian + * Copyright (C) 2010, Rob Norris * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +24,11 @@ #include "config.h" #endif #include +#ifdef HAVE_UNISTD_H +#include +#endif +#include #include #include @@ -52,6 +58,7 @@ VikDataSourceInterface vik_datasource_gps_interface = { VIK_DATASOURCE_CREATENEWLAYER, VIK_DATASOURCE_INPUTTYPE_NONE, TRUE, + TRUE, (VikDataSourceInitFunc) datasource_gps_init_func, (VikDataSourceCheckExistenceFunc) NULL, (VikDataSourceAddSetupWidgetsFunc) datasource_gps_add_setup_widgets, @@ -119,9 +126,15 @@ static void datasource_gps_get_cmd_string ( gpointer user_data, gchar **babelarg #endif if (!strcmp(proto, "Garmin")) { device = "garmin"; - } else { + } else if (!strcmp(proto, "Magellan")) { device = "magellan"; } + else if (!strcmp(proto, "DeLorme")) { + device = "delbin"; + } + else { + device = "navilink"; + } *babelargs = g_strdup_printf("-D 9 -t -w -i %s", device); /* device points to static content => no free */ @@ -165,7 +178,11 @@ static void datasource_gps_off ( gpointer user_data, gchar **babelargs, gchar ** #endif if (!strcmp(proto, "Garmin")) { device = "garmin,power_off"; - } else { + } + else if (!strcmp(proto, "NAViLink")) { + device = "navilink,power_off"; + } + else { return; } @@ -281,6 +298,18 @@ static void datasource_gps_progress ( BabelProgressCode c, gpointer data, acq_di } 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], w); + } + g_strfreev(tokens); + } if (strstr(line, "RECORD")) { int lsb, msb, cnt; @@ -313,6 +342,8 @@ void datasource_gps_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpo w->proto_b = GTK_COMBO_BOX(gtk_combo_box_new_text ()); gtk_combo_box_append_text (w->proto_b, "Garmin"); gtk_combo_box_append_text (w->proto_b, "Magellan"); + gtk_combo_box_append_text (w->proto_b, "DeLorme"); + gtk_combo_box_append_text (w->proto_b, "NAViLink"); gtk_combo_box_set_active (w->proto_b, 0); g_object_ref(w->proto_b); @@ -321,16 +352,23 @@ void datasource_gps_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpo #ifdef WINDOWS gtk_combo_box_append_text (w->ser_b, "com1"); #else - gtk_combo_box_append_text (w->ser_b, "/dev/ttyS0"); - gtk_combo_box_append_text (w->ser_b, "/dev/ttyS1"); - gtk_combo_box_append_text (w->ser_b, "/dev/ttyUSB0"); - gtk_combo_box_append_text (w->ser_b, "/dev/ttyUSB1"); + /* Here just try to see if the device is available which gets passed onto gpsbabel + List USB devices first as these will generally only be present if autogenerated by udev or similar + User is still able to set their own free text entry */ + if (g_access ("/dev/ttyUSB0", R_OK) == 0) + gtk_combo_box_append_text (w->ser_b, "/dev/ttyUSB0"); + if (g_access ("/dev/ttyUSB1", R_OK) == 0) + gtk_combo_box_append_text (w->ser_b, "/dev/ttyUSB1"); + if (g_access ("/dev/ttyS0", R_OK) == 0) + gtk_combo_box_append_text (w->ser_b, "/dev/ttyS0"); + if (g_access ("/dev/ttyS1", R_OK) == 0) + gtk_combo_box_append_text (w->ser_b, "/dev/ttyS1"); #endif gtk_combo_box_append_text (w->ser_b, "usb:"); gtk_combo_box_set_active (w->ser_b, 0); g_object_ref(w->ser_b); - w->off_request_l = gtk_label_new (_("Turn Off After Transfer\n(Garmin Only)")); + w->off_request_l = gtk_label_new (_("Turn Off After Transfer\n(Garmin/NAViLink Only)")); w->off_request_b = GTK_CHECK_BUTTON ( gtk_check_button_new () ); box = GTK_TABLE(gtk_table_new(2, 3, FALSE));