Sign in to follow this  
Followers 0
Hawkear

Problem with ErrorStdOut

2 posts in this topic

I want to use an DLL (Motion Controller) in AutoIt.

Whether the DLL works depends on how i start the script. I cant start it from Scite, because AutoIt3Wrapper runs it the "wrong" way.

If I use the /ErrorStdOut parameter and the complete path to the script, it does not work.

C:\Programme\AutoIt3\autoit3.exe /ErrorStdOut D:\SVN\AutoIt\C843_Test.au3

Returns:

qVST: 
GetError: -1039 Could not open parameter file

If I call it without /ErrorStdOut or only use the filename of the script, it works

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

Returns:

qVST: C-136.10 
C-136.10-PWM 
<long list with motor stages>

GetError: 0 No error

What exactly does /ErrorStdOut do? (i looked at the AutoIt 3.1.0 source but couldnt find anything that explains that)

How can i prevent this?

Bye, Hawkear

$_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   ;==>_C843_CloseConnection

Func _C843_Connect($BoardNumber)
    Local $aResult
    $aResult = DllCall($_C843_DLL, "int", "C843_Connect", "int", $BoardNumber)
    Return $aResult[0]
EndFunc   ;==>_C843_Connect

Func _C843_GetError($ID)
    Local $aResult
    $aResult = DllCall($_C843_DLL, "int", "C843_GetError", "int", $ID)
    Return $aResult[0]
EndFunc   ;==>_C843_GetError

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   ;==>_C843_TranslateError
#EndRegion DLL initialization and comm functions

#Region general

;===============================================================================
;
; 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   ;==>_C843_qVST
#EndRegion general

Share this post


Link to post
Share on other sites



As a Workaround i have changed the AutoIt3Wrapper.au3 (Version 2.0.0.1 Line 1036)

But i would really like to know what ErrorStdOut changes in the environment, that some external DLLs wont work anymore.

; Run your script
  $ScriptFile_In_Path = StringLeft($ScriptFile_In, StringInStr($ScriptFile_In, "\", 0, -1))
  $ScriptFile_In_File = StringMid($ScriptFile_In, StringInStr($ScriptFile_In, "\", 0, -1) + 1)
  $Pid = Run('"' & $AutoIT3_PGM & '" /ErrorStdOut "' & $ScriptFile_In_File & '" ' & $s_CMDLine, $ScriptFile_In_Path, -1, $STDERR_CHILD + $STDOUT_CHILD)

Bye, Hawkear

Share this post


Link to post
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
Sign in to follow this  
Followers 0