adafruit / Adafruit_Python_PureIO

Pure python (i.e. no native extensions) access to Linux IO including I2C and SPI. Drop in replacement for smbus and spidev modules.
MIT License
54 stars 39 forks source link

Exception being thrown in spi.py with new Python 3.9 #21

Closed gcs278 closed 4 years ago

gcs278 commented 4 years ago
- List the steps to reproduce the problem below (if possible attach code or commands
  to run):
1. Install python 3.9
2. `pip3 install adafruit-circuitpython-mcp3xxx` (this is what uses spi.py and why I'm here)
3.  Write the code (this is a snippet from my project, may not be 100% right)

import adafruit_mcp3xxx.mcp3008 as MCP from adafruit_mcp3xxx.analog_in import AnalogIn adc1 = MCP.MCP3008(spi, chip_select) pin1 = AnalogIn(adc1, MCP.P0) pin1.voltage

File "/usr/local/lib/python3.9/site-packages/adafruit_mcp3xxx/analog_in.py", line 78, in voltage return (self.value * self._mcp.reference_voltage) / 65535 File "/usr/local/lib/python3.9/site-packages/adafruit_mcp3xxx/analog_in.py", line 70, in value self._mcp.read(self._pin_setting, is_differential=self.is_differential) << 6 File "/usr/local/lib/python3.9/site-packages/adafruit_mcp3xxx/mcp3xxx.py", line 99, in read spi.write_readinto(self._out_buf, self._in_buf) File "/usr/local/lib/python3.9/site-packages/busio.py", line 310, in write_readinto return self._spi.write_readinto( File "/usr/local/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 130, in write_readinto data = self._spi.transfer(list(buffer_out[out_start : out_end + 1])) File "/usr/local/lib/python3.9/site-packages/Adafruit_PureIO/spi.py", line 411, in transfer data = array.array("B", data).tostring() AttributeError: 'array.array' object has no attribute 'tostring'



EDIT: 
Oh and I've been running with adafruit-circuitpython-mcp3xxx for the last 5 months, no problems, until I went to rebuild my docker container (and got a new python update). I nearly got the soldering iron out again until I saw the exception.
gcs278 commented 4 years ago

Wow that was incredibly fast thanks!! On a Friday evening too.

ladyada commented 4 years ago

we may be werewolves