Shared library problems C++
Ältere Kommentare anzeigen
Hi everyone,
I am trying to read data from a sensor using a dll-file. I actually managed to get a valid connection to the sensor, but my problem occurs at the following step when I try to get the sensor information. The information for the function I get from the header file and as Matlab converts the data types pretty much on its own, it should be straight forward. At least I thought that.
% -- 3. Get general information about the sensor --
% Scanner_Info (void *pScanner, char *chInfo, int iBuffer, char *chMode);
% signature: [int32, voidPtr, cstring, cstring] Scanner_Info (voidPtr, cstring, int32, cstring)
% pScanner = SensorHandle
chInfo = blanks(128*1024); % char-buffer: 0x00 ended (from the header file)
iBuffer = length(chInfo); % size of the input buffer
chMode = 'xml'; % „xml“
infoVal = calllib ('EthernetScanner', 'Scanner_Info', SensorHandle, chInfo, iBuffer, chMode);
The thing is that I am not getting any error message on this one. I get an integer output for infoVal, however it is not a valid one. So if I do not have an obvious mistake in the above code, the problem has to lie somewhere else. I hope I have provided enough information. To be honest I came to this point with a lot of trial and error.
Cheers
Antworten (1)
Guillaume
am 26 Okt. 2016
0 Stimmen
From a matlab point of view there is nothing wrong with what you've written (I'd use numel instead of length, it's safer, but in your case it makes no difference) so the problem is on the dll side. Maybe you misunderstood the inputs, maybe there's a bug in the dll, maybe the documentation is not adequate.
The dll interface is in C by the way. You wouldn't be able to talk to a C++ interface from matlab.
Kategorien
Mehr zu Call C from MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!