diff options
author | Manel Caro <mcaro@iseebcn.com> | 2020-03-04 17:46:36 +0100 |
---|---|---|
committer | Manel Caro <mcaro@iseebcn.com> | 2020-03-04 17:46:36 +0100 |
commit | 09de774dcc1a5abc1c8f3a00fdb039aa3c522f52 (patch) | |
tree | c4bd3963d0df01d2e3a33732247388ed4651b186 /test-cli/test/tests/qserial.py | |
parent | b6932fbaf898724ae87c29f8965621610f377084 (diff) | |
download | board-09de774dcc1a5abc1c8f3a00fdb039aa3c522f52.zip board-09de774dcc1a5abc1c8f3a00fdb039aa3c522f52.tar.gz board-09de774dcc1a5abc1c8f3a00fdb039aa3c522f52.tar.bz2 |
SOPA Initial Commit
Diffstat (limited to 'test-cli/test/tests/qserial.py')
-rw-r--r-- | test-cli/test/tests/qserial.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/test-cli/test/tests/qserial.py b/test-cli/test/tests/qserial.py index 43ba3c8..d3e2ee6 100644 --- a/test-cli/test/tests/qserial.py +++ b/test-cli/test/tests/qserial.py @@ -6,11 +6,17 @@ import time class Qserial(unittest.TestCase): - def __init__(self, testname, testfunc, port, baudrate): + def __init__(self, testname, testfunc, varlist): super(Qserial, self).__init__(testfunc) - self.__port = port + if "port" in varlist: + self.__port = varlist["port"] + else: + raise Exception('port param inside Qserial must be defined') self.__serial = serial.Serial(self.__port, timeout=1) - self.__serial.baudrate = baudrate + if "baudrate" in varlist: + self.__baudrate = varlist["baudrate"] + else: + raise Exception('baudrate param inside Qserial must be defined') self._testMethodDoc = testname def __del__(self): @@ -19,12 +25,15 @@ class Qserial(unittest.TestCase): def execute(self): self.__serial.flushInput() self.__serial.flushOutput() + #generate a random uuid test_uuid = str(uuid.uuid4()).encode() + #send the uuid through serial port self.__serial.write(test_uuid) time.sleep(0.05) # there might be a small delay if self.__serial.inWaiting() == 0: self.fail("failed: PORT {} wait timeout exceded, wrong communication?".format(self.__port)) else: + # check if what it was sent is equal to what has been received if (self.__serial.readline() != test_uuid): self.fail("failed: PORT {} write/read mismatch".format(self.__port)) |