[Gambas-user] TERMINAL Application + Serial Port

Benoit Minisini gambas at ...1...
Wed Aug 4 23:07:28 CEST 2004


On Wednesday 04 August 2004 17:22, Daniel wrote:
> El mié, 04-08-2004 a las 09:12, Budi Arief Gusandi escribió:
> > Hi...
> >
> > I'm going to create Application for reading and writing to serial PORT
> > run on console only (Terminal).
> > 1. How can i activate COM Reading Event ? Is there any like WITH EVENT
> > com declaration like in VB. fe. DIM WITHEVENT MyCOMM as New SerialPort.
>
> Dim MyCOMM As SerialPort
>
> MyCOMM = New SerialPort As "MyCOMM"
>
> ...
>
> Public Sub MyCOMM_Read()
> 	...
> END
>
> > 2. How to make the application not quit after executing all the code in
> > main module in console app. ?
>
> You have to create an infinite loop, like all common console
> applications that doesn't finish...
>

Actually this is unneeded. As soon as you have opened the serial port object, 
Gambas knows that there is some file descriptor to watch, and so it will 
start an event loop after Main() has terminated, and will stop the program 
only when this file descriptor is closed. But you must put your serial port 
object reference in a global variable so that it is not freed.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list