NI-XNET API for LabVIEW and C

XNET Convert (Byte Array to Frame CAN).vi

  • Updated2023-11-11
  • 4 minute(s) read
 XNET Convert (Byte Array to Frame CAN).vi

XNET Convert (Byte Array to Frame CAN).vi

Purpose

Converts between an NI-XNET byte array signal and CAN frame data.

Format

Inputs

session in is the session to read. This session is returned from the XNET Create Session VI. The session mode must be Conversion.
signal data contains a byte array representation of the signal value. The bytes will be transferred 1:1 to the signal in the frame.

If the session contains more than one signal, or the signal cannot be represented as a byte array, an error is returned.

The data provides the value for the next conversion of the signal.

error in is the error cluster input (refer to Error Handling).

Outputs

session out is the same as session in, provided for use with subsequent VIs.
frame data returns the array of LabVIEW clusters.

Each array element corresponds to a frame the session converted.

The elements of each cluster are specific to the CAN protocol. For more information, refer to Summary of the CAN Standard or the CAN protocol specification.

The cluster elements are:

identifier is the CAN frame arbitration identifier.

If extended? is false, the identifier uses standard format, so 11 bits of this identifier are valid.

If extended? is true, the identifier uses extended format, so 29 bits of this identifier are valid.

extended? is a Boolean value that determines whether the identifier uses extended format (true) or standard format (false).
echo? is a Boolean value that determines whether the frame was an echo of a successful transmit (true), or received from the network (false). For conversion, it is always set to false.
type is the frame type (decimal value in parentheses):
  • CAN Data (0): The CAN data frame contains payload data. This is the most commonly used frame type for CAN. When the session is in ISO CAN FD mode, the CAN type is more specific according to the CAN I/O mode of the frame in the database (one of the types listed below).
  • CAN 2.0 Data (8): The frame contains payload data and has been transmitted in an ISO CAN FD session using the CAN 2.0 standard.
  • CAN FD Data (16): The frame contains payload data and has been transmitted in an ISO CAN FD session using the CAN FD standard.
  • CAN FD+BRS Data (24): The frame contains payload data and has been transmitted in an ISO CAN FD session using the CAN FD+BRS standard.
timestamp represents the absolute time when the XNET interface received the frame (end of frame), accurate to microseconds. The timestamp returned by the conversion is always invalid (0).
payload is the array of data bytes for the CAN data frame.

The array size indicates the received frame value payload length. According to the CAN protocol, this payload length range is 0–8. For CAN FD, the range can be 0–8, 12, 16, 20, 24, 32, 48, or 64.

For a received remote frame (type of CAN Remote), the payload length in the frame value specifies the number of payload bytes requested. This payload length is provided to your application by filling payload with the requested number of bytes. Your application can use the payload array size, but you must ignore the actual values in the payload bytes.

error out is the error cluster output (refer to Error Handling).

Log in to get a better experience