Solution
To capture discrete packets into separate records relative to a trigger and fetch them while the acquisition is running, follow the configuration steps below:
Initialize the session, assign the required digital channels, and configure the sample clock rate and source.
Use the niHSDIO Configure Acquisition Size VI to configure the records:
- Samples per record: Set this to the size in samples (or bits, for single-channel serial acquisitions) of each individual data packet.
- Number of records: Set this to the total number of data packets expected during the acquisition session (or an arbitrarily large number if the total packet count is not known in advance).

For a multi-record acquisition in which each record is acquired relative to a trigger, it is needed to configure both a reference trigger and an advance trigger. This will require two instances of niHSDIO Configure Trigger corresponding to the source of the trigger signal, as shown in the image below:

4. Commit and Initiate Acquisition
Finally, commit the settings and initiate the acquisition.
5. Fetch Records in a While Loop
Use the niHSDIO Fetch Multi Record (WDT) VI inside a loop to retrieve records incrementally as they arrive:
- In addition to the standard inputs (
Instrument Handle, Channel List, Error In), configure the necessary inputs as below:
starting recordrecords to fetch
The below image shows an example of how fetching records in a loop could look:

This loop will fetch 5 records at a time, then use the number of records previously acquired to set the starting record for the next loop iteration. There are two things to be aware of:
- If the fetch VI times out before all 5 records are present, the VI will return an error. One way to handle this is to clear the error, as shown, and continue with the next loop iteration. Another option is to increase the timeout of the Fetch VI. The better approach depends on whether the time required to acquire all 5 records is deterministic.
- The loop can be stopped before all the records specified in number of records have been acquired. This is useful when it is not known in advance how many records will be needed and have set number of records to an arbitrarily large value.
There may be other ways to achieve the same result, but this is one method that differs significantly from the shipping examples.