OpenWrt Forum Archive

Topic: trunk, I2C an python

The content of this topic has been archived on 12 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I'm trying to use I2C with python on my TL-MR3020.  My problem is, it seems like there are missing packages in trunk, compare yourself:
in http://downloads.openwrt.org/backfire/1 … /packages/ you can find:
i2c-tools
python-smbus
but you can't find them in trunk: http://downloads.openwrt.org/snapshots/ … /packages/

I installed i2c-tools from backfire and it works, but it seems like this method doesn't work for python-smbus:

root@OpenWrt:~# opkg install http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/python-smbus_3.0.3-1_ar71xx.ipk
Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/python-smbus_3.0.3-1_ar71xx.ipk.
Installing python-smbus (3.0.3-1) to root...
Configuring python-smbus.
root@OpenWrt:~# cat i2c-test.py 
#!/usr/bin/env python

import smbus
import time
 
bus = smbus.SMBus(0)
 
for a in range(0,256):
    bus.write_byte(0x20,a)
    time.sleep(0.1)
root@OpenWrt:~# ./i2c-test.py 
Traceback (most recent call last):
  File "./i2c-test.py", line 3, in <module>
    import smbus
ImportError: No module named smbus

I'm not completely sure about my sourcecode, but i think with a proper installed python-smbus this should work...?


Would be glad if someone could help me here smile

Greetings
schuhumi

PS: I don't want to use an older release because of ZRam

There was a problem with one of the buildbots which has caused some of the packages not to get biult in trunk.
It should get fixed very soon.
Or you could use AArc1 instead of trunk.

Thank you for your answer!

I would use AArc1 if there would be zram support, but since there are no zram-packages in http://downloads.openwrt.org/attitude_a … /packages/, there is no support I guess.

I tried to use python-smbus from there, but i get "Segmentation fault" when running the python-program. So I think best solution would be to wait unitl the buildbot has finished its job, but how long will this take?

In the meantime, I compiled it myself, but I get a "Segmentation fault" again.

So I installed AArc1, but now I can't install "kmod-i2c-gpio-custom":

root@OpenWrt:~# opkg install kmod-i2c-gpio-custom
Installing kmod-i2c-gpio-custom (3.3.8-2) to root...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/generic/packages/kmod-i2c-gpio-custom_3.3.8-2_ar71xx.ipk.
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-i2c-gpio-custom:
 *     kmod-i2c-gpio * 
 * opkg_install_cmd: Cannot install package kmod-i2c-gpio-custom.

So I took a look at http://downloads.openwrt.org/attitude_a … /packages/ -> no "kmod-i2c-gpio"-package


actually kinda hard to get a working i2c and python-smbus on openwrt.. hmm

I got the same problem over here.
Any news on this issue?

I'm in Attitude Adjustment 12.09, and i can see the devices with i2cdetect, and reading with i2cget, etc. but the problem seems to be the SMBus. I have the same Segmentation Fault. Any progress on this?
Thanks, greetings!

I've trying with Trunk, but Python dont recognise the SMBUS libraries. What can we do with that?? I'm loosing it! Hahaha.

Same problem here.

Tried with trunk and Attitude_adjustment, but in both cases python-smbus returns Segmentation fault.

Also tried with python3, but sadly, py-smbus is not compiled for it sad

The discussion might have continued from here.