serial port access and code generation errors
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to use the codegen function to create c code. I get the following fault when using the serial function:
'serial' is not a supported enumeration. For code generation, enumerations must inherit from 'int32' or 'Simulink.IntEnumType'.
I also get an error when using instrfind. The error function is as follows:
'serial' is not a supported enumeration. For code generation, enumerations must inherit from 'int32' or 'Simulink.IntEnumType'.
Is it possible to create a work around that will allow the codegen to create the c code or is it impossible? Thank you.
0 commentaires
Réponse acceptée
Alexander Bottema
le 5 Juil 2011
This is a bad error message (and has been fixed for later releases). The issue here is that the 'serial' function is not supported for code generation because it is a class.
The function 'instrfind' gives a different error message though. It says:
??? The function 'instrfind' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.
So the issue here is that you're trying to use functions that are not supported for code generation. As our goal is to generate standalone ANSI-C, there's no ANSI-C equivalent for what you're trying to do (the serial COM layer in MATLAB goes through Java).
Basically, you have two options:
1) Write your own equivalent custom C code to manage these functions and use coder.ceval to call your custom C code. 2) If your plan is to use MEX generated functions (C code itself irrelevant) then you can declare these functions as coder.extrinsic and let the MATLAB environment handle the calls to 'serial' and 'instrfind' at runtime.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Deployment, Integration, and Supported Hardware 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!