From: mhoffman@lightlink.com (Mark M. Hoffman)
To: lm-sensors@vger.kernel.org
Subject: Python bindings to i2c-dev
Date: Thu, 19 May 2005 06:25:28 +0000 [thread overview]
Message-ID: <20041229050526.GA5431@jupiter.solarsys.private> (raw)
Hi:
(cc James, who IIRC is a Python guy...)
After a couple false starts and some hair-pulling, here is a Python module
which allows SMBus access through the I2C /dev interface. I would like to
eventually add this to the lm_sensors project.
http://members.dca.net/mhoffman/sensors/python/
To build it and use it in place, start with this:
$ python setup.py build
Then, e.g. (as root):
# python
(...)
>>> from smbus import SMBus
>>> b = SMBus(0) # 0 indicates /dev/i2c-0
>>> b.read_byte_data(0x2f,0x58)
114
If there's no device to ack the address, or in case of any other bus
error, it raises an exception:
>>> b.write_quick(0x2e)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 1] Operation not permitted
TODO: the rest of the bus transactions, and the capabilities query.
WARNING: I have managed to lock up my machine's SMBus more than once, so
the usual caveats apply. If you lock up your bus (such that write_quick
commands to known good addresses start to fail) you may need to COMPLETELY
power off your machine, including physically removing the plug from the
power supply. In my case, the machine fails the BIOS POST until I do that.
Of course, this is no worse than what is possible from i2c-dev directly.
Which reminds me... Khali: Is i2c-dev safe (ruin-proof) for people with
IBM laptops? Or would that check need to be built in to this?
Comments and suggestions are welcome.
Regards,
--
Mark M. Hoffman
mhoffman@lightlink.com
next reply other threads:[~2005-05-19 6:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-19 6:25 Mark M. Hoffman [this message]
2005-05-19 6:25 ` Python bindings to i2c-dev Mark M. Hoffman
2005-05-19 6:25 ` Mark Studebaker
2005-05-19 6:25 ` Jean Delvare
2005-05-19 6:25 ` Mark M. Hoffman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041229050526.GA5431@jupiter.solarsys.private \
--to=mhoffman@lightlink.com \
--cc=lm-sensors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.