Prev: Sparse Matrix Size gets reduces when we take transpose of this
Next: Simulink Report Generation from the Command Line
From: Miles on 26 Feb 2010 09:44 Hi, I have limited MATLAB experience buit I 'm trying to call a DLL in Matlab. The DLL contains a number of functions for sending/receiving instructions to a laboratory instrument we have here. I am using calllib to send the commands. Sending commands is successful e.g. calllib('twi_mpl','SendMPMessage',1,'DOF 4'), but I am stumped how to get data back from the instrument. The DLL function descirbed in the header is: int GetMPResponse (int iToken, unsigned char* pszReply, unsigned int isize); in MATLAB I was expecting to use something like calllib('twi_mpl','GetMPResponse',1, Buffer,10); This function basically gets 10 bytes of bytes and puts it into a Buffer. But I don't know how to ge the Buffer into MATLAB. Ideally it would be an array of bytes which I can then read element by element, but I don't know how to set this up. Defining Buffer as an array doesn't work. Is it even possible using Calllib or must a mex file be made? thanks
From: Philip Borghesani on 26 Feb 2010 15:42 Try this: [retval,reply]=calllib('twi_mpl','GetMPResponse',1, blanks(10),10); "Miles " <miles(a)mathworks.spam> wrote in message news:hm8mnk$nce$1(a)fred.mathworks.com... > Hi, I have limited MATLAB experience buit I 'm trying to call a DLL in Matlab. The DLL contains a number of functions for > sending/receiving instructions to a laboratory instrument we have here. I am using calllib to send the commands. Sending commands > is successful e.g. calllib('twi_mpl','SendMPMessage',1,'DOF 4'), > > but I am stumped how to get data back from the instrument. > > The DLL function descirbed in the header is: > > int GetMPResponse (int iToken, unsigned char* pszReply, unsigned int isize); > > in MATLAB I was expecting to use something like > calllib('twi_mpl','GetMPResponse',1, Buffer,10); This function basically gets 10 bytes of bytes and puts it into a Buffer. > > But I don't know how to ge the Buffer into MATLAB. Ideally it would be an array of bytes which I can then read element by element, > but I don't know how to set this up. > Defining Buffer as an array doesn't work. > Is it even possible using Calllib or must a mex file be made? > > thanks >
From: Miles on 4 Mar 2010 08:34 Hello Philip, Thanks for the help. > > [retval,reply]=calllib('twi_mpl','GetMPResponse',1, blanks(10),10); > I shall try this but do I need to define any variables before this line? i.e. retval, reply, blanks? thanks Miles
From: Miles on 4 Mar 2010 08:48
I just tried and unfortunately I got this message: ??? Error using ==> calllib Array must be numeric or logical or a pointer to one. Error in ==> aquisition at 64 [retval,reply]=calllib('twi_mpl','GetMPResponse',1,blanks(10),10); Anyone know what this could mean? Miles |