mex file and gpib link

1 vue (au cours des 30 derniers jours)
Vlad
Vlad le 11 Juin 2014
Hello everyone.
I have the following question. I adjust some device via gpib-connection. In main m-file I write:
glink=gpib('ni', 0 , 1);
Can I call my mex-file with glink parameter: myMex(glink)? I mean, there is a string somewhere in mex-file:
fopen(glink);
fprintf(glink, '*IDN?');
fscanf(glink);
fclose(glink);
And how can I check glink is an object? Does the 'mxIsObject' exist?

Réponses (2)

James Tursa
James Tursa le 11 Juin 2014
To examine what the class name is for a variable in a mex routine you can use mxGetClassName:
E.g.,
char *classname;
classname = mxGetClassName(prhs[0]);
Then you can test classname against any particular string (e.g., "glink") to see if it is an object of that class.

Dekun Pei
Dekun Pei le 16 Juin 2014
In addition to what James said, I would be careful with using "fopen", "fprintf", "fscanf" and "fclose" in your mex file. These functions in MATLAB are overloaded to support instrument objects. However, this is NOT the case in mex file as the C/C++ version of these function will be used and they are most definitely not set up to handle MATLAB objects.
If you must use them on glink in a C/C++ mex file, call them through "mexCallMATLAB" (<http://www.mathworks.com/help/matlab/apiref/mexcallmatlab.html)>, which essentially calls these function in MATLAB.

Catégories

En savoir plus sur External Language Interfaces dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by