This format is used for CAN, FlexRay, and LIN interfaces. This includes frames for SAE J1939 and CAN FD. Refer to the NI-XNET log file examples for functions and VIs that convert raw frame data to/from LabVIEW clusters for CAN, FlexRay, or LIN frames. Each frame is encoded as one Base Unit, followed by zero or more Payload Units.

Base Unit

In the following table, Byte Offset refers to the offset from the frame start. For example, if the first frame is in raw data bytes 0–23, and the second frame is in bytes 24–47, the second frame Identifier starts at byte 32 (24 + Byte Offset 8).

Element Byte Offset Description
Timestamp 0 to 7

64-bit timestamp in 100 ns increments.

The timestamp format is absolute. The 64-bit element contains the number of 100 ns intervals that have elapsed since 1 January 1601 00:00:00 Coordinated Universal Time (UTC). IN previous releases, this timestamp was called nxTimestamp_t.

This element contains a 64-bit unsigned integer (U64) in native byte order. For little-endian computing platforms (for example, Windows), Byte Offset 0 is the least significant byte. For more information, refer to the NI-XNET examples for log file access.

Identifier 8 to 11

The frame identifier.

This element contains a 32-bit unsigned integer (U32) in native byte order.

When Type specifies a CAN frame, bit 29 (hex 20000000) indicates the CAN identifier format: set for extended, clear for standard. If bit 29 is clear, the lower 11 bits (0–10) contain the CAN frame identifier. If bit 29 is set, the lower 29 bits (0–28) contain the CAN frame identifier.

When Type specifies a FlexRay frame, the lower 16 bits contain the slot number.

When Type specifies a LIN frame, this element contains a number in the range 0–63 (inclusive). This number is the LIN frame's ID (unprotected).

For SAE J1939 frames, the PGN and address fields are mapped to the Extended CAN identifier and written in the same way as for CAN.

All unused bits are 0.

Type 12

The frame type.

This element specifies the fundamental frame type. The Identifier, Flag, and Info element interpretations are different for each type.

The upper 3 bits of this element specify the protocol. The valid values in decimal are:
0 CAN
1 FlexRay
2 LIN
6 J1939
7 Special
The lower 5 bits of this element contain the specific type.
Table 6. CAN Type Values
CAN Data (0) The CAN data frame contains payload data. This is the most commonly used frame type for CAN.
CAN 2.0 Data (8) The CAN frame contains payload data. It has been transmitted in ISO CAN FD mode as a CAN 2.0 frame.
CAN FD Data (16) The CAN frame contains payload data. It has been transmitted in ISO CAN FD+BRS mode as a CAN FD frame.
CAN FD+BRS Data (24) The CAN frame contains payload data. It has been transmitted in ISO CAN FD+BRS mode as a CAN FD+BRS frame.
CAN Remote (1) A CAN remote frame. An ECU transmits a CAN remote frame to request data for the corresponding identifier. Your application can respond by writing a CAN data frame for the identifier.
Delay (224) The Delay frame is used with the replay feature to insert a relative time delay between frame transmissions. For information about this frame, including the other frame fields, refer to Special Frames.
Log Trigger (225) A Log Trigger frame. This frame is generated when a trigger occurs on an external connection (for example, PXI_Trig0). For information about this frame, including the other frame fields, refer to Special Frames.
Start Trigger (226) A Start Trigger frame is generated when the interface is started. (Refer to Start Interface for more information.) For information about this frame, including the other frame fields, refer to Special Frames.
CAN Bus Error (2) A CAN Bus Error frame is generated when a bus error is detected on the CAN bus. For information about this frame, including the other frame fields, refer to Special Frames.
Table 7. FlexRay Type Values
FlexRay Data (32) FlexRay data frame. The frame contains payload data. This is the most commonly used frame type for FlexRay. All elements in the frame are applicable.
FlexRay Null (33) FlexRay null frame. When a FlexRay null frame is received, it indicates that the transmitting ECU did not have new data for the current cycle.

Null frames occur in the static segment only. This frame type does not apply to frames in the dynamic segment.

This frame type occurs only when you set the XNET Session Interface:FlexRay:Null Frames To Input Stream? property to true. This property enables logging of received null frames to a session with the Frame Input Stream Mode. Other sessions are not affected.

For this frame type, the payload array is empty (size 0), and preamble? and echo? are false. The remaining elements in the frame reflect the data in the received null frame and the timestamp when it was received.

FlexRay Symbol (34)

FlexRay symbol frame. The frame contains a symbol received on the FlexRay bus.

For this frame type, the first payload byte (offset 0) specifies the type of symbol: 0 for MTS, 1 for wakeup. The frame payload length is 1 or higher, with bytes beyond the first byte reserved for future use. The frame timestamp specifies when the symbol window occurred. The cycle count, channel A indicator, and channel B indicator are encoded the same as FlexRay data frames. All other fields in the frame are unused (0).

