1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 12:53:22 +00:00

Fixed a bunch of error handling

This commit is contained in:
fordsfords
2016-07-04 13:56:11 -05:00
parent fd29b17796
commit 0e7d03c472
11 changed files with 787 additions and 309 deletions

View File

@ -0,0 +1,96 @@
# The default ``config.py``
def set_prefs(prefs):
"""This function is called before opening the project"""
# Specify which files and folders to ignore in the project.
# Changes to ignored resources are not added to the history and
# VCSs. Also they are not returned in `Project.get_files()`.
# Note that ``?`` and ``*`` match all characters but slashes.
# '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
# 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
# '.svn': matches 'pkg/.svn' and all of its children
# 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
# 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
prefs['ignored_resources'] = [
'*.pyc', '*~', '.ropeproject', '.hg', '.svn', '_svn', '.git',
'.tox', '.env', 'node_modules', 'bower_components']
# Specifies which files should be considered python files. It is
# useful when you have scripts inside your project. Only files
# ending with ``.py`` are considered to be python files by
# default.
#prefs['python_files'] = ['*.py']
# Custom source folders: By default rope searches the project
# for finding source folders (folders that should be searched
# for finding modules). You can add paths to that list. Note
# that rope guesses project source folders correctly most of the
# time; use this if you have any problems.
# The folders should be relative to project root and use '/' for
# separating folders regardless of the platform rope is running on.
# 'src/my_source_folder' for instance.
#prefs.add('source_folders', 'src')
# You can extend python path for looking up modules
#prefs.add('python_path', '~/python/')
# Should rope save object information or not.
prefs['save_objectdb'] = True
prefs['compress_objectdb'] = False
# If `True`, rope analyzes each module when it is being saved.
prefs['automatic_soa'] = True
# The depth of calls to follow in static object analysis
prefs['soa_followed_calls'] = 0
# If `False` when running modules or unit tests "dynamic object
# analysis" is turned off. This makes them much faster.
prefs['perform_doa'] = True
# Rope can check the validity of its object DB when running.
prefs['validate_objectdb'] = True
# How many undos to hold?
prefs['max_history_items'] = 32
# Shows whether to save history across sessions.
prefs['save_history'] = True
prefs['compress_history'] = False
# Set the number spaces used for indenting. According to
# :PEP:`8`, it is best to use 4 spaces. Since most of rope's
# unit-tests use 4 spaces it is more reliable, too.
prefs['indent_size'] = 4
# Builtin and c-extension modules that are allowed to be imported
# and inspected by rope.
prefs['extension_modules'] = []
# Add all standard c-extensions to extension_modules list.
prefs['import_dynload_stdmods'] = True
# If `True` modules with syntax errors are considered to be empty.
# The default value is `False`; When `False` syntax errors raise
# `rope.base.exceptions.ModuleSyntaxError` exception.
prefs['ignore_syntax_errors'] = False
# If `True`, rope ignores unresolvable imports. Otherwise, they
# appear in the importing namespace.
prefs['ignore_bad_imports'] = False
# If `True`, rope will transform a comma list of imports into
# multiple separate import statements when organizing
# imports.
prefs['split_imports'] = False
# If `True`, rope will sort imports alphabetically by module name
# instead of alphabetically by import statement, with from imports
# after normal imports.
prefs['sort_imports_alphabetically'] = False
def project_opened(project):
"""This function is called after opening the project"""
# Do whatever you like here!

View File

@ -0,0 +1,2 @@
<EFBFBD>}q(Utest_softpwm_setup]q(Uteardown_moduleqUTestSoftpwmSetupqeUtest_gpio_output]q(hUTestGPIOOutputqeUtest_pwm_setup]q(hU TestPwmSetupqeUtest_gpio_setup]q (hU TestSetupq
eUtest_gpio_input]q (hU

View File

@ -0,0 +1 @@
<EFBFBD>]q(]q]qe.

View File

@ -0,0 +1 @@
<EFBFBD>}q.

View File

