OpenPortEx Method - neoVI API

This function is deprecated. Use the OpenNeoDevice method instead.

This function opens a connection to a neoVI device.

int _stdcall icsneoOpenPortEx( int lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB, int lIPAddressLSBOrBaudRate, int bConfigRead, unsigned char * bNetworkID, int * hObject);

Parameters

lPortNumber

[in] Specifies which USB, TCP/IP, or Comm port to use. The USB port is a logic port starting with 1 up to the number of devices. For example, if 3 devices are connected, valid lPortNumber values will be 1,2, and 3. Comm ports also start at 1. For TCP/IP it specifies the TCP/IP port number.

lPortType

[in] Specifies the port type of what the device is connected to. This parameter is used with lPortNumber described above. This parameter can be set to NEOVI_COMMTYPE_RS232 (0) for a RS232 Comm port, NEOVI_COMMTYPE_USB_BULK (1) for a USB, or NEOVI_COMMTYPE_TCPIP (3) for a TCP/IP connection. More information on the different types of hardware and the connection it uses can be found in the OpenPortEx Hardware Type help topic.

lDriverType

[in] Specifies which neoVI driver to use. This should always be set to INTREPIDCS_DRIVER_STANDARD (0).

lIPAddressMSB

[in] Specifies upper two bytes of TCP/IP address if the lPortType is set to NEOVI_COMMTYPE_TCPIP (bytes 4 and 3 of this TCP/IP address: 1.2.3.4).

lIPAddressLSBOrBaudRate

[in] Specifies the baud rate if lPortType is NEOVI_COMMTYPE_RS232 and the lower two bytes of the TCP/IP address (bytes 2 and 1 of this TCP/IP address: 1.2.3.4).

bConfigRead

[in] Specifies whether the DLL should read the configuration before enabling the device. It is recommended to set this value to 1. This parameter is ignored when the object is created because the configuration is read by default.

bNetworkIDs

[in] This is an array of number IDs which specify the NetworkID parameter of each network. This allows you to assign a custom network ID to each network. Normally, you will assign consecutive IDs to each of the networks. The network IDs are specified in the following list: NETID_DEVICE = 0, NETID_HSCAN = 1, NETID_MSCAN = 2, NETID_SWCAN = 3, NETID_LSFTCAN = 4, NETID_FORDSCP = 5, NETID_J1708 = 6, NETID_AUX = 7, NETID_JVPW = 8, NETID_ISO = 9. You may also set this parameter to NULL (zero) and the default network ID’s will be used.

The neoVI DLL will use this array when it receives a network message. For example, when the DLL receives a message from HSCAN network it will set the NetworkID parameter of the message structure with the value bNetworkID(NETID_HSCAN).

hObject

[in, out] This is the handle of the neoVI driver object. If this handle is 0, the method will create a new neoVI driver object. This handle will be used in other neoVI API calls to read and transmit messages.

Every time you create a new neoVI driver object you must call icsneoFreeObject (after ClosePort). If you do not you will create a memory leak.

Return Values

If the port has been opened successfully and connection to neoVI is attained, the return value will be 1. If the function fails the return value will be zero. The most common reason for failure is when the neoVI is not connected to the port described in the parameters.

Remarks

Each successful call to OpenPort should be matched with a call to ClosePort. The OpenPort call will reset the timestamp clock.

Examples

unsigned char bNetworkID[16];     // array of network ids
int hObject = 0;         // holds a handle to the neoVI object
unsigned long lCount;            // counter variable
int iIPLSB;
int iIPMSB;

// initialize the networkid array
for (lCount=0;lCount<16;lCount++)
    bNetworkID[lCount] = lCount;


if (!m_bPortOpen) // only if not already opened
{
    iIPLSB = 57600;
    iIPMSB = 0;

    lResult = icsneoOpenPortEx(1 ,NEOVI_COMMTYPE_RS232,INTREPIDCS_DRIVER_STANDARD,iIPMSB,iIPLSB,1,bNetworkID,&hObject);
    if (lResult == 0)
        MessageBox(hWnd,TEXT("Problem Opening Port"),TEXT("neoVI Example"),0);
    else
    {
        m_bPortOpen =true;
        MessageBox(hWnd,TEXT("Port Opened Successfully"),TEXT("neoVI Example"),0);
    }
}

Last updated