ScriptWriteRxMessage 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 alter a receive message defined within script on a neoVI device.

C/C++ Declare

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

Visual Basic Declare

Public
Declare Function icsneoScriptWriteRxMessage 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 icsneoScriptWriteRxMessage 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 icsneoScriptWriteRxMessage(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

pRxMessageMask
  
[in] This is the address of an instance of an allocated icsSpyMessage structure. The structure will be used to change the specified receive message mask.

pRxMessage
  
[in] This is the address of an instance of an allocated icsSpyMessage structure. The structure will be used to change the specified 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

Remarks

The script containing the specified receive message must have been successfully downloaded to the neoVI using ScriptLoad. 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

sMessage.ArbIDOrHeader = CLng("&H" + txtArbID.Text)
sMessage.Data(0) =
CByte("&H" + txtByte(0).Text)
sMessage.Data(1) =
CByte("&H" + txtByte(1).Text)
sMessage.Data(2) =
CByte("&H" + txtByte(2).Text)
sMessage.Data(3) =
CByte("&H" + txtByte(3).Text)
sMessage.Data(4) =
CByte("&H" + txtByte(4).Text)
sMessage.Data(5) =
CByte("&H" + txtByte(5).Text)
sMessage.Data(6) =
CByte("&H" + txtByte(6).Text)
sMessage.Data(7) =
CByte("&H" + txtByte(7).Text)
sMessage.NumberBytesData =
CByte(cboNumberOfBytes.ListIndex)
sMessage.NetworkID =
CByte(NetworkIDConvert(cboNetwork.ListIndex))

'//set the message
iResult = icsneoScriptWriteRxMessage(m_hObject, CLng(cboMsgToSet.ListIndex), sMessageMask, sMessage)

'//Check the Results
If iResult = 0 Then
    lstMessages.AddItem("Problem!")
Else
    lstMessages.AddItem("Set!")
End
If
 

C/C++ Example:

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

//first read the existing message to get a baseline
iRetVal = icsneoScriptReadRxMessage(hObject, Receive_Msg_1, &MsgMask, &Msg);

if(iRetVal == 0)
{
    iRetVal = icsneoGetLastAPIError(hObject, &lLastErrNum);
    printf(
"\nFailed to read the receive message before writing it);
    printf(
"\nPress a key to continue");
}
Msg.ArbIDOrHeader = 0x030;
memset(Msg.Data, 0x03, 8);
iRetVal = icsneoScriptWriteRxMessage(hObject, Receive_Msg_1, &MsgMask, &Msg);

if(iRetVal == 0)
{
    printf(
"\nFailed to write the receive message.);
}
else
{
   
printf("\nWrote the transmit message to the script"
);
}



C# Example:

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

sMessage.ArbIDOrHeader = ConvertFromHex(txtArbID.Text);
sMessage.Data1 = Convert.ToByte(ConvertFromHex(txtDataByte1.Text));
sMessage.Data2 = Convert.ToByte(ConvertFromHex(txtDataByte2.Text));
sMessage.Data3 = Convert.ToByte(ConvertFromHex(txtDataByte3.Text));
sMessage.Data4 = Convert.ToByte(ConvertFromHex(txtDataByte4.Text));
sMessage.Data5 = Convert.ToByte(ConvertFromHex(txtDataByte5.Text));
sMessage.Data6 = Convert.ToByte(ConvertFromHex(txtDataByte6.Text));
sMessage.Data7 = Convert.ToByte(ConvertFromHex(txtDataByte7.Text));
sMessage.Data8 = Convert.ToByte(ConvertFromHex(txtDataByte8.Text));
sMessage.NumberBytesData = Convert.ToByte(lstNumberOfBytes.SelectedIndex);
sMessage.NetworkID = NetworkIDConvert[lstNetwork.SelectedIndex];

//set the message
iResult = icsNeoDll.icsneoScriptWriteRxMessage(m_hObject, Convert.ToUInt32(cboMsgToSet.SelectedIndex),ref sMessageMask,ref sMessage);

//Check the Results
if (iResult==0)
{
    lstMessages.Items.Add("Problem!");
}
else
{
    lstMessages.Items.Add("Set!");
}



Visual Basic .NET Example:

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

sMessage.ArbIDOrHeader = Convert.ToInt32("&H" + txtArbID.Text)
sMessage.Data1 = Convert.ToByte("&H" + txtDataByte1.Text)
sMessage.Data2 = Convert.ToByte("&H" + txtDataByte2.Text)
sMessage.Data3 = Convert.ToByte("&H" + txtDataByte3.Text)
sMessage.Data4 = Convert.ToByte("&H" + txtDataByte4.Text)
sMessage.Data5 = Convert.ToByte("&H" + txtDataByte5.Text)
sMessage.Data6 = Convert.ToByte("&H" + txtDataByte6.Text)
sMessage.Data7 = Convert.ToByte("&H" + txtDataByte7.Text)
sMessage.Data8 = Convert.ToByte("&H" + txtDataByte8.Text)
sMessage.NumberBytesData = Convert.ToByte(lstNumberOfBytes.SelectedIndex)
sMessage.NetworkID = Convert.ToByte(NetworkIDConvert(lstNetwork.SelectedIndex))

'//set the message
iResult = icsneoScriptWriteRxMessage(m_hObject, Convert.ToUInt32(cboMsgToSet.SelectedIndex), sMessageMask, sMessage)
'//Check the Results
lstMessages.Items.Clear()

If
iResult = 0
Then
    txtMSGWrite.Text = "Problem!"
Else
    txtMSGWrite.Text = "Set!"
End If

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

Last Updated : Tuesday, December 30, 2008