int OpenCom (int COMPort, char deviceName[]);
Opens a COM port using the default settings for the port parameters. If you want to set port settings, call OpenComConfig instead.
You can set parameters such as baud rate, data bits, parity, stop bits and flow control through the COM port configuration of the operating system.
OpenCom uses 512 bytes of the buffer for the input queue and 512 bytes for the output. OpenCom assumes the default baud rate, parity, stop bits, data bits, port address, and handshake mode established through the COM port configuration of the operating system. The timeout for I/O operations is 5 seconds. Refer to SetXMode, SetCTSMode, SetComTime, and OpenComConfig if you want to change these defaults.
If the specified port is already open, OpenCom closes the port and then opens it again.
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.
|
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. |