From: Jose on 8 Jun 2010 11:45 Hello everyone, I try to use the timer object instead of a while loop, because it is necessary in my software. The problem is, after the first iteration, I got the next message error: ??? Error while evaluating TimerFcn for timer 'timer-1' Invalid handle object. And I have not idea why is the problem, any help? Here below, i attach the piece of my code: ****************************************** function proc1 (src, ~) % This function is called when I click a pushbutton (e) in a global panel (mean GUI). % Connect to the server on port 3000 svrsock = mslisten(3000); sock=msaccept(svrsock) msclose(svrsock); global hfigure h1 h2 h3 h4 global isnr isnr2 isnr3 isnr4 global ssnr ssnr2 ssnr3 ssnr4 global snr snrtest global icxx global hz global deltaz sm global processpause global sumcum global anoise isxxy xcount global t1 kj global sdata global adc global suc e=get(src,'parent'); if kj(e)>0 % To be sure if i push the button (e) in the main pannel if ishandle(hfigure{e}) % for a second time nothing more happens. return; end end kj(e)=1; epsn=0 anoise(e)=0 % receive the variable1 over the socket sm_ack=6; sm_init=5; sm_startmove=1; sm_endmove=2; sm_adc=3; sm_elpsn=4; dir_bk=0; dir_fwd=1; el_notloaded=0; el_up=1; el_surf=2; el_cx=3; el_broken=-1; s=receivestructure2(sock) sendvar2m=1; isxxy(e)=0; isnr=0; ssnr=zeros(1,100); isnr2=0; ssnr2=zeros(1,100); isnr3=0; ssnr3=zeros(1,100); isnr4=0; ssnr4=zeros(1,100); %receiving data from the acquisition card. ai = analoginput('nidaq','Dev1'); addchannel(ai, 1); set(ai,'InputType'); set(ai,'InputType','SingleEnded'); Fs=25000; duration=1; ai.SampleRate = Fs; ai.SamplesPerTrigger = duration*Fs; set(ai,'TriggerType','manual'); deltaz=1; hz(e)=0.1; store(1)=-1; s=makesdata; icxx(e)=0; xcount(e)=0; processpause(e) = false; % I think the mistake is here. t1 = timer('TimerFcn',{@timerFun,e},'BusyMode','Queue','executionmode','fixedrate','period',0.5); start(t1); function timerFun(obj,~,e) xdin=get(obj,'TasksExecuted') % get the raw of data from the acquisition card start(ai); trigger(ai); wait(ai,duration+1); recvvar1 = getdata(ai); if sendvar2m ~=0 s=receivestructure(sock); else suc=1; end if suc>=0 if s.smtype==4 & suc==0 epsn=s.depth(3) end data=recvvar1; store(2)=epsn; deltax=store(2)-store(1); .. .. .. .. .. .. end % close the socket msclose(sock); end ********************************* Thnaks in advance.
From: Walter Roberson on 8 Jun 2010 18:44 Jose wrote: > Hello everyone, I try to use the timer object instead of a while loop, > because it is necessary in my software. > > The problem is, after the first iteration, I got the next message error: > > ??? Error while evaluating TimerFcn for timer 'timer-1' > Invalid handle object. > > And I have not idea why is the problem, any help? Does it not indicate the line that is the problem? In any case, at the command line, type dbstop if error and then execute the routine. You do not appear, by the way, to be initializing "suc", at least not with certainty. You also appear to be overwriting "s" (the socket) inside the timer function, as your "sendvar2m" starts out 1 which is ~= 0
From: Jose on 8 Jun 2010 19:31 Walter Roberson <roberson(a)hushmail.com> wrote in message <humh8f$klu$1(a)canopus.cc.umanitoba.ca>... > Jose wrote: > > Hello everyone, I try to use the timer object instead of a while loop, > > because it is necessary in my software. > > > > The problem is, after the first iteration, I got the next message error: > > > > ??? Error while evaluating TimerFcn for timer 'timer-1' > > Invalid handle object. > > > > And I have not idea why is the problem, any help? > > Does it not indicate the line that is the problem? > > In any case, at the command line, type > > dbstop if error > > and then execute the routine. > > You do not appear, by the way, to be initializing "suc", at least not with > certainty. You also appear to be overwriting "s" (the socket) inside the timer > function, as your "sendvar2m" starts out 1 which is ~= 0 Hello Walter, It does not indicate waht line is the problem... by the way, Thank you for your suggestion, i'll type this...on the other hand, I don´t think I have conflict with s, suc and sendvar2m...it works fine. I'll let you know.
From: Jose on 9 Jun 2010 10:48 "Jose " <jose.l.vega(a)gmail.com> wrote in message <humjro$dk9$1(a)fred.mathworks.com>... > Walter Roberson <roberson(a)hushmail.com> wrote in message <humh8f$klu$1(a)canopus.cc.umanitoba.ca>... > > Jose wrote: > > > Hello everyone, I try to use the timer object instead of a while loop, > > > because it is necessary in my software. > > > > > > The problem is, after the first iteration, I got the next message error: > > > > > > ??? Error while evaluating TimerFcn for timer 'timer-1' > > > Invalid handle object. > > > > > > And I have not idea why is the problem, any help? > > > > Does it not indicate the line that is the problem? > > > > In any case, at the command line, type > > > > dbstop if error > > > > and then execute the routine. > > > > You do not appear, by the way, to be initializing "suc", at least not with > > certainty. You also appear to be overwriting "s" (the socket) inside the timer > > function, as your "sendvar2m" starts out 1 which is ~= 0 > > Hello Walter, > It does not indicate waht line is the problem... > by the way, Thank you for your suggestion, i'll type this...on the other hand, I don´t think I have conflict with s, suc and sendvar2m...it works fine. > > I'll let you know. Walter still doesn´t work when i add to my code dbstop if errot, we´ve got the same mistake: ??? Error while evaluating TimerFcn for timer 'timer-1' Invalid handle object. Any idea:
From: Walter Roberson on 9 Jun 2010 10:54 Jose wrote: > Walter still doesn´t work when i add to my code dbstop if errot, we´ve > got the same mistake: > > ??? Error while evaluating TimerFcn for timer 'timer-1' > Invalid handle object. > > Any idea: Do not add dbstop if error to your code, just type it at the command line and then run your code. When the problem occurs you will be put into the debugger and able to see the problem and examine variables to determine what is being looked at and what values are actually there.
|
Next
|
Last
Pages: 1 2 Prev: Matlab Compiler Runtime - memory footprint Next: Matlab help Matlab – VaR |