First of all! Hello Community! This is my first post in this community! That means, most of my problems i had before (and i had a lot of them) were solved without asking a question. But now it is time!
Introduction:
I have two computers (named: 'Master' and 'Slave') running Matlab! On both i have a gui made with guide! The two computers communicate with TCP/IP via Matlab using asynchronous read/write operations. Therefor i use the 'BytesAvailableFcn' to start a communication.
For example: On the Master PC i Press a Button in the gui. In the Button-Callback i send data with TCP/IP. On the Slave PC the 'BytesAvailableFcn' - called 'Bytes_Callback' is called.
In the 'BytesAvailableFcn' i call a function from the Slave-Gui (called 'Test_Callback' (note: for testing, this function i can call also from a button)
function Bytes_Callback(obj, event)
Slave_gui('Test_Callback', hObject, eventdata, handles);
end
In these Test_Callback, i call anoter function in an external *.m file. The file called 'test_timer.m' and the function is called 'test_timer'
function Test_Callback (hObject, eventdata, handles);
test_timer;
The test_timer.m looks like followed:
function test_timer
global ok;
ok = 1;
t = timer('TimerFcn',@timer_callback, 'ExecutionMode', 'singleShot',...
start(t);
while ok
drawnow;
end
function timer_callback
ok = 0;
Problem
When i am in the while loop, the 'timer_callback' isn't called. But when i start 'Test_Callback' from Slave_Gui without TCP, it works fine!
I also noticed, when i start the routin with Master via TCP, enter while-loop with debugger and wait the 'StartDelay' time, nothing happens, but when i hit 'Exit Debugging Mode' -Button after a while, I then suddenly jump in de 'timer_callback' (i think that means, the timer_callback is in the event_queue).
So my Question, how can i interrupt my routin with an Timer? (Need this, because the 'test_timer' - Routine does exist already!
Maybe another way of solving: Can i instruct Matlab to finish the 'Bytes_Callback' fist, and afterword i call Slave_gui('Test_Callback', hObject, eventdata, handles);
Thanks a lot
Rittmeister - Matlab R2011a