CONNECT.PORT()

CONNECT.PORT()

Top  Previous  Next

 

The CONNECT.PORT() function converts a phantom process into an interactive session, using a serial port as its terminal device.

 

This function is only available on Windows.

 

 

Format

 

CONNECT.PORT(port, baud, parity, bits, stop)

 

where

 

portis the name of the serial port to be used (e.g. COM1).

 

baudevaluates to the data rate (e.g. 9600).

 

parityspecifies the parity setting for the connection (0 = none, 1 = odd, 2 = even).

 

bitsspecifies the number of bits per byte.

 

stopspecifies the number of stop bits (1 or 2).

 

 

The CONNECT.PORT() function enables an application to start a phantom process that then uses a serial port as though it were a terminal device. The function returns True if successful, False if it fails. The STATUS() function can be used to determine the cause of failure.

 

Once the connection has been created, the process changes from a phantom to an interactive session and can use the normal QMBasic terminal i/o statements such as INPUT and PRINT to access the port. If the program exits to the command processor, the connection can be used in exactly the same way as if the user had logged in over the serial port. To terminate the session from within a program, execute the QUIT command.

 

Because this function converts the phantom process into an interactive user, the process consumes a licence. The CONNECT.PORT() function will fail if the user limit has been reached.

 

 

Example

 

IF NOT(CONNECT.PORT('COM1', 9600, 0, 8, 1)) THEN

  STOP 'Cannot open COMO1 port'

END

 

This program fragment, used in a phantom process, connects to the device on the COM1 port as the command source, converting the process into an interactive session.