Jump to content

Recommended Posts

Posted

Hi guys,

I'm not new to AutoIt but DLLs so I want to try to move on to DLL's and other magic functions..

So here one of the first issue I have. My goal is to write some script that gets values from a digital oscilloscope from PicoTech.

Its programmers guide describes on page 54 the very first DLL "ps4000OpenUnit" call to initialize and should return "PICO OK" or so.

 

PICO_STATUS ps4000OpenUnit

(

int16_t * handle

)

 

This is what I have for now:

$dll = DllOpen(@ScriptDir & "\ps4000.dll")


$handle = DllCall($dll, "int", "ps4000OpenUnit", "str*", 0)
$nError = @error

If IsArray($handle) Then

   ConsoleWrite('Handle = ' & $handle[0] & @CRLF)
   
Else

   MsgBox(16, 'Error = ' & $nError, 'Are you sure there is not more to this DLLCall?')
   
EndIf


DllClose($dll)

Exit

 

While executing the script the PicoScope splash is seen, it tries to load something and then AU3 is crashing.

The LED on the scope blinks for a moment so the hardware and drivers are connected. To me It looks like the DLL call is not written right or so.

On the web several example codes are found in C/C++, C#, Py and Excel but still no luck due to the lack of experience I guess.

Here the line of code in VBA:  Declare Function ps4000OpenUnit Lib "ps4000.dll" (ByRef handle As Integer) As Long

Perhaps some DLLstruct is needed before the DLL is called.

 

Any ideas how to go ahead with this issue? Many thanks in advance!

Posted

Hello. I did not check help file but I think this should work. 

Global $hPS4000 = DllOpen(@ScriptDir & "\ps4000.dll")


Local $aCall = DllCall($hPS4000, "long", "ps4000OpenUnit", "short*", 0)
Local $nError = @error

If IsArray($aCall) Then
    ConsoleWrite('PICO_STATUS = ' & $aCall[0] & @CRLF)
    ConsoleWrite('Handle = ' & $aCall[1] & @CRLF)
Else
    MsgBox(16, 'Error = ' & $nError, 'Are you sure there is not more to this DLLCall?')
EndIf

DllClose($hPS4000)

Exit
 

 

Saludos

Posted

Many thanks Danyfirex !

The ConsoleWrite('Handle = ' & $aCall[1] & @CRLF)  now shows me if the scope is connected or not.

I noticed AU3 always crashes when the dll has been called.  So it just displays the call to the console and then crashes. :(

Would it be possible some extra parameter has to be added to the dll call? Or is it possible to 'trace' AU3 why it crashes?

Thanks in advance, Audrey

Posted

Do you have the error/crush codes? I would guess it might be #requireadmin or #AutoIt3Wrapper_UseX64=Y or N options that you need to play with.

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
  • Recently Browsing   0 members

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