Purpose |
Open a serial port. |
Syntax |
COMM OPEN "COMn" AS [#] hComm |
Remarks |
Opens a serial port to begin communications, creating a relationship between a file number and a specific serial port device. |
COMn |
Identifies the serial port number, for example, COM1, COM4, etc. A colon must not follow the port specification. See Restrictions below. |
hComm |
A valid
The Number symbol (#) prefix is optional, but recommended for the purposes of clarity. If the port was not opened successfully, the ERR system variable will contain the error code. Before actual communications through the port can commence, you must configure the communication parameters by using a COMM SET statement for each parameter. |
Restrictions |
COMM OPEN cannot use an operating system file handle, nor open a port that is already in use. When opening ports above COM9, Windows requires the port name to be specified using the following syntax: COMM OPEN "\\.\COM15" AS #hComm |
See also |
Serial Communications, COMM CLOSE, COMM function, COMM LINE, COMM PRINT, COMM RECV, COMM RESET, COMM SEND, COMM SET, FREEFILE, OPEN |
Example |
DIM hComm AS LONG hComm = FREEFILE COMM OPEN "COM1" AS #hComm COMM OPEN "COM2" AS #5 |