OpenPortEx Method - intrepidcs API
C/C++ declare -
VB declare - VB.NET declare - C# declare - Parameters - Return
Values - Remarks - C/C++ example
- VB example - VB.NET example - C# example
This method opens the communication link with the neoVI hardware.
int
_stdcall icsneoOpenPortEx( int lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB, int lIPAddressLSBOrBaudRate, int bConfigRead, unsigned char * bNetworkID, int * hObject);
Public Declare Function icsneoOpenPortEx
Lib "icsneo40.dll" _
(ByVal
lPortNumber As Long, ByVal lPortType
As Long, _
ByVal lDriverID
As Long, ByVal lIPAddressMSB
As Long, _
ByVal
lIPAddressLSBOrBaudRate As Long,
ByVal lForceConfigRead As Long, _
ByRef bNetworkID
As Byte, ByRef hObject As Long) As Long
Visual Basic .NET Declare
Public
Declare Function
icsneoOpenPortEx Lib
"icsneo40.dll" (ByVal
lPortNumber As Integer,
ByVal lPortType As
Integer, ByVal
lDriverID As Integer,
ByVal lIPAddressMSB As
Integer, ByVal
lIPAddressLSBOrBaudRate As
Integer, ByVal
lForceConfigRead As Integer,
ByRef bNetworkID As
Byte, ByRef
hObject As Integer)
As Integer
[DllImport("icsneo40.dll")]
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.
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.
Each successful call to OpenPort should be matched with a call to ClosePort. The OpenPort call will reset the timestamp clock.
Examples
Dim lResult As Long '// Used to store the return value
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);
}
}
byte
bNetworkIDs = 1;
intrepidcs API Documentation - (C) Copyright 2000-2009 Intrepid Control Systems, Inc. (www.intrepidcs.com) |
Last Updated : Wednesday, July 30, 2008