ScriptReadRxMessage 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 is used to read the parameters for a receive message defined with a script on a neoVI device.

C/C++ Declare

int _stdcall icsneoScriptReadRxMessage(int hObject unsigned int iIndex,  icsSpyMessage *pRxMessageMask icsSpyMessage *pRxMessage);


Visual Basic Declare

Public Declare Function icsneoScriptReadRxMessage Lib "icsneo40.dll" (ByVal hObject As Long, ByVal iIndex As Long, ByRef pRxMessageMask As icsSpyMessage, ByRef pRxMessageValue As icsSpyMessage) As Long


Visual Basic .NET Declare

Public Declare Function icsneoScriptReadRxMessage Lib "icsneo40.dll" (ByVal hObject As Int32, ByVal iIndex As UInt32, ByRef pRxMessageMask As icsSpyMessage, ByRef pRxMessageValue As icsSpyMessage) As Int32

C# Declare

[DllImport("icsneo40.dll")]
public static extern Int32 icsneoScriptReadRxMessage(Int32 hObject, UInt32 iIndex,ref icsSpyMessage pRxMessageMask, ref icsSpyMessage pRxMessageValue);

Parameters

hObject
   
[in] Specifies the driver object created by OpenNeoDevice.

iIndex
   
[in] The index value of the transmit message to read

pTxMessageMask
   
[in] This is the address of an instance of an allocated icsSpyMessage structure. The structure will be loaded with the requested receive message mask.

pTxMessage
   
[in] This is the address of an instance of an allocated icsSpyMessage structure. The structure will be loaded with the requested receive message.

Return Values

1 if the function succeeded. 0 if it failed for any reason. 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
NEOVI_ERROR_DLL_SCRIPT_INVALID_MSG_INDEX = 224
NEOVI_ERROR_DLL_SCRIPT_NO_SCRIPT_RUNNING = 226

Remarks

The script containing the specified receive message must have been successfully downloaded to the neoVI using LoadScript. The script must also have been started using ScriptStart. This function will fail if ScriptStop has been called. The valid index values for receive messages within a script can be found in the cmvspy.vs3cmb.h file that is produced by Vehicle Spy. Please see Vehicle Spy documentation.


Examples

Visual Basic Example

Dim iResult As Long
Dim
sMessage As icsSpyMessage
Dim sMessageMask As icsSpyMessage

'//Read Tx Message
iResult = icsneoScriptReadRxMessage(m_hObject, CLng(cboMessageToRead.ListIndex), sMessageMask, sMessage)

If iResult = 0 Then
    lstMessages.AddItem("Problem!")
Else
    //Read the icsSpyMessage Structure
End
If

C/C++ Example:

int iRetVal;
int i;
unsigned long lLastErrNum;
icsSpyMessage MsgMask, Msg;


iRetVal = icsneoScriptReadRxMessage(hObject, Receive_Msg_1, &MsgMask, &Msg);
if(iRetVal == 0)
{
    printf(
"\nFailed to read the receive message.");
}
else
{
    printf(
"\nRead the receive message from the script.");
    printf(
"ArbID = %X Data bytes: ", Msg.ArbIDOrHeader);
   
for(i = 0; i < 8; i++)
    {
        printf(
"%02X "
, Msg.Data[i]);
    }
}

 


C# Example:

Int32 iResult;
icsSpyMessage sMessage =
new icsSpyMessage();
icsSpyMessage sMessageMask =
new icsSpyMessage();

// Has the uset open neoVI yet?;
if (m_bPortOpen==false)
{
    MessageBox.Show("neoVI not opened");
    return; // do not read messages if we haven't opened neoVI yet
}

//Read Rx Message
iResult = icsNeoDll.icsneoScriptReadRxMessage(m_hObject, Convert.ToUInt32(cboMessageToRead.SelectedIndex),ref sMessageMask,ref sMessage);

if (iResult == 0)
{
    lstMessages.Items.Add("Problem!");
}
else
{
    //Read the icsSpyMessage Structure
}


Visual Basic .NET Example:


Dim iResult As Int32
Dim sMessage As icsSpyMessage
Dim sMessageMask As icsSpyMessage

'//Read Tx Message
iResult = icsneoScriptReadRxMessage(m_hObject, Convert.ToUInt32(cboMessageToRead.SelectedIndex), sMessageMask, sMessage)

If iResult = 0 Then
    lstMessages.Items.Add("Problem!")
Else
   
'//Read the icsSpyMessage Structure
End
If

 

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

Last Updated : Tuesday, December 30, 2008