Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: Check for DAQmx event registration errors
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Keryan <brad.keryan@ni.com>
bkeryan committed May 22, 2023

Verified

This commit was signed with the committer’s verified signature.
frapell Franco Pellegrini
1 parent c8548a0 commit cee5c93
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions examples/nidaqmx/analog-input-every-n-samples-aio.py
Original file line number Diff line number Diff line change
@@ -97,15 +97,21 @@ def check_for_warning(response):
)
)

# Wait for initial_metadata to ensure that the callback is registered before starting
# the task.
# Wait for initial_metadata and check for stream errors to ensure that the callback is
# registered before starting the task.
await every_n_samples_stream.initial_metadata()
if every_n_samples_stream.done():
every_n_samples_response = await every_n_samples_stream.read()
check_for_warning(every_n_samples_response)

done_event_stream = client.RegisterDoneEvent(
nidaqmx_types.RegisterDoneEventRequest(task=task)
)

await done_event_stream.initial_metadata()
if done_event_stream.done():
done_response = await done_event_stream.read()
check_for_warning(done_response)

start_task_response = await client.StartTask(nidaqmx_types.StartTaskRequest(task=task))
check_for_warning(start_task_response)
10 changes: 8 additions & 2 deletions examples/nidaqmx/analog-input-every-n-samples.py
Original file line number Diff line number Diff line change
@@ -99,15 +99,21 @@ def check_for_warning(response):
)
)

# Wait for initial_metadata to ensure that the callback is registered before starting
# the task.
# Wait for initial_metadata and check for stream errors to ensure that the callback is
# registered before starting the task.
every_n_samples_stream.initial_metadata()
if every_n_samples_stream.done():
every_n_samples_response = next(every_n_samples_stream)
check_for_warning(every_n_samples_response)

done_event_stream = client.RegisterDoneEvent(
nidaqmx_types.RegisterDoneEventRequest(task=task)
)

done_event_stream.initial_metadata()
if done_event_stream.done():
done_response = next(done_event_stream)
check_for_warning(done_response)

start_task_response = client.StartTask(nidaqmx_types.StartTaskRequest(task=task))
check_for_warning(start_task_response)

0 comments on commit cee5c93

Please sign in to comment.