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 CHANGED
@@ -1,9 +1,9 @@
1
1
  import time
2
2
 
3
- __version__ = "2.4.0"
3
+ __version__ = "2.4.2"
4
4
  "Module version string."
5
5
 
6
- version = (2, 4, 0)
6
+ version = (2, 4, 2)
7
7
  "Module version tuple."
8
8
 
9
9
 
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
@@ -76,7 +76,7 @@ class I2C(object):
76
76
  self._devpath = devpath
77
77
 
78
78
  # Query supported functions
79
- buf = array.array('I', [0])
79
+ buf = array.array('L', [0])
80
80
  try:
81
81
  fcntl.ioctl(self._fd, I2C._I2C_IOC_FUNCS, buf, True)
82
82
  except (OSError, IOError) as e:
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 = array.array('B', data)
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 = buf_addr
181
- spi_xfer.rx_buf = buf_addr
182
- spi_xfer.len = buf_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(bytearray(buf))
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.tolist()
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
1
+ Metadata-Version: 2.4
2
2
  Name: python-periphery
3
- Version: 2.4.0
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=7nyzjr8tHnGQw3qW2YoGgoo95Vqm665hhrG_TYtkhH8,1030
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=9uaACzyDeLDu68PpHtF3NwdATbpSgYQXJDRD0hR_MgE,21051
6
+ periphery/gpio_cdev2.py,sha256=84nMmPrtJ0StJcAwE8iw45YadV45CpHBrmLBruomzGw,21199
7
7
  periphery/gpio_sysfs.py,sha256=da-8uMziBAA_wQOaEWO8DXysilOndOMVrRLmtQUc8zs,11903
8
- periphery/i2c.py,sha256=PQBrWZ5ePKa21x18_6Cs-plAWsbZEYPHIxV-7KizBLg,6769
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=LTEpKBvvrhIdfcav-Zr08JKt_75BMYLaPoOYBCPzvtg,15568
19
+ periphery/spi.py,sha256=_7JSHlON8xl-QJZERA0UNljqMi4dSuUdFS9Ep_3LdtU,15836
20
20
  periphery/spi.pyi,sha256=xpDxe72ffXmjT905fMwJDHTMZgTSxOY4Wtpk-JJiBrU,806
21
- python_periphery-2.4.0.dist-info/LICENSE,sha256=MhEkRh6fhvT3u59XFQC_WOwbdiBrZC5QXOF9t_fIjgU,1099
22
- python_periphery-2.4.0.dist-info/METADATA,sha256=wVtMDdRG1lBb27vCs4rzUbRanDGMvl09lF8En6Z37Jg,1457
23
- python_periphery-2.4.0.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
24
- python_periphery-2.4.0.dist-info/top_level.txt,sha256=b4Woy5NSzNa7ZPLaz2cmCExhZP2-5zOgtUZog8ASZy0,10
25
- python_periphery-2.4.0.dist-info/RECORD,,
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,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: setuptools (83.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2023 vsergeev / Ivan (Vanya) A. Sergeev
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