Creating and Monitoring Peer-to-Peer Streams
- Updated2023-02-21
- 2 minute(s) read
Creating and Monitoring Peer-to-Peer Streams
Use the Peer To Peer Streaming VIs to create and monitor peer-to-peer streams.
Creating a Peer-to-Peer Stream
Complete the following steps to create a stream.
- Configure the writer and reader. Refer to the hardware API documentation for information about configuring a writer or reader.
- Obtain the references to the writer and reader using methods associated with the hardware API.
- Wire the writer and reader references to the writer and reader inputs of the niP2P Create Peer to Peer Stream VI. This VI associates the writer and reader with the stream. After this VI runs, the stream is in a Disabled or Enabled state depending on the value of enable stream.
- (Optional) Use the niP2P Enable Peer to Peer Stream VI to enable the stream. You do not need to use this VI if you wire a TRUE value to the enable stream input of the niP2P Create Peer to Peer Stream VI.
- Stop the data transmission and disable the stream using the niP2P Disable Peer to Peer Stream VI or the niP2P Flush And Disable Peer to Peer Stream VI.
- Use the niP2P Destroy Peer to Peer Stream VI to unlink and destroy the stream.
Monitoring the Status of a Peer-to-Peer Stream
In LabVIEW, you can monitor peer-to-peer stream events such as overflow, underflow, and stream state using an interrupt method or a polling method.
The interrupt method uses the niP2P Handle Events VI. The niP2P Handle Events VI automatically creates an Event structure and Register for Events node when you place the niP2P Handle Events VI on the block diagram. Wire the stream session output from the niP2P Create Peer to Peer Stream VI to the event source input of the Register for Events node to access stream events. Then implement code in each event case to handle the interrupt.
The polling method uses the Property Node configured for peer-to-peer streams to determine the state of the stream during run time. Place the Property Node in a While Loop to continuously monitor the stream and create code to handle changes in stream state.