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
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 App Building 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!