To configure a peer-to-peer stream using the NI-P2P API, a writer and reader handle for each endpoint are required.

Use Get Stream Endpoint Handle to generate a reader endpoint handle.

Configuring Flow Control

To configure flow control in NI-RFSA and NI-RFSG, complete the following steps:

  1. 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.
  2. 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:

  • NI-RFSG StartTrig.P2PEndpointFullness.Level —Starts generation after the endpoint receives the specified number of samples. If no number of samples is specified, the driver automatically selects an appropriate value. This method should work for most applications and requires the least amount of configuration. This property is used when StartTrig.Type is set to P2P Endpoint Fullness.
  • Manual preparation—Configure the application so that the writer peer sends data to the RF vector signal transceiver endpoint prior to the RF vector signal transceiver initiating generation.
  • To prepare for generation manually, complete the following steps:

    1. Configure both peers for peer-to-peer streaming.
    2. Link both peers with NI-P2PCreate Peer to Peer Stream.
    3. 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
    4. Start the writer peer first so that it begins sending data to the RF vector signal transceiver prior to initiation.
    5. 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
    6. Call NI-RFSGInitiate.

    Stopping Peer-to-Peer Generation

    Avoid receiving an underflow error by using a supported technique to stop peer-to-peer generation.

    Use either of the following techniques to stop peer-to-peer generation without generating an underflow error:
    OptionDescription
    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.
    In either preceding technique, use NI-RFSGCheck Generation Status function to determine whether generation is complete. After generation is done, you can abort the generation using NI-RFSGAbort. When generation aborts, all data in the endpoint is cleared to prepare the device for subsequent generations.
    Note When using the NI-P2P API to configure the stream, call NI-P2PFlush and Disable Peer to Peer Stream or NI-P2PDisable Peer to Peer Stream and wait for the done? parameter from NI-RFSGCheck Generation Status to assert before aborting the RF vector signal transceiver. If data is still in the endpoint when NI-RFSGAbort is called, it is cleared to prepare the device for subsequent generations.

    Stopping Peer-to-Peer Acquisition

    When stopping peer-to-peer acquisition, you must clear the data from the stream before starting a new acquisition.

    Use either of the following techniques to clear the stream:
    • 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.