[futurebasic] Re: [FB] [X-FB] Strings, Communication, Resourc

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 1999 : Group Archive : Group : All Groups

From: Greg_Neagle@...
Date: Mon, 07 Jun 1999 13:57:19 -0700
On 6/7/99 at 6:48 AM, tedd wrote:

> Now, if I only understood binary streams. You see, I have a program that
> accepts data from Casio BOSS units and works fine -- except it's slower
> than what I wanted. While I can't do anything about speeding up
> communication from the Mac to the Casio unit (because of internal sorting
> problems within the unit), I think that I might be able speed up
> communications between the Casio to the Mac. I need to be able to view the
> entire packet of data (sent by the Casio and received by the Mac) at one
> shot --- in other words, I want to be able to view the communication
> buffer. Any suggestions?

The fastest way to deal with serial data is to create a buffer yourself (either
a pointer or a handle) and read all the available characters into that buffer. 
Simply get the number of available characters and read that many into the
buffer.  You now have the communication buffer - you've essentially copied the
internal comm buffer into your buffer.  There's nothing else - any remaining
serial communication simply hasn't come over the wire yet.

If the "packet" of communications from the Casio ends with  a distictive
character sequence, you can do this (psuedo-code):

search$ = "end of packet characters"
found& = 0
buffer& = FN NEWHANDLE(0)
DO
   charsAvail& = FN GetAvailableCharacters&(thePort)
   LONG IF charsAvail&
      oldSize& = FN GETHANDLESIZE(buffer&)
      err = FN SETHANDLESIZE(buffer&,oldSize&+charsAvail&)
      err = FN ReadSerialCharacters(thePort,[buffer&]+oldSize&,charsAvail&)
      found& = FN MUNGER(buffer&,0,@search$,LEN(search$)+1,0,0)
   END IF
UNTIL found&
   

- via BulkRate