add api test
This commit is contained in:
parent
ffd562598c
commit
d803d078cb
1 changed files with 23 additions and 0 deletions
23
spitest.py
Executable file
23
spitest.py
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python2.7
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
import spidev
|
||||
import random
|
||||
|
||||
spi = spidev.SpiDev()
|
||||
spi.open(0, 0)
|
||||
|
||||
random.seed()
|
||||
|
||||
dataout = []
|
||||
|
||||
for i in range(32):
|
||||
dataout.append(random.randint(0, 255))
|
||||
|
||||
print "Transfering testdata", dataout
|
||||
datain = spi.xfer2(dataout)
|
||||
|
||||
if dataout == datain:
|
||||
print "Received data OK!"
|
||||
|
||||
spi.close()
|
Loading…
Reference in a new issue