Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Serial port :bytesAvailable

Subject: Serial port :bytesAvailable

From: Gary B

Date: 18 Aug, 2008 18:06:01

Message: 1 of 2

Hello,

I am reading binary data from a serial port (it is actually
a virtual serial port created for FDTI usb connection). I
have no problem reading data, I am reading data from an eye
movement measurement device, however I am trying to
synchronize my measurement with a CRT monitor controlled
through matlab using a purpose built graphics card. Which
requires very specific timing control (my graphics card has
timing control independent of windows so it is very
accurate) and accurate readings of how much bytes are in the
input buffer, for this I am using the bytesAvailable function.

Ok first question once the port is opened can windows
interrupt the flow of data into the input buffer when
reading asychronously, is this flow usually continuous or
does it go in in chunks (maybe this is specific to the
instrument). As I am getting a problem that when a call the
bytesAvailable function after opening the port, the number
of bytes returned are always in multiples of 3968 or 4092 (I
realise these are significant numbers in binary terms) but
is this a general property of bytes available or is it maybe
related to my instrument. Even with the most simplest code
where i might open the port pause for 0.1 second and read
the data the bytesAvailable function always seems to read in
in chunks (being 0 3968 or 4092 in this case).

Does anyone know why this would occur?

Thanks very much,

Gary

Subject: Serial port :bytesAvailable

From: Trent Jarvi

Date: 18 Aug, 2008 22:14:11

Message: 2 of 2


"Gary B" <bargaryg@tcd.ie> wrote in message
news:g8cdm9$ifd$1@fred.mathworks.com...
> Hello,
>
> I am reading binary data from a serial port (it is actually
> a virtual serial port created for FDTI usb connection). I
> have no problem reading data, I am reading data from an eye
> movement measurement device, however I am trying to
> synchronize my measurement with a CRT monitor controlled
> through matlab using a purpose built graphics card. Which
> requires very specific timing control (my graphics card has
> timing control independent of windows so it is very
> accurate) and accurate readings of how much bytes are in the
> input buffer, for this I am using the bytesAvailable function.
>
> Ok first question once the port is opened can windows
> interrupt the flow of data into the input buffer when
> reading asychronously, is this flow usually continuous or
> does it go in in chunks (maybe this is specific to the
> instrument). As I am getting a problem that when a call the
> bytesAvailable function after opening the port, the number
> of bytes returned are always in multiples of 3968 or 4092 (I
> realise these are significant numbers in binary terms) but
> is this a general property of bytes available or is it maybe
> related to my instrument. Even with the most simplest code
> where i might open the port pause for 0.1 second and read
> the data the bytesAvailable function always seems to read in
> in chunks (being 0 3968 or 4092 in this case).
>
> Does anyone know why this would occur?
>
> Thanks very much,
>
Hi Gary

The serial input buffer is filled with data as it becomes available and
reporting the bytes available in that buffer. By default, the serial port
is polled every ~20ms for incomming data while using ReadAsyncMode =
continuous. You may be observing behavior related to how the FDTI
USB/Serial driver is delivering data acrossed the USB interface and then
discovered by the serial polling mechanism.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us