Skip to content

Commit d66117e

Browse files
committedJun 8, 2015
pxi6733: cleanup
1 parent c251601 commit d66117e

File tree

1 file changed

+10
-11
lines changed
  • artiq/devices/pxi6733

1 file changed

+10
-11
lines changed
 

Diff for: ‎artiq/devices/pxi6733/driver.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
from ctypes import byref, c_ulong
44
import numpy as np
5+
import logging
6+
7+
logger = logging.getLogger(__name__)
58

69

710
class DAQmxSim:
@@ -14,12 +17,6 @@ def close(self):
1417
def ping(self):
1518
return True
1619

17-
def string_to_bytes(string, name):
18-
if isinstance(string, str):
19-
string = bytes(string, encoding="ascii")
20-
elif not isinstance(string, bytes):
21-
raise ValueError("{} must be of either str or bytes type".format(name))
22-
return string
2320

2421
class DAQmx:
2522
"""NI PXI6733 DAQ interface."""
@@ -38,13 +35,15 @@ def __init__(self, channels, clock):
3835

3936
import PyDAQmx as daq
4037

41-
self.channels = string_to_bytes(channels, "channels")
42-
self.clock = string_to_bytes(clock, "clock")
38+
self.channels = channels.encode()
39+
self.clock = clock.encode()
4340
self.task = None
4441
self.daq = daq
4542

4643
def done_callback_py(self, taskhandle, status, callback_data):
Has conversations. Original line has conversations.
47-
if taskhandle == self.task:
44+
if taskhandle != self.task:
45+
logger.warning("done callback called with unexpected task")
46+
else:
4847
self.clear_pending_task()
4948

5049
def ping(self):
@@ -60,7 +59,7 @@ def load_sample_values(self, sampling_freq, values):
6059
6160
This loads sample values into the PXI 6733 device.
6261
The device will output samples at each clock rising edge.
Has a conversation. Original line has a conversation.
63-
The first sample is output at the first clock rising edge.
62+
The device waits for a clock rising edge to output the first sample.
6463
6564
When using several channels simultaneously, you must concatenate the
6665
values for the different channels in the ``values`` array.
@@ -92,7 +91,7 @@ def load_sample_values(self, sampling_freq, values):
9291
channel_number = self.daq.int32()
9392
t.GetTaskNumChans(byref(channel_number))
9493
nb_values = len(values)
95-
if nb_values % channel_number.value > 0:
94+
if nb_values % channel_number.value:
9695
self.daq.DAQmxClearTask(t.taskHandle)
9796
raise ValueError("The size of the values array must be a multiple "
9897
"of the number of channels ({})"

0 commit comments

Comments
 (0)
Please sign in to comment.