From: W. Trevor King Date: Mon, 8 Dec 2008 17:24:09 +0000 (-0500) Subject: Cast data to int in PyComediSingleIO.write_chan_index. X-Git-Tag: 0.2~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5b69b33d46529be30bbdf15b392f0b96986bdcdd;p=pycomedi.git Cast data to int in PyComediSingleIO.write_chan_index. Without the cast, I got this traceback when data was a numpy.uint16: Traceback (most recent call last): File "", line 1, in 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' --- diff --git a/pycomedi/common.py b/pycomedi/common.py index 4484073..970a31b 100644 --- a/pycomedi/common.py +++ b/pycomedi/common.py @@ -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