Skip to content

Commit

Permalink
added pprint in event example
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneDroid committed Apr 19, 2024
1 parent b80bae8 commit 688c1c0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/analog_in/ai_voltage_waveform_cont_acq_with_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
unresponsive while waiting for samples to become available.
"""

import pprint

import nidaqmx
from nidaqmx.constants import AcquisitionType

pp = pprint.PrettyPrinter(indent=4, compact=True)

with nidaqmx.Task() as task:
sample_size = 0

def callback(task_handle, every_n_samples_event_type, number_of_samples, callback_data):
"""Callback function for reading singals."""
print("Every N Samples callback invoked.")
global sample_size
sample_size += len(task.read(number_of_samples_per_channel=100))
pp.pprint(task.read(number_of_samples_per_channel=100))

return 0

Expand All @@ -26,7 +28,6 @@ def callback(task_handle, every_n_samples_event_type, number_of_samples, callbac
task.register_every_n_samples_acquired_into_buffer_event(100, callback)
task.start()

input("Running task. Press Enter to stop and see number of accumulated samples.\n")
input("Running task. Press Enter to stop.\n")

task.stop()
print(sample_size)

0 comments on commit 688c1c0

Please sign in to comment.