Example Code

Convert 0xXX Hex Data to a U8 Byte Array

Code and Documents

Attachment

Overview
This example VI Convert 0xXX hex data to a U8 byte array.


Description

Often hex data will be represented in the format 0xXX, 0xYY, 0xZZ etc. In LabVIEW it is best converted to a byte array for manipulation. The easiest way is to cut the hex data into a string control and use regular expression pattern matching to extract the bytes.

As each byte is extracted the loop will build the data into an array at the output tunnel. Once the entire string has been scanned a position of -1 is output, stopping the loop. Once the loop is stopped, the U8 byte array is released.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Download the attached file to your computer
  2. Open the VI " 0xXX hex data to u8 array 2012 NIVerified.vi"
  3. Run the program

 

Additional Information or References
VI Snippet

Block Diagram.PNG

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Stephen C
Applications Engineer

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