Calling library problem

7 vues (au cours des 30 derniers jours)
Perron Jonathan
Perron Jonathan le 10 Mar 2011
Commenté : ludwig law le 5 Mai 2017
Hello, I am currently working on importation of .tdms files (obtained with Labview) and I'm meeting some scripting problems. Indeed, I was working on a modified version of their "Matlab TDMS example" (that can be found here : http://zone.ni.com/devzone/cda/epd/p/id/5957), and i met the following issue: From the original version, I meet no problem for calling a library, but in my version, I have this message :
??? Error using ==> calllib Library was not found
Error in ==> ReadFile_trololo at 44 [err,dummyVar,dummyVar,file]=calllib(libname,'DDC_OpenFileEx',Data_Path,'',1,fileIn);
Error in ==> run at 57 evalin('caller', [s ';']);
I had understood that my libname variable is not correct, but I don't see how I can fix this issue. For informations here is the original part of the NI file :
%Check if the paths to 'nilibddc.dll' and 'nilibddc_m.h' have been
%selected. If not, prompt the user to browse to each of the files.
if exist('NI_TDM_DLL_Path','var')==0 [dllfile,dllfolder]=uigetfile('*dll','Select nilibddc.dll'); libname=strtok(dllfile,'.'); NI_TDM_DLL_Path=fullfile(dllfolder,dllfile); end if exist('NI_TDM_H_Path','var')==0 [hfile,hfolder]=uigetfile('*h','Select nilibddc_m.h'); NI_TDM_H_Path=fullfile(hfolder,hfile); end
%Prompt the user to browse to the path of the TDM or TDMS file to read [filepath,filefolder]=uigetfile({'*.tdm';'*.tdms'},'Select a TDM or TDMS file'); Data_Path=fullfile(filefolder,filepath);
%Load nilibddc.dll (Always call 'unloadlibrary(libname)' after finished using the library) loadlibrary(NI_TDM_DLL_Path,NI_TDM_H_Path);
%Open the file (Always call 'DDC_CloseFile' when you are finished using a file) fileIn = 0; [err,dummyVar,dummyVar,file]=calllib(libname,'DDC_OpenFileEx',Data_Path,'',1,fileIn);
And here is what I have done :
%Path of the nilibdcc.dll and nilibdcc_m.h Trololopath= 'C:\Program Files\MATLAB\R2010b'; hfile = [Trololopath '\extern\include\nilibddc_m.h']; dllfile = [Trololopath '\bin\win32\nilibddc.dll']; libname=strtok(hfile,'.'); loadlibrary(dllfile, hfile);
% attribution of libname libname=strtok(dllfile,'.');
%Prompt the user to browse to the path of the TDMS file to read [filepath,filefolder]=uigetfile('*.tdms'},'Select a TDMS file'); Data_Path=fullfile(filefolder,filepath);
%Load nilibddc.dll (Always call 'unloadlibrary(libname)' after finished using the library) loadlibrary(dllfile,hfile);
%Open the file (Always call 'DDC_CloseFile' when you are finished using a file) fileIn = 0; [err,dummyVar,dummyVar,file]=calllib(libname,'DDC_OpenFileEx',Data_Path,'',1,fileIn);

Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 10 Mar 2011
Why do you define libname as:
libname=strtok(hfile,'.');
The original code says:
libname=strtok(dllfile,'.');
  1 commentaire
ludwig law
ludwig law le 5 Mai 2017
right ans.

Connectez-vous pour commenter.

Plus de réponses (1)

Perron Jonathan
Perron Jonathan le 10 Mar 2011
Oops, indeed, it is. I had fix that point since then, but I still got have my problem. I think I have found from where is coming the problem. When I execute the original version, libname takes the value "nilibddc", but when I execute my version, libname takes "C:\Program Files\MATLAB\R2010b\bin\win32\nilibddc". I tried several things, including libname = 'nilibddc', but it is still not working. So, I guess that this is because of the lines :
[dllfile,dllfolder]=uigetfile('*dll','Select nilibddc.dll');
libname=strtok(dllfile,'.');
When I run the original code, dllfile takes the value "nilibdcc.dll" and dllfolder, the path of the folder, so it explains me why libname take the value "nilibdcc". But, in my code, I don't want to use uigetfile,so is there another function with the same way to use [dllfile,dllfolder] ?
  1 commentaire
Walter Roberson
Walter Roberson le 10 Mar 2011
perhaps you are looking for fileparts() to extract just the name ?

Connectez-vous pour commenter.

Catégories

En savoir plus sur TDMS Format Files dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by