GetMessages 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 reads messages from the neoVI device.
int _stdcall icsneoGetMessages(void * hObject, icsSpyMessage *pMsg, int *pNumberOfMessages, int *pNumberOfErrors);
Visual Basic .NET Declare
Public
Declare
Function icsneoGetMessages
Lib "icsneo40.dll" (ByVal
hObject As IntPtr,
ByRef pMsg
As icsSpyMessage,
ByRef pNumberOfMessages
As Int32,
ByRef pNumberOfErrors
As Int32)
As
Int32
C# Declare
[DllImport("icsneo40.dll")]
public
static
extern Int32
icsneoGetMessages(IntPtr hObject, ref
icsSpyMessage pMsg, ref
Int32 pNumberOfMessages, ref
Int32 pNumberOfErrors);
Parameters
hObject
[in] Specifies the driver object created by OpenNeoDevice.
pMsg
[out] This is the address of the first element of an array of
icsSpyMessage structures. This array will be
loaded with messages received by the hardware. This array must be sized to fit 20,000
icsSpyMessage structures.
pNumberOfMessages
[out] Specifies the number of messages the driver has loaded
in the pMsg array. This number can be up to 20,000 messages.
pNumberOfErrors
[out] Specifies the number of errors in the neoVI DLL error queue.
Errors are obtained using GetErrorMessages.
Returns 1 if successful, 0 if an error
occurred. GetLastAPIError
must be called to obtain the specific error. This
function will return 1 even if no messages were received, provided there are no
errors. The errors that can be
generated by this function are:
NEOVI_ERROR_DLL_NEOVI_NO_RESPONSE
= 75
The driver object will hold 20,000 received messages before it will generate an rx buffer overflow error (indicated by a NEOVI_ERROR_DLL_RX_MSG_BUFFER_OVERFLOW error message in the error queue). It is the job of the application software to read this buffer at regular intervals. The rate that the application needs to read these messages is dependant on the rate messages are received on the bus. For example, a high bandwidth CAN bus can generate 5000 messages per second. In this case you must read out the messages at least every four seconds or overflow errors will result.
Examples
void * hObject = 0;
// holds a handle to the neoVI object
icsSpyMessage stMessages[20000]; // holds the received messages
int
iResult;
int iNumberOfErrors;
int iNumberOfMessages;
// read out the messages
iResult = icsneoGetMessages(hObject,stMessages,&iNumberOfMessages,&iNumberOfErrors);
if (iResult == 0)
MessageBox(hWnd,TEXT("Problem Reading
Messages"),TEXT("neoVI Example"),0);
else
MessageBox(hWnd, TEXT("Messages Read Successfully"),TEXT("neoVI Example"),0);
C# Example
long
lResult; //Storage the Result for the
function call
int lNumberOfErrors
= 0; //Storage for the number of Errors
int
lNumberOfMessages = 0; //Storage for the
number of messages
//Call Get messages
lResult = icsNeoDll.icsneoGetMessages(m_hObject, ref
stMessages[0],ref
lNumberOfMessages,ref
lNumberOfErrors);
if(lResult == 0) //Check
the Results to see if there is a problem
{
MessageBox.Show ("Problem Getting Messages");
return;
}
IntrepidCS API Documentation - (C) Copyright 2000-2022 Intrepid Control Systems, Inc. (www.intrepidcs.com) |
Last Updated : Thursday, September 08, 2016