python-periphery 2.4.0__py2.py3-none-any.whl → 2.4.2__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- periphery/__init__.py +2 -2
- periphery/gpio_cdev2.py +2 -0
- periphery/i2c.py +1 -1
- periphery/spi.py +11 -10
- {python_periphery-2.4.0.dist-info → python_periphery-2.4.2.dist-info}/METADATA +11 -2
- {python_periphery-2.4.0.dist-info → python_periphery-2.4.2.dist-info}/RECORD +9 -9
- {python_periphery-2.4.0.dist-info → python_periphery-2.4.2.dist-info}/WHEEL +1 -1
- {python_periphery-2.4.0.dist-info → python_periphery-2.4.2.dist-info/licenses}/LICENSE +1 -1
- {python_periphery-2.4.0.dist-info → python_periphery-2.4.2.dist-info}/top_level.txt +0 -0
periphery/__init__.py
CHANGED
periphery/gpio_cdev2.py
CHANGED
|
@@ -121,6 +121,7 @@ class Cdev2GPIO(GPIO):
|
|
|
121
121
|
_GPIO_V2_LINE_FLAG_BIAS_PULL_UP = 0x100
|
|
122
122
|
_GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = 0x200
|
|
123
123
|
_GPIO_V2_LINE_FLAG_BIAS_DISABLED = 0x400
|
|
124
|
+
_GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = 0x800
|
|
124
125
|
|
|
125
126
|
SUPPORTED = KERNEL_VERSION >= (5, 10)
|
|
126
127
|
|
|
@@ -257,6 +258,7 @@ class Cdev2GPIO(GPIO):
|
|
|
257
258
|
|
|
258
259
|
if direction == "in":
|
|
259
260
|
flags |= Cdev2GPIO._GPIO_V2_LINE_FLAG_EDGE_RISING if edge == "rising" else Cdev2GPIO._GPIO_V2_LINE_FLAG_EDGE_FALLING if edge == "falling" else (Cdev2GPIO._GPIO_V2_LINE_FLAG_EDGE_RISING | Cdev2GPIO._GPIO_V2_LINE_FLAG_EDGE_FALLING) if edge == "both" else 0
|
|
261
|
+
flags |= Cdev2GPIO._GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME if edge != "none" else 0
|
|
260
262
|
|
|
261
263
|
line_request.offsets[0] = self._line
|
|
262
264
|
line_request.consumer = self._label
|
periphery/i2c.py
CHANGED
periphery/spi.py
CHANGED
|
@@ -149,11 +149,12 @@ class SPI(object):
|
|
|
149
149
|
|
|
150
150
|
# Methods
|
|
151
151
|
|
|
152
|
-
def transfer(self, data):
|
|
152
|
+
def transfer(self, data, inplace=False):
|
|
153
153
|
"""Shift out `data` and return shifted in data.
|
|
154
154
|
|
|
155
155
|
Args:
|
|
156
156
|
data (bytes, bytearray, list): a byte array or list of 8-bit integers to shift out.
|
|
157
|
+
inplace (bool): read in-place into data. data must be of type `bytearray`.
|
|
157
158
|
|
|
158
159
|
Returns:
|
|
159
160
|
bytes, bytearray, list: data shifted in.
|
|
@@ -166,20 +167,20 @@ class SPI(object):
|
|
|
166
167
|
"""
|
|
167
168
|
if not isinstance(data, (bytes, bytearray, list)):
|
|
168
169
|
raise TypeError("Invalid data type, should be bytes, bytearray, or list.")
|
|
170
|
+
elif inplace and not isinstance(data, bytearray):
|
|
171
|
+
raise TypeError("Invalid data type, should be bytearray for in-place read.")
|
|
169
172
|
|
|
170
173
|
# Create mutable array
|
|
171
174
|
try:
|
|
172
|
-
buf =
|
|
175
|
+
buf = data if inplace else bytearray(data)
|
|
173
176
|
except OverflowError:
|
|
174
177
|
raise ValueError("Invalid data bytes.")
|
|
175
178
|
|
|
176
|
-
buf_addr, buf_len = buf.buffer_info()
|
|
177
|
-
|
|
178
179
|
# Prepare transfer structure
|
|
179
180
|
spi_xfer = _CSpiIocTransfer()
|
|
180
|
-
spi_xfer.tx_buf =
|
|
181
|
-
spi_xfer.rx_buf =
|
|
182
|
-
spi_xfer.len =
|
|
181
|
+
spi_xfer.tx_buf = (ctypes.c_ubyte * len(data)).from_buffer(buf)
|
|
182
|
+
spi_xfer.rx_buf = spi_xfer.tx_buf
|
|
183
|
+
spi_xfer.len = len(data)
|
|
183
184
|
|
|
184
185
|
# Transfer
|
|
185
186
|
try:
|
|
@@ -189,11 +190,11 @@ class SPI(object):
|
|
|
189
190
|
|
|
190
191
|
# Return shifted out data with the same type as shifted in data
|
|
191
192
|
if isinstance(data, bytes):
|
|
192
|
-
return bytes(
|
|
193
|
+
return bytes(buf)
|
|
193
194
|
elif isinstance(data, bytearray):
|
|
194
|
-
return bytearray(buf)
|
|
195
|
+
return buf if inplace else bytearray(buf)
|
|
195
196
|
elif isinstance(data, list):
|
|
196
|
-
return buf
|
|
197
|
+
return list(buf)
|
|
197
198
|
|
|
198
199
|
def close(self):
|
|
199
200
|
"""Close the spidev SPI device.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-periphery
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.2
|
|
4
4
|
Summary: A pure Python 2/3 library for peripheral I/O (GPIO, LED, PWM, SPI, I2C, MMIO, Serial) in Linux.
|
|
5
5
|
Home-page: https://github.com/vsergeev/python-periphery
|
|
6
6
|
Author: vsergeev
|
|
@@ -19,5 +19,14 @@ Classifier: Topic :: Software Development :: Embedded Systems
|
|
|
19
19
|
Classifier: Topic :: System :: Hardware
|
|
20
20
|
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
21
21
|
License-File: LICENSE
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: keywords
|
|
28
|
+
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: summary
|
|
22
31
|
|
|
23
32
|
python-periphery is a pure Python library for GPIO, LED, PWM, SPI, I2C, MMIO, and Serial peripheral I/O interface access in userspace Linux. It is useful in embedded Linux environments (including Raspberry Pi, BeagleBone, 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. See https://github.com/vsergeev/python-periphery for more information.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
periphery/__init__.py,sha256=
|
|
1
|
+
periphery/__init__.py,sha256=pZAY_rDiG1aYx4B4vek8QK9P5NdS5aLmyBnXSjXBcYo,1030
|
|
2
2
|
periphery/__init__.pyi,sha256=kNV-srVZuc_gxTFhINQaQhFYhwfxePFOoW4zwZysiyA,698
|
|
3
3
|
periphery/gpio.py,sha256=JhDIEcC2BEmpSKXlnAxNkeM3pvzaVClE42yAER_lEuw,9960
|
|
4
4
|
periphery/gpio.pyi,sha256=3xHOcsmXxdcc-sXy3KNb0beuCp-KCW759Duq1jr88J4,1935
|
|
5
5
|
periphery/gpio_cdev1.py,sha256=QdGcPRLQlboz64M1_TL-cjcrQcqdcIMRT1HnHC0Ksxk,20665
|
|
6
|
-
periphery/gpio_cdev2.py,sha256=
|
|
6
|
+
periphery/gpio_cdev2.py,sha256=84nMmPrtJ0StJcAwE8iw45YadV45CpHBrmLBruomzGw,21199
|
|
7
7
|
periphery/gpio_sysfs.py,sha256=da-8uMziBAA_wQOaEWO8DXysilOndOMVrRLmtQUc8zs,11903
|
|
8
|
-
periphery/i2c.py,sha256=
|
|
8
|
+
periphery/i2c.py,sha256=tMS7XQ10DAblbqinSHHjYB6xNUPns71_JZvfm1cLZPc,6769
|
|
9
9
|
periphery/i2c.pyi,sha256=dfWclTARt3iCvIwMoV1IwiUS5WyssSrPm_nE-gLyUHg,752
|
|
10
10
|
periphery/led.py,sha256=waQ3nrlzyvTBKqZQpPva4AuyITGoUirJ5ROVUeklxAE,5997
|
|
11
11
|
periphery/led.pyi,sha256=f_lUJNlamKkbbH2Ivj-ZUGylXC4bVVINp2NcQXzYTSY,704
|
|
@@ -16,10 +16,10 @@ periphery/pwm.pyi,sha256=bHNZzrtRGRv7KSVL_-4zR8bjBt1JXYFlf1mhc0vu5TE,749
|
|
|
16
16
|
periphery/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
periphery/serial.py,sha256=L-tNg7aOTL_-c4tJ2qOXtp1I8LMRgYFmQWLnMmW2VCo,25275
|
|
18
18
|
periphery/serial.pyi,sha256=LCU7XhhD-yyCGG5cWM7C-K0r-FOaUydGo4GB1v9KD_Y,1114
|
|
19
|
-
periphery/spi.py,sha256=
|
|
19
|
+
periphery/spi.py,sha256=_7JSHlON8xl-QJZERA0UNljqMi4dSuUdFS9Ep_3LdtU,15836
|
|
20
20
|
periphery/spi.pyi,sha256=xpDxe72ffXmjT905fMwJDHTMZgTSxOY4Wtpk-JJiBrU,806
|
|
21
|
-
python_periphery-2.4.
|
|
22
|
-
python_periphery-2.4.
|
|
23
|
-
python_periphery-2.4.
|
|
24
|
-
python_periphery-2.4.
|
|
25
|
-
python_periphery-2.4.
|
|
21
|
+
python_periphery-2.4.2.dist-info/licenses/LICENSE,sha256=uv-e__4tQsDlgnHRd8NFan5DbsfFxHoC2pG7x23oOHc,1099
|
|
22
|
+
python_periphery-2.4.2.dist-info/METADATA,sha256=Atkv1WPL6Qz3Eve2pHh7XPiOMpCoc0f4ZapvCA6cDrA,1629
|
|
23
|
+
python_periphery-2.4.2.dist-info/WHEEL,sha256=qWEHOWeXof9kJLXAXJ1hukQ_MvVtaV9UUAew6N7Y99E,109
|
|
24
|
+
python_periphery-2.4.2.dist-info/top_level.txt,sha256=b4Woy5NSzNa7ZPLaz2cmCExhZP2-5zOgtUZog8ASZy0,10
|
|
25
|
+
python_periphery-2.4.2.dist-info/RECORD,,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2015-
|
|
1
|
+
Copyright (c) 2015-2026 vsergeev / Ivan (Vanya) A. Sergeev
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
|
File without changes
|