OpenNeoDevice 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 a communication link the a neoVI device.

C/C++ Declare

int _stdcall icsneoOpenNeoDevice(NeoDevice *pNeoDevice, int *hObject, unsigned char *bNetworkIDs, int bConfigRead, int bSyncToPC);

Visual Basic Declare

Public Declare Function icsneoOpenNeoDevice Lib "icsneo40.dll" (ByRef pNeoDevice As NeoDevice, ByRef hObject As Long, ByRef bNetworkIDs As Byte, ByVal bConfigRead As Long, ByVal bSyncToPC As Long) As Long


Visual Basic .NET Declare

Public Declare Function icsneoOpenNeoDevice Lib "icsneo40.dll" (ByRef pNeoDevice As NeoDevice, ByRef hObject As Int32, ByRef bNetworkIDs As Byte, ByVal bConfigRead As Int32, ByVal bSyncToPC As Int32) As Int32


C# Declare

[DllImport("icsneo40.dll")]
public static extern Int32 icsneoOpenNeoDevice(ref NeoDevice pNeoDevice, ref Int32 hObject, ref byte bNetworkIDs, Int32 bConfigRead, Int32 bSyncToPC);


Parameters

pNeoDevice
    [in] A valid NeoDevice structure filled with information about a specific neoVI device. This must be obtained by calling FindNeoDevices.

hObject
    [out] The address of an int value. This will be set to the handle of the neoVI driver object that is created. It is needed as an input parameter to other API function calls.   Every time you create a new neoVI object you must call ClosePort and FreeObject to avoid creating a memory and resource leak.

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. See NetworkIDList for a list of current network ID's. You may also set this parameter to NULL (zero) and the default network ID's will be used.

bConfigRead
    [in] Specifies whether the DLL should read the neoVI's device configuration before enabling the device. It is recommended that this value be set to 1.

 bSyncToPC
    [in] Specifies whether timestamps for messages should be adjusted to the PC’s clock to compensate for time drift.  This drift is caused by differences that occur over time between the clocks on the neoVI device and the PC.

Return Values

If the port has been opened successfully,  the return value will be 1. Otherwise the return value will be zero. 

Remarks

Each successful call to OpenNeoDevice should be matched with a call to the  ClosePort and FreeObject methods. 


Examples

Visual Basic Example

Dim m_hObject As Long '//handle for device
Dim lResult As Long '//Holds the results from function call
Dim ndNeoToOpen As NeoDevice '//Struct holding detected hardware information
Dim bNetwork(0 to 63) As Byte '//List of hardware IDs
Dim iCount As Integer '//counter

'//File NetworkID array
For iCount = 0 To 63
    bNetwork(iCount) =
CByte(iCount)
Next iCount

'//Open the first found device, ndNeoToOpen acquired from FindNeoDevices
lResult = icsneoOpenNeoDevice(ndNeoToOpen, m_hObject, bNetwork(0), 1, 0)
If CBool(lResult) Then
    MsgBox(
"Port Opened OK!", vbOKOnly)
Else
    MsgBox(
"Problem Opening Port", vbOKOnly)
    Exit Sub
End
If
 

C/C++ Example

int hObject = 0;  // holds a handle to the neoVI object
int iRetVal;
int iCount;
NeoDevice *pDevice = pParmIn;
//created previously       

iRetVal = icsneoOpenNeoDevice(pDevice, &hObject, NULL, 1, 0);
 

Visual Basic .NET Example

Dim m_hObject As Integer '//handle for device
Dim iResult As Integer '//Holds the results from function call
Dim ndNeoToOpen As NeoDevice '//Struct holding detected hardware information
Dim bNetwork(64) As Byte '//List of hardware IDs
Dim iCount As Integer '//counter

'//File NetworkID array
For iCount = 0 To 63
    bNetwork(iCount) =
CByte(iCount)
Next iCount
'//Open the first found device, ndNeoToOpen acquired from FindNeoDevices
iResult = icsneoOpenNeoDevice(ndNeoToOpen, m_hObject, bNetwork(0), 1, 0)
If CBool(iResult) Then
    MsgBox(
"Port Opened OK!")
Else
    MsgBox(
"Problem Opening Port")
    Exit Sub
End
If


C# Example


int
m_hObject; //handle for device
int iResult; //Holds the results from function call
NeoDevice ndNeoToOpen =
new NeoDevice(); //Struct holding detected hardware information
byte[] bNetwork = new byte[64]; //List of hardware IDs
int iCount; //counter

//File NetworkID array
for (iCount = 0; iCount < 64; iCount++)
{
    bNetwork[iCount] =
Convert.ToByte(iCount);
}
//Open the first found device, ndNeoToOpen acquired from FindNeoDevices
iResult = icsNeoDll.icsneoOpenNeoDevice(
ref ndNeoToOpen, ref m_hObject, ref bNetwork[0], 1, 0);
if (iResult == 1)
{
    MessageBox.Show("Port Opened OK!");
}
else
{
   
MessageBox.Show("Problem Opening Port");
    return
;
}


intrepidcs API Documentation - (C) Copyright 2000-2010 Intrepid Control Systems, Inc. 
(www.intrepidcs.com)

Last Updated : Tuesday, December 16, 2008