6

I would like to call the following function from Mathematica

ps3000aOpenUnit
PICO_STATUS ps3000aOpenUnit
(
   short * handle,
   char * serial
)

I define the DLLFunciton in Mathematica:

ps3000OpenUnit =  DefineDLLFunction["ps3000aOpenUnit", "PS3000a.dll", "short", {"short[]", "char[]"}]

I get following error when executing

ps3000OpenUnit[handle, serial]
NET::methodargs: Improper arguments supplied for method named ps3000aOpenUnit.

What is wrong with my code?

Thanx for helping me in advance.

Jozef
  • 91
  • 2
  • I don't recall "short" or "char" being a valid type for the definition - shouldn't they be "integer" and "string" (or "char*"? – ciao Jun 05 '14 at 07:52
  • It seems like your function signature declares your parameters as pointers, but in your DefineDLLFunction you specify arrays. What are the values of handle and serial? – mfvonh Jun 05 '14 at 14:03

1 Answers1

2

"short" or "char" are in the C programming language data typs.

Try this:

ps3000aOpenUnit = 
  DefineDLLFunction["ps3000aOpenUnit", "ps3000a.dll", "short", {"short*"}];

handle=0;
status = ps3000aOpenUnit[handle];
Corpec
  • 43
  • 6
  • I tried this. However I am getting an error.
    NET::netexcptn: A .NET exception occurred: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    

    at Wolfram.NETLink.DynamicDLLNamespace.DLLWrapper1.ps3000aOpenUnit(Int16& ).

    any suggestions? Tnx!

    – Jozef Mar 04 '16 at 11:36