[futurebasic] Serial Port Read Consistancy Errors

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2000 : Group Archive : Group : All Groups

From: Rodney Kobayakawa <vanda@...>
Date: Sun, 23 Jul 2000 10:11:31 -1000
>I am trying to read a serial port after sending a command to a device.
> The problem is that it works most of the times, but
>every 5th, or 10th, or 20th read (it varies), I get extraneous characters,
>first couple of characters missed, or just plain jibberish.
>characAvail=LOF(thePort,1)
>LONG IF characAvail
>    characToRead=characAvail
>    IF characToRead>255 then characToRead=255
>    READ FILE thePort,@x$+1, characToRead
>    POKE@x$,characToRead
>END IF

>Hard to see anything wrong with your code. Two long shots:
>(1) Bad Stuff will happen if x$ is DIMmed at less than 255 bytes.
>(2) If you are using FB^3, and if characAvail or characToRead are DIMmed as
>byte variables, Strange Things would happen whenever LOF(thePort,1) > 127.

>Robert P.

I am using FB^3. My cable is good as I get the same results from all of
them. It is wired as RS-422. Variables are long integer. I neglected to
state that I send out a command first and try to retrieve an answer from the
device. I discovered that if I force a deleay of 20 or so, the reads start
to work. However, my concern is what happens on a slower or faster machine?
I need the speed as the reads should occur as often as possible, and on a
fast machine the delay I put in may not be enough causing erroneous reads.
Even if I do a DO UNTIL charactAvail%, sometimes the data is wrong (unless I
put in a delay). The perplexing thing is that with Terminal or White Knight,
the reads are always consistant. How do they do it?

Also, can you elaborate on why you can't dim strings less than 255 bytes? Is
it a bug or is it just that way?

Thanks for the help so far.

rod k.