OpenNeoDevice Method - intrepidcs API
C/C++ declare -
VB.NET declare - C# declare - Parameters - Return
Values - Remarks - C/C++ example
- VB.NET example - C# example
This method opens a communication link the
a neoVI device.
int
_stdcall
icsneoOpenNeoDevice(NeoDevice
*pNeoDevice,
void
* hObject,
unsigned char
*bNetworkIDs,
int
bConfigRead,
int
bSyncToPC);
Visual Basic .NET Declare
Public
Declare
Function
icsneoOpenNeoDevice Lib
"icsneo40.dll" (ByRef
pNeoDevice As
NeoDevice, ByRef
hObject As IntPtr,
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
IntPtr hObject, ref
byte
bNetworkIDs, Int32 bConfigRead, Int32 bSyncToPC);
Parameters
pNeoDevice
[in] A valid NeoDevice
structure filled with information about a specific neoVI device. For C++ a
"void*" can be used. For .NET, "IntPtr" is used. This
must be obtained by calling FindNeoDevices.
hObject
[out] This parameter needs to be 32 bit in a 32 bit program and 64 bit in a
64 bit program. 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.
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.
If the port has been opened successfully, the return value will be 1. Otherwise the return value will be zero.
To connect to more than
one piece of hardware, multiple calls to OpenNeoDevice
can be made. The
key is to provide a different
NeoDevice
for each device you want to open. For other function calls, use the
returned hObject to talk to that device.
Each successful call to OpenNeoDevice
should be matched with a call to a ClosePort
when you are finished accessing the hardware.
FreeObject methods.
Examples
void *
hObject; //
holds a handle to the neoVI object
int
iRetVal;
int
iCount;
NeoDevice ndNeoToOpen; //created previously
Dim m_hObject As IntPtr '//handle for device
C# Example
IntPtr
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[255];
//List of hardware IDs
int iCount;
//counter
//File NetworkID array
for (iCount = 0;
iCount < 255; 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-2022 Intrepid Control Systems, Inc. (www.intrepidcs.com) |
Last Updated : Wednesday, August 24, 2016