Message Structures - neoVI API
C/C++ declare - VB declareVB.NET declare - C# declare - Remarks - C/C++ example - VB example - VB.NET example - C# example

These structures are used to represent messages both received and transmitted by the neoVI device. These structures can also be represented as an array of bytes described in a separate topic.

C/C++ Declare

typedef struct // matching C structure
{
    unsigned long StatusBitField; 
    unsigned long StatusBitField2; 
    unsigned long TimeHardware; 
    unsigned long TimeHardware2; 
    unsigned long TimeSystem; 
    unsigned long TimeSystem2; 
    unsigned char TimeStampHardwareID; 
    unsigned char TimeStampSystemID;
    unsigned char NetworkID; 
    unsigned char NodeID;
    unsigned char Protocol;
    unsigned char MessagePieceID; 
    unsigned char ColorID; 
    unsigned char NumberBytesHeader;
    unsigned char NumberBytesData; 
    short DescriptionID; 
    long ArbIDOrHeader; 
    unsigned char Data[8]; 
    unsigned char AckBytes[8]; 
    float Value;
    unsigned char MiscData;
} icsSpyMessage;

typedef struct // matching C structure
{
    unsigned long StatusBitField; 
    unsigned long StatusBitField2; 
    unsigned long TimeHardware; 
    unsigned long TimeHardware2; 
    unsigned long TimeSystem; 
    unsigned long TimeSystem2; 
    unsigned char TimeStampHardwareID; 
    unsigned char TimeStampSystemID; 
    unsigned char NetworkID; 
    unsigned char NodeID; 
    unsigned char Protocol; 
    unsigned char MessagePieceID; 
    unsigned char ColorID; 
    unsigned char NumberBytesHeader;
    unsigned char NumberBytesData; 
    short DescriptionID; 
    unsigned char Header[4]; 
    unsigned char Data[8];
    unsigned char AckBytes[8]; 
    float Value;
    unsigned char MiscData;
} icsSpyMessageJ1850;

Visual Basic Declares


Public Type icsSpyMessage
    StatusBitField As Long 
    StatusBitField2 As Long 
    TimeHardware As Long
    TimeHardware2 As Long
    TimeSystem As Long
    TimeSystem2 As Long
    TimeStampHardwareID As Byte 
    TimeStampSystemID As Byte
    NetworkID As Byte
    NodeID As Byte
    Protocol As Byte
    MessagePieceID As Byte
    ColorID As Byte
    NumberBytesHeader As Byte 
    NumberBytesData As Byte 
    DescriptionID As Integer 
    ArbIDOrHeader As Long 
    Data(1 To 8) As Byte 
    AckBytes(1 To 8) As Byte 
    Value As Single 
    MiscData As Byte
End Type


Public Type icsSpyMessageJ1850
    StatusBitField As Long 
    StatusBitField2 As Long 
    TimeHardware As Long 
    TimeHardware2 As Long 
    TimeSystem As Long 
    TimeSystem2 As Long
    TimeStampHardwareID As Byte
    TimeStampSystemID As Byte
    NetworkID As Byte 
    NodeID As Byte
    Protocol As Byte
    MessagePieceID As Byte 
    ColorID As Byte 
    NumberBytesHeader As Byte 
    NumberBytesData As Byte 
    DescriptionID As Integer 
    Header(1 To 4) As Byte 
    Data(1 To 8) As Byte 
    AckBytes(1 To 8) As Byte 
    Value As Single 
    MiscData As Byte
End Type

Visual Basic .NET Declares

Public Structure icsSpyMessage
    Dim StatusBitField As Integer 
    Dim StatusBitField2 As Integer 
    Dim TimeHardware As Integer 
    Dim TimeHardware2 As Integer 
    Dim TimeSystem As Integer 
    Dim TimeSystem2 As Integer
    Dim
TimeStampHardwareID As Byte 
    Dim TimeStampSystemID As Byte
    Dim
NetworkID As Byte 
    Dim NodeID As Byte
    Dim
Protocol As Byte
    Dim
MessagePieceID As Byte
    Dim ColorID As Byte 
    Dim NumberBytesHeader As Byte 
    Dim NumberBytesData As Byte
    Dim DescriptionID As Short 
    Dim ArbIDOrHeader As Integer 
    Dim Data1 As Byte 
    Dim Data2 As Byte
    Dim
Data3 As Byte
    Dim
Data4 As Byte
    Dim
Data5 As Byte
    Dim
Data6 As Byte
    Dim
Data7 As Byte
    Dim
Data8 As Byte
    Dim