Log Trigger (225) A Log Trigger frame. This frame is generated when a trigger occurs on an external connection (for example, PXI_Trig0). For information about this frame, including the other frame fields, refer to Special Frames.
Start Trigger (226) A Start Trigger frame is generated when the interface is started. For information about this frame, including the other frame fields, refer to Special Frames.
Table 8. LIN Type Values
LIN Data (64) The LIN data frame contains payload data.
Log Trigger (225) A Log Trigger frame. This frame is generated when a trigger occurs on an external connection (for example, PXI_Trig0). For information about this frame, including the other frame fields, refer toSpecial Frames.
Start Trigger (226) A Start Trigger frame is generated when the interface is started. (Refer to Start Interface for more information.) For information about this frame, including the other frame fields, refer to Special Frames
LIN Bus Error (65) A LIN Bus Error frame is generated when a bus error is detected on the LIN bus. For information about this frame, including the other frame fields, refer to Special Frames.
LIN No Response (66) A LIN No Response frame is generated when a header with no response is detected on the LIN bus. For information about this frame, including the other frame fields, refer to Special Frames.
Flags 13 Eight Boolean flags that qualify the frame type.

Bit 7 (hex 80) is protocol independent (supported in CAN, FlexRay, and LIN frames). If set, the frame is echoed (returned from the appropriate nxRead function or XNET Read VI after NI-XNET transmitted on the network). If clear, the frame was received from the network (from a remote ECU).

For FlexRay frames:
  • Bit 0 is set if the frame is a Startup frame.
  • Bit 1 is set if the frame is a Sync frame.
  • Specifies the frame Preamble bit.
  • Specifies if the frame transfers on Channel A.
  • Specifies if the frame transfers on Channel B.
For LIN frames:
  • Bit 0 is set if the frame occurred in an event-triggered entry (slot). When bit 0 is set, the Info element contains the event-triggered frame ID, and the Identifier element contains the Unconditional ID from the first payload byte.

All unused bits are zero.

Info 14 Information that qualifies the frame Type.

This element is not used for CAN.

For FlexRay frames, this element provides the frame cycle count (0–63).

For LIN frames read for a non-stream input session, if bit 0 of the Flags element is clear, the Info element is unused (0). If bit 0 of the Flags element is set (event-triggered entry), the Info element contains the event-triggered frame ID, and the Identifier element contains the Unconditional ID from the first payload byte.

For LIN frames read for a stream input session, if Interface:LIN:Checksum to Input Stream? is false (default), the Info element contains 0 for each frame. If true, the Info element contains the received checksum for each frame.

For SAE J1939 frames, the three lowest bits of this element contain the three highest bits of the PayloadLength.

Payload Length 15 The PayloadLength indicates the number of valid data bytes in Payload.

For all standard CAN and LIN frames, PayloadLength cannot exceed 8. Because this base unit always contains 8 bytes of payload data, the entire frame is contained in the base unit, and no additional payload units exist.

For CAN FD frames, PayloadLength can be 0–8, 12, 16, 20, 24, 32, 48, or 64.

For FlexRay frames, PayloadLength is 0–254 bytes.

For SAE J1939 frames, PayloadLength is 0–1785 bytes; the low 8 bits are in this element, and the high three bits are found in the low bits of the Info field.

If PayloadLength is 0–8, only the base unit exists. If PayloadLength is 9 or greater, one or more payload units follow the base unit. Additional payload units are provided in increments of 8 bytes, to optimize efficiency for DMA transfers. For example, if PayloadLength is 12, bytes 0–7 are in the base unit Payload, bytes 8–11 are in the first half of the next payload unit, and the last 4 bytes of the next payload unit are ignored.

In other words, each raw data frame can vary in length. You can calculate each frame size (in bytes) using the following pseudocode:

  U16 FrameSize; // maximum 272 for largest FlexRay frame
  FrameSize = 24; // 24 byte base unit
  if (PayloadLength > 8)
    FrameSize = FrameSize +
      (U16)(PayloadLength - 1) AND 0xFFF8;

The last pseudocode line subtracts 1 and truncates to the nearest multiple of 8 (using bitwise AND). This adds bytes for additional payload units. For example, PayloadLength of 9 through 16 requires one additional payload unit of 8 bytes.

The NI-XNET example code helps you handle the variable-length frame encoding details.

Payload 16 to 23 This element always uses 8 bytes in the log file, but PayloadLength determines the number of valid bytes.

Payload Unit

The base unit PayloadLength element determines the number of additional payload units (0–31).

Element Byte Offset Description
Payload 0 to 7 This element always uses 8 bytes in the log file, but PayloadLength determines the number of valid bytes.