JAVA code - gps connection

cassianotartari's picture

Hi,

   I downloaded the source code of the project to try to understand how it is made the connection with the GPS. I need this java code for my master. However, reading the code I cannot understand how this work, I understood that the main classes for the connection is gps.connection.GPSrxtx and gps.connection.GPSPort but I cannot found how the port is openned and how I can get information from the GPS.

   I'm working with a BT-Q890 connected on USB port, starting the jar app I saw that it work because the app could get the model information and the current coordinates from my GPS.

   Can someone give me a hand?

Tks

mdeweerd's picture

Hi Have a look at

Hi

Have a look at 'BT747cmd.java' which implements the CLI and which does most of the top level operations in a single file.

BT747 is multi-platform.  As the serial connection depends on the platform, the class really handling the connection is set in the main class like this:

 

if (!GPSrxtx.hasDefaultPortInstance()) {

GPSrxtx.setDefaultGpsPortInstance(new gps.connection.GPSRxTxPort());

}

 

The connection is started by calling 'connectGps' of the controller ( c.connectGPS(); ).  The controller will get the parameters (port, speed) form the options.

In GpsController.java there is a function called 'run' which is called on regular intervals - it is not really a thread, but almost (the SuperWaba platform does not allow threads - 'run' can not hava an indefinite loop).

This loop calls 'handler.getResponse()' which returns a "packet" from the link.  That packet is then analysed for its semantics.  The packet itself is built based on protocol syntax by the decoders.

GpsRxTx does the decoding, and how it does the decoding depends on the 'state' of GpsRxTx .  There is for instance gps.connection.NMEADecoderState.  'state.getResponse()' is called in GpsRxTx's getResponse().

The DecoderStateFactory returns an instance of the requested decoder state which is called from GPSrxtx (newState).  The default state is defined there (NMEA_STATE) and is changed when the device is put into binary mode for instance (as in MtkBinWriter in setMtkBinMode or doSetNmeaMode, depending on whether the device is supposed to enter or exit binary mode).

To be perfect, more stuff should be refactored (class names, organisation), but it is as it is. 

cassianotartari's picture

Thanks for the reply, I'll

Thanks for the reply, I'll study what you said.

Post new comment

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br>
  • Lines and paragraphs break automatically.
  • Use the special tag [adsense:format:slot] or [adsense:format:[group]:[channel][:slot]] or [adsense:block:location] to display Google AdSense ads.
  • Images can be added to this post.

More information about formatting options