121
OpenComm
int OpenComm(lpszDevControl, cbInQueue, cbOutQueue)
LPCSTR lpszDevControl;
/* Address of the device control information */
UNIT cbInQueue;
/* Size of the reception queue */
UNIT cbOutQueue;
/* Size of the transmission queue */
The OpenComm function will open the communication device.
< Parameter >
lpszDevControl: Pointer to a character string that ends with a NULL. This character string is the
device name in the format of COMn (n denotes the device number).
cbInQueue: Specifies the size of the reception queue in bytes.
cbOutQueue: Specifies the size of the transmission queue in bytes.
< Return value >
Returns a value that identifies the opened device if the function is terminated normally. Otherwise it
returns a value less than zero.
< Error values >
IE_BADID
The device ID is invalid or not supported.
IE_BAUDRATE
The device baud rate is not supported.
IE_BYTESIZE
The specified byte size is invalid.
IE_ DEFAULT
The default parameter is incorrect.
IE_HARDWARE
The hardware is not available (locked by another device).
IE_MEMORY
The function cannot assign a queue.
IE_NOPEN
The device is not open
IE_OPEN
The device is already open. If calling this function by specifying zero for the
size of both the queues, IE_OPEN or IE_MEMORY will be returned
depending on whether the device is already open.
Note:
For Windows COM ports 1 through 9 are available. If the device driver does not support these
communication port numbers, execution of the OpenComm function fails. The communication
device is initialized by the default settings. To set other values for the device use the SetCommState
function. The reception and transmission queues are used for the interrupt-driven type device driver.