Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Need both modes of BytesAvailableFcnMode at the same time
Date: Tue, 2 Oct 2007 15:08:54 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 73
Message-ID: <fdtmu6$55f$1@fred.mathworks.com>
References: <1190513835.238939.231600@y42g2000hsy.googlegroups.com> <1190735910.568277.10280@r29g2000hsg.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1191337734 5295 172.30.248.37 (2 Oct 2007 15:08:54 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 2 Oct 2007 15:08:54 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1030060
Xref: news.mathworks.com comp.soft-sys.matlab:431018



 "G.A.M." <x0Zero@gmail.com> wrote in message
<1190735910.568277.10280@r29g2000hsg.googlegroups.com>...
> On Sep 22, 10:30 pm, "G.A.M." <x0Z...@gmail.com> wrote:
> > On Sep 22, 10:17 pm, "G.A.M." <x0Z...@gmail.com> wrote:
> >
> > > The data sent back from my instrument are of two types:
> > > 1. short codes under 20 bytes containing status info
> > > 2. data over 1000 bytes
> >
[snip]
> >
> > Here is an old message from 2002 with a similar
question. If anyone
> > has an answer to this older question, that would
probably solve my
> > issue too. Here is the older question:
> >
> > % Newsgroups: comp.soft-sys.matlab
> > % From: "Fred Dilkes"
> > % Date: Thu, 18 Jul 2002 16:45:16 -0400
> > % Local: Thurs, Jul 18 2002 4:45 pm
> > % Subject: BytesAvailable on a serial device
> > %
> > % I'm having difficulty handling variable-length message
packets from
> > a
> > % device connected by RS232 to a PC running Matlab 6.1.
> > %
> > % The device sends some long binary message packets (say
16k bytes)
> > and
> > % some short messages (4 bytes) to the PC.  I'm trying
to handle them
> > % both with a Matlab serial object by setting
'BytesAvailableFcnCount'
> > % to 4 and 'BytesAvailableFcn' to an event-handling
function.  The
> > % event-handler uses fread to read the first 4 bytes and
then it
> > % decides whether or not it needs to read the other 16k-4.
> > %
> > % The problem is that each long message now generates
16k/4=4096 calls
> > % to the event-handling function.  The first call reads
all 16k, but
> > % the last 4095 calls are just overhead since there are
no more bytes
> > % to read.  They just slow down my GUI.
> > %
> > % Can anybody tell me whether there is a better way to
handle
> > % variable-length message packets?
> > %
> > % Thanks,
> > % Fred
> 
> If I have a lot of bytes coming in via the serial port,
can I change
> the mode of the BytesAvailableFcn in the midst of
receiving this data?
> Could I start off with a small value for bytes count and
increase it
> to a larger value at a certain point? Would the change be
effective
> quickly enough to alter the way the BytesAvailableFcn is
called for
> the remaining data? Thanks.
> 


I'm about to give up on solving this elegantly, but I'm
going to try again and see if I can get an answer to this
question. I appreciate any thoughts anyone can offer. :)