serial port access and code generation errors
20 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Alexander Bottema
2011-7-5
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!