@ -42,7 +42,7 @@ if (GPIO.input("XIO-P0") != GPIO.HIGH):
num_errs += 1
GPIO.cleanup()
GPIO.setup("XIO-P0", GPIO.IN)
GPIO.setup("U14_13", GPIO.IN) # XIO-P0
GPIO.setup("CSID0", GPIO.OUT, initial=GPIO.LOW)
if (GPIO.input("XIO-P0") != GPIO.LOW):
print "A low output on CSI0 does not lead to a low input on XIO-P0."
@ -51,7 +51,7 @@ if (GPIO.input("XIO-P0") != GPIO.LOW):
GPIO.cleanup()
GPIO.setup("XIO-P0", GPIO.IN)
GPIO.setup("CSID0", GPIO.OUT)
GPIO.setup("U14_31", GPIO.OUT) # CSID0
# VERIFY SIMPLE FUNCTIONALITY
print "VERIFY SIMPLE FUNCTIONALITY"
@ -66,7 +66,7 @@ assert(GPIO.input("XIO-P0") == GPIO.LOW)
# ==============================================
# EDGE DETECTION - AP-EINT1
print "SETTING UP EDGE DETECTION ON AP-EINT1"
print "SETTING UP RISING EDGE DETECTION ON AP-EINT1"
GPIO.setup("AP-EINT1", GPIO.IN)
print "adding event detect"
GPIO.add_event_detect("AP-EINT1", GPIO.RISING)
@ -75,13 +75,12 @@ print "VERIFYING EDGE DETECT"
f = open("/sys/class/gpio/gpio193/edge", "r")
edge = f.read()
f.close()
print "edge='", edge, "'"
assert(edge == "rising\n")
GPIO.remove_event_detect("AP-EINT1")
# ==============================================
# EDGE DETECTION - AP-EINT3
print "SETTING UP EDGE DETECTION ON AP-EINT3"
print "SETTING UP BOTH EDGE DETECTION ON AP-EINT3"
GPIO.setup("AP-EINT3", GPIO.IN)
GPIO.add_event_detect("AP-EINT3", GPIO.BOTH)
@ -89,13 +88,12 @@ print "VERIFYING EDGE DETECT"
f = open("/sys/class/gpio/gpio35/edge", "r")
edge = f.read()
f.close()
print "EDGE: %s" % edge
assert(edge == "both\n")
GPIO.remove_event_detect("AP-EINT3")
# ==============================================
# EDGE DETECTION - EXPANDED GPIO
print "SETTING UP EDGE DETECTION ON XIO-P0"
print "SETTING UP FALLING EDGE DETECTION ON XIO-P0"
GPIO.add_event_detect("XIO-P0", GPIO.FALLING, myfuncallback)
print "VERIFYING EDGE DETECT"
@ -104,7 +102,6 @@ gfile = "/sys/class/gpio/gpio%d/edge" % base
f = open(gfile, "r")
edge = f.read()
f.close()
print "EDGE: %s" % edge
assert(edge == "falling\n")
# LOOP WRITING ON CSID0 TO HOPEFULLY GET CALLBACK TO WORK
@ -134,14 +131,60 @@ GPIO.setup("CSID1", GPIO.IN)
try:
GPIO.add_event_detect("CSID1", GPIO.FALLING, myfuncallback)
print "Oops, it did not throw an exception! BUG!!!"
except:
num_errors += 1
except ValueError, ex:
print "error msg=", ex.args[0]
pass
except RuntimeError, ex:
print "error msg=", ex.args[0]
pass
print "TESTING ERRORS THROWN WHEN SETTING UP AN ALREADY EXPORTED GPIO"
try:
GPIO.output("XIO-P0", GPIO.LOW)
print "Oops, it did not throw an exception! BUG!!!"
num_errors += 1
except ValueError, ex:
print "error msg=", ex.args[0]
pass
except RuntimeError, ex:
print "error msg=", ex.args[0]
pass
print "TESTING ERRORS THROWN WHEN WRITING TO A GPIO WITH NO DIRECTION"
try:
GPIO.output("CSID1", GPIO.LOW)
print "Oops, it did not throw an exception! BUG!!!"
except:
num_errors += 1
except ValueError, ex:
print "error msg=", ex.args[0]
pass
except RuntimeError, ex:
print "error msg=", ex.args[0]
pass
print "TESTING ERRORS THROWN FOR ILLEGAL GPIO"
try:
GPIO.setup("NOTUSED", GPIO.IN)
print "Oops, it did not throw an exception! BUG!!!"
num_errors += 1
except ValueError, ex:
print "error msg=", ex.args[0]
pass
except RuntimeError, ex:
print "error msg=", ex.args[0]
pass
print "TESTING ERRORS THROWN FOR NON-GPIO"
try:
GPIO.setup("FEL", GPIO.IN)
print "Oops, it did not throw an exception! BUG!!!"
num_errors += 1
except ValueError, ex:
print "error msg=", ex.args[0]
pass
except RuntimeError, ex:
print "error msg=", ex.args[0]
pass
print "CLEANUP"