How Do I Add Termination Characters to VISA Serial Writes in LabVIEW?

Updated Dec 5, 2023




My serial instrument requires termination characters, but when I send a command to the serial port using the VISA Serial VIs, sometimes it is not possible to add an LF (line feed), a CR (carriage return), or an EOL (end of line) at the end of the string to send. How can I add the required termination characters?

You need to set the Termination Character Enable, Termination Character, and Serial End Mode for Writes properties in the NI-VISA driver.
  1. Create a VISA property node by right-clicking the block diagram and selecting Instrument I/O»VISA»Advanced»VISA Property Node.
  2. Expand the VISA Property Node to accommodate three properties.
  3. Right-click on the property node and select Change All to Write.
  4. To select a Property: right click on 'Property' and select Select Property»Message Based Settings»Termination Character Enable.
  5. Select second property by right-clicking and selecting Select Property»Message Based Settings»Termination Character.
  6. Select third property by right-clicking and selecting Select Property»Serial Settings»End Mode for Writes.
  7. Wire a True constant to the TermChar En property.
  8. Wire the decimal value of the ASCII character you want to append to the TermChar property. The decimal value for Linefeed is 10 and for Carriage Return is 13. The End of Line character is a combination of Carriage Return followed by Linefeed and is not supported as a termination character through this method. For an alternate approach that allows for multiple termination characters or if you are unsure of the ASCII value of the termination character, please see this white paper on Termination Characters in NI-VISA.
  9. Right-click the ASRL End Out property and select Create»Constant. This will create the enum of terminal character options. Select TermChar from the enum list.

All of your writes will now be automatically terminated with that character.

Additional Information

  1. Note: TermChar En and TermChar are for reading only, and TermChar En must be set to true in order to set the TermChar Property. Alternatively, ASRL End Out is for reading and writing.

    Alternatively, you can use the Concatenate Strings function to build the string to send to the serial port. LabVIEW has three commonly used termination characters that are string constants in the Strings function palette: the Carriage Return Constant, the Line Feed Constant, and the End of Line Constant.

    If you need something other than the pre-made LabVIEW constants, you can always create your own. Create a String Constant on your block diagram and right-click on it. Select '\' Codes Display from the pop-up menu. Now you can use the Codes Display format. See the Termination Character Codes Table below for more information.

    Termination Character Codes Table
    Termination CharactersCodes Display
    Linefeed (LF)


    Carriage return (CR)


    End of Line (EOL)


    Form feed (FF)


  2. Keep in mind that termination on the physical hardware needs to comply with the appropriate Serial standard. If the termination on the physical component is incorrect then it will cause issues with termination characters on the software side.