COM Port Interrupt in Multiwindow App

I was wondering if it is possible to pass an interrupt function between mutiwindow applications? I know that I can pass variables between apps, but could I also tell the main app to use the interrupt callback that was set in the child app?
The basic idea is as following. Two or more windows for the app. The first main window visualizes measurement results from an external board that sends messages through a COM port. The measurement results are taken automatically by the external board and transmitted as soon as a result becomes available. To keep the application clearly arranged the dialog for the selection of the used COM port should be located in another window.
This code already sets the COM Port information in the parent app when the COM port was connected.
Child:
properties (Access = private)
CallingApp
end
function startupFcn(app,mainapp)
app.CallingApp = mainapp;
freeports = serialportlist("available");
app.SelectCOMPortDropDown.Items = freeports;
end
function OKButtonPushed(app, event)
port = getappdata(app.SelectedCOMPortDropDownLabels,'comport');
s = serial(port,'BaudRate',9600);
s.BytesAvailableFcnCount = 1;
s.BytesAvailableFcn = @uartcallback;
fopen(s);
if(strcmpi(s.Status,'Open'))
setcomport(app.Callingapp,s);
end
app.delete;
end
Parent:
methods(Access=public)
function setcomport(app,port)
app.comport = port;
app.comopend = 1;
end
end
but it does not seems that I can now simply use the uartcallback in the main window. Any idea how to make it work?
Best regards,
Chris

Antworten (0)

Kategorien

Mehr zu App Building finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2019b

Gefragt:

CK
am 7 Jan. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by