Shop OBEX P1 Docs P2 Docs Learn Events
Strange GPS fractional minutes — Parallax Forums

Strange GPS fractional minutes

JacEJacE Posts: 6
edited 2009-11-30 02:21 in General Discussion
hello everybody,

This time i've got a problem with my gps-module.

I need the lat and long coordinates for my navigation. My get-method looks like this:
public int getLongFracmin() {
    smartRequest(GetLong,5);
    lngFracmin = (buf&0xFF)|(buf<<8);
    return lngFracmin;
    }


Thoses methods exist for every part of the coordinates (degrees,minutes, fractional minutes)
The methods for degrees and minutes are working fine, but both fracmin-methods are returning with negative results:
Javelin Terminal said...

Your current position is:
Longitude: 9 1 -5883
Latitude: 51 37 -5883

Could somebody see where my mistake is?

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-11-30 01:07
    The getLong() method from the Parallax_GPS.java is

      public void getLong() {
        smartRequest(GetLong,5);
        lngDegrees = buf[noparse][[/noparse]0]&0xFF;
        lngMinutes = buf[noparse][[/noparse]1]&0xFF;
        lngFracmin = (buf[noparse][[/noparse]3]&0xFF)|(buf[noparse][[/noparse]2]<<8);
        lngDirection = buf[noparse][[/noparse]4]&0xFF;
      }
    
    

    Your routine uses
    lngFracmin·=·(buf&0xFF)|(buf<<8);
    I assume this is a typo because it will not compile.

    If you use simply System.out.print(lngFracmin) then
    the number appears negative if it is in the range 0x8000-0xFFFF

    I believe the lngFracmin value should be in range 0-9999
    Is it possible your actual expression looks like
    ··· lngFracmin = (buf[noparse][[/noparse]2]&0xFF)|(buf[noparse][[/noparse]3]<<8);
    (swapped buf locations)

    regards peter
  • JacEJacE Posts: 6
    edited 2009-11-30 01:51
    Very strange. It looks like all brackets (is it the right word? I mean the square clamps you use at example for an array) are omitted in my last post. My method looks almost like the original method. I only changed the method into some smaller methods, which returns with degrees or minutes or fractional minutes.

    Thank you for your patience (and sorry for my english )

    Regards


    Edit:

    I've attached my Gps_Parallax.java as .txt

    Post Edited (JacE) : 11/30/2009 2:01:50 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-11-30 02:21
    That version has LSB and MSB swapped.
    Attached is the correct version.

    BTW, your 'shorter' methods require multiple calls to smartRequest.
    The class holds public variables for LAT and LNG, all of which
    are valid after a single call to smartRequest.
    You can use these variables directly, no need to create wrapper methods.

    regards peter

    Post Edited (Peter Verkaik) : 11/30/2009 2:31:31 AM GMT
Sign In or Register to comment.