summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qamp.py
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-06 12:46:27 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-06 12:46:27 +0100
commit9f07a57d89a927aa9b172c1bf20c7ab563658c73 (patch)
tree3691cb8d09862db185a628c7bb07df6dd50a64bb /test-cli/test/tests/qamp.py
parent98d40cecc9818360984188755e455aa53933aab0 (diff)
downloadboard-9f07a57d89a927aa9b172c1bf20c7ab563658c73.zip
board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.tar.gz
board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.tar.bz2
Fixed multiple errors.
Diffstat (limited to 'test-cli/test/tests/qamp.py')
-rw-r--r--test-cli/test/tests/qamp.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/test-cli/test/tests/qamp.py b/test-cli/test/tests/qamp.py
index 3e38ce9..cf18fc5 100644
--- a/test-cli/test/tests/qamp.py
+++ b/test-cli/test/tests/qamp.py
@@ -3,10 +3,13 @@ import unittest
import serial
import time
+
class Qamp(unittest.TestCase):
+ params = None
- #varlist: undercurrent, overcurrent
+ # varlist: undercurrent, overcurrent
def __init__(self, testname, testfunc, varlist):
+ self.params = varlist
self._current = 0.0
if "undercurrent" in varlist:
self._undercurrent = varlist["undercurrent"]
@@ -16,7 +19,7 @@ class Qamp(unittest.TestCase):
self._overcurrent = varlist["overcurrent"]
else:
raise Exception('overcurrent param inside Qamp must be defined')
- self._vshuntfactor=16384.0
+ self._vshuntfactor = 16384.0
self._ser = serial.Serial()
self._ser.port = '/dev/ttyUSB0'
self._ser.baudrate = 115200
@@ -34,19 +37,19 @@ class Qamp(unittest.TestCase):
def execute(self):
# Open Serial port ttyUSB0
- error=0
+ error = 0
try:
self._ser.open()
except:
self.fail("failed: IMPOSSIBLE OPEN USB-SERIAL PORT ( {} )".format(self._ser.port))
- error=1
- if error==0:
+ error = 1
+ if error == 0:
# Clean input and output buffer of serial port
self._ser.flushInput()
self._ser.flushOutput()
# Send command to read Voltage at Shunt resistor
# Prepare cmd
- cmd = ('at+in?\n\r')
+ cmd = 'at+in?\n\r'
i = 0
# Write, 1 by 1 byte at a time to avoid hanging of serial receiver code of listener, emphasis being made at sleep of 50 ms.
@@ -57,7 +60,7 @@ class Qamp(unittest.TestCase):
# Read, 1 by 1 byte
res = []
- while (self._ser.inWaiting() > 0): # if incoming bytes are waiting to be read from the serial input buffer
+ while self._ser.inWaiting() > 0: # if incoming bytes are waiting to be read from the serial input buffer
res.append(self._ser.read(1).decode('ascii')) # read the bytes and convert from binary array to ASCII
string = ''.join(res)
@@ -65,12 +68,8 @@ class Qamp(unittest.TestCase):
self._current = float(int(string, 0)) / self._vshuntfactor
print(self._current)
# In order to give a valid result it is importarnt to define an under current value
- if (self._current > float(self._overcurrent)):
+ if self._current > float(self._overcurrent):
self.fail("failed: OVERCURRENT DETECTED ( {} )".format(self._current))
- if (self._current < float(self._undercurrent)):
+ if self._current < float(self._undercurrent):
self.fail("failed: UNDERCURRENT DETECTED ( {} )".format(self._current))
-
-
-
-