Why do I receive the error "Invalid Signal" when using "getsignal" from Simulink Real-Time in R2020a and earlier?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 9 Fév 2017
Modifié(e) : MathWorks Support Team
le 29 Juil 2021
I'm trying to retrieve the value of a signal from my Simulink Real-Time (SLRT) model running on the target machine. However, "getsignal" claims that the signal does not exist - despite it being listed:
>> tg.load('rtapp');
>> tg.ShowSignals = 'on'
Target: TargetPC1
Connected = Yes
Application = rtapp
Mode = Real-Time Single-Tasking
Status = running
CPUOverload = none
<...>
Scopes = 1
NumSignals = 2
ShowSignals = on
Signals = INDEX VALUE Type BLOCK NAME LABEL
0 1.000000 DOUBLE Gain myGain
1 0.737111 DOUBLE Source block mySource
NumParameters = 2
ShowParameters = off
>> tg.getsignal('myGain')
Error using xpctarget.xpc/getsignal
Invalid Signal
What am I doing wrong?
Réponse acceptée
MathWorks Support Team
le 29 Juil 2021
Modifié(e) : MathWorks Support Team
le 29 Juil 2021
The SimulinkRealTime.target.getsignal function accepts either a signal ID or a SLRT signal name (block path) as the input. In this case, although "myGain" is the name of the Simulink signal, it is considered the label of the SLRT signal.
To access the signal by label, we must first access its signal ID, as follows:
>> sigID = tg.getsignalidsfromlabel('myGain');
>> tg.getsignal(sigID)
However, we recommend using "getsignal" with the block path instead of the signal label. For instance:
>> tg.getsignal('Gain')
This is a neater solution to access the signal compared to using the signal ID.
More information regarding accessing SLRT signals by name can be found in the documentation: https://www.mathworks.com/help/releases/R2020a/xpc/api/getsignal.html#d120e44386
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Target Computer Setup dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!