After you verify that your hardware is working properly, and that the Eclipse configuration is correct, verify that the hardware is communicating with the Java code.
To determine whether your hardware is communicating with the Java code, write a program that uses the serial port to listen to the GPS and prints any received data to the GPS.
To verify that the Connection Layer is functioning properly, use the following instructions:
<classpath> <classpathentry kind="src" path=""/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="DEVICEKIT/bundlefiles/Connection.jar" sourcepath="DEVICEKIT/bundlefiles/source/src-Connection.jar"/> <classpathentry kind="var" path="DEVICEKIT/bundlefiles/SerialConnection.jar"/> <classpathentry kind="var" path="SERIAL_HOME/serial.jar"/> <classpathentry kind="var" path="DEVICEKIT/bundlefiles/Core.jar" sourcepath="DEVICEKIT/bundlefiles/source/src-Core.jar"/> <classpathentry kind="output" path=""/> </classpath>
package tests.serial;
// Copyright (c) 1999, 2009 IBM.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM - initial API and implementation
import java.io.IOException;
import org.eclipse.soda.dk.serial.connection.SerialConnection;
public class GPSTest {
public static void main(String[] args){
//Create a Connection
SerialConnection conn = new SerialConnection(1, 4800, SerialConnection.DATABITS_8, SerialConnection.PARITY_NONE, SerialConnection.STOPBITS_1, 0, 0, 100, 100, 100);
//Create a place to put the read data, and a counter of how much data was read
byte[] data = new byte[1000];
int bytesRead = 0;
try{
//Open the Connection
conn.open();
//Run Until Terminated
while(true){
//Read In The Data
bytesRead = conn.read(data, 0, data.length);
//If we got data, and didn't timeout, then print the data
if(bytesRead > 0)
System.out.println("Message RX :" + new String(data, 0, bytesRead));
}
}catch(IOException e){
//Print any errors
e.printStackTrace();
}
try{
//Attempt to close the serial port
conn.close();
}catch(IOException closeError){
//Print any errors closing the port
closeError.printStackTrace();
}
}
}
If necessary, troubleshoot the test results.
© Copyright 2001, 2009 IBM Corporation and others.