AckBytes1 As Byte 
    Dim AckBytes2 As Byte
    Dim
AckBytes3 As Byte
    Dim
AckBytes4 As Byte
    Dim
AckBytes5 As Byte
    Dim
AckBytes6 As Byte
    Dim
AckBytes7 As Byte
    Dim
AckBytes8 As Byte
    Dim
Value As Single 
    Dim MiscData As Byte
End
Structure

Public Structure icsSpyMessageJ1850
    Dim StatusBitField As Integer 
    Dim StatusBitField2 As Integer 
    Dim TimeHardware As Integer 
    Dim TimeHardware2 As Integer 
    Dim TimeSystem As Integer 
    Dim TimeSystem2 As Integer
    Dim
TimeStampHardwareID As Byte 
    Dim TimeStampSystemID As Byte
    Dim
NetworkID As Byte 
    Dim NodeID As Byte
    Dim
Protocol As Byte
    Dim
MessagePieceID As Byte 
    Dim ColorID As Byte 
    Dim NumberBytesHeader As Byte 
    Dim NumberBytesData As Byte 
    Dim DescriptionID As Short 
    Dim Header1 As Byte 
    Dim Header2 As Byte
    Dim
Header3 As Byte
    Dim
Header4 As Byte
    Dim
Data1 As Byte 
    Dim Data2 As Byte
    Dim
Data3 As Byte
    Dim
Data4 As Byte
    Dim
Data5 As Byte
    Dim
Data6 As Byte
    Dim
Data7 As Byte
    Dim
Data8 As Byte
    Dim
AckBytes1 As Byte
    Dim
AckBytes2 As Byte
    Dim
AckBytes3 As Byte
    Dim
AckBytes4 As Byte
    Dim
AckBytes5 As Byte
    Dim
AckBytes6 As Byte
    Dim
AckBytes7 As Byte
    Dim
AckBytes8 As Byte
    Dim
Value As Single 
    Dim MiscData As Byte
End
Structure


C# Declares

[StructLayout(LayoutKind.Sequential)]
public struct icsSpyMessage 
{
    public int StatusBitField; 
    public int StatusBitField2; 
    public int TimeHardware; 
    public int TimeHardware2; 
    public int TimeSystem;
    public int TimeSystem2;
    public byte TimeStampHardwareID; 
    public byte TimeStampSystemID;
    public byte NetworkID; 
    public byte NodeID;
    public byte Protocol;
    public byte MessagePieceID; 
    public byte ColorID; 
    public byte NumberBytesHeader; 
    public byte NumberBytesData; 
    public short DescriptionID; 
    public int ArbIDOrHeader; 
    public byte Data1;
    public byte Data2;
    public byte Data3;
    public byte Data4;
    public byte Data5;
    public byte Data6;
    public byte Data7;
    public byte Data8;
    public byte AckBytes1;
    public byte AckBytes2;
    public byte AckBytes3;
    public byte AckBytes4;
    public byte AckBytes5;
    public byte AckBytes6;
    public byte AckBytes7;
    public byte AckBytes8;
    public Single Value; 
    public byte MiscData;
}
[StructLayout(LayoutKind.Sequential)]
public struct icsSpyMessageJ1850
{
    public int StatusBitField; 
    public int StatusBitField2;
    public int TimeHardware; 
    public int TimeHardware2;
    public int TimeSystem;
    public int TimeSystem2;
    public byte TimeStampHardwareID; 
    public byte TimeStampSystemID;
    public byte NetworkID; 
    public byte NodeID;
    public byte Protocol;
    public byte MessagePieceID; 
    public byte ColorID; 
    public byte NumberBytesHeader; 
    public byte NumberBytesData; 
    public short DescriptionID; 
    public byte Header1; 
    public byte Header2;
    public byte Header3;
    public byte Header4;
    public byte Data1;
    public byte Data2;
    public byte Data3;
    public byte Data4;
    public byte Data5;
    public byte Data6;
    public byte Data7;
    public byte Data8;
    public byte AckBytes1;
    public byte AckBytes2;
    public byte AckBytes3;
    public byte AckBytes4;
    public byte AckBytes5;
    public byte AckBytes6;
    public byte AckBytes7;
    public byte AckBytes8;
    public Single Value; 
    public byte MiscData;
}

Remarks

There are two structures here. Both are equivalent. The only difference is how they represent message bytes. The icsspyMessageJ1850 provides a more convenient representation for J1850 or ISO messages with a header array holding the first three bytes of the message.

These structures can be use interchangeably in C by casting one type to the other. In Visual Basic, you can copy one structure to the other using the LSet method.

