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 ni.com/downloads.

    Software

  • LabVIEW

    Programming Language

  • LabVIEW G

Code and Documents

Attachment

Description

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

blobid1710918273175.png

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

mceclip0.png

 

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

Contributors