[Gambas-user] Serial Port Reading Issue

Mike Keehan Mike at ...680...
Fri Feb 8 19:42:39 CET 2008


Hi Marco.

The 'READ #Sport' returns after a number of characters, or after a 
timeout.  It does not give you a whole line of text, usually.

I think it is the 'Print s' that is making it look like separate 
partial lines.

You will need to build up another string adding in each part of the 
'Read Sport'.  And then scan this complete string to see what has been 
received.

For a simple test, try this (untested I'm afraid :( )

PUBLIC SUB Sport_Read()

DIM s AS String
DIM t as String

READ #Sport, s, Lof(Sport)

t = t & s

Print t

END


This will repeat all it's input each time the READ occurs, but it 
might help explain what is happening.

Mike.

Marco Mascia wrote:
> Hi there!
> We have some trouble making a Serial port Read (first time that i work 
> on it).
> 
> Our card reader is a device that sends a "await command" every 500 ms
> (Note: the device works on a serial port standard RS232 br: 19200, 
> 8-N-1, no flow control.)
> 
> if we do from shell cat /dev/ttyS0/ we obtain:
> 
> INSERISCI COMANDO
> INSERISCI COMANDO
> MEMORIZZAZIONE CODICE ->101027256<- (a card read)
> INSERISCI COMANDO
> ...
> etc
> 
> 
> Instead a read on gambas console with this code:
> 
> PUBLIC SUB Sport_Read()
> 
> DIM s AS String
> 
> READ #Sport, s, Lof(Sport)
> print s
> 
> END
> 
> 
> we obtain:
> 
> 
> INSERISC
> I COMANDO
> 
> INSERISC
> I COMANDO
> 
> MEMORIZZ
> AZIONE CODICE ->10102725
> 6<-
> 
> INSERISC
> I COMANDO
> ...
> etc
> 
> problems:
> 
> Weird output or i am a noob and i miss something? :D
> I need to extract the card code between "->" and "<-" from the stream.
> any help/suggestion?
> 
> anybody knows how to obtain the same result of cat command inside gambas?
> 
> tnx in advance.
> 
> ---
> Marco
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
> 






More information about the User mailing list