Jump to content

Read GPS - USB - Error


Recommended Posts

Hello! (I'm new with AutoIt)

I have tried this example script.

The Code:

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.2.0
Author: metaborn

Script Function:
Modular use of NETComm, Find GPS comm port

Function List:
Install_NETComm()
getGPS_port()
_CheckCommError()
MsgBoxGPS_Port()
#ce ----------------------------------------------------------------------------
#NoTrayIcon

main()
Func main()
MsgBoxGPS_Port()
EndFunc ;main()

Func Install_NETComm()
Dim $ExtractDest = "C:\WINDOWS\SYSTEM32\NETComm\"
DirRemove("C:\WINDOWS\SYSTEM32\NETComm\", 1)
DirCreate("C:\WINDOWS\SYSTEM32\NETComm\")
FileInstall("C:\metaborn\apps\NETCommOCX\DeIsL1.isu", $ExtractDest & "DeIsL1.isu", 1)
FileInstall("C:\metaborn\apps\NETCommOCX\install.txt", $ExtractDest & "install.txt", 1)
FileInstall("C:\metaborn\apps\NETCommOCX\NETComm.ocx", $ExtractDest & "NETComm.ocx", 1)
FileInstall("C:\metaborn\apps\NETCommOCX\NETCommOCXSourceCode.zip", $ExtractDest & "NETCommOCXSourceCode.zip", 1)
FileInstall("C:\metaborn\apps\NETCommOCX\VB6.zip", $ExtractDest & "VB6.zip", 1)
FileInstall("C:\metaborn\apps\NETCommOCX\VBNET.zip", $ExtractDest & "VBNET.zip", 1)
FileInstall("C:\metaborn\apps\NETCommOCX\_DEISREG.ISR", $ExtractDest & "_DEISREG.ISR", 1)
FileInstall("C:\metaborn\apps\NETCommOCX\_ISREG32.DLL", $ExtractDest & "_ISREG32.DLL", 1)
$results = RunWait(@ComSpec & " /c C:\WINDOWS\SYSTEM32\REGSVR32.EXE /s C:\WINDOWS\SYSTEM32\NETComm\NETComm.ocx", "C:\WINDOWS\SYSTEM32\", @SW_HIDE)
EndFunc ;Install_NETComm()


Func getGPS_port()
Install_NETComm()
$ComPort = ObjCreate("NETCommOCX.NETComm");Create NETComm.ocx object
Dim $cnt = 1
Dim $GPS_port

While $cnt <= 15
$ComPort.CommPort = string($cnt)
$ComPort.Settings = "4800,N,8,1"
$ComPort.InputLen = 0
$ComPort.InputMode = 0
$ComPort.HandShaking = 0
$ComPort.PortOpen = "True"

If @error > 0 then
$ComPort.PortOpen = "False"
Else
Sleep(3000)
If $ComPort.InBufferCount > 0 Then
if( StringInStr($ComPort.InputData, "$GP") ) Then
$GPS_port = $ComPort.CommPort
Else
$GPS_port = "False"
EndIf

If $GPS_port <> "False" Then
$ComPort.PortOpen = "False"
$ComPort = 0
Return $GPS_port
EndIf
EndIf
Endif

$cnt = $cnt + 1
WEnd

$ComPort.PortOpen = "False"
$ComPort = 0
Return "False"
EndFunc ;getGPS_port()


Func _CheckCommError()
setError(1)
EndFunc ;_CheckCommError


Func MsgBoxGPS_Port()
Dim $port = getGPS_port()
If $port = "False" Then
BlockInput(0)
MsgBox(0, "Error", "No GPS data. Please verify that your GPS Receiver is plugged into the correct port or contact your system administrator.")
Exit(1)
EndIf
MsgBox(0,"GPS Port", "GPS Port: " & $port)
EndFunc ;MsgBoxGPS_Port()

But it doesn't work for me. (I have an new installation of AutoIt & Win XP)

When I tried to run the program I got the following error message:

Line 46

$ComPort.CommPort = string($cnt)

$ComPort^ERROR

Error: Variable must be of type "Object".

And I don't know what the error message mean.

(Maybe another program might read GPS bytes better today?)

//Jan

Link to comment
Share on other sites

Have found that I have to installing "NETCommOCX"

Now I have installed this version: NETCommOCX (Don't know if this was the correct version).

But, Now I get the following error message:

Line 51

$ComPort.PortOpen = "True"

$ComPort.PortOpen = "True"^ERROR

Error: The requested action with this object has failed.

What's wrong?

What can I do?

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...