Effacer les filtres
Effacer les filtres

How to auto generate wrapper for MatLab coder generated file?

21 vues (au cours des 30 derniers jours)
Murali Kannan Thiraviam
Murali Kannan Thiraviam le 10 Juil 2017
Commenté : Royi Avital le 14 Sep 2019
I am looking for help in using the MatLab generated DLL into my application directly. I have created a simple function in MatLab:
function [RetVal] = CalculateSum(SingleDimArray)
RetVal = sum(SingleDimArray);
end
Then I used a MatLab coder to generate a C/C++ DLL, which generates binary with following syntax:
double CalculateSum(const emxArray_real_T * SingleDimArray);
My application is having different requirement for using a DLL so I have created another DLL to wrap the DLL generated from MatLab coder like:
extern "C" __declspec(dllexport) void MyCalculateSum(VARIANT* Input, double* RetVal)
{
//Fetch Input array
SAFEARRAY *pInputArray = *(Input->pparray);
long arraySize = pInputArray->rgsabound[0].cElements;
double *pData = (double *) pInputArray->pvData;
//Create Input Args - Wrapper for MatLab generated code
emxArray_real_T *MLInputArray = emxCreateWrapper_real_T(pData, 1, MySize);
//Call MatLab functions
*RetVal = CalculateSum(MLInputArray);
//Release the struct
emxFree_real_T(&MLInputArray);
}
Currently I am doing this manually. Is there any way to generate this wrapper code through MatLab coder itself? If so then I can use the binary generated by MatLab coder directly in my application. I explored the possibility of including the “Custom C Code for Generated Files” but the content that I need to feed is static. I would like to know is there any way to generate the wrapper code for all the functions which is compiled from MatLab coder. I am trying to explore the “Code Replacement Library” option but didn’t get good example. Please throw some light on this area.

Réponses (1)

Sally Al Khamees
Sally Al Khamees le 13 Juil 2017
I do not think that there is a way to do this. You will probably have to do it manually.
See if the following link helps
it has some information on code replacement.
  1 commentaire
Royi Avital
Royi Avital le 14 Sep 2019
It was really nice if there was an option to generate a code which an its entry point use regular types of C.
Namely regular pointers of C to arrays instead of the types defined by MATLAB.
To the leats you could add an auxiliray function which its input is a regular array of C and a vector of its dimensions and a scalar of the number of dimensions and its ouptut is the types of Coder.
At the moment coder yield a code which isn't fun to integrate to other projects.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by