Vehicle Spy Binary File Buffer File Spec - Vehicle Spy 3

Overview

This document describes the binary file format for Vehicle Spy 3 datafiles. This binary file format was designed to optimize file save time as opposed to file size.  There are 3 versions for Vehicle Spy's Binary File Buffer.  The 7th byte gives the version number

Basics
Version 0x101

Description Length Notes
text identifier 6 single byte char array with text "icsbin" used to identify file type.
file version 4 unsigned int values indicate version.
length of vs3 file 4 unsigned int value indicating the length of the next section (the vs3 file). A zero indicates not vs3 file is present.
vs3 file variable (see above) The vs3 file used to save this binary file. This vs3 file is later used to decode the binary data into useable information.
length of text comment 4 unsigned int indicating the length of the text header comment of the saved file. SINCE THE COMMENT IS UNICODE THEREFORE HIS IS THE LENGTH IN CHARACTERS - NOT BYTES.
text comment 2 bytes per character (see above for number of characters) Unicode text comment.
Number of bytes for stored buffer messages 4 sizeof(icsSpyMessage) * Number of messages saved to the file
Current Buffer Pointer 4 unsigned int value which is the pointer to the most recent buffer item +1. (only needed if Number of All time messages > Original buffer size)
Original Buffer Size 4 unsigned int value which is the size of the buffer memory originally allocated by this buffer
Number of All time messages 4 This indicates how many messages were received by this buffer (this number will indicate overflows)
Buffer of Messages Struct icsSpyMessage icsSpyMessage structures
Start Time of Collection Struct icsspyMsgTime This is a comparison value between the system time stamp and the neoVI timestamp.

Network ID Default list

HS_CAN=0
MS_CAN=1
SW_CAN=2
J1850 VPW=3
ISO9141_KW2K=4
LSFT_CAN=5
J1850 PWM=6
J1708=7
neoVI=8
HS CAN2=9
HS CAN3=10
LIN2=11
LIN3=12
LIN4=13
CGI=14


Version 0x102
*The difference between version 0x102 and 0x103 is the meaning of the NetworkID in the icsspyMessageStructure.

Description Length Notes
text identifier 6 single byte char array with text "icsbin" used to identify file type.
file version 4 unsigned int values indicate version.
Buffer of Messages Struct icsSpyMessage icsSpyMessage structures

Network ID list

NETID_DEVICE = 0
NETID_HSCAN = 1
NETID_MSCAN = 2
NETID_SWCAN = 3
NETID_LSFTCAN = 4
NETID_FORDSCP = 5
NETID_J1708 = 6
NETID_AUX = 7
NETID_JVPW = 8
NETID_ISO = 9
NETID_LIN = 9
NETID_ISOPIC = 10
NETID_MAIN51 = 11
NETID_SCI = 13
NETID_ISO2 = 14
NETID_FIRE_HSCAN1 = 41
NETID_FIRE_HSCAN2 = 42
NETID_FIRE_MSCAN1 = 43
NETID_FIRE_HSCAN3 = 44
NETID_FIRE_SWCAN = 45
NETID_FIRE_LSFT = 46
NETID_FIRE_LIN1 = 47
NETID_FIRE_LIN2 = 48
NETID_FIRE_LIN3 = 49
NETID_FIRE_LIN4 = 50

Version 0x103

Description Length Notes
text identifier 6 single byte char array with text "icsbin" used to identify file type.
file version 4 unsigned int values indicate version.
length of vs3 file 4 unsigned int value indicating the length of the next section (the vs3 file). A zero indicates not vs3 file is present.
vs3 file variable (see above) The vs3 file used to save this binary file. This vs3 file is later used to decode the binary data into useable information.
length of text comment 4 unsigned int indicating the length of the text header comment of the saved file. SINCE THE COMMENT IS UNICODE THEREFORE HIS IS THE LENGTH IN CHARACTERS - NOT BYTES.
text comment 2 bytes per character (see above for number of characters) Unicode text comment.
Number of bytes for stored buffer messages 4 sizeof(icsSpyMessage) * Number of messages saved to the file
Current Buffer Pointer 4 unsigned int value which is the pointer to the most recent buffer item +1. (only needed if Number of All time messages > Original buffer size)
Original Buffer Size 4 unsigned int value which is the size of the buffer memory originally allocated by this buffer
Number of All time messages 4 This indicates how many messages were received by this buffer (this number will indicate overflows)
Buffer of Messages Struct icsSpyMessage icsSpyMessage structures
Start Time of Collection Struct icsspyMsgTime This is a comparison value between the system time stamp and the neoVI timestamp.

Network ID list

NETID_DEVICE = 0
NETID_HSCAN = 1
NETID_MSCAN = 2
NETID_SWCAN = 3
NETID_LSFTCAN = 4
NETID_FORDSCP = 5
NETID_J1708 = 6
NETID_AUX = 7
NETID_JVPW = 8
NETID_ISO = 9
NETID_LIN = 9
NETID_ISOPIC = 10
NETID_MAIN51 = 11
NETID_SCI = 13
NETID_ISO2 = 14
NETID_FIRE_HSCAN1 = 41
NETID_FIRE_HSCAN2 = 42
NETID_FIRE_MSCAN1 = 43
NETID_FIRE_HSCAN3 = 44
NETID_FIRE_SWCAN = 45
NETID_FIRE_LSFT = 46
NETID_FIRE_LIN1 = 47
NETID_FIRE_LIN2 = 48
NETID_FIRE_LIN3 = 49
NETID_FIRE_LIN4 = 50

Structs from icsSpyData.h

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

