self.set_pindir(pindir)
self.set_pinstate(pinstate)
+ def close(self):
+ """Set all pins to input and release the port. Class is useless after
+ calling this method.
+ """
+ cmd = chr(self.ftdi.SET_BITS_LOW) + chr(0) + chr(0)
+ self._raw_write(cmd)
+ self.ftdi.usb_close(self.context)
+
+ def _raw_write(self, data):
+ """Write data as
+ """
+ #translate data to a string
+ if not isinstance(data, str):
+ data = ''.join(map(chr, data))
+ ret = self.ftdi.write_data(self.context, data, len(data))
+ if ret < 0:
+ raise FTDI_Error(self.ftdi.get_error_string(self.context))
+
+
def _clear_scl(self):
self.io[self.scl] = 1
self.ftdi.set_bitmode(self.context, int(self.io), self.ftdi.BITMODE_BITBANG)
self.ftdi.usb_purge_buffers(self.context)
+ def close(self):
+ """Set all pins to input and release the port. Class is useless after
+ calling this method.
+ """
+ cmd = chr(self.ftdi.SET_BITS_LOW) + chr(0) + chr(0)
+ self._raw_write(cmd)
+ self.ftdi.usb_close(self.context)
+
def _raw_write(self, data):
"""Write data as
"""