Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Serial fscanf timeout with Guide GUI
Date: Mon, 6 Jul 2009 08:36:37 -0400
Organization: The MathWorks, Inc.
Lines: 34
Message-ID: <h2sr4m$kr9$1@fred.mathworks.com>
References: <h2ji35$5if$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: jarvit.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1246883798 21353 172.31.56.68 (6 Jul 2009 12:36:38 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 6 Jul 2009 12:36:38 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:553050



"Camron Call" <camroncall@gmail.cam> wrote in message 
news:h2ji35$5if$1@fred.mathworks.com...
>I have a couple of things I am trying to fix:
>
> 1 -
>
> I am working on handling the timeout when no data is received from the 
> serial port.  I am using a GUI to format and plot data from the serial 
> port. When no data is received from the serial port, the warning that the 
> timeout occurred shows in the command window and the script continues only 
> to find that I obviously have no data to work with.    What is the best 
> way to handle the warning?  I would like to have it close the serial 
> object and go back to my GUI with no issues.
>
> 2-
>
> I currently am using fscanf to read the data with a timeout of 30 seconds. 
> I need to do this because I need to wait for a human to decide to press 
> the upload key on the instrument I am using (some people are a little 
> slow).  However, I would like to not have to wait that long if they 
> pressed the 'Download Data' button in my GUI by accident.  Can I make a 
> cancel button to stop the waiting?  What commands would cancel the fscanf 
> before any data was received or the timeout occurred?
>
> I am thankful for any suggestions.  Thanks

Hi Camron,

Rather than waiting for FSCANF to timeout and handle the errors, I'd suggest 
looking at the Serial BytesAvailable property and deciding if you want to 
read.  That gives you more control over what to do in the GUI.