Thread Subject: Timeout when reading from serial connection

Subject: Timeout when reading from serial connection

From: Jon

Date: 15 Nov, 2009 23:17:03

Message: 1 of 2

Hi,
I am reading data from a LeCroy oscilloscope using MATLAB's instrument control toolbox with a serial RS232 connection. It works great and I receive the data fine, but then MATLAB hangs until the timeout occurs. How can I tell it to stop reading once a terminator is received?
Here is the code:
while isempty(msg)
   [newData, count, msg] = fread(interface,elementsToRead,type);
   data = [data; newData];
end
The oscilloscope appends a terminator CR/LF to the end of each message but MATLAB ignores it.
Thanks.

Subject: Timeout when reading from serial connection

From: Trent Jarvi

Date: 16 Nov, 2009 21:48:18

Message: 2 of 2


"Jon " <jkopechek@hotmail.com> wrote in message
news:hdq25f$68j$1@fred.mathworks.com...
> Hi,
> I am reading data from a LeCroy oscilloscope using MATLAB's instrument
> control toolbox with a serial RS232 connection. It works great and I
> receive the data fine, but then MATLAB hangs until the timeout occurs. How
> can I tell it to stop reading once a terminator is received?
> Here is the code:
> while isempty(msg)
> [newData, count, msg] = fread(interface,elementsToRead,type);
> data = [data; newData];
> end
> The oscilloscope appends a terminator CR/LF to the end of each message but
> MATLAB ignores it.
> Thanks.

Hi Jon,

Serial FREAD will treat the data as binary and ignore the terminator while
Serial FSCANF will read and stop after receiving the terminator.

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
serial Jon 15 Nov, 2009 18:19:03
rs232 Jon 15 Nov, 2009 18:19:03
instrument cont... Jon 15 Nov, 2009 18:19:03
lecroy Jon 15 Nov, 2009 18:19:03
oscilloscope Jon 15 Nov, 2009 18:19:03
terminator Jon 15 Nov, 2009 18:19:03
rssFeed for this Thread

Contact us at files@mathworks.com