Sorry admin, I don't know how to append a message I already sent:
the transfer function expects an input of a bytearray and returns the same: def transfer(self, data): """Full-duplex SPI read and write. The specified array of bytes will be clocked out the MOSI line, while simultaneously bytes will be read from the MISO line. Read bytes will be returned as a bytearray object. """ # Build command to read and write SPI data. command = 0x30 | (self.lsbfirst << 3) | (self.read_clock_ve << 2) | self.write_clock_ve logger.debug('SPI transfer with command {0:2X}.'.format(command)) # Compute length low and high bytes. # NOTE: Must actually send length minus one because the MPSSE engine # considers 0 a length of 1 and FFFF a length of 65536 length = len(data) len_low = (length-1) & 0xFF len_high = ((length-1) >> 8) & 0xFF # Send command and length. self._assert_cs() self._ft232h._write(str(bytearray((command, len_low, len_high)))) self._ft232h._write(str(bytearray(data))) self._ft232h._write('\x87') self._deassert_cs() # Read response bytes. return bytearray(self._ft232h._poll_read(length)) _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor