Skip to content

Instantly share code, notes, and snippets.

@timwood0
Last active August 29, 2015 14:26
Show Gist options
  • Save timwood0/cc6226d7e6d730322180 to your computer and use it in GitHub Desktop.
Save timwood0/cc6226d7e6d730322180 to your computer and use it in GitHub Desktop.
Doceme/py-spidev wrmsg test cases
#!/usr/bin/env python
# Written by Tim Wood.
# This code is released into the public domain
import time
import os
import sys
import RPi.GPIO as GPIO
import spidev
import pdb
spi = spidev.SpiDev()
spi.open(0, 0)
DEBUG = 0
IS_TEST = 0
# Negative test cases; all should report wrmsg_ messages from spidev_module.c and continue
try:
r = spi.xfer2([])
except Exception as exc:
print exc
try:
ta = []
for i in range(4097):
ta.append(i)
r = spi.xfer2(ta)
except Exception as exc:
print exc
try:
r = spi.xfer2([ "0x1234567892345678901218195739184" ])
except Exception as exc:
print exc
spi.close()
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment