Jump to content

GPS code translator


JonBMN
 Share

Recommended Posts

I implemented this in; not sure if I plugged in values correctly, but its not writing to the console for me.

$Start = $Longitude and $Latitude
$Current = $start
For $I = 1 to 1000
$Current = $I
If $Current <> $Start Then
ConsoleWrite("My current position is " $Current & @CR "I have moved " & $Current - $Start & " miles from the beginning" & @CR)
EndIf
Next
Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

What is this line $Start = $Longitude and $Latitude supposed to be doing? Because the result of that will be that $start will equal 0 or 1 depending upon what's in the other 2 variables.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm recieving an error:

For $I = $Latitude and $Longitude

For $I = $Latitude and $Longitude^ ERROR

am I missing a carriage return or something elsc

I changed and to To

This ran; but I need to pause the start time; and let the $Current-$Start change.

$Start = 0
$Current = $Start
For $I = $Latitude To $Longitude
$Current = $I
If $Current <> $Start Then
ConsoleWrite("My current position is " & $Current & @CR & "I have moved " & $Current - $Start & " miles from the beginning" & @CR)
EndIf
Next
Edited by JonBMN
Link to comment
Share on other sites

simplified your script...you need to define what array data point maps to the data you need, based on the communication type:

1) blindly split the data

2) depending on the type, map out the long, lat, and time

3) adds the data to an array

you can then do whatever you need with that array

#include <Array.au3>

