Why do I receive the error "Invalid Signal" when using "getsignal" from Simulink Real-Time in R2020a and earlier?

12 ビュー (過去 30 日間)
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?

採用された回答

MathWorks Support Team
MathWorks Support Team 2021 年 7 月 29 日
編集済み: MathWorks Support Team 2021 年 7 月 29 日
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 件)

カテゴリ

Help Center および File ExchangeTarget Computer Setup についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by