How to block a drawnow from executing callbacks?
Mathworks has recklessly put a drawnow inside of its asynciolib for hardware read and writes:
toolboxsharedasynciolib+matlabshared+asyncio+internalStream.m Line 184: drawnow(‘limitrate’);
This will then execute callbacks in the middle of data transfer! I could remove those lines of code for every Matlab install, but if an update restores the code then I have a dangerous bug. Is there a way I can temporarily pause the event queue from executing callbacks?
The following function CallbackTest has a 10 second main loop which should not be interrupted with the press of a button. However if TCPIP commands are executed in the loop then a hidden drawnow is invoked and the button callback will be processed.
function CallbackTest(Do_TCPIP)
% Test to see if TCPIP reads evaluate callbacks.
% There is a 10s main loop which the button callback should not interrupt.
% The main loop will not be interrupted when Do_TCPIP is 0.
% However when Do_TCPIP is 1 then it will be interrupted.
%Initialize figure and button
hFigure=uifigure();
uibutton(hFigure,ButtonPushedFcn=@ACallBack);
%Initialize TCPIP
echotcpip("on",4000);
t = tcpclient("localhost",4000);
configureTerminator(t,"CR");
waitfor(hFigure,’FigureViewReady’)
%10 second main loop which should not be interrupted because there is no drawnow, figure, pause, or waitfor command
n=0;
while n < 20
if Do_TCPIP
writeline(t,"loop");
readline(t);
end
n=n+1;
java.lang.Thread.sleep(500);
end
% Wrap up
echotcpip("off");
delete(hFigure)
fprintf(‘Done!n’);
end
function ACallBack(~,~)
fprintf(‘Main loop interrupted.n’);
endMathworks has recklessly put a drawnow inside of its asynciolib for hardware read and writes:
toolboxsharedasynciolib+matlabshared+asyncio+internalStream.m Line 184: drawnow(‘limitrate’);
This will then execute callbacks in the middle of data transfer! I could remove those lines of code for every Matlab install, but if an update restores the code then I have a dangerous bug. Is there a way I can temporarily pause the event queue from executing callbacks?
The following function CallbackTest has a 10 second main loop which should not be interrupted with the press of a button. However if TCPIP commands are executed in the loop then a hidden drawnow is invoked and the button callback will be processed.
function CallbackTest(Do_TCPIP)
% Test to see if TCPIP reads evaluate callbacks.
% There is a 10s main loop which the button callback should not interrupt.
% The main loop will not be interrupted when Do_TCPIP is 0.
% However when Do_TCPIP is 1 then it will be interrupted.
%Initialize figure and button
hFigure=uifigure();
uibutton(hFigure,ButtonPushedFcn=@ACallBack);
%Initialize TCPIP
echotcpip("on",4000);
t = tcpclient("localhost",4000);
configureTerminator(t,"CR");
waitfor(hFigure,’FigureViewReady’)
%10 second main loop which should not be interrupted because there is no drawnow, figure, pause, or waitfor command
n=0;
while n < 20
if Do_TCPIP
writeline(t,"loop");
readline(t);
end
n=n+1;
java.lang.Thread.sleep(500);
end
% Wrap up
echotcpip("off");
delete(hFigure)
fprintf(‘Done!n’);
end
function ACallBack(~,~)
fprintf(‘Main loop interrupted.n’);
end Mathworks has recklessly put a drawnow inside of its asynciolib for hardware read and writes:
toolboxsharedasynciolib+matlabshared+asyncio+internalStream.m Line 184: drawnow(‘limitrate’);
This will then execute callbacks in the middle of data transfer! I could remove those lines of code for every Matlab install, but if an update restores the code then I have a dangerous bug. Is there a way I can temporarily pause the event queue from executing callbacks?
The following function CallbackTest has a 10 second main loop which should not be interrupted with the press of a button. However if TCPIP commands are executed in the loop then a hidden drawnow is invoked and the button callback will be processed.
function CallbackTest(Do_TCPIP)
% Test to see if TCPIP reads evaluate callbacks.
% There is a 10s main loop which the button callback should not interrupt.
% The main loop will not be interrupted when Do_TCPIP is 0.
% However when Do_TCPIP is 1 then it will be interrupted.
%Initialize figure and button
hFigure=uifigure();
uibutton(hFigure,ButtonPushedFcn=@ACallBack);
%Initialize TCPIP
echotcpip("on",4000);
t = tcpclient("localhost",4000);
configureTerminator(t,"CR");
waitfor(hFigure,’FigureViewReady’)
%10 second main loop which should not be interrupted because there is no drawnow, figure, pause, or waitfor command
n=0;
while n < 20
if Do_TCPIP
writeline(t,"loop");
readline(t);
end
n=n+1;
java.lang.Thread.sleep(500);
end
% Wrap up
echotcpip("off");
delete(hFigure)
fprintf(‘Done!n’);
end
function ACallBack(~,~)
fprintf(‘Main loop interrupted.n’);
end drawnow, tcpip, hardware, callbacks MATLAB Answers — New Questions