AutoItWinSetTitle("ArchangelProgram")
AutoItSetOption("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
AutoItSetOption("MustDeclareVars", 1)
Opt("TrayMenuMode", 1)
HotKeySet("{ESC}", "Quit")
$Debug = False
Global $CommPort = "COM5", $Baudrate = 4800, $Received, $GPSHeader, $CurrentLongitude, $CurrentLatitude, $LastLongitude, $LastLatitude, $LastTime, $CurrentTime, $Longitude, $Latitude
$HerbieError = True
Dim $aAllReturnedData[1][3] = ["Long","Lat","Time"]
While 1 ; Haven't accounted for Under/Under
 $bAddToArray = True
 
 If $HerbieError = True Then
  InitializeCommunications()
 EndIf
 $Received = _CommReceiveString(100, 5000, @CR)
 $aReturned = Parse ( $Received )
 
 If IsArray ( $aReturned ) Then
 
  Switch $aReturned[1]
   Case "$GPGSA"
    ; Need to add all the mappings to standardized variables
    $Longitude = $aReturned[3]
    $Latitude = $aReturned[2]   
    $Time = $aReturned[4]   
   Case "$GPRMC"
    ; Need to add all the mappings to standardized variables
    $Longitude = $aReturned[3]
    $Latitude = $aReturned[2]   
    $Time = $aReturned[4]  
   Case "$GPGGA"
    ; Need to add all the mappings to standardized variables
    $Longitude = $aReturned[3]
    $Latitude = $aReturned[2]   
    $Time = $aReturned[4] 
   Case "GPGSV"   
    ; Need to add all the mappings to standardized variables
    $Longitude = $aReturned[3]
    $Latitude = $aReturned[2]   
    $Time = $aReturned[4]
   Case Else
    $bAddToArray = False
  EndSwitch
 Else
  $bAddToArray = False
 EndIf
 
 If $bAddToArray Then
  ReDim $aAllReturnedData[UBound($aAllReturnedData)+1][3]
  $aAllReturnedData[UBound($aAllReturnedData)-1][0] = $Longitude
  $aAllReturnedData[UBound($aAllReturnedData)-1][1] = $Latitude 
  $aAllReturnedData[UBound($aAllReturnedData)-1][2] = $Time 
  _ArrayDisplay ( $aAllReturnedData )
 EndIf
 Sleep(500)
WEnd
Func Quit()
 If $SerialPortHandle <> -1 Then
  _CommClose()
 EndIf
 Exit
EndFunc   ;==>Quit
Func Parse($Received)
 $aSplit = StringSplit($Received, ",")
 Return $aSplit 
EndFunc   ;==>Parse
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Very helpful jdelaney, but it looks like most of my script that you simplified is missing. All I see included is lat, long, time. I need all the other variables as well; sea level and all that jazz.

I'm not saying do it for me; you made a great data array and once I really figure out how to do this I will be sure to convert to your simplified script and add to it.

Edited by JonBMN
Link to comment
Share on other sites

just change the 2nd dimension to include the necessary elements (Dim $aAllReturnedData[1][x] = ["Long","Lat","Time",[add your defs]])

And inside the switch case, add the needed mappings.

Then, on the array defining, add in those new elements....the building blocks are all there for you

modified a bit for simplicity:

#include <Array.au3>

AutoItWinSetTitle("ArchangelProgram")
AutoItSetOption("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
AutoItSetOption("MustDeclareVars", 1)
Opt("TrayMenuMode", 1)
HotKeySet("{ESC}", "Quit")
$Debug = False
Global $CommPort = "COM5", $Baudrate = 4800, $Received, $GPSHeader, $CurrentLongitude, $CurrentLatitude, $LastLongitude, $LastLatitude, $LastTime, $CurrentTime, $Longitude, $Latitude
$HerbieError = True

; ALL the data you want to store in the array...add additional data as needed, prior to the $iArray_2D_UBound
Global Enum $iArray_Longitude = 0, _
 $iArray_Latitude, _
 $iArray_Time, _
 $iArray_2D_UBound
Dim $aAllReturnedData[1][$i2D_UBound]
Dim $aAllReturnedData[0][$iArray_Longitude] = "Longitude"
Dim $aAllReturnedData[0][$iArray_Latitude] = "Latitude"
Dim $aAllReturnedData[0][$iArray_Time] = "Time"
; Etc, add as needed
While 1 ; Haven't accounted for Under/Under
 $bAddToArray = True
 
 If $HerbieError = True Then
  InitializeCommunications()
 EndIf
 $Received = _CommReceiveString(100, 5000, @CR)
 $aReturned = Parse ( $Received )
 
 If IsArray ( $aReturned ) Then
 
  Switch $aReturned[1]
   Case "$GPGSA"
    ; Need to add all the mappings to standardized variables...the 3,2,4 are bogus place holders, you need to replace with the proper array element
    $iLongitude = $aReturned[3]
    $iLatitude = $aReturned[2]   
    $iTime = $aReturned[4]
    ; add additional mappings as needed
   Case "$GPRMC"
    ; Need to add all the mappings to standardized variables...the 3,2,4 are bogus place holders, you need to replace with the proper array element
    $Longitude = $aReturned[3]
    $Latitude = $aReturned[2]   
    $Time = $aReturned[4]  
    ; add additional mappings as needed
   Case "$GPGGA"
    ; Need to add all the mappings to standardized variables...the 3,2,4 are bogus place holders, you need to replace with the proper array element
    $Longitude = $aReturned[3]
    $Latitude = $aReturned[2]   
    $Time = $aReturned[4] 
    ; add additional mappings as needed
   Case "GPGSV"   
    ; Need to add all the mappings to standardized variables...the 3,2,4 are bogus place holders, you need to replace with the proper array element
    $Longitude = $aReturned[3]
    $Latitude = $aReturned[2]   
    $Time = $aReturned[4]
    ; add additional mappings as needed
   Case Else
    $bAddToArray = False
  EndSwitch
 Else
  $bAddToArray = False
 EndIf
 
 If $bAddToArray Then
  ReDim $aAllReturnedData[UBound($aAllReturnedData)+1][$iArray_2D_UBound]
  $aAllReturnedData[UBound($aAllReturnedData)-1][$iArray_Longitude] = $Longitude
  $aAllReturnedData[UBound($aAllReturnedData)-1][$iArray_Latitude] = $Latitude 
  $aAllReturnedData[UBound($aAllReturnedData)-1][$iArray_Time] = $Time 
  _ArrayDisplay ( $aAllReturnedData )
 EndIf
 Sleep(500)
WEnd
Func Quit()
 If $SerialPortHandle <> -1 Then
  _CommClose()
 EndIf
 Exit
EndFunc   ;==>Quit
Func Parse($Received)
 $aSplit = StringSplit($Received, ",")
 Return $aSplit 
EndFunc   ;==>Parse
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

This is what worked for me

Global $GetInitial = True

if $GPSHeader == "$GPGGA" Then
DecodeGPGGA()
IF $GetInitial == True Then
$IniLongitude = $Longitude
$IniLatitude = $Latitude
$GetInitial = False
EndIf
EndIf



ConsoleWrite("My Initial Latitude is:" & $IniLatitude & " My Initial Longitude is:" & $IniLongitude & @CR)
ConsoleWrite("My Current latitude is:" & $Latitude & " My current Longitude is:" & $Longitude & @CR)
ConsoleWrite( @CR)

sleep(1500)
Edited by JonBMN
Link to comment
Share on other sites

I'm not sure what other programming languages you use, but in AutoIt the operator "==" should only be used for case sensitive string comparisons. The operator "=" is used for any other comparisons needed. Incorrect usage of that operator can cause, and has caused, script to exhibit odd behavior because of the internal manipulations that AutoIt does when it tries to compare strings to things that aren't strings. Just an FYI.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

"="

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Let's say that you are going from Montreal to Vancouver. You may be interested to know how many Km (or miles) that you have already made and you may also be interested to know how many Km (or miles again) there is left to arrive to destination.

The GPS is always sending the current position. This is not static as it is always changing.

In order to know how far you are from Montreal you need to have stored the Montreal coordinates somewhere. This is static as it will not change.

Now, all there is to do (and it is not that easy) is to calculate the distance betwen these 2 coordinates.

To know the distance left to arrive to Vancouver, store the Vancouver coordinates instead of the Montreal ones.

Well... I suppose that this example is a bit simplistic. I am sorry if it is too much. :graduated:

Edited by AlainB
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...