1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-19 20:33:21 +00:00

Fixes in LRADC.py for debug printing failing when using Python3. Updates to the README to detail running unit tests for either Python version. Ref #42 and #47

This commit is contained in:
Robert Wolterman
2017-01-06 04:11:12 +00:00
parent 8ecec67bad
commit 6972f352ae
2 changed files with 21 additions and 13 deletions

View File

@ -75,7 +75,7 @@ def get_scale_factor():
# Debug
if DEBUG:
print("Current LRADC Scaling Factor: {0}").format(SCALE_FACTOR)
print("Current LRADC Scaling Factor: {0}".format(SCALE_FACTOR))
return SCALE_FACTOR
@ -91,7 +91,7 @@ def get_allowable_sample_rates():
global SAMPLE_RATES
tmp = dat.strip().split(" ")
for i in xrange(len(tmp)):
for i in range(len(tmp)):
if "." in tmp[i]:
tmp[i] = float(tmp[i])
else:
@ -102,7 +102,7 @@ def get_allowable_sample_rates():
if DEBUG:
print("Allowable Sampling Rates:")
for rate in SAMPLE_RATES:
print("{0}").format(rate)
print("{0}".format(rate))
return tuple(SAMPLE_RATES)
@ -111,10 +111,6 @@ def set_sample_rate(rate):
if not DEVICE_EXIST:
raise Exception("LRADC Device does not exist")
# Debug
if DEBUG:
print("Setting Sample Rate to: {0}").format(rate)
# Check to see if the rates were gathered already
global SAMPLE_RATES
if SAMPLE_RATES == []:
@ -124,6 +120,10 @@ def set_sample_rate(rate):
if rate not in SAMPLE_RATES:
raise ValueError("Input Rate an Acceptable Value")
# Debug
if DEBUG:
print("Setting Sample Rate to: {0}".format(rate))
# Write the rate
f = open(LRADC_BASE_DEVICE_FILE+CURRENT_SAMPLE_RATE_FILE,"w")
mystr = "%.2f" % rate
@ -153,7 +153,7 @@ def get_sample_rate():
# Debug
if DEBUG:
print("Current Sampling Rate: {0}").format(dat)
print("Current Samplig Rate: {0}".format(dat))
return dat
@ -171,7 +171,7 @@ def get_chan0_raw():
# Debug
if DEBUG:
print("CHAN0 RAW: {0}").format(dat)
print("CHAN0 RAW: {0}".format(dat))
return dat
@ -189,7 +189,7 @@ def get_chan1_raw():
# Debug
if DEBUG:
print("CHAN1 RAW: {0}").format(dat)
print("CHAN1 RAW: {0}".format(dat))
return dat
@ -205,7 +205,7 @@ def get_chan0():
# Debug
if DEBUG:
print("CHAN0: {0}").format(dat)
print("CHAN0: {0}".format(dat))
return dat
@ -221,7 +221,7 @@ def get_chan1():
# Debug
if DEBUG:
print("CHAN1: {0}").format(dat)
print("CHAN1: {0}".format(dat))
return dat

View File

@ -345,11 +345,19 @@ To use the utilities, here is sample code::
Install py.test to run the tests. You'll also need the python compiler package for py.test.::
# Python 2.7
sudo apt-get install python-pytest
# Python 3
sudo apt-get install python3-pytest
Execute the following in the root of the project::
To run the tests, do the following.::
# If only one version of Python is installed
sudo py.test
# If more than one version of Python
cd test
sudo python2 -m pytest
sudo python3 -m pytest
**Credits**