# OpenComConfig

int OpenComConfig (int COMPort, char deviceName[], long baudRate, int parity, int dataBits, int stopBits, int inputQueueSize, int outputQueueSize);

## Purpose

Opens a COM port and sets port parameters. If inputQueueSize or outputQueueSize is between 1 and 29, OpenComConfig forces it to 30.

OpenComConfig disables XON/XOFF mode and CTS hardware handshaking. Refer to the SetXMode, SetCTSMode, and SetComTime function descriptions if you want to change these defaults.

If the specified port is already open, OpenComConfig closes the port and then opens it again. Refer to the CloseCom function description for more information.

Use the Control Panel to set the port hardware I/O address and interrupt level.

You can use nonstandard baud rates. All baud rate values are interpreted literally by the comm driver.

## Parameters

Input
Name | Type | Description
COMPort | integer | A number that indicates the COM port on which to operate. This number is paired with deviceName, which represents the COM port, during the OpenComConfig function call. Default Value: 1—COM1 Valid Range: 1—1,000
deviceName | string | The name of the COM port in ASCII string format. For example, deviceName can be "COM1" for COM port 1 under Windows using comm.drv. Linux For example, deviceName can be "/dev/ttyS0" for COM port 1. comm.drv, which comes with Windows, recognizes COM1 through COM4 only. Refer to the documentation for your Expanded Com Port Board for Device Names beyond COM4. If you pass a NULL pointer or an empty string for deviceName, the library uses device names depending on the COM port number you specify. The following table shows the syntax for opening ports one through four. You can follow this model to open higher-numbered ports.
Port Number | deviceName under Windows | deviceName under Linux
1 | "COM1" | "/dev/ttyS0"
2 | "COM2" | "/dev/ttyS1"
3 | "COM3" | "/dev/ttyS2"
4 | "COM4" | "/dev/ttyS3"
baudRate | long | The baud rate for the selected port. Default Value: 9600 baud Valid Values: 110, 150, 300, 600, 1,200, 2,400, 4,800, 9,600, 14,400, 19,200, 28,800, 38,400, 56,000, 57,600, 115,200, 128,000, and 256,000.
| Note PCs do not support 150. Some PC serial drivers do not support 115,200, 128,000, and 256,000.
You can use nonstandard baud rates. All baud rate values are interpreted literally by the comm driver.
parity | integer | The parity mode for the selected port. Default Value: 0—no parity Valid Values 0 = no parity 1 = odd parity 2 = even parity 3 = mark parity 4 = space parity
dataBits | integer | The number of data bits for the selected port. Default Value: 7 data bits Valid Values: 5,6,7 or 8 data bits
stopBits | integer | The number of stop bits for the selected port. Default Value: 1 stop bit Valid Values: 1 or 2 stop bits
inputQueueSize | integer | The size of the input queue for the selected port. If you specify 0, OpenComConfig uses 512. If you specify a value greater than 0 but less than 30, OpenComConfig uses 30. There is no maximum limitation on the queue size. However, some serial drivers have a maximum of 32,767 and give undefined behavior when you use a larger queue size. NI recommends that you use a queue size no greater than 32,767. LabWindows/CVI passes this number to the Windows serial driver, which might use a different number. For example, the Microsoft serial driver imposes a minimum input queue size of 4,096 and requires that the input queue size be an even number. If you pass an odd number for inputQueueSize, LabWindows/CVI rounds it to the next highest even number.
outputQueueSize | integer | The size of the output queue for the selected port. If you specify 0, OpenComConfig uses 512. If you specify a value greater than 0 but less than 30, OpenComConfig uses 30. If you specify a negative value for outputQueueSize, the output queue is not used and the data is written to the port directly. There is no maximum limitation on the queue size. However, some serial drivers have a maximum of 32,767 and give undefined behavior when you use a larger queue size. NI recommends that you use a queue size no greater than 32,767. Linux OpenComConfig ignores outputQueueSize. The serial driver determines the queue size.
| Note Write operations are generally faster if you disable the output queue.

## Return Value

Name | Type | Description
result | integer | The result of this function call. This code is a negative value that specifies the type of error that occurred.