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$
  • $\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$ – ciao Jun 5 '14 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$ – mfvonh Jun 5 '14 at 14:03
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];
| improve this answer | |
$\endgroup$
  • $\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$ – Jozef Mar 4 '16 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.