Toolbox to check Enumeration cast from uint16
2 次查看(过去 30 天)
显示 更早的评论
Hi all
I am running a simulation wherein I am using a Simulink Enumerated type. So I have defined a limited amount of enumerated values inside this Enum variable. I am now doing a bit operation on this enumerated type, which cannot be performed on an enum datatype. So I change the data type to a uint16, I perform the bit operation and then cast again to the enumerated type.
I have now noticed that the model builds, but during runtime the model generates an error because the uint16 value cannot be mapped on a value inside the enumerated type. I corrected my mistake and the algorithm now works as intended.
I understand that casting to an enumerated type from a uint16 can be dangerous, but I was wondering if there is a certain testing toolbox which can detect this before compiling the code? I intend to generate embedded code from this model. Do I need Polyspace Code Prover to be 100% sure that these errors do not occur during runtime? Or how can I have guaranteed working code with enums?
Many thanks,
Jonas
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bug Finder Analysis in Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!