Thread Subject: Clear InputBuffer

Subject: Clear InputBuffer

From: Jeremy

Date: 25 Aug, 2008 02:29:02

Message: 1 of 3

Is there a way to clear the inputbuffer when using a serial
port without having to close or delete it?

Jeremy

Subject: Clear InputBuffer

From: Walter Roberson

Date: 25 Aug, 2008 04:26:23

Message: 2 of 3

Jeremy wrote:
> Is there a way to clear the inputbuffer when using a serial
> port without having to close or delete it?

I don't know if there is a specific buffer clear (I haven't looked
at the facilities much) -- but you could use

fread(s,s.BytesAvailable)

and then just not do anything with what you read.


--
Q = quotation(rand);
if isempty(Q); error('Quotation server filesystem problems')
else sprintf('%s',Q), end

Subject: Clear InputBuffer

From: Ankit Desai

Date: 7 Nov, 2008 00:09:01

Message: 3 of 3

Walter Roberson <roberson@hushmail.com> wrote in message <Pvqsk.36221$hx.24348@pd7urf3no>...
> Jeremy wrote:
> > Is there a way to clear the inputbuffer when using a serial
> > port without having to close or delete it?
>
> I don't know if there is a specific buffer clear (I haven't looked
> at the facilities much) -- but you could use
>
> fread(s,s.BytesAvailable)
>
> and then just not do anything with what you read.
>
>
> --
> Q = quotation(rand);
> if isempty(Q); error('Quotation server filesystem problems')
> else sprintf('%s',Q), end

If you have Instrument Control Toolbox, you can use 'FLUSHINPUT' and/or 'FLUSHOUTPUT' to flush out the input and output buffer.

flushinput(serialObj);
flushoutput(serialObj);

-Ankit

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
rs232 Ankit Desai 6 Nov, 2008 19:10:04
serial Ankit Desai 6 Nov, 2008 19:10:04
bytesavailable Jeremy 24 Aug, 2008 22:30:06
port Jeremy 24 Aug, 2008 22:30:06
serial Jeremy 24 Aug, 2008 22:30:06
rssFeed for this Thread

Contact us at files@mathworks.com