Serial Port Forwarding (Port Sniffer/Logger)

製品と環境

このセクションは、サンプルの作成に使用された製品およびOSを反映します。

以下に示された製品を含め、NIのソフトウェアをダウンロードするには、ni.com/downloadsをご覧ください。

    ハードウェア

  • Instrument Control

    ソフトウェア

  • LabVIEW

    ドライバ

  • NI VISA

コードとドキュメント

添付

すべてをダウンロード

Overview

This example demonstrates reading data from one serial port and forwarding this data to be written out of another port. This is useful when there are multiple serial ports and you are interested in sniffing or monitoring the serial communication between two points.


Description

Read the data in from one port with VISA Read and write it to another port with VISA Write. Both ports need to be configured. This example also displays a log of the data read in so that it can be viewed on the front panel.

Requirements

Software

LabVIEW 8.6 (or compatible)

NI-VISA


Steps to Implement or Execute Code

  1. Configure the two serial ports (baud rate, data bits, parity, stop bits, and flow control)
  2. Use a property node to extract the number of bytes available at the serial port being read.
  3. Use VISA Read to read in the data. Use the value returned by the property node for the byte count input of VISA Read.
  4. Use VISA Write to write the data to the second port.
  5. Display the read data by formatting the string for the log. 
  6. Close VISA sessions to both ports to free them up for other applications.


Additional Information or References
fp.JPG


VI Snippet

Serial Port Forwarding.png

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

---

Peter Flores
Applications Engineer

NIコミュニティのサンプルコード交換のサンプルコードは、MIT Licenseによりライセンス供与されています。

コメント
mrx 23
Member
Member

Could anyone upload the Block diagram of this project? Or a Labview v7.1 compatible vi file?
Thanks.

pflores
NI Employee (retired)

They're up!

---

Peter Flores
Applications Engineer
mrx 23
Member
Member

Thank you very much!

刘林
Member
Member

A good idea。

Huck
Member
Member

could someone point me to the Full block diagram of this so that i can attempt to rebuild it for myself in LabView 6.0 ?

Thanks,

aniketjha
Member
Member

Sorry, for bumping the old thread but my requirement is similar to this.

 

Is it possible that from 1 port i receive the data and forward this data to 2 port as well as receive the data from 2 ports and forward to the same single port?

 

Thanks 

ThamS
Member
Member
寄稿者