From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Serial Port Sniffer 2-way communication (Host Command <-> Slave Response)

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


  • LabVIEW

    Programming Language

  • LabVIEW G

Code and Documents



Inspired from Serial Port Forwarding Example code. Then enhenced it into not only snif/forwarding 1 way communication from 1st Port to 2nd Port, but also viseversa that is snif/forward the response from 2nd Port to 1st Port.

This is useful when we are interested in sniffing the communication between Host/Master <-> Slave Device in two way communication (aka Command - Response).

How to Use

  1. Select the Com# ports each for the Host/Master and Slave/Device
  2. Configure the serial ports (baud rate, data bits, parity, stop bits, and flow control) equally for both.
  3. Make sure each Port are properely connected as physically or virutally.
  4. Run the VI to open both Com Port and start Sniffing.
  5. the Communication Log between the two ports are then Listed  in the Log Indicator [Array]
  6. The Enum: "Command", "Response" are indicating wether the communication is from the Host to Slave ro viseversa.
  7. You may write Remark to manually Insert any necesary notes.
  8. Click Stop button to close both communication Ports and stop sniffing.

Additional Information


You can also view the communication protocol/data in different format: Text/char, '\' code, as well as Hex 



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