Problems with calling a function from a dll
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello, I have a question regarding the usage of a dll with the calllib function. More precisely, I want to read in data from a laser and as I have limited experience with C, C++ and whatnot, I am using Matlab. The dll is provided by the laser manufacturer and I actually can establish a connection with the sensor via the loadlibrary and the calllib function. However I have a particular problem with one function, which is needed for getting information from the sensor and which I need to proceed. My question is if you guys can check my little piece of code, in order to tell me if there is a something entirely wrong with it.
% -- Download the linearisation table from the sensor for the DLL --
% libfunctionsview shows:
% [int32, voidPtr, cstring, cstring] EthernetScanner_GetInfo (voidPtr, cstring, int32, cstring)
Following is the information from the provided header file.
void *pEthernetScanner: the Handle of the Scanner
%char *chInfo: String-Buffer for the general Information's(eds with \0)
%int iBuffer: Size of the String Buffer
%char *chMode: resesrved for future: "xml"
extern int _stdcall EthernetScanner_GetInfo(void *pEthernetScanner, char *chInfo, int iBuffer, char *chMode);
And this is how I am calling the function.
iRes = calllib ('EthernetScanner','EthernetScanner_GetInfo', m_CEthernetScannerScanner1, blanks(100), numel(blanks(100)), 'xml');
I have found a C++ test file where it is called like this:
iRes = EthernetScanner_GetInfo(m_CEthernetScannerScanner1, m_chEthernetScanner1InfoXML, ETHERNETSCANNER_GETINFOSIZEMAX, "xml");
with the iBuffer
#define ETHERNETSCANNER_GETINFOSIZEMAX 128 * 1024
Any advice is appreciated.
Cheers
댓글 수: 0
답변 (1개)
Philip Borghesani
2017년 6월 23일
편집: Philip Borghesani
2017년 6월 23일
Without an error message or description of what is going wrong all we can do is guess at it. I would start with this code instead:
ScannerSizeMax=128*1024 ; % any size big enough should work
[iRes, ~, info] = calllib ('EthernetScanner','EthernetScanner_GetInfo', m_CEthernetScannerScanner1, blanks(ScannerSizeMax), ScannerSizeMax, 'xml')
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!