Thread Subject: Serial fscanf timeout with Guide GUI

Subject: Serial fscanf timeout with Guide GUI

From: Camron Call

Date: 3 Jul, 2009 00:07:01

Message: 1 of 2

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

Subject: Serial fscanf timeout with Guide GUI

From: Trent Jarvi

Date: 6 Jul, 2009 12:36:37

Message: 2 of 2


"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.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
timeout Camron Call 2 Jul, 2009 20:09:04
fscanf Camron Call 2 Jul, 2009 20:09:04
serial Camron Call 2 Jul, 2009 20:09:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com