Configuring a Peer-to-Peer Stream
- Updated2024-09-19
- 3 minute(s) read
To configure a peer-to-peer stream using the NI-P2P API, a writer and reader handle for each endpoint are required.
Configuring Flow Control
To configure flow control in NI-RFSA and NI-RFSG, complete the following steps:
- Call Get Stream Endpoint Handle for your driver to get the RF vector signal transceiver reader handle and the appropriate handle from the writer peer API.
-
Call NI-P2PCreate Peer to Peer Stream to configure NI-P2P with information regarding each endpoint to link the endpoints into a
stream.
You must specify both a reader and writer endpoint handle.
Starting Peer-to-Peer Generation
If the RF vector signal transceiver begins generating data from a peer-to-peer stream immediately after the first sample is received, the device may not have enough data to continue the generation and can underflow at startup. This problem is due to latency across the bus, and it is especially likely when heavy, possibly unrelated, traffic is on the bus. To avoid underflow at startup, prime the endpoint with data before starting generation so the device has a backlog of data to insulate the generation from the bursty nature of data flowing across the bus.
The following two methods are available for preparing the RF vector signal transceiver endpoint for startup:
To prepare for generation manually, complete the following steps:
- Configure both peers for peer-to-peer streaming.
- Link both peers with NI-P2PCreate Peer to Peer Stream.
-
Enable the stream in either of the following ways:
- Set enable stream to True with NI-P2PCreate Peer to Peer Stream
- Call NI-P2PEnable Peer to Peer Stream
- Start the writer peer first so that it begins sending data to the RF vector signal transceiver prior to initiation.
-
Depending on the language you are using, query the following after starting the writer
peer to ensure that sufficient data has been transferred to the RF vector signal
transceiver.
- LabVIEW: NI-RFSGSpace Available in Endpoint
- C: NIRFSG_ATTR_P2P_ENDPOINT_FULLNESS_START_TRIGGER_LEVEL or NIRFSG_ATTR_P2P_SPACE_AVAILABLE_IN_ENDPOINT
- Call NI-RFSGInitiate.
Stopping Peer-to-Peer Generation
Avoid receiving an underflow error by using a supported technique to stop peer-to-peer generation.
Option | Description |
---|---|
Is Finite P2P Generation | If the RF vector signal transceiver receives the specified number of samples from the writer peer, the NI-RFSG session completes without an underflow error. Use Number of P2P Samples to Generate to specify the sample number |
Continuous Generation Using User-Requested Abort | Using the NI-RFSGAbort or NI-RFSGCheck Generation Status returns True for Done. However, if the writer peer is not configured carefully for this event, it may overflow because the RF vector signal transceiver is no longer allowing it to send data through the stream. |
Stopping Peer-to-Peer Acquisition
When stopping peer-to-peer acquisition, you must clear the data from the stream before starting a new acquisition.
- Call NI-P2PFlush and Disable Peer to Peer Stream before starting a new acquisition. This function automatically clears the remaining data from the stream.
- Configure the reader peer to read the remaining samples in the stream, then call NI-P2PDisable Peer to Peer Stream before starting a new acquisition.