Vector工具录制的数据,一般有ASC和BLF两种格式,本文介绍ASC。
1.BLF定义
BLF(binary logging format)即二进位数据文件。
2.BLF查看
因其是二进位文件,且又做了数据压缩,已经无法直接看到物理数值。需要在Vector工具中回放。
3.BLF组成
安装完Vector软体后,可以在DocLoggingFormat_BLF目录下看到《CAN_and_General_BLF_Format.pdf》(回复「BLF文档"获取)。此文档详细说明了BLF内容。BLF内由一系列数据块组成。介绍几个常用的:
1)VBLObjectHeaderBase
2)VBLObjectHeader
3)VBLCANMessage
4.BLF解析
因BLF的保密性,无法直接读到值,需要使用Vector提供的binlog.dll,相关的例子可以参考《C:UsersPublicDocumentsVectorCANoe9.0
/******************************************************************************
*
* read BL file
******************************************************************************/
int read_test( LPCTSTR pFileName, LPDWORD pRead)
{
HANDLE hFile;
VBLObjectHeaderBase base;
VBLCANMessage message;
VBLEnvironmentVariable variable;
VBLEthernetFrame ethframe;
VBLAppText appText;
VBLFileStatisticsEx statistics = { sizeof( statistics)};
BOOL bSuccess;
if ( NULL == pRead)
return -1;
}
*pRead = 0;
/* open file */
hFile = BLCreateFile( pFileName, GENERIC_READ);
if ( INVALID_HANDLE_VALUE == hFile)
BLGetFileStatisticsEx( hFile, &statistics);
bSuccess = TRUE;
/* read base object header from file */
while ( bSuccess && BLPeekObject( hFile, &base))
switch ( base.mObjectType)
case BL_OBJ_TYPE_CAN_MESSAGE:
/* read CAN message */
message.mHeader.mBase = base;
bSuccess = BLReadObjectSecure(
/* free memory for the CAN
if( bSuccess) {
BLFreeObject( hFile,
break;
case BL_OBJ_TYPE_ENV_INTEGER:
case BL_OBJ_TYPE_ENV_DOUBLE:
case BL_OBJ_TYPE_ENV_STRING:
case BL_OBJ_TYPE_ENV_DATA:
/* read environment variable */
variable.mHeader.mBase = base;
/* free memory for the
case BL_OBJ_TYPE_ETHERNET_FRAME:
/* read ethernet frame */
ethframe.mHeader.mBase = base;
/* free memory for the frame */
case BL_OBJ_TYPE_APP_TEXT:
/* read text */
appText.mHeader.mBase = base;
if ( NULL != appText.mText)
printf(
/* free memory for the text */
default:
/* skip all other objects */
bSuccess = BLSkipObject( hFile,
if ( bSuccess)
*pRead += 1;
/* close file */
if ( !BLCloseHandle( hFile))
return bSuccess ? 0 : -1;
1)hFile
以读取的方式,打开BLF文件
2)BLGetFileStatisticsEx(
读取文件统计信息
3)while
读取文件object
4)switch
5)bSuccess
读取CAN message
6)bSuccess
跳过其他object
7) if
5.开发步骤
需要c/c++基础
1)新建vc++项目
2)引入头文件:binlog.h和binlog_objects.h
3)引入库文件:binlog.dll和binlog.lib
4)参考bl.c开发