6
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ I don't recall "short" or "char" being a valid type for the definition - shouldn't they be "integer" and "string" (or "char*"? $\endgroup$ Commented Jun 5, 2014 at 7:52
  • $\begingroup$ 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? $\endgroup$ Commented Jun 5, 2014 at 14:03

1 Answer 1

2
$\begingroup$

"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]; 
$\endgroup$
1
  • $\begingroup$ 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! $\endgroup$ Commented Mar 4, 2016 at 11:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.