Skip to content
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

busio I2C import on RPi #49

Closed
magnus-haw opened this issue Nov 26, 2018 · 12 comments
Closed

busio I2C import on RPi #49

magnus-haw opened this issue Nov 26, 2018 · 12 comments

Comments

@magnus-haw
Copy link

Line 21 in busio.py should have an "elif" statement instead of an "if" statement. Currently, if the board is not a beaglebone_black, the code attempts to execute the last else statement. This creates an error for Raspberry pi boards which do not use the Micropython machine module.

Discovered this issue when trying to install CircuitPython from this tutorial: https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi

def init(self, scl, sda, frequency):
self.deinit()
if board_id == "raspi_3" or board_id == "raspi_2":
from adafruit_blinka.microcontroller.raspi_23.i2c import I2C as _I2C
if board_id == "beaglebone_black":
from adafruit_blinka.microcontroller.raspi_23.i2c import I2C as _I2C
else:
from machine import I2C as _I2C

->>>
def init(self, scl, sda, frequency):
self.deinit()
if board_id == "raspi_3" or board_id == "raspi_2":
from adafruit_blinka.microcontroller.raspi_23.i2c import I2C as _I2C
elif board_id == "beaglebone_black":
from adafruit_blinka.microcontroller.raspi_23.i2c import I2C as _I2C
else:
from machine import I2C as _I2C

@gjoseph
Copy link

gjoseph commented Nov 26, 2018

Found the same thing @magnus-haw - here's a PR that I hope will get merged soon :)

@asyzen
Copy link

asyzen commented Nov 26, 2018

@magnus-haw Thanks!

@ladyada
Copy link
Member

ladyada commented Nov 26, 2018

we're about to fix this with a different PR, hold tight!

@ladyada
Copy link
Member

ladyada commented Nov 26, 2018

apologies for the break. lots of dev goin' on
please try 0.3.1 - i tested it but it could use more testin' as always :)

@csylvain
Copy link

csylvain commented Nov 26, 2018

that (0.3.1) broke something (0.3.0 worked after changing that one "if" to "elif")
Traceback (most recent call last):
File "bme280_simpletest.py", line 8, in
i2c = busio.I2C(board.SCL, board.SDA)
File "/home/pi/.local/lib/python3.5/site-packages/busio.py", line 15, in init
self.init(scl, sda, frequency)
File "/home/pi/.local/lib/python3.5/site-packages/busio.py", line 20, in init
from adafruit_blinka.microcontroller.generic_linux.i2c import I2C as _I2C
ImportError: No module named 'adafruit_blinka.microcontroller.generic_linux'

fix with
~/.local/lib/python3.5/site-packages/adafruit_blinka/microcontroller $ ln -sf raspi_23 generic_linux

@ladyada
Copy link
Member

ladyada commented Nov 26, 2018

hmm - lemme take another look

@ladyada
Copy link
Member

ladyada commented Nov 26, 2018

ok i think it's cause i forgot a init.py file - fun times! new release coming soon

@ladyada
Copy link
Member

ladyada commented Nov 26, 2018

OK please try 0.3.2!

@ladyada
Copy link
Member

ladyada commented Nov 26, 2018

i think this is resolved now, @brennen tested it. closing - please reopen if it's still an issue

@ladyada ladyada closed this as completed Nov 26, 2018
@csylvain
Copy link

no pin.py in generic_linux ? only in raspi_23.

@ladyada
Copy link
Member

ladyada commented Nov 26, 2018

thats correct, we have not done our libgpiod changes so pin control is still board specific

@csylvain
Copy link

k!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants