-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for 'write_then_readfrom' #7
Conversation
Added support for the busio 'write_then_readfrom' function as some i2c devices require this (e.g. the Adafruit i2c FRAM module)
lgtm, @caternuson wanna try it out? |
I'm not seeing this used in the FRAM library: |
Thought that might be the intention here. But PR is But also, I think my code comment here is wrong: Went ahead and wired up a TCA and I2C FRAM and it's currently working OK: Adafruit CircuitPython 3.1.2 on 2019-01-07; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board, busio
>>> import adafruit_tca9548a
>>> import adafruit_fram
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> tca = adafruit_tca9548a.TCA9548A(i2c)
>>> fram = adafruit_fram.FRAM_I2C(tca[1])
>>> fram[0] = 1
>>> fram[0]
bytearray(b'\x01')
>>> |
maybe a typo? :) you hit the issue on raspberry pi more because it cant do repeated start in two commands |
With the new code the FRAM module works ok on my RaspberryPi.
|
Oh, I see what's going on. It's to support this: |
@StevenBruinen Thanks. Set this up on a Pi and got same error. Tested your fix and it works. Can you add a code comment to the function similar to this: |
Great! |
Sorry, I think I did something wrong now but I don't know what. |
adafruit_tca9548a.py
Outdated
@@ -81,6 +81,12 @@ def writeto(self, address, buffer, **kwargs): | |||
raise ValueError("Device address must be different than TCA9548A address.") | |||
return self.tca.i2c.writeto(address, buffer, **kwargs) | |||
|
|||
def writeto_then_readfrom(self, address, buffer_out, buffer_in, **kwargs): | |||
"""Pass thru for writeto_then_readfrom.""" | |||
"""In linux, at least, this is a special kernel function call""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis isn't liking the two string literals back to back. Could make it one docstring, but I'd say just change this to:
# In linux, at least, this is a special kernel function call
Awesome! Thanks for finding this and submitting the fix. Look ma, no I/O errors: pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board, busio
>>> import adafruit_tca9548a
>>> import adafruit_fram
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> tca = adafruit_tca9548a.TCA9548A(i2c)
>>> fram = adafruit_fram.FRAM_I2C(tca[1])
>>> fram[0] = 0x10
>>> fram[0]
bytearray(b'\x10') |
Cool! Solved for everybody now \0/ |
Updating https://github.com/adafruit/Adafruit_CircuitPython_TCA9548A to 0.2.0 from 0.1.2: > Merge pull request adafruit/Adafruit_CircuitPython_TCA9548A#7 from StevenBruinen/patch-1
Added support for the busio 'write_then_readfrom' function as some i2c devices require this (e.g. the Adafruit i2c FRAM module)