1# Copyright (c) 2007 Patrick Giraudoux and Roger Bivand 2 3readGPS <- function(i="garmin", f="usb:", type="w", invisible=TRUE, ...) { 4 GB <- Sys.which("gpsbabel") 5 if (nchar(GB) == 0 || !file.exists(GB)) stop("gpsbabel not found") 6 if (.Platform$OS.type == "windows") 7 gpsdata <- system(paste(GB, " -", type, " -i ", i, " -f ", f, 8 " -o tabsep -F -", sep=""), intern=TRUE, invisible=invisible) 9 else gpsdata <- system(paste(GB, " -", type, " -i ", i, " -f ", f, 10 " -o tabsep -F -", sep=""), intern=TRUE) 11 if (any(grep("Can't init", gpsdata))) 12 stop("Cannot read GPS: check connexion") 13 gpsdf <- read.table(con <- textConnection(gpsdata), fill=TRUE, ...) 14 close(con) 15 gpsdf 16} 17 18