Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/Unable to attach add_exec_event_listener to a block when using Simulink Compiler

Unable to attach add_exec_event_listener to a block when using Simulink Compiler

PuTI / 2025-02-04
Unable to attach add_exec_event_listener to a block when using Simulink Compiler
Matlab News

I am trying to get real-time data from simulink model (rtl-sdr receiver) and display it on gui, so I am using `add_exec_event_listener` in Simulink model callback as written here: https://www.mathworks.com/matlabcentral/answers/446302-how-do-i-update-a-gui-designed-in-app-designer-with-data-from-a-running-simulink-model
Interaction with model based on Simulink Compiler functions, e.g. creation a SimulationInput object and simulink.compiler.configureForDeployment.
The problem is that I get an error when the line below is executed:
out=sim(in)
Full text of an error:
Error evaluating ‘StartFcn’ callback of block_diagram ‘gsmAdGui2’.
Callback string is ‘blk = ‘gsmAdGui2/Gain’;
event = ‘PostOutputs’;
listener = @(app, event) updateGUI(hApp);
h = add_exec_event_listener(blk, event, listener);
Caused by:
Error using Simulink.Simulation.internal.DesktopSimHelper
Adding a listener for a block method execution event for ‘gsmAdGui2/Gain’ is not supported. Listeners can be added only when block diagram is executing.
I don’t understand what should I do to correctly attach the listener to a gain block (because it cannot be attached directly to a rtl-sdr). Thank for any help.
Here is main callback function:
function StartButtonPushed(app, event)
app.StartButton.Enable = ‘off’;
app.StopButton.Enable = ‘on’;
app.SamplingRate=app.SampRateEditField.Value;
%Create a SimulationInput object for this model
in=Simulink.SimulationInput(app.modelName);
in=in.setModelParameter(‘StartTime’,’0.01′,’StopTime’, num2str(app.StopTimeEditField.Value));
in = in.setVariable(‘sdrGain’, app.GainEditField.Value);
in = in.setVariable(‘fc’, app.CenterFreqEditField.Value);
in = in.setVariable(‘sampRate’, app.SamplingRate);
in.applyToModel;
in=simulink.compiler.configureForDeployment(in);
out=sim(in);%запуск симуляции
app.StartButton.Enable = ‘on’;
app.StopButton.Enable = ‘off’;
end
Here is updateGUI function that receives real-time data from model:
function updateGUI(app, varargin) %plots fft of received 2048 samples per frame iq stream
% Create an object that gets the run-time value of the specified block
rto = get_param([bdroot,’/Gain’],’RuntimeObject’);
% Update the GUI accordingly
currentTime = rto.CurrentTime;
app.SimTime.Text = num2str(currentTime);
sdrData = rto.InputPort(1).Data;
sdrData=sdrData.*app.W; % hamming window
sdrFft = fftshift(fft(sdrData));
sdrFft=20*log10((abs(sdrFft))/2048);
plot(app.UIAxes, app.freqvec, sdrFft,’b’);
end
Here is model InitFcn: hApp = sdrAdGui8 %name of an app
Here is model StartFcn:
blk = ‘gsmAdGui2/Gain’; %block to listen
event = ‘PostOutputs’;
listener = @(app, event) updateGUI(hApp);
h = add_exec_event_listener(blk, event, listener);I am trying to get real-time data from simulink model (rtl-sdr receiver) and display it on gui, so I am using `add_exec_event_listener` in Simulink model callback as written here: https://www.mathworks.com/matlabcentral/answers/446302-how-do-i-update-a-gui-designed-in-app-designer-with-data-from-a-running-simulink-model
Interaction with model based on Simulink Compiler functions, e.g. creation a SimulationInput object and simulink.compiler.configureForDeployment.
The problem is that I get an error when the line below is executed:
out=sim(in)
Full text of an error:
Error evaluating ‘StartFcn’ callback of block_diagram ‘gsmAdGui2’.
Callback string is ‘blk = ‘gsmAdGui2/Gain’;
event = ‘PostOutputs’;
listener = @(app, event) updateGUI(hApp);
h = add_exec_event_listener(blk, event, listener);
Caused by:
Error using Simulink.Simulation.internal.DesktopSimHelper
Adding a listener for a block method execution event for ‘gsmAdGui2/Gain’ is not supported. Listeners can be added only when block diagram is executing.
I don’t understand what should I do to correctly attach the listener to a gain block (because it cannot be attached directly to a rtl-sdr). Thank for any help.
Here is main callback function:
function StartButtonPushed(app, event)
app.StartButton.Enable = ‘off’;
app.StopButton.Enable = ‘on’;
app.SamplingRate=app.SampRateEditField.Value;
%Create a SimulationInput object for this model
in=Simulink.SimulationInput(app.modelName);
in=in.setModelParameter(‘StartTime’,’0.01′,’StopTime’, num2str(app.StopTimeEditField.Value));
in = in.setVariable(‘sdrGain’, app.GainEditField.Value);
in = in.setVariable(‘fc’, app.CenterFreqEditField.Value);
in = in.setVariable(‘sampRate’, app.SamplingRate);
in.applyToModel;
in=simulink.compiler.configureForDeployment(in);
out=sim(in);%запуск симуляции
app.StartButton.Enable = ‘on’;
app.StopButton.Enable = ‘off’;
end
Here is updateGUI function that receives real-time data from model:
function updateGUI(app, varargin) %plots fft of received 2048 samples per frame iq stream
% Create an object that gets the run-time value of the specified block
rto = get_param([bdroot,’/Gain’],’RuntimeObject’);
% Update the GUI accordingly
currentTime = rto.CurrentTime;
app.SimTime.Text = num2str(currentTime);
sdrData = rto.InputPort(1).Data;
sdrData=sdrData.*app.W; % hamming window
sdrFft = fftshift(fft(sdrData));
sdrFft=20*log10((abs(sdrFft))/2048);
plot(app.UIAxes, app.freqvec, sdrFft,’b’);
end
Here is model InitFcn: hApp = sdrAdGui8 %name of an app
Here is model StartFcn:
blk = ‘gsmAdGui2/Gain’; %block to listen
event = ‘PostOutputs’;
listener = @(app, event) updateGUI(hApp);
h = add_exec_event_listener(blk, event, listener); I am trying to get real-time data from simulink model (rtl-sdr receiver) and display it on gui, so I am using `add_exec_event_listener` in Simulink model callback as written here: https://www.mathworks.com/matlabcentral/answers/446302-how-do-i-update-a-gui-designed-in-app-designer-with-data-from-a-running-simulink-model
Interaction with model based on Simulink Compiler functions, e.g. creation a SimulationInput object and simulink.compiler.configureForDeployment.
The problem is that I get an error when the line below is executed:
out=sim(in)
Full text of an error:
Error evaluating ‘StartFcn’ callback of block_diagram ‘gsmAdGui2’.
Callback string is ‘blk = ‘gsmAdGui2/Gain’;
event = ‘PostOutputs’;
listener = @(app, event) updateGUI(hApp);
h = add_exec_event_listener(blk, event, listener);
Caused by:
Error using Simulink.Simulation.internal.DesktopSimHelper
Adding a listener for a block method execution event for ‘gsmAdGui2/Gain’ is not supported. Listeners can be added only when block diagram is executing.
I don’t understand what should I do to correctly attach the listener to a gain block (because it cannot be attached directly to a rtl-sdr). Thank for any help.
Here is main callback function:
function StartButtonPushed(app, event)
app.StartButton.Enable = ‘off’;
app.StopButton.Enable = ‘on’;
app.SamplingRate=app.SampRateEditField.Value;
%Create a SimulationInput object for this model
in=Simulink.SimulationInput(app.modelName);
in=in.setModelParameter(‘StartTime’,’0.01′,’StopTime’, num2str(app.StopTimeEditField.Value));
in = in.setVariable(‘sdrGain’, app.GainEditField.Value);
in = in.setVariable(‘fc’, app.CenterFreqEditField.Value);
in = in.setVariable(‘sampRate’, app.SamplingRate);
in.applyToModel;
in=simulink.compiler.configureForDeployment(in);
out=sim(in);%запуск симуляции
app.StartButton.Enable = ‘on’;
app.StopButton.Enable = ‘off’;
end
Here is updateGUI function that receives real-time data from model:
function updateGUI(app, varargin) %plots fft of received 2048 samples per frame iq stream
% Create an object that gets the run-time value of the specified block
rto = get_param([bdroot,’/Gain’],’RuntimeObject’);
% Update the GUI accordingly
currentTime = rto.CurrentTime;
app.SimTime.Text = num2str(currentTime);
sdrData = rto.InputPort(1).Data;
sdrData=sdrData.*app.W; % hamming window
sdrFft = fftshift(fft(sdrData));
sdrFft=20*log10((abs(sdrFft))/2048);
plot(app.UIAxes, app.freqvec, sdrFft,’b’);
end
Here is model InitFcn: hApp = sdrAdGui8 %name of an app
Here is model StartFcn:
blk = ‘gsmAdGui2/Gain’; %block to listen
event = ‘PostOutputs’;
listener = @(app, event) updateGUI(hApp);
h = add_exec_event_listener(blk, event, listener); app designer, gui, event listener, simulink compiler MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Warning: Error updating FunctionLine in using fplot
2025-05-12

Warning: Error updating FunctionLine in using fplot

Solid creation Simulink, simscape multibody: stuck in loading
2025-05-12

Solid creation Simulink, simscape multibody: stuck in loading

Issues with EMG Signal Acquisition via Simulink Desktop Real-Time (SDRT) and DAQ Board Usage
2025-05-12

Issues with EMG Signal Acquisition via Simulink Desktop Real-Time (SDRT) and DAQ Board Usage

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss