Shared library problems C++
Show older comments
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
Answers (1)
Guillaume
on 26 Oct 2016
0 votes
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.
Categories
Find more on Call C from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!