Need help communicating with a "primitive" I2C device
I have compiled libsoc and its python2- and python3-bindings ( https://github.com/jackmitch/libsoc ) for the Omega2. libsoc allows you to read or write without specifying the register, so go nuts with it, if you please. A python-example is available at https://github.com/jackmitch/libsoc/blob/master/test/i2c_test.py
libsoc itself: https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/libsoc_0.8.2-230117-1_mipsel_24kc.ipk
EDIT: Thought to add the LEDE-package Makefile for libsoc that I made: https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/lede-libsoc-Makefile -- this is only useful for those who wish to build their own LEDE-packages, so everyone else can just ignore this.
Finally getting a chance to look at this again.
I want to thank everyone for their thoughtful responses.
I'm afraid I have a IoT noob question. How do I go about installing an .ipk file? I'd like to have a go with WereCatf's libsoc. Seems like the path of least resistance.
How do I go about installing an .ipk file?
Download the file, then
opkg install package.ipk
Do note that I haven't tested these on the official firmware, so I don't 100% guarantee they work. But they should work just fine.
Wow, I must be a total doof. I tried to use opkg to attempt to install python-libsoc_xxxxxxxxxx and I just got an error:
Installing python-libsoc (0.8.2-230117-1) to root...
- satisfy_dependencies_for: Cannot satisfy the following dependencies for python-libsoc:
pkg-config * libsoc *
- opkg_install_cmd: Cannot install package python-libsoc.
@Art-Milburn Did you download and install libsoc? Also, install pkg-config from repos.
I can't figure out where to get pkg-config
I got it all installed but I get a segmentation fault when I try to import I2C
Ugh I was just trying to get this to work myself. What is annoying is there IS a write function that allows a no address write, but no corresponding read! Not sure why this was part of the kickstarter if its not easy to control, at least via python.
Has anyone found any reasonably straightforward solution here? I appreciate all the suggestions from folks, but am very surprised by the lack of corresponding function to the arduino Wire library for OMega2 + Python for I2C. I'm trying to get a board running that is working on Arduino utilizing the Wire API to get data from the device using Wire.requestFrom(), Wire.available(), and Wire.read(). Is the most straightforward solution to add parameter compatible calls to OmegaExpansion.onionI2c? I might be able to assist in any efforts if this seems like a path Onion would like to take that would be useful to others. Btw, I do love my Omega2. I think it just needs a little more library love!
Original Arduino Source: https://github.com/SparkysWidgets/MinipHBFW/blob/master/MinipH.ino
Python Version: https://github.com/SparkysWidgets/MinipHBFW/blob/master/RaspberryPi - Python3/pHReader.py
Maybe posting here will make them merge the PR: https://github.com/OnionIoT/i2c-exp-driver/pull/15
Compiled packages are available on https://www.dropbox.com/sh/p7mki5nbgyu1tcv/AABPC1HzA848MbEA9RpNiNNva?dl=0
One can install them with opkg install libonioni2c_0.4-2_mipsel_24kc.ipk pyOnionI2C_0.4-2_mipsel_24kc.ipk pyOmegaExpansion_0.4-2_mipsel_24kc.ipk liboniondebug_0.4-2_mipsel_24kc.ipk
Example using modified python library: https://gist.github.com/foxel/a163231293d7cf6f24831b363a91dfe5