[Gambas-user] Serial Port Reading Issue

Marco Mascia marco at ...1785...
Wed Feb 13 08:59:52 CET 2008


nando wrote:
> The SPort_Read() routine runs when there are SOME
> characters received from the serial port..
> and they get printed with the PRINT statement.
> The PRINT statement adds the LineFeed, so the next
> print statement begins on the next line.
>
> So:
>
> INSERISC     <----These characters were available with one SPort_Read event
> I COMANDO    <----These characters were available with next SPort_Read event
>
> You have to remember that data transfer at 19200 is very slow compared to the
> speed the CPU works, so it can print what it has before all characters arrive.
>
> Here is an idea to solve your problem:
>
> 1) Have a public string
> PUBLIC serialportread AS STRING
>
> 2) the following will accumulate characters received in 'serialportread'
> PUBLIC SUB Sport_Read()
>
>   DIM s AS String
>
>   READ #Sport, s, Lof(Sport)
>   serialportread = serialportread & s
>
>   'Test here if 'serialportread' has "->" and "<-" in it
>   'if it does, then use it. Don't forget to clear serialportread
>   'if it doesn't have -> and <-, just exit..hopefully the next event will have it.
>   
> END
>
> -Fernando
It works! now i understand, tnx for the explanation! :)

Marco





More information about the User mailing list