XNET Convert (Frame CAN to Byte Array).vi

NI-XNET Hardware and Software Help

Edition Date: November 2018

Part Number: 372841U-01

»View Product Info
Download Help (Windows Only)

Purpose

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

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.
frame data provides the array of LabVIEW clusters.

Each array element corresponds to a frame value to convert.

The data you write is converted to signal values in the order you provide them. Only the latest signal value is returned.

For an example of how this data applies, refer to Conversion Mode.

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 not used for conversion. You must set this element 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.
  • CAN Remote (1): CAN remote frame. Your application transmits a CAN remote frame to request data for the corresponding identifier. A remote ECU should respond with a CAN data frame for the identifier, which you can obtain using the XNET Read VI. This value is not meaningful, as a remote frame does not contain any data to convert.
timestamp represents absolute time using the LabVIEW absolute timestamp type. timestamp is not used for conversion. You must set this element to the default value, invalid (0).
payload is the array of data bytes for a CAN data frame.

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

For more information, refer to the section for each mode.

For a transmitted remote frame (CAN Remote type), the payload length in the frame value specifies the number of payload bytes requested. Your application provides this payload length by filling payload with the requested number of bytes. This enables your application to specify the frame payload length, but the actual values in the payload bytes are ignored (not contained in the transmitted frame).

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.
signal data returns a byte array representation of the single signal in the conversion session.

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

The data returns the most recent converted value for the signal. If multiple frames for the signal are input, only signal data from the most recent frame is returned. Here, most recent is defined by the order of the frames in the frame data array, not the timestamp.

If no frame is input for the corresponding signals, the XNET Signal Default Value is returned.

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

WAS THIS ARTICLE HELPFUL?

Not Helpful