serial port access and code generation errors

20 visualizaciones (últimos 30 días)
samson p
samson p el 4 de Jul. de 2011
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.

Respuesta aceptada

Alexander Bottema
Alexander Bottema el 5 de Jul. de 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.

Más respuestas (0)

Categorías

Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by