Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python.announce > #1828
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <vsergeev@gmail.com> |
| X-Original-To | python-announce-list@python.org |
| Delivered-To | python-announce-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'defaults': 0.05; 'setup.py': 0.07; 'subject:ANN': 0.07; '128': 0.09; 'git': 0.09; 'timeout': 0.09; 'url:github': 0.09; 'python': 0.10; 'output': 0.13; 'subject:python': 0.14; 'clone': 0.16; 'easy_install': 0.16; 'msgs': 0.16; 'subsystem': 0.16; 'world!")': 0.16; 'byte': 0.18; 'bytes': 0.18; 'input': 0.18; 'library': 0.20; 'clock': 0.22; 'environments': 0.22; 'skip:% 10': 0.22; 'installation': 0.23; 'thanks,': 0.24; 'import': 0.24; 'examples': 0.24; 'written': 0.24; 'module': 0.25; 'install': 0.25; 'linux': 0.26; 'compatible': 0.27; 'external': 0.27; 'message- id:@mail.gmail.com': 0.27; 'interface': 0.29; 'i/o': 0.29; '(including': 0.30; 'skip:[ 10': 0.31; 'skip:s 30': 0.31; 'embedded': 0.32; 'useful': 0.33; 'real-time': 0.33; 'open': 0.33; 'received:google.com': 0.35; 'direction': 0.35; 'skip:i 20': 0.36; 'url:org': 0.36; 'flow': 0.36; 'mode': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'mac': 0.37; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'address:': 0.60; 'address': 0.61; 'serial': 0.70; 'pip': 0.84; 'url:readthedocs': 0.84; 'controller': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=uiikBJwGzT5fUJglqJu9XbgWU676ho+V1hAh3zbE4uE=; b=F9M0Bn4lBhtXRnN1FapgsDw7Si0NXdvPD98B3OBdctZcDiBoIhTaaABBOuxBqkQtoL QelVR/hmW+aSODXvROW6bc+KtQIO4Le9KK6zznGNoSrts3ETbPq/kAKkYspgaVDS5TaB dUEgcKiBEH35X7O2+Oz4mN08KrX0PMxZ4WDRYBV24UaevTWBvAUIdGcdJYDobygdD5xH 8kZHeEvaG25N9jpb4akyfPA/FwLQZRRqaUYrh/BboimAI5OLrlXCnTrA8wmhsZOuiMxa 55z3Xqdp3mMcs9fX0DLora54qVqujDfapMnrpDFRJ+Jw51NRSyP3x59lB7UDUDGRQmKK X4fg== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.143.101 with SMTP id sd5mr1018117igb.44.1440717645980; Thu, 27 Aug 2015 16:20:45 -0700 (PDT) |
| Date | Thu, 27 Aug 2015 16:20:45 -0700 |
| Subject | ANN: python-periphery 1.0.0 |
| From | Ivan Sergeev <vsergeev@gmail.com> |
| To | python-announce-list@python.org |
| X-Mailman-Approved-At | Fri, 28 Aug 2015 09:02:08 +0200 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| X-BeenThere | python-announce-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | Announcement-only list for the Python programming language <python-announce-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-announce-list/> |
| List-Post | <mailto:python-announce-list@python.org> |
| List-Help | <mailto:python-announce-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=subscribe> |
| Approved | python-announce-list@python.org |
| Newsgroups | comp.lang.python.announce |
| Message-ID | <mailman.102.1440745329.11709.python-announce-list@python.org> (permalink) |
| Lines | 125 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1440745329 news.xs4all.nl 23721 [2001:888:2000:d::a6]:44961 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 6165 |
| X-Received-Body-CRC | 1574942196 |
| Xref | csiph.com comp.lang.python.announce:1828 |
Show key headers only | View raw
Linux Peripheral I/O (GPIO, SPI, I2C, MMIO, Serial) with Python 2 / Python 3
python-periphery is a pure Python library for GPIO, SPI, I2C, MMIO, and
Serial peripheral I/O interface access in userspace Linux. It is useful in
embedded Linux environments (including BeagleBone, Raspberry Pi, etc.
platforms) for interfacing with external peripherals. python-periphery is
compatible with Python 2 and Python 3, is written in pure Python, and is
MIT licensed.
GitHub: https://github.com/vsergeev/python-periphery
Documentation: http://python-periphery.readthedocs.org/
Examples
GPIO
from periphery import GPIO
# Open GPIO 10 with input direction
gpio_in = GPIO(10, "in")
# Open GPIO 12 with output direction
gpio_out = GPIO(12, "out")
value = gpio_in.read()
gpio_out.write(value)
gpio_in.close()
gpio_out.close()
SPI
from periphery import SPI
# Open spidev1.0 with mode 0 and max speed 1MHz
spi = SPI("/dev/spidev1.0", 0, 1000000)
data_out = [0xaa, 0xbb, 0xcc, 0xdd]
data_in = spi.transfer(data_out)
print("shifted out [0x%02x, 0x%02x, 0x%02x, 0x%02x]" % tuple(data_out))
print("shifted in [0x%02x, 0x%02x, 0x%02x, 0x%02x]" % tuple(data_in))
spi.close()
I2C
from periphery import I2C
# Open i2c-0 controller
i2c = I2C("/dev/i2c-0")
# Read byte at address 0x100 of EEPROM at 0x50
msgs = [I2C.Message([0x01, 0x00]), I2C.Message([0x00], read=True)]
i2c.transfer(0x50, msgs)
print("0x100: 0x%02x" % msgs[1].data[0])
i2c.close()
MMIO
from periphery import MMIO
# Open am335x real-time clock subsystem page
rtc_mmio = MMIO(0x44E3E000, 0x1000)
# Read current time
rtc_secs = rtc_mmio.read32(0x00)
rtc_mins = rtc_mmio.read32(0x04)
rtc_hrs = rtc_mmio.read32(0x08)
print("hours: %02x minutes: %02x seconds: %02x" % (rtc_hrs, rtc_mins,
rtc_secs))
rtc_mmio.close()
# Open am335x control module page
ctrl_mmio = MMIO(0x44E10000, 0x1000)
# Read MAC address
mac_id0_lo = ctrl_mmio.read32(0x630)
mac_id0_hi = ctrl_mmio.read32(0x634)
print("MAC address: %04x%08x" % (mac_id0_lo, mac_id0_hi))
ctrl_mmio.close()
Serial
from periphery import Serial
# Open /dev/ttyUSB0 with baudrate 115200, and defaults of 8N1, no flow
control
serial = Serial("/dev/ttyUSB0", 115200)
serial.write(b"Hello World!")
# Read up to 128 bytes with 500ms timeout
buf = serial.read(128, 0.5)
print("read %d bytes: _%s_" % (len(buf), buf))
serial.close()
Installation
with pip,
$ pip install python-periphery
with easy_install,
$ easy_install python-periphery
with setup.py,
$ git clone https://github.com/vsergeev/python-periphery.git
$ cd python-periphery
$ python setup.py install
Thanks,
~vsergeev
Vanya Sergeev
Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread
ANN: python-periphery 1.0.0 Ivan Sergeev <vsergeev@gmail.com> - 2015-08-27 16:20 -0700
csiph-web