Example Code

Inspect strings, compute and add checksums, add non-printable ASCII values Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Description

A new version of the sub vi Checksum.vi can be found at: https://forums.ni.com/t5/Example-Code/Checksum-generator-XOR-8-bit-8-bit-sum-LRC-8-bit-16-bit-sum/ta...

 

Overview
String inspector was developed as a tool for investigating serial type communication protocols. It lets you inspect text in different formats, compose command type strings with none-printable ASCII characters and calculate XOR and 8 bit sum checksums. For TCP communication, you can prefix the command string with string length. The string length value is formatted as either a 4 byte text or 4 byte type cast. You can view text in ASCII (text), hex, '\', binary and decimal mode.


Description
The vi can be run as a stand alone vi or it can be called from another vi with the text you want to inspect. The vi returns the (edited/a new) text.

To add non-printable ASCII characters to the text pick a decimal number in ASCII table and hit -> (right arrow). The character is inserted at the cursor position. Number of characters in Text (string length) is displayed above the Text box. You can add the string length to text in Text by hitting Add in section String length. The value is inserted at the cursor position. Mark text if you want to get string length of only part of text. The string length can be added as either a 4 byte text or a 4 byte type cast value. This is useful for testing TCP connections when the string length prefixes the string. You can choose a checksum type and hit Calculate to calculate the checksum of text in Text. Check Invert to negate the result. Mark text if you want to calculate the checksum of only part of text. Choose how the checksum shall be represented in Add as and hit Add to insert checksum at cursor position. ASCII inserts checksum as the ASCII character represented by the checksum value, e.g. decimal value 65 will be inserted as the character A.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Open the String inspector llb
  2. Open and run String inspector.vi
  3. Enter some text in Text box. You can copy text from some where and hit Paste
  4. Click on a decimal value in the ASCII table and hit -> to insert the character at the cursor position in Text
  5. Choose a display mode
  6. Switch back to Normal dispaly mode and hit Calculate in Checksum to calculate and view the checksum result. Hit Invert if you want to negate the checksum value
  7. Place the cursor at the end of the text in Text and hit Add to add the checksum
  8. Choose a calculation mode for string length
  9. Place the cursor at the start of the text and hit Add to to add string length to the start of the text in Text. Hit Get Text to return the text in Text to your calling vi (assuming you called the vi from another vi)

 

Additional Information or References
Front Panel of String Inspector

 1.PNG

 

 

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

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