python-periphery 2.4.2__py2.py3-none-any.whl → 2.4.3__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/spi.py +10 -11
- {python_periphery-2.4.2.dist-info → python_periphery-2.4.3.dist-info}/METADATA +1 -1
- {python_periphery-2.4.2.dist-info → python_periphery-2.4.3.dist-info}/RECORD +7 -7
- {python_periphery-2.4.2.dist-info → python_periphery-2.4.3.dist-info}/WHEEL +1 -1
- {python_periphery-2.4.2.dist-info → python_periphery-2.4.3.dist-info}/licenses/LICENSE +0 -0
- {python_periphery-2.4.2.dist-info → python_periphery-2.4.3.dist-info}/top_level.txt +0 -0
periphery/__init__.py
CHANGED
periphery/spi.py
CHANGED
|
@@ -149,12 +149,11 @@ class SPI(object):
|
|
|
149
149
|
|
|
150
150
|
# Methods
|
|
151
151
|
|
|
152
|
-
def transfer(self, data
|
|
152
|
+
def transfer(self, data):
|
|
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`.
|
|
158
157
|
|
|
159
158
|
Returns:
|
|
160
159
|
bytes, bytearray, list: data shifted in.
|
|
@@ -167,20 +166,20 @@ class SPI(object):
|
|
|
167
166
|
"""
|
|
168
167
|
if not isinstance(data, (bytes, bytearray, list)):
|
|
169
168
|
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.")
|
|
172
169
|
|
|
173
170
|
# Create mutable array
|
|
174
171
|
try:
|
|
175
|
-
buf =
|
|
172
|
+
buf = array.array('B', data)
|
|
176
173
|
except OverflowError:
|
|
177
174
|
raise ValueError("Invalid data bytes.")
|
|
178
175
|
|
|
176
|
+
buf_addr, buf_len = buf.buffer_info()
|
|
177
|
+
|
|
179
178
|
# Prepare transfer structure
|
|
180
179
|
spi_xfer = _CSpiIocTransfer()
|
|
181
|
-
spi_xfer.tx_buf =
|
|
182
|
-
spi_xfer.rx_buf =
|
|
183
|
-
spi_xfer.len =
|
|
180
|
+
spi_xfer.tx_buf = buf_addr
|
|
181
|
+
spi_xfer.rx_buf = buf_addr
|
|
182
|
+
spi_xfer.len = buf_len
|
|
184
183
|
|
|
185
184
|
# Transfer
|
|
186
185
|
try:
|
|
@@ -190,11 +189,11 @@ class SPI(object):
|
|
|
190
189
|
|
|
191
190
|
# Return shifted out data with the same type as shifted in data
|
|
192
191
|
if isinstance(data, bytes):
|
|
193
|
-
return bytes(buf)
|
|
192
|
+
return bytes(bytearray(buf))
|
|
194
193
|
elif isinstance(data, bytearray):
|
|
195
|
-
return
|
|
194
|
+
return bytearray(buf)
|
|
196
195
|
elif isinstance(data, list):
|
|
197
|
-
return
|
|
196
|
+
return buf.tolist()
|
|
198
197
|
|
|
199
198
|
def close(self):
|
|
200
199
|
"""Close the spidev SPI device.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
periphery/__init__.py,sha256=
|
|
1
|
+
periphery/__init__.py,sha256=bFlQwbt4Eo3p9VjzuaRpVIhbPyIKhX50EOXmNi_Maak,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
|
|
@@ -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=LTEpKBvvrhIdfcav-Zr08JKt_75BMYLaPoOYBCPzvtg,15568
|
|
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.3.dist-info/licenses/LICENSE,sha256=uv-e__4tQsDlgnHRd8NFan5DbsfFxHoC2pG7x23oOHc,1099
|
|
22
|
+
python_periphery-2.4.3.dist-info/METADATA,sha256=B7WyU7pOHadweyN-LfD02Uq74NCfAU29W-VWQJa9wgU,1629
|
|
23
|
+
python_periphery-2.4.3.dist-info/WHEEL,sha256=4YBfCYNH4wlLpv3pzq1hbEuIlXA4WJabKLFurZ7eTL0,109
|
|
24
|
+
python_periphery-2.4.3.dist-info/top_level.txt,sha256=b4Woy5NSzNa7ZPLaz2cmCExhZP2-5zOgtUZog8ASZy0,10
|
|
25
|
+
python_periphery-2.4.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|