Example Code

Read and Write BLF Files

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Programming Language

  • LabVIEW G

Code and Documents

Attachment

Description

Overview

Read and write BLF binary files using the Vector provided DLL, or a more Raw API using the zLib Inflate/Deflate. 

Description

Vector has a custom binary file format used primarily for logging raw CAN data.  When using a Vector product such as CANalyzer, a log can be done in ASCII which baloons the file size but has the most compatibility, or you can log in BLF which is a small binary file, which also has some level of object compression built in.  With this API you can now read these BLF files and get the raw CAN frames in a form that is similar to the XNet frame structure, allowing for easy conversion using the XNet API.  You can also use this API to perform the reverse function.  Where you may want to log into a BLF file, so that Vector tools like CANalyzer can analyze and view your data.

 

All the core functions are implemented by calling the Vector provided DLL, which is documented online and has a shipped example installed with CANalyzer.  There is an alternate API that also allows for reading and writing BLF files by not using the Vector DLL and instead uses the OpenG zip utility.

Hardware and Software Requirements

Back saved into LabVIEW 2014 (version 2) or LabVIEW 2017 for version 3, and requires the Windows platform for executing the binlog.dll.  Version 8 is saved in 2018 and has an example of both the DLL version and the Raw version which requires the OpenG zip package.  The OpenG zip method works on all platforms that API supports, and is much faster than the DLL method.

Steps to Implement or Execute Code

The external dependencies are referenced with the Package Dependency.vipc file.  Once those packages are installed through VIPM, open either of the examples and run them to write and read a file.

 

Untitled.png

Additional Information or References

Version History

 

Version 8

  • Raw Open has Overwrite input
  • Raw added Polymorphic Write CAN Data, that can write a single frame, multiple frames to the same channel, or multiple frames to different channels.
  • Raw bug fix with ID mask of standard CAN frames when reading.

Version 7

  • Bug fix with uncommon object types
  • Added IDs To Return filtering on the Raw Read function

Version 6

  • Made reading more robust supporting other objects like System Variables in the BLF.

Version 5

  • Added a secondary API for reading and writing using the OpenG zip utilities.
  • Added reading and writing CAN FD frames

Version 4

  • When writing to a BLF the day light savings flag is used and will offset the write by an hour if necessary
  • Object Offset was removed and instead before every read the Object Offset is read from the session.  This is used instead of tracking the current offset since it had issues with newer CANalyzer files

Version 3

  • Bug fix with the Read CAN Frames.vi which now accepts reading CAN_MESSAGE2 which newer Vector tools may write to
  • Fixed Read CAN Frame.vi to return an ID masking out the 29 bits for extended, not 27

Version 2

  • Back saved to 2014
  • Added CAN Channel input and output to the Read and Write functions

 

 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
A-T-R
Active Participant
Active Participant
on

Currently I'm installing OpenG library to LV26.

During installation, it tells me the following:

 

LabVIEW ZIP library, version 5.0.9
----------------------------------

Copyright 2002-2025 Rolf Kalbermatter


Please read this document before you upgrade from an older version of LVZIP.

Version 5.0 of LVZIP is a fundamentally redeveloped package. It still has the basic ZIP functionality and the interface as before but uses underneath its own file IO functions instead of the LabVIEW functions in order to support both long pathnames > 260 characters as well as Unicode characters in paths.

While there is a great effort to keep this package upwards compatible with previous versions, there can be some differences that could require rewiring of some of the functions to make it executable again.


Version 2.2 of LVZIP has some modifications to the VI connector panes in comparison to earlier versions which might require you to slightly redo your project.

 

Will this affect your toolkit?

 

Regards

Achim

Contributors