Why do I receive the error "Invalid Signal" when using "getsignal" from Simulink Real-Time in R2020a and earlier?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 9 de Feb. de 2017
Editada: MathWorks Support Team
el 29 de Jul. de 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?
Respuesta aceptada
MathWorks Support Team
el 29 de Jul. de 2021
Editada: MathWorks Support Team
el 29 de Jul. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Target Computer Setup en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!