Calling library problem

조회 수: 7 (최근 30일)
Perron Jonathan
Perron Jonathan 2011년 3월 10일
댓글: ludwig law 2017년 5월 5일
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);

채택된 답변

Kaustubha Govind
Kaustubha Govind 2011년 3월 10일
Why do you define libname as:
libname=strtok(hfile,'.');
The original code says:
libname=strtok(dllfile,'.');
  댓글 수: 1
ludwig law
ludwig law 2017년 5월 5일
right ans.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Perron Jonathan
Perron Jonathan 2011년 3월 10일
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
Walter Roberson
Walter Roberson 2011년 3월 10일
perhaps you are looking for fileparts() to extract just the name ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 TDMS Format Files에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by