How to Implement Legacy Code that can be called both in Simulink and MATLAB?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
We have a Simulink Coder project we are working on, and I've gotten relatively familiar with using S-Function Builder blocks to copy old legacy code that we have into the S-Function Wrapper code and use it to create code that will get compiled into Simulink. Now we are learning how to create Test Harnesses to validate the performance of our models. One part of the model uses a custom CRC calculator compiled into an S-Function. Since I need the Test Assessment block to verify that the CRC was calculated correctly, I also need the Test Assessment block to be able to call the CRC calculator, but this means the same legacy code has to be executable in the MATLAB environment since it uses the MATLAB action language. Is there some way to call the already-built S-Function from a MATLAB context, or does it have to be built using a different method to be able to be called from both contexts?
0 Commenti
Risposte (1)
Eeshan Mitra
il 28 Dic 2023
A Test Assessment or Test Sequence block cannot directly call an S-Function. However, if the S-Function has input and output ports, the Test Sequence/Test Assessment block can be used to drive inputs and read/verify outputs.
One approach is to generate a Simulink Test harness around the S-Function block (See https://www.mathworks.com/help/sltest/gs/create-a-test-harness.html)
Within the harness creation dialog you can choose a checkbox to insert a Test Assessment block to read the output of the harnessed component (the S-Function block) and perform verifications.
Vedere anche
Categorie
Scopri di più su Inputs in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!