SetSimViewingDevice(true)' , which prevents an output port from being created for the S-function.
4 次查看(过去 30 天)
显示 更早的评论
hello every one.
I am using serial receive port block in simulink while trying to read data from serial port I am getting this error message can any explain me what is this and how to solve this the error message is :-
Level-2 MATLAB S-function 'sserialrb' in 'ardled/Serial Receive' specifies 'SetSimViewingDevice(true)' , which prevents an output port from being created for the S-function.
I already saw that it don't work on rapid accelerator and only on normal or accelerator. But the problem is that this is already on normal mode. Is there an answer to solve this problem?
You can see the problem and the setting of normal mode in the pictures below.


thank you
2 个评论
回答(1 个)
Aravind
2025-3-13
The "SetSimViewingDevice" parameter is used to prevent S-functions from generating code. The "Serial Receive" block is implemented as an S-function and does not support code generation, so the "SetSimViewingDevice" parameter is set to "true" to stop it from attempting code generation. You can find more information in these links and documentation pages:
- https://www.mathworks.com/matlabcentral/answers/349868-what-is-setsimviewingdevice
- https://www.mathworks.com/help/simulink/sfg/simviewing-matlab.html
Based on the screenshots you shared, Simulink is trying to generate code using Embedded Coder. Even though you set the simulation mode to "Normal," it appears your model is still configured to generate code with Embedded Coder, causing the error you encountered.
To resolve this error, you could implement the serial receiving and sending functionality with custom S-functions, which means you would not use the internal blocks, or disable the code generation setup and run the simulation in "Normal" mode without code generation.
Alternatively, since code generation is supported for the "Serial Receive" and "Serial Send" blocks from MATLAB R2021a onwards, you might consider upgrading to a version later than MATLAB R2021a. This would enable you to perform code generation and deployment without encountering the error you experienced.
I hope this answers your question. If you can provide more details about your use case and setup, I can offer more specific advice.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Block and Blockset Authoring 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!