Azzera filtri
Azzera filtri

How to Implement Legacy Code that can be called both in Simulink and MATLAB?

2 visualizzazioni (ultimi 30 giorni)
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?

Risposte (1)

Eeshan Mitra
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.
  1 Commento
Dana Schwanke
Dana Schwanke il 2 Gen 2024
I know that it can't call a Simulink S-Function, but why not a MATLAB S-Function? If the action language for the Test Sequence/Test Assessment blocks is MATLAB, they should be able to call any MATLAB function, even custom ones defined in .m files, shouldn't they?

Accedi per commentare.

Categorie

Scopri di più su Test Model Components in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by