Ich möchte eine externe DLL (für eine Motorsteuerung) aus Autoit heraus ansteuern.
Nun ist es vom Aufruf abhängig, ob das Programm funktioniert oder nicht. Aus Scite heraus funktioniert es beispielsweise nicht, weil AutoIt3Wrapper es auf die "falsche" Weise aufruft.
Spoiler anzeigen
$_C843_DLL = DllOpen("C843_GCS_DLL.dll")
If $_C843_DLL = -1 Then
ConsoleWrite("DLL could not be opened" & @CRLF)
Exit
EndIf
; Connect to the first board
$ID = _C843_Connect(1)
If $ID < 0 Then
ConsoleWrite("Connection Failed!" & @CRLF)
Exit
EndIf
; Get the list of motors in the parameter files
$Stages = _C843_qVST($ID)
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$Stages' & @lf & @lf & 'Return:' & @lf & $Stages) ;### Debug MSGBOX
ConsoleWrite("qVST: " & $Stages & @CRLF)
; Get the last error
$Error = _C843_GetError($ID)
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$Error' & @lf & @lf & 'Return:' & @lf & $Error) ;### Debug MSGBOX
ConsoleWrite("GetError: " & $Error & " " & _C843_TranslateError($Error) & @CRLF)
; Disconnect from board
_C843_CloseConnection($ID)
; ****************************************************************************
#Region DLL initialization and comm functions
Func _C843_CloseConnection($Id)
DllCall($_C843_DLL,"none","C843_CloseConnection","int",$Id)
EndFunc
Func _C843_Connect($BoardNumber)
Local $aResult
$aResult = DllCall($_C843_DLL,"int","C843_Connect","int",$BoardNumber)
Return $aResult[0]
EndFunc
Func _C843_GetError($Id)
Local $aResult
$aResult = DllCall($_C843_DLL,"int","C843_GetError","int",$Id)
Return $aResult[0]
EndFunc
Func _C843_TranslateError($ErrNr)
local $tData, $aResult, $Return
$tData = DllStructCreate("char[1024]")
$aResult = DllCall($_C843_DLL,"int","C843_TranslateError","int",$ErrNr,"ptr",DllStructGetPtr ($tData),"int",1023)
If $aResult[0] Then
$Return = DllStructGetData($tData, 1)
Else
$Return = "Errormessage to long"
EndIf
$tData = 0
Return $Return
EndFunc
#EndRegion
#Region general
[/autoit] [autoit][/autoit] [autoit];===============================================================================
;
; Function Name: _C843_qVST()
; Description::Get the names of the available stage types.
; Parameter(s):$Id - Id of the C843-board
; Return Value(s): Returns list of stages or "" in case of error
; @error Value(s):1 - Error Calling C843 DLL
; 2 - DLL returned an error
; Author(s): Hawkear (Holger Kuhn)
;
;===============================================================================
;
Func _C843_qVST($Id)
local $tData, $aResult, $Return
$tData = DllStructCreate("char[8192]")
;BOOL C843_FUNC_DECL C843_qVST(const int iId, char* buffer, const int maxlen);
$aResult = DllCall($_C843_DLL,"int","C843_qVST","int",$Id,"ptr",DllStructGetPtr ($tData),"int",8191)
If @error > 0 Then
$Return = ""
SetError(1)
Else
If $aResult[0] Then
$Return = DllStructGetData($tData, 1)
Else
$Return = ""
SetError(2)
EndIf
EndIf
$tData = 0
Return $Return
EndFunc
#endregion
Rufe ich das Programm mit /ErrorStdOut und vollem Pfad auf, dann funktioniert es nicht.
Rückgabe:
Anders funktioniert es
C:\Programme\AutoIt3\autoit3.exe D:\SVN\AutoIt\C843_Test.au3
C:\Programme\AutoIt3\autoit3.exe /ErrorStdOut C843_Test.au3
C:\Programme\AutoIt3\autoit3.exe C843_Test.au3
Rückgabe:
Was ist denn bei dem Aufruf mit /ErrorStdOut so gross anders?
Hat jemand eine Idee, wie man das Problem umgehen kann?
Ciao, Holger