WaitForRxMessagesWithTimeOut Method - intrepidcs API
C/C++ declare -
VB declare - VB.NET delcare - C# declare - Parameters - Return
Values - Remarks - C/C++ example
- VB example - VB.NET example - C# example
This method is used to wait a specified amount of time for received messages from the neoVI hardware.
int _stdcall icsneoWaitForRxMessagesWithTimeOut(int hObject, unsigned int iTimeOut);
Visual Basic Declare
Public
Declare
Function
icsneoWaitForRxMessagesWithTimeOut Lib
"icsneo40.dll" (ByVal
hObject As
Long,
ByVal iTimeOut
As
Long)
As
Long
Visual Basic .NET Declare
Public
Declare
Function
icsneoWaitForRxMessagesWithTimeOut Lib
"icsneo40.dll" (ByVal
hObject As Int32,
ByVal iTimeOut
As UInt32)
As
Int32
C# Declare
[DllImport("icsneo40.dll")]
public
static
extern
Int32 icsneoWaitForRxMessagesWithTimeOut(Int32 hObject, UInt32 iTimeOut);
Parameters
hObject
[in] Specifies the driver object created by OpenNeoDevice.
iTimeOut
[in] Specifies the amount of time in milliseconds that the
function will wait for a received message before returning.
0 if no message was received during the wait
period. 1 if a message was received. -1 will be returned if there is an
error condition. GetLastAPIError
must be called to obtain the specific error. The errors that can be
generated by this function are:
NEOVI_ERROR_DLL_NEOVI_NO_RESPONSE
= 75
This function allows an application to avoid 'polling' for received messages. It will return as soon as a message is received or when the timeout specified has been reached.
Examples
Visual Basic Example
Private
m_hObject As
Long
'// Declared at form level and previously open
with a call to OpenNeoDevice
Dim lResult
As
Long
Dim iTimeOut As
Long
iTimeOut = 5000 '//Set timeout to 5
seconds
lblWaitForRxMessageWithTimeOutResult.Caption =
"Status"
DoEvents()
'//This function will block until, A: A
Message is received by the hardware, or B: the timeout is reached
lResult = icsneoWaitForRxMessagesWithTimeOut(m_hObject, iTimeOut)
If lResult = 1
Then
'Message received
before timeout
lblWaitForRxMessageWithTimeOutResult.Caption =
"Message received"
'//Do something with
the messages received
Call
cmdReceive_Click()
Else
'Timeout reached and no
messages received
lblWaitForRxMessageWithTimeOutResult.Caption =
"Message Not received"
'//Take action if no
messages were received
End
If
Visual Basic .NET Example
Private
m_hObject As
Integer
'// Declared at form level and previously open
with a call to OpenNeoDevice
Dim iResult
As
Integer
Dim iTimeOut As
UInt32
iTimeOut = Convert.ToUInt32(5000)
lblWaitForRxMessageWithTimeOutResult.Text =
"Status"
Application.DoEvents()
'//This function will block until, A: A
Message is received by the hardware, or B: the timeout is reached
iResult = icsneoWaitForRxMessagesWithTimeOut(m_hObject, iTimeOut)
If iResult = 1
Then
'Message received
before timeout
lblWaitForRxMessageWithTimeOutResult.Text =
"Message received"
Call
cmdReceive_Click(sender, e)
'//Do something with
the messages received
Else
'Timeout reached and no
messages received
lblWaitForRxMessageWithTimeOutResult.Text =
"Message Not received"
'//Take action if no
messages were received
End
If
C# Example
//Declared at
form level and previously open with a call to OpenNeoDevice
int m_hObject;
//handle for device
int iResult;
UInt32 iTimeOut = 5000;
//Set timeout to 5 seconds
lblWaitForRxMessageWithTimeOutResult.Text =
"Status";
Application.DoEvents();
//This function will block until, A: A
Message is received by the hardware, or B: the timeout is reached
iResult = icsNeoDll.icsneoWaitForRxMessagesWithTimeOut(m_hObject, iTimeOut);
if (iResult == 1)
{
//Message received
before timeout
lblWaitForRxMessageWithTimeOutResult.Text =
"Message received";
//Do something with the
messages received
cmdReceive_Click(sender, e);
}
else
{
//Timeout reached and
no messages received
lblWaitForRxMessageWithTimeOutResult.Text =
"Message Not received";
//Take action if no
messages were received
}
| intrepidcs API Documentation - (C) Copyright 2000-2012 Intrepid Control Systems, Inc. (www.intrepidcs.com) |
Last Updated : Tuesday, December 16, 2008