typedef struct // matching C structure
{
unsigned long SystemTimeStampID; // 4
unsigned long SystemTime1; // 4
unsigned long SystemTime2; // 4
unsigned long HardwareTimeStampID; // 4
unsigned long HardwareTime1; // 4
unsigned long HardwareTime2; // 4

} icsSpyMsgTime;

 

Example for reading version 0x101

// binary file load
bool cicsSpyBuffer::LoadBufferBinary(ICSCHAR * szFilePathName, PVOID pArg, cicsString & sComment,
cicsDynamicArrayTemplate<unsigned char> & obSetupArray, icsspyMsgTime & stMsgStartTime, cicsString & sReadErrorString)
{

HANDLE hFile;
unsigned char bTemp;
int iVersion;
unsigned long iNumBytesRead;
long lResult;
bool bInvalidFormat =true;
int iFileSize;
short iShortTemp;
int iCount;
int iBufferSizeInBytes;
int iBufferSizeInMsgs;
int iTempBuffSizeInMsgsSaved;
int iTempBuffCurrentItem;

// open the file for reading
hFile = ICSCreateFile(szFilePathName,GENERIC_READ,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if (hFile == INVALID_HANDLE_VALUE)
return false;

// return ReadFile(hFile, obArray, iByteCount, &iBytesRead, NULL);
// step 1: read a file header with version ////////////////////////////////////////////////////////////////////

lResult = ReadFile(hFile,&bTemp,1,&iNumBytesRead,NULL);
if (bTemp != 'i')
goto HasbInvalidFormat;
lResult = ReadFile(hFile,&bTemp,1,&iNumBytesRead,NULL);
if (bTemp != 'c')
goto HasbInvalidFormat;
lResult = ReadFile(hFile,&bTemp,1,&iNumBytesRead,NULL);
if (bTemp != 's')
goto HasbInvalidFormat;
lResult = ReadFile(hFile,&bTemp,1,&iNumBytesRead,NULL);
if (bTemp != 'b')
goto HasbInvalidFormat;
lResult = ReadFile(hFile,&bTemp,1,&iNumBytesRead,NULL);
if (bTemp != 'i')
goto HasbInvalidFormat;
lResult = ReadFile(hFile,&bTemp,1,&iNumBytesRead,NULL);
if (bTemp != 'n')
goto HasbInvalidFormat;
lResult = ReadFile(hFile,&iVersion,sizeof(iVersion),&iNumBytesRead,NULL);
if (iVersion != 0x101)
goto HasbInvalidFormat;
//////////////////////////////////////////////////////////////////////////////////////////////////////

// if we made it this far we should be safe
bInvalidFormat = false;

HasbInvalidFormat:
if (bInvalidFormat)
{
sReadErrorString = ICSUNI("This binary file is not a valid Vehicle Spy Buffer file.");
return false;

}
/////////////////////////////// /////////////////////////////////////////////////////////////////////
// Start the conversion....
//////////////////////////////////////////////////////////////////////////////////////////////////////

// step 2 : read the size of the setup (vs3) file ////////////////////////////////////////////////////
lResult = ReadFile(hFile,&iFileSize,sizeof(int),&iNumBytesRead,NULL);

// resize the setup array to fit the setup file
obSetupArray.Redim(iFileSize,false);

// step 3: read the setup file ///////////////////////////////////////////////////////////////////////
lResult = ReadFile(hFile,obSetupArray.obItems,obSetupArray.iNumItems,&iNumBytesRead,NULL);

// step 4: read the comment as unicode ///////////////////////////////////////////////////////////////////////////
// first read the length in characters
lResult = ReadFile(hFile,&iFileSize,sizeof(iFileSize),&iNumBytesRead,NULL);

if (iFileSize==0)
sComment = ICSUNI("");
else
{
sComment.Redim(iFileSize+1,false);

// write the characters
for (iCount=0;iCount<iFileSize;iCount++)
{
lResult = ReadFile(hFile,&iShortTemp,sizeof(iShortTemp),&iNumBytesRead,NULL);
sComment.szOut[iCount] = (ICSCHAR) iShortTemp;

}
// null terminaotr
sComment.szOut[iFileSize] = 0;
}

// step 5: read the size of the binary file ////////////////////////////////////////////////////////////
// number of messages
lResult = ReadFile(hFile,&iBufferSizeInBytes,sizeof(iBufferSizeInBytes),&iNumBytesRead,NULL);
iBufferSizeInMsgs = iBufferSizeInBytes / sizeof(icsSpyMessage);

// size of original buffer
lResult = ReadFile(hFile,&iTempBuffSizeInMsgsSaved,sizeof(iTempBuffSizeInMsgsSaved),&iNumBytesRead,NULL);
// current buffer position
lResult = ReadFile(hFile,&iTempBuffCurrentItem,sizeof(iTempBuffCurrentItem),&iNumBytesRead,NULL);

SetBufferSize(iTempBuffSizeInMsgsSaved);
lCurrentItem = iTempBuffCurrentItem;
// lNumberOfMessagesAllTime
lResult = ReadFile(hFile,&lNumberOfMessagesAllTime,sizeof(lNumberOfMessagesAllTime),&iNumBytesRead,NULL);

// step 6: write the array structure of messages //////////////////////////////////////////////////////////////
lResult = ReadFile(hFile,mMessages,iBufferSizeInBytes,&iNumBytesRead,NULL);

// step 7: read the monitor start time
lResult = ReadFile(hFile,&stMsgStartTime,sizeof(stMsgStartTime),&iNumBytesRead,NULL);

// close the file handle
CloseHandle(hFile);

return true;

}

 

 

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

Last Updated : Tuesday, December 16, 2008