adafruit / Adafruit_CircuitPython_BusDevice

Two helper classes that handle transaction related state for I2C and SPI including locks.
MIT License
108 stars 76 forks source link

TypeError: can't convert NoneType to int #44

Closed caternuson closed 4 years ago

caternuson commented 4 years ago

Guessing this is related to recent update to remove kwargs.

Using library bundle 2020-02-18.

Original issue showed up in Clue library. Traced that to LSM6DS. Traced that to Bus Device. Below is a simple hand hacked write to one of the LSM6DS's registers to show the general issue.

Adafruit CircuitPython 5.0.0-beta.5 on 2020-02-05; Adafruit CLUE nRF52840 Express with nRF52840
>>> import board
>>> from adafruit_bus_device.i2c_device import I2CDevice
>>> i2cdev = I2CDevice(board.I2C(), 0x6a)
>>> buf = bytes([0x12, 0x00])
>>> with i2cdev as i2c:
...     i2c.write(buf)
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "<stdin>", line 2, in <module>
  File "adafruit_bus_device/i2c_device.py", line 99, in write
TypeError: can't convert NoneType to int
>>> 
caternuson commented 4 years ago

reverting to 4.1.2 release works:

Adafruit CircuitPython 5.0.0-beta.5 on 2020-02-05; Adafruit CLUE nRF52840 Express with nRF52840
>>> import board
>>> import adafruit_bus_device.i2c_device
>>> adafruit_bus_device.i2c_device.__version__
'4.1.2'
>>> i2cdev = adafruit_bus_device.i2c_device.I2CDevice(board.I2C(), 0x6a)
>>> buf = bytes([0x12, 0x00])
>>> with i2cdev as i2c:
...     i2c.write(buf)
... 
>>>