Skip to content

Commit 24adf05

Browse files
committed
Implement spiRead with cap of 8191 bytes
1 parent 07fba43 commit 24adf05

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pytronics.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@ def toggle(pin):
129129
else:
130130
digitalWrite(pin, 'HIGH')
131131

132-
def spiRead():
133-
pass
132+
def spiRead(bytes, cs='0'):
133+
with open('/dev/spidev1.' + str(cs), 'r') as f:
134+
data = f.read(min(bytes, 8191))
135+
f.close()
136+
return data
134137

135138
def spiWrite(val, cs='0'):
136139
with open('/dev/spidev1.' + str(cs), 'w') as f:

0 commit comments

Comments
 (0)