Compiler errors with PS3000a and MATLAB

Post your MATLAB discussions here
Post Reply
DavidMcKnight
Newbie
Posts: 0
Joined: Mon Aug 13, 2012 1:24 pm

Compiler errors with PS3000a and MATLAB

Post by DavidMcKnight »

Hi,

I've been trying to get a 3206B to talk with MATLAB, with not too much success. I modified a very simple script from elsewhere on this board and when I try to get it to run, the compiler complains and returns some errors.

I suspect that either a compiler setting has gone wrong, or there is some additional header file required and is missing, but if someone could give me some hints where to start to look that would be very much appreciated.

Code: Select all

    global data;

    loadlibrary('PS3000a.dll','ps3000aApi.h');
    if ~libisloaded('PS3000a')
        error('library PS3000a.dll or PS3000a.h not found') %check if the library is loaded
    end

    data.unithandle = 0;
    data.serial =[];

    [status_open, data.unithandle, data.serial] = calllib('PS3000a', 'ps3000aOpenUnit', data.unithandle, data.serial)

    status_close = calllib('PS3000a', 'ps3000aCloseUnit', data.unithandle);

    unloadlibrary('PS3000a');

The errors I get are:

Code: Select all

>> PicoMatlab
Warning: Warnings messages were produced while parsing.  Check the functions you intend to use for correctness.  Warning text can be viewed using:
 [notfound,warnings]=loadlibrary(...) 
> In loadlibrary at 347
  In PicoMatlab at 4 
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********

Type 'u_int64_t' was not found.  Defaulting to type error.

Found on line 6609 of input from line 812 of file C:\\Users\\david.mcknight\\Documents\\MATLAB\\WSL\\ps3000aApi.h
*********
Error using loadlibrary (line 421)
Building PS3000a_thunk_pcwin64 failed.  Compiler output is:
cl -I"C:\Program Files\MATLAB\R2011b\extern\include"   /W3  /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0  /nologo
-I"C:\Users\david.mcknight\Documents\MATLAB\WSL" -I"C:\Users\david.mcknight\Documents\MATLAB\WSL" "PS3000a_thunk_pcwin64.c" -LD -Fe"PS3000a_thunk_pcwin64.dll"
PS3000a_thunk_pcwin64.c
C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(54) : error C2628: 'int64_t' followed by '__int64' is illegal (did you forget a ';'?)
C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(54) : warning C4091: 'typedef ' : ignored on left of '_Longlong' when no variable is declared
C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(810) : error C2146: syntax error : missing ')' before identifier 'holdoff'
C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(810) : error C2081: 'u_int64_t' : name in formal parameter list illegal
C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(810) : error C2061: syntax error : identifier 'holdoff'
C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(810) : error C2059: syntax error : ';'
C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(810) : error C2059: syntax error : ','
C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(812) : error C2059: syntax error : ')'
PS3000a_thunk_pcwin64.c(951) : error C2065: 'u_int64_t' : undeclared identifier
PS3000a_thunk_pcwin64.c(951) : error C2146: syntax error : missing ';' before identifier 'p1'
PS3000a_thunk_pcwin64.c(951) : error C2065: 'p1' : undeclared identifier
PS3000a_thunk_pcwin64.c(952) : error C2275: 'PS3000A_HOLDOFF_TYPE' : illegal use of this type as an expression
        C:\Users\david.mcknight\Documents\MATLAB\WSL\ps3000aApi.h(329) : see declaration of 'PS3000A_HOLDOFF_TYPE'
PS3000a_thunk_pcwin64.c(952) : error C2146: syntax error : missing ';' before identifier 'p2'
PS3000a_thunk_pcwin64.c(952) : error C2065: 'p2' : undeclared identifier
PS3000a_thunk_pcwin64.c(955) : error C2065: 'p1' : undeclared identifier
PS3000a_thunk_pcwin64.c(955) : error C2146: syntax error : missing ')' before identifier 'u_int64_t'
PS3000a_thunk_pcwin64.c(955) : error C2065: 'u_int64_t' : undeclared identifier
PS3000a_thunk_pcwin64.c(955) : error C2100: illegal indirection
PS3000a_thunk_pcwin64.c(955) : error C2059: syntax error : ')'
PS3000a_thunk_pcwin64.c(955) : error C2297: '*' : illegal, right operand has type 'const char *'
PS3000a_thunk_pcwin64.c(956) : error C2065: 'p1' : undeclared identifier
PS3000a_thunk_pcwin64.c(956) : error C2065: 'p1' : undeclared identifier
PS3000a_thunk_pcwin64.c(956) : error C2065: 'p1' : undeclared identifier
PS3000a_thunk_pcwin64.c(957) : error C2065: 'p2' : undeclared identifier
PS3000a_thunk_pcwin64.c(958) : error C2065: 'p2' : undeclared identifier
PS3000a_thunk_pcwin64.c(958) : error C2065: 'p2' : undeclared identifier
PS3000a_thunk_pcwin64.c(958) : error C2065: 'p2' : undeclared identifier
PS3000a_thunk_pcwin64.c(959) : error C2059: syntax error : ','
PS3000a_thunk_pcwin64.c(959) : error C2146: syntax error : missing ')' before identifier 'u_int64_t'
PS3000a_thunk_pcwin64.c(959) : error C2146: syntax error : missing ')' before identifier 'u_int64_t'
PS3000a_thunk_pcwin64.c(959) : error C2065: 'u_int64_t' : undeclared identifier
PS3000a_thunk_pcwin64.c(959) : error C2059: syntax error : 'type'
PS3000a_thunk_pcwin64.c(963) : error C2061: syntax error : identifier 'ulongint16PS3000A_CHANNEL_INFOint32voidPtrvoidPtrint32Thunk'
PS3000a_thunk_pcwin64.c(963) : error C2059: syntax error : ';'
PS3000a_thunk_pcwin64.c(963) : error C2059: syntax error : 'type'

Error in PicoMatlab (line 4)
loadlibrary('PS3000a.dll','PS3000aApi.h');

Hitesh

Re: Compiler errors with PS3000a and MATLAB

Post by Hitesh »

Hi David,

It looks as though the compiler is not picking up the PicoStatus.h file - you might be able to confirm this by calling the 'libfunctionsview' function on the library and seeing the the return type for the 'status' value from the PS3000a dll function call.

Please refer to the following post in this forum:

http://www.picotech.com/support/topic10809.html

which uses the 'addheader' function; the alternative being to create your own protofile.

Regards,

DavidMcKnight
Newbie
Posts: 0
Joined: Mon Aug 13, 2012 1:24 pm

Re: Compiler errors with PS3000a and MATLAB

Post by DavidMcKnight »

Hi Hitesh,

Thanks for looking at the problem. It wasn't the PicoStatus.h file (which I renamed and tried again and got a very different error message)

I've got the code to compile now, by changing the following things:
1) Commenting out line 54. It was typedef int64_t __int64; and came right after an #include stdint.h, which I think includes this.
2) Changing line 810 from u_int64_t to uint64_t

It now compiles, but when I try to run it MATLAB is unhappy about the dll file.
Error using loadlibrary (line 421)
There was an error loading the library "C:\Users\david.mcknight\Documents\MATLAB\WSL\PS3000a.dll"
C:\Users\david.mcknight\Documents\MATLAB\WSL\PS3000a.dll is not a valid Win32 application.

Caused by:
Error using loaddefinedlibrary
C:\Users\david.mcknight\Documents\MATLAB\WSL\PS3000a.dll is not a valid Win32 application.
I am wondering if it might be that my 64 bit version of MATLAB is having trouble with the driver running in 32bit compatibility mode. Might it be possible to get a DLL compiled as 64bit?

Hitesh

Re: Compiler errors with PS3000a and MATLAB

Post by Hitesh »

Hi David,

Thanks for your reply.

I hadn't realised you are using a 64-bit version of MATLAB. Unfortunately, we do not have any 64-bit drivers available. It is something that is being considered but there are no immediate plans for a 64-bit driver.

Regards,

Hitesh

Re: Compiler errors with PS3000a and MATLAB

Post by Hitesh »

Update:

64-bit drivers are now available in the Software Development Kit.

Post Reply