I'm trying to get the dll's working in MATLAB 2012bx64. I'm only at the loadlibrary() stage.
The SDK has the x64 DLL's which is great, but there's no x64-compatible header file so it errors immediately. Naively commenting out the "ifndef WIN32" gives the error...
Error using loadlibrary (line 419)
Building usbtc08_thunk_pcwin64 failed. Compiler output is:
cl -I"C:\Program Files\MATLAB\R2012b\extern\include" /W3 /D_CRT_SECURE_NO_DEPRECATE
/D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo -I"C:\Users\iprdadmin\Documents\MATLAB"
-I"C:\Program Files (x86)\Pico Technology\Pico Full" "usbtc08_thunk_pcwin64.c" -LD
-Fe"usbtc08_thunk_pcwin64.dll"
usbtc08_thunk_pcwin64.c
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
I don't have the chops to roll my own header files....any suggestions?
Please try this and post back here as to whether it works or not - unfortunately we don't have a 64-bit version of MATLAB to test against.
Another option might be to create a prototype file using the loadlibrary command on a 32-bit version of MATLAB and see if that works on the 64-bit version.
Matlab gives me the following error when I try that header file:
Error using loadlibrary (line 419)
Building usbtc08_thunk_pcwin64 failed. Compiler output is:
cl -I"C:\Program Files\MATLAB\R2012b\extern\include" /W3 /D_CRT_SECURE_NO_DEPRECATE
/D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo -I"C:\Users\iprdadmin\Documents\MATLAB" -I"C:\Program
Files (x86)\Pico Technology\Pico Full\USBTC08sdk_r10_5_0_19\x64" "usbtc08_thunk_pcwin64.c" -LD
-Fe"usbtc08_thunk_pcwin64.dll"
usbtc08_thunk_pcwin64.c
C:\Program Files (x86)\Pico Technology\Pico Full\USBTC08sdk_r10_5_0_19\x64\usbtc08.h(71) : error C2628:
'int64_t' followed by '__int64' is illegal (did you forget a ';'?)
C:\Program Files (x86)\Pico Technology\Pico Full\USBTC08sdk_r10_5_0_19\x64\usbtc08.h(71) : warning C4091:
'typedef ' : ignored on left of '_Longlong' when no variable is declared
...hopefully this is just a typo rather than something more fundamentally wrong?
The officially supported compiler (http://www.mathworks.com/support/compil ... win64.html) is the Windows SDK 7.1 (http://www.microsoft.com/en-us/download ... px?id=8279), but unfortunately it errors on installation for reasons that I don't fully understand, but suspect are due to work security/admin settings. Instead I installed Visual C++ 2010 Express. MATLAB won't detect this, so I forced it using 'mex -setup', 'n', option 14. I was going t o try this on my laptop at home to check if it was indeed a settings issue. The work OS is W7x64 Enterprise.
cLanguageCC.Name
ans =
Intel C++
ans =
Intel C++
ans =
Intel C++
ans =
Intel C++
ans =
Microsoft SDK
ans =
Microsoft Visual C++ 2010
ans =
Microsoft Visual C++ 2005 SP1
ans =
Microsoft Visual C++ 2008
Maybe I'm just being a little bit stupid here - do I need a C rather than C++ compiler for this?
On my laptop I install SDK 7.1 without any problem, so this is definitely something I'll have to speak to IT about. The library is loaded just fine, but now at the calllib stage to open communications comes up with a 0..
Part of the problem I'd had was with using legacy calls from a previous version of the DLL's, but now it more or less seems to be working apart from a couple of niggling things On my laptop running W7HPx64 with compilers properly installed I can now connect properly. libisloaded works fine, so on the work PC obviously there are some compiler configuration issues that I need to see IT about, but that's my problem
Some things work and some things don't (all assume a prefix of "usb_tc08_")
Things that work:
open_unit
close_unit
get_minimum_interval_ms
set_channel
get_temp_single (about 0.9 s per call)
run
stop
get_temp (about 1 ms per call )
Things that sort of work:
get_formatted_info - works, but causes MATLAB to crash if called repeatedly within a short window of time (say, 5 times in a second).
Things that don't:
get_unit_info - gives an error (0) and an empty structure if using struct([]) (although each field has the right name and some dimensions) and get_last_error says no errors have happened - using libpointer('tUSBTC08InfoPtr') gives the right fieldnames and the right datatypes but all are empty
libsfunctionsview shows up a method of "get_info2" which shouldn't be defined and when you try and call it it doesn't appear to exist.
% Get unit information
for n = 1:10
infostring = blanks(512);
[status, infostring] = calllib('usbtc08', 'usb_tc08_get_formatted_info', ...
data.unithandle, infostring, 512)
pause(0.2)
end
I'm not sure why get_info2 function is not documented but I am able to query it:
The last parameter is the information type and should be in the range 0 - 5 which should correspond to the enUSBTC08InfoLine enumerations.
Could you post the code that shows how you setup the structure and query the get_unit_info function? Are you setting the size parameter in the structure to 40?
Your code works! The problem here is that the unit_info argument wasn't right, because the Programming Guide ~= libfunctionsview == yourCode
The programming guide says it should be a char pointer (a 1xn char in matlab), where as libfunctionsview says that the unit_info argument should be a cstring (i.e. not a pointer), which is how your code is working. For what its worth, here's what I was doing:
initialValue = struct([]);
%infoPointer = initialValue;
%infoPointer = libpointer('tUSBTC08InfoPtr');
infoPointer = libpointer('tUSBTC08InfoPtr', initialValue); % same as if not specified
% reads it
[readSuccess, info] = calllib('usbtc08', 'usb_tc08_get_unit_info', handle, infoPointer);
if readSuccess
disp('Should have worked...')
else
disp('Didn''t read it properly.')
end
disp(info)
disp(get(infoPointer, 'Value'))
...but I can read temperature out of my USB TC-08 which is the most important thing...this is just tidying up loose ends.
That works for me too - I didn't realise I had to more fully define the structure before populating it. Thanks for your help! Presumably this header file will get rolled into future SDK releases so other people don't run into the same problems?
We are in the process of developing generic MATLAB Instrument Drivers for our products, but in the meantime we'll look to provide some helper files in the SDK for Customers looking to create their own scripts.