Cast data to int in PyComediSingleIO.write_chan_index.
authorW. Trevor King <wking@drexel.edu>
Mon, 8 Dec 2008 17:24:09 +0000 (12:24 -0500)
committerW. Trevor King <wking@drexel.edu>
Mon, 8 Dec 2008 17:24:09 +0000 (12:24 -0500)
Without the cast, I got this traceback when data was a numpy.uint16:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/wking/.python/unfold.py", line 101, in __init__
    self.zp.jumpToPos(self.zp.pos_nm2out(0))
  File "/home/wking/.python/z_piezo.py", line 161, in jumpToPos
    self.curIn = self._jump.jumpToPos(self.curOut)
  File "/home/wking/.python/z_piezo.py", line 248, in jumpToPos
    self.AO.write(out)
  File
"/home/wking/lib/python2.5/site-packages/pycomedi-0.1-py2.5.egg/pycomedi/single_aio.py",
line 90, in write
    self.write_chan_index(i, data[i])
  File
"/home/wking/lib/python2.5/site-packages/pycomedi-0.1-py2.5.egg/pycomedi/common.py",
line 411, in write_chan_index
    rc = c.comedi_data_write(self.dev, self.subdev,
self.chan[chan_index], self._range[chan_index], self._aref[chan_index],
data);
TypeError: in method 'comedi_data_write', argument 6 of type 'lsampl_t'

pycomedi/common.py

index 44840739d5392c3c6aebdae01756ac1b83574e02..970a31b51154c03caf8be108decec4d6a7b25808 100644 (file)
@@ -403,7 +403,9 @@ class PyComediSingleIO (PyComediIO) :
         """
         if self.output != True :
             raise pycomediError, "Must be an output to write"
-        rc = c.comedi_data_write(self.dev, self.subdev, self.chan[chan_index], self._range[chan_index], self._aref[chan_index], data);
+        rc = c.comedi_data_write(self.dev, self.subdev, self.chan[chan_index],
+                                 self._range[chan_index],
+                                 self._aref[chan_index], int(data));
         if rc != 1 : # the number of samples written
             self._comedi.comedi_perror("comedi_data_write")
             raise pycomediError, "comedi_data_write returned %d" % rc