|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjwo.landserf.process.gps.garmin.GarminPacket
Represents a packet of information sent to or from Garmin GPS. See Garmin Protocol Specification at www.garmin.com/support/commProtocol.html
Field Summary | |
static int |
Cmnd_Abort_Transfer
Abort current transfer. |
static int |
Cmnd_Start_Pvt_Data
Start transmitting PVT (Position, velocity, time) Data. |
static int |
Cmnd_Stop_Pvt_Data
Stop transmitting PVT (Position, velocity, time) Data. |
static int |
Cmnd_Transfer_Alm
Transfer almanac. |
static int |
Cmnd_Transfer_Posn
Transfer position. |
static int |
Cmnd_Transfer_Prx
Transfer proximity waypoints. |
static int |
Cmnd_Transfer_Rte
Transfer routes. |
static int |
Cmnd_Transfer_Time
Transfer time. |
static int |
Cmnd_Transfer_Trk
Transfer track log. |
static int |
Cmnd_Transfer_Wpt
Transfer waypoints. |
static int |
Cmnd_Turn_Off_Pwr
Turn off power. |
static int |
DLE
Data link escape. |
static int |
ETX
End of text. |
protected int[] |
packet
The packet in byte form. |
static int |
Pid_Ack_Byte
|
static int |
Pid_Almanac_Data
|
static int |
Pid_Command_Data
|
static int |
Pid_Date_Time_Data
|
static int |
Pid_Nak_Byte
|
static int |
Pid_Position_Data
|
static int |
Pid_Product_Data
|
static int |
Pid_Product_Rqst
|
static int |
Pid_Protocol_Array
|
static int |
Pid_Prx_Wpt_Data
|
static int |
Pid_Pvt_Data
|
static int |
Pid_Records
|
static int |
Pid_Rte_Hdr
|
static int |
Pid_Rte_Link_Data
|
static int |
Pid_Rte_Wpt_Data
|
static int |
Pid_Trk_Data
|
static int |
Pid_Trk_Hdr
|
static int |
Pid_Wpt_Data
|
static int |
Pid_Xfer_Cmplt
|
Constructor Summary | |
GarminPacket()
Creates an empty packet. |
|
GarminPacket(int[] packet)
Creates a new GarminPacket with the given contents. |
|
GarminPacket(int[] packet,
boolean calcChecksum)
Creates a new GarminPacket with the given contents. |
Method Summary | |
int |
calcChecksum()
Calculates the checksum for the packet. |
static String |
commandToString(int command)
Reports the name of the given command ID. |
static GarminPacket |
createBasicPacket(int type,
int[] data)
Factory method to create an instance of a basic packets from L000 (basic link protocol). |
static GarminPacket |
createCommandPacket(int type)
Factory method to create an instance of a command packets from A010 (Device Command Protocol 1). |
protected int |
getByte(int pos)
Reports the packet byte at the given position. |
int |
getDataLength()
Reports the number of bytes in the data field of this packet. |
int |
getID()
Reports the ID (ie type) of the packet. |
protected int |
getLength()
Reports the length of the entire packet in bytes. |
protected int[] |
getPacket()
Reports the packet in its original byte form. |
String |
getRawPacket()
Reports a text representation of the bytes in the packet. |
static String |
idToString(int id)
Reports the name of the given packet ID. |
int |
isLegal()
Checks if the packet is valid with regards to header, footer, data field length and checksum. |
protected short |
readByte(int pos)
Reads a single byte in the packet and returns it as a short. |
protected double |
readDouble(int pos)
Reads a Garmin 8-byte double value from the packet. |
protected float |
readFloat(int pos)
Reads a Garmin 4-byte float value from the packet. |
protected int |
readLong(int pos)
Reads a Garmin 4-byte word in the packet and returns it as an int. |
protected String |
readNullTerminatedString(int pos)
Reads a null-terminated string at the given offset in the packet. |
protected int |
readWord(int pos)
Reads a Garmin 2-byte word in the packet and returns it as an integer. |
void |
setPacket(int[] packet,
boolean calcChecksum)
Sets the packet contents to the given given content. |
String |
toString()
Reports a summary of the packet's type. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int Pid_Ack_Byte
public static final int Pid_Nak_Byte
public static final int Pid_Protocol_Array
public static final int Pid_Product_Rqst
public static final int Pid_Product_Data
public static final int Pid_Command_Data
public static final int Pid_Xfer_Cmplt
public static final int Pid_Date_Time_Data
public static final int Pid_Position_Data
public static final int Pid_Prx_Wpt_Data
public static final int Pid_Records
public static final int Pid_Rte_Hdr
public static final int Pid_Rte_Wpt_Data
public static final int Pid_Almanac_Data
public static final int Pid_Trk_Data
public static final int Pid_Wpt_Data
public static final int Pid_Pvt_Data
public static final int Pid_Rte_Link_Data
public static final int Pid_Trk_Hdr
public static final int Cmnd_Abort_Transfer
public static final int Cmnd_Transfer_Alm
public static final int Cmnd_Transfer_Posn
public static final int Cmnd_Transfer_Prx
public static final int Cmnd_Transfer_Rte
public static final int Cmnd_Transfer_Time
public static final int Cmnd_Transfer_Trk
public static final int Cmnd_Transfer_Wpt
public static final int Cmnd_Turn_Off_Pwr
public static final int Cmnd_Start_Pvt_Data
public static final int Cmnd_Stop_Pvt_Data
public static final int DLE
public static final int ETX
protected int[] packet
Constructor Detail |
public GarminPacket()
public GarminPacket(int[] packet)
packet
- Contents to be placed in packet.
InvalidPacketException
- if packet is malformed.public GarminPacket(int[] packet, boolean calcChecksum)
packet
- Contents to be placed in packet.calcChecksum
- Calculates checksum if true.
InvalidPacketException
- if packet is malformed.Method Detail |
public void setPacket(int[] packet, boolean calcChecksum)
packet
- Contents to be placed in packet.calcChecksum
- Calculates checksum if true.
InvalidPacketException
- if packet is malformed.public int calcChecksum()
public int getID()
public int getDataLength()
protected int getByte(int pos)
pos
- Offset position in packet.
protected int[] getPacket()
protected int getLength()
protected int readWord(int pos)
pos
- Offset position in packet.
protected int readLong(int pos)
pos
- Offset position in packet.
protected short readByte(int pos)
pos
- Offset position in packet.
protected float readFloat(int pos)
pos
- Offset position in packet.
protected double readDouble(int pos)
pos
- Offset position in packet.
protected String readNullTerminatedString(int pos)
pos
- Offset position in packet.
public static String idToString(int id)
id
- ID to tranlate.
public static String commandToString(int command)
command
- Command ID to tranlate.
public String getRawPacket()
public static GarminPacket createCommandPacket(int type)
type
can be one of the
following constants:
type
- Type of packet to create.
public static GarminPacket createBasicPacket(int type, int[] data)
type
can be one of the
following constants:
type
- Type of packet to create.data
- Data that will be put in the data field of the packet.
public int isLegal()
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |