serial port access and code generation errors

17 Ansichten (letzte 30 Tage)
samson p
samson p am 4 Jul. 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.

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Deployment, Integration, and Supported Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by