After the header, the NI-CAN logfile will contain zero or more events. Each event typically represents a single CAN frame, but it can also encode other information such as errors or triggers.
For this version of the specification, the size of each event in the logfile is the same. This fixed size is 24 bytes (as shown in the subsequent table). Given that the size of the header and the size of each event are fixed, you can often determine the number of events from the file’s size.
In the subsequent text, the phrase Net Interface Read function refers to the reference for the NI-CAN Frame API Read function for the Network Interface. Depending on which application development environment you use, this can be found in the NI-CAN Hardware and Software Manual in either:
- Chapter 10, Frame API for LabVIEW, ncReadNetMult.vi
- Chapter 11, Frame API for C, ncRead, CAN Network Interface Object
It is highly recommended that the first frame in the logfile consist of an NI-CAN start trigger frame (type 4). The start trigger contains an absolute timestamp (date/time) for the start of the CAN measurement, as well as an indication of the timestamp format for subsequent CAN frames (absolute or relative). If the start trigger is missing from a logfile, the start of the CAN measurement is assumed to be the same as the timestamp of the first CAN frame. For more information on the start trigger frame, refer to the Net Interface Read function.
64-bit timestamp in 100 nanosecond increments. The timestamp format can be absolute (date/time) or relative (zero-based).
For NI-CAN development in LabVIEW, the timestamp within NI-CAN frames is floating-point (DBL) seconds. For logfile access, you must convert this floating timestamp to/from two U32 fields (see examples). LabVIEW’s binary file I/O functions use big-endian, so you can simply access the most-significant U32 followed by the least significant U32.
For NI-CAN development in C/C++ (or other languages), the timestamp within NI-CAN frames is two U32 fields. Since each U32 in NI-CAN is stored as little-endian (least-significant byte first), you must swap the byte order prior to accessing the logfile.
For LabVIEW FPGA development, the timestamp is two U32 fields. LabVIEW’s binary file I/O functions use big-endian, so you can simply access the most-significant U32 followed by the least significant U32.
Identifier of the CAN frame.
Bit 29 (hex 0x20000000 ) indicates the format of the CAN identifier: set for extended, clear for standard.
The conventions for byte swapping match the technique described for each U32 portion of the Timestamp.
Type of event (frame).
This field is 0 to indicate a CAN data frame, and 1 to indicate a CAN remote frame. NI-CAN supports additional values.
For NI-CAN development in LabVIEW, this corresponds to the IsRemote field in the CAN frame. For information on types other than CAN frames, refer to the Net Interface Read function.
For NI-CAN development in C/C++ (or other languages), this corresponds to the FrameType field in the CAN frame. For information on types other than CAN frames, refer to the Net Interface Read function.
For LabVIEW FPGA development, this corresponds to the Type field in the CAN frame. LabVIEW FPGA supports only CAN data frames and CAN remote frames.
Information that qualifies the Type.
This information does not exist for NI-CAN.
This information exists for LabVIEW FPGA, but currently it is not used (reserved for future).
When reading the logfile you should ignore this field. When writing the logfile you must set this field to zero.
Information that qualifies the Type.
You should interpret this field the same as InfoA (ignore).
|For CAN data frames, the DataLength indicates the number of valid bytes in Data. For CAN remote frames, the DataLength indicates the bytes requested, not the number of valid bytes in Data. For all other frame Type values, the DataLength indicates the number of valid bytes in Data.|
|This field always contains 8 bytes in the logfile, but the number of valid bytes is often determined by DataLength.|
Table 2: NI-CAN Logfile Event information