Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Pass arbitrary pointer type between mex functions
Replies: 6   Last Post: Dec 4, 2012 6:24 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Chris

Posts: 1
Registered: 12/4/12
Some hints or code snippets of the solution.
Posted: Dec 4, 2012 6:24 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Cody" wrote in message <jprg9e$184$1@newscl01ah.mathworks.com>...
> Thanks for the suggestions! I was able to pass the pointer created in the mex functions by a lower-level C library back to the Matlab environment in an appropriately sized mxArray and then back into a different mex function as suggested. I was also able to declare a persistent memory location in the mex-file C-code so that sucessive invocations of the same mex function could access the pointer.

Hey Cody,

I'm facing exactly the same problem: I have a USB device to which I can transmit data via a provided driver. I call the driver's functions within a mex-File and want to open the device, transmit data and eventually close the device. The handle which I receive from the open-function (of the driver) is an unsigned long variable. However, I'm quite frustrated because I'm not able to pass this device handle back to Matlab so as to call another mex-function which internally calls the driver function to transmit data.
So far, I've tried to create a persistent variable using mxCalloc and mxMakeMemoryPersistant but this approach does not result in the desired functionality.

I would really appreciate it if you give me a hint or some code snippets explaining your solution of this issue.

Chris



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.