[Gambas-user] Issue/Problem with Serial Port Component

nando nando_f at ...951...
Mon Jun 5 01:41:22 CEST 2006


This example may work around the issue.
It also uses the cpu more than the LOF method.
It is more efficient to take a bunch or chars from the kernel
in one shot than asking for one at a time.

It is the same issue are reading a file one byte at a time
or a bunch of bytes at a time.  The first way is much slower.



---------- Original Message -----------
From: ron <ronstk at ...239...>
To: nando_f at ...951..., mailing list for gambas users
<gambas-user at lists.sourceforge.net>
Sent: Mon, 5 Jun 2006 01:33:08 +0200
Subject: Re: [Gambas-user] Issue/Problem with Serial Port Component

> On Monday 05 June 2006 01:22, nando wrote:
> > The remark line after the READ does some testing to see 
> > if complete data received matches known formats.  There is no CR/LF
> > embedded within the stream.  I am well practiced in ASCII/CL/LF stuff
> > and binary over serial.
> > 
> > The _read events fires and the bunch of chars already received in the kernel
> > are appended to the accumulating string.
> > 
> > The string is tested each _read event.
> > 
> > The problem here is that if you read *ALL* LOF(SPort) every _read event,
> > there will not be a _read event for the last bunch.
> > 
> > Reading one less than LOF(SPort) ensures the _event one more time.
> > 
> > I have tried it here over 100 times with the same results.
> > It's fascinating!
> > 
> > -Fernando
> >
> 
> Why don't you try
> 
> SUB SPort_Read()
> 
>   DIM s AS STRING
>   DIM ls AS INTEGER
>   dim ssum as string
>   ssum=""
>   DO UNTIL EOF(SPort)
>     READ # SPort, s, 1
>     ssum &= s
>   Loop
>   SPortReceiveString = SPortReceiveString & ssum
> END
> 
> Ron
> 
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list