Table 1 below lists the members of the structure and specific remarks about there use.

Table 1 - Message Structure Elements

Item Description
StatusBitField 
StatusBitField2 
Bitfields which describe the message. These are described in a separate topic.
TimeHardware
TimeHardware2
This is the hardware time stamp. The TimeStamp is reset to zero every time the OpenPort method is called.

For the neoVI hardware, TimeHardware2 is more significant than TimeHardware. The resolution of TimeHardware is 1.6µs and and TimeHardware2 is 104.8576 ms. To calculate the time of the message in seconds use the following formula: "Timestamp (sec) = TimeHardware2* 0.1048576 + TimeHardware2 * 0.0000016". 

For the neoVI PRO or ValueCAN hardware, TimeHardware2 is more significant than TimeHardware. The resolution of TimeHardware is 1.0µs and and TimeHardware2 is 65.536 ms. To calculate the time of the message in seconds use the following formula: "Timestamp (sec) = TimeHardware2* 0.065536 + TimeHardware2 * 0.000001". 

 

TimeSystem 
TimeSystem2   
This is the system time stamp. TimeSystem is loaded with the value received from the timeGetTime call in the WIN32 multimedia API. The timeGetTime accuracy is up to 1 millisecond. See the WIN32 API documentation for more information. This timestamp is useful for time comparing with other system events or data which is not synced with the neoVI timestamp. Currently, TimeSystem2 is not used.
TimeStampHardwareID This is an identifier  of what type of hardware timestamp is used. Since neoVI's timestamp is always the same, this doesn't change.
TimeStampSystemID This is an identifier  of what type of system timestamp is used. Since WIN32 neoVI's timestamp is always the same, from the timeGetTime API, this doesn't change.
NetworkID This is the NetworkID as assigned in the OpenPort method. This value is used to identify which network this message was received on.
NodeID Not Used in the neoVI API.
Protocol This is the type of protocol which the message belongs to. Valid values are SPY_PROTOCOL_CAN, SPY_PROTOCOL_J1850VPW, and SPY_PROTOCOL_ISO9141.
MessagePieceID Not Used in the neoVI API.
ColorID Not Used in the neoVI API.
NumberBytesHeader Used for J1850/ISO messages. It indicates how many bytes are stored in the Header(1 to 4) array.
NumberBytesData Holds the number of bytes in the Data(1 to 8) array or the number of bytes in a CAN remote frame (The DLC).
DescriptionID Not Used in the neoVI API.
Header(1 To 4) or ArbIDOrHeader  Holds up to 3 byte 1850 header (bytes 1 through 3) or a 29 bit CAN header.
Data(1 To 8)  Holds the 8 data bytes in CAN messages or bytes 4 through 11 in J1850/ISO messages.
AckBytes(1 To 8) Not Used in the neoVI API.
Value     Not Used in the neoVI API.
MiscData Not Used in the neoVI API.

 


Examples

Visual Basic Examples

Interchangeably using the structures : Copying a icsSpyMessage to an icsSpyMessageJ1850

Dim stMessagesTx As icsSpyMessage
Dim stJMsg As icsSpyMessageJ1850

'// copy the J1850 message structure into the structure that will be transmitted
LSet stMessagesTx = stJMsg

Timestamps : Calculating a TimeStamp

Dim dTime As Double

'// Determine the timestamp
dTime  = NEOVI_TIMEHARDWARE2_SCALING * stMessage.TimeHardware2 + NEOVI_TIMEHARDWARE_SCALING * stMessage.TimeHardware

 

C/C++ Example

Interchangeably using the structures : Casting a icsSpyMessage to an icsSpyMessageJ1850

((icsSpyMessageJ1850 *) stMessages)[lCount].Header[0]

Timestamps : Calculating a TimeStamp

// Calculate the time for this message
dTime = ((double) stMessages[lCount].TimeHardware2) * NEOVI_TIMESTAMP_2 + 
                ((double) stMessages[lCount].TimeHardware) * NEOVI_TIMESTAMP_1;


C# Example

Timestamps : Calculating a TimeStamp

double dTime; //Storage for message time

dTime = icsNeoDll.icsneoGetTimeStamp(stMessages[lCount-1].TimeHardware, stMessages[lCount-1].TimeHardware2);

 

Visual Basic .NET Example

Timestamps : Calculating a TimeStamp

Dim dTime As Double

dTime = icsneoGetTimeStamp(stMessages(lCount - 1).TimeHardware, stMessages(lCount - 1).TimeHardware2)

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

Last Updated : Thursday, December 11, 2003