// EPS: Elgaard Positioning System: GPS navigation software. // Copyright (C) 1997, 1999 Niels Elgaard Larsen // 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 // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Niels Elgaard Larsen, // // Garmin communication code is based on Gpstrans by Carsten Tschach // (tschach@zedat.fu-berlin.de) import java.util.Date; class Sendgpsinfo implements Runnable{ int ptype; static byte newTrack; static byte message[] = new byte[100]; Prefs gFilePrefs; Sendgpsinfo(int pt){ ptype =pt; } static void sendGPSOff() { int err; if (!Garmincomm.CheckGPS()) { CAux.perr("GPS is not responding - make sure it is on and set to GRMN/GRMN protocol.",4); } if ((err = Garmincomm.serialOpen(Garmincomm.GRM_comm)) != 0) { CAux.perr( "The port initialization has failed.",4); // Continue. Netscape/IE problem } Garmincomm.sendGPSMessage(Gpsmessage.off1, 4); Garmincomm.serialClose(); } public void run() { int recs, processed = 0; int err; int result = 1; String rType ="?"; byte term[]= null; Thread thisThread = Thread.currentThread(); if (!Garmincomm.CheckGPS()) { CAux.perr("GPS is not responding - make sure it is on and set to GRMN/GRMN protocol.",4); } if ((err = Garmincomm.serialOpen(Garmincomm.GRM_comm)) != 0) { CAux.perr("The port initialization of " + ptype +" has failed.",4); // Continue. Netscape/IE problem } recs = records(ptype); CAux.perr("sending "+ recs + " records",1); if (sendRecords(recs) > 0) { if (ptype== Gpsmessage.ALMANAC) { } else if (ptype== Gpsmessage.ROUTE){ WayPoint wp; int nw; Route rt; int nr; rType = "routes"; term = Gpsmessage.rtet; CAux.perr("Route",1); for (nr=0 ; nr=0) { n=n0; } else { n=0x1000000000L + n0; } p3 = n/0x1000000L; p2 = (n-p3*0x1000000L)/0x10000L; p1 = (n - p3*0x1000000L - p2*0x10000L)/0x100L; p0 = n - p1*0x100L - p2*0x10000L -p3*0x1000000L; //System.out.println("p0= " + p0 + " p1=" + p1+ " p2=" + p2 + " p3=" + p3); p[st+3] = (byte)p3; p[st+2] = (byte)p2; p[st+1] = (byte)p1; p[st ] = (byte)p0; } static void cpystr(byte p[], String q, int st, int n) { int ix=0; while (ix