- https://www.mathworks.com/matlabcentral/answers/349868-what-is-setsimviewingdevice
- https://www.mathworks.com/help/simulink/sfg/simviewing-matlab.html
Serial receive simulink block of a USB IMU
6 views (last 30 days)
Show older comments
I am trying to use the serial configuration and receive blocks to read IMU data but when I do I get this error:
Level-2 MATLAB S-function 'sserialrb' in 'IMU/Treadmill Hardware Interface/Serial Receive' specifies 'SetSimViewingDevice(true)' , which prevents an output port from being created for the S-function.
I have seen this asked in:
But I have not seen any resolution and have had trouble building my own S-function. I have explored the QUARC Stream Call and Mulitwii Connect but I need an additional license and I would rather not do that.
0 Comments
Answers (1)
Aravind
on 13 Mar 2025
The "SetSimViewingDevice" parameter is used to prevent S-functions from generating code. Since the "Serial Receive" block is implemented as an S-function and does not support code generation in MATLAB R2018a, the "SetSimViewingDevice" parameter is set to "true" to avoid attempting code generation. You can find more information in the following links and documentation pages:
Upon reviewing the Simulink file you shared, I noticed it is configured for code generation and deployment using the "quarc_win64.tlc" system target file. When you run or build the model, it attempts to generate code, which is not supported for the "Serial Receive" block, resulting in the error you encountered.
To resolve this error in MATLAB R2018a, you could either implement the serial receiving and sending functionality with custom S-functions, avoiding the internal blocks, or perform 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 allow code generation and deployment without 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 Comments
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!