阅读:1291回复:0
【转】基于Java的GPS接收机解析器 (5)
/*
* * TestGps.java * * This is a simple program to test the GpsReceiver class. * * Author : Qingye Jiang (John) * HappyFox Engineering Solutions * qjiang@tsinghua.edu * */ public class TestGps { /* * * Testing program. * */ public static void main(String[] args) { GpsInfo GpsData = new GpsInfo(); // Input from the GPS receiver, which is connected to COM2 of th // "true" means record the GPS data into a file. //GpsReceiver GPS = new GpsReceiver("com2", 0, true); //GPS.StartReceiver(); // Input from a file call "gps.dat", with an acceleration factor // "false" means do not record the GPS data into a file. GpsReceiver GPS = new GpsReceiver("COM1", 0, false); GPS.StartReceiver(); for (int i = 0; i < 200; i++) { GpsData = GPS.GetGpsData(); System.out.println(GpsData.GetTime()); System.out.println(GpsData.GetNS() + " " + GpsData.GetL System.out.println(GpsData.GetEW() + " " + GpsData.GetL System.out.println(GpsData.GetAltitude()); // If using a GPS receiver, uncommend the following slee // to get real-time data. try { Thread.sleep(1000); } catch (InterruptedException e) {} } GPS.StopReceiver(); } } |
|
|