MATLAB Answers

Toolbox to check Enumeration cast from uint16

2 ビュー (過去 30 日間)
Jonas 2020 年 7 月 7 日
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,

  0 件のコメント


回答 (0 件)




Community Treasure Hunt

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

Start Hunting!

Translated by