Platform/operating system (i.e. Raspberry Pi with Raspbian operating system,
Windows 32-bit, Windows 64-bit, Mac OSX 64-bit, etc.): Raspberry Pi with HassIO
Python version (run python -version or python3 -version): Python 3.9.0
Error message you are receiving, including any Python exception traces:
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'
- 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.
Platform/operating system (i.e. Raspberry Pi with Raspbian operating system, Windows 32-bit, Windows 64-bit, Mac OSX 64-bit, etc.): Raspberry Pi with HassIO
Python version (run
python -version
orpython3 -version
): Python 3.9.0Error message you are receiving, including any Python exception traces:
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'