From 72b3a0e14c7e98c642f4eac21cf06dc4195e2223 Mon Sep 17 00:00:00 2001 From: "Jasper v. Blanckenburg" Date: Sat, 1 Apr 2023 20:51:35 +0200 Subject: [PATCH] Make voltage & temperature test repeatable --- canTest.py | 4 ++-- tempTest.py | 31 +++++++++++++++++-------------- voltageTest.py | 17 ++++++++++------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/canTest.py b/canTest.py index 68845c3..e12df2c 100644 --- a/canTest.py +++ b/canTest.py @@ -31,10 +31,10 @@ def recive(bustype="socketcan", channel="can0"): return message -def waitForUserInput(waitForUserInput): +def waitForUserInput(waitForUserInput, prompt="Ready to start?"): if waitForUserInput: readInput = "n" - print("Ready to start ? ") + print(prompt) while "y" not in readInput: print("Enter y to start or c to cancel ") readInput = input(" ") diff --git a/tempTest.py b/tempTest.py index 22a1442..90eecc1 100644 --- a/tempTest.py +++ b/tempTest.py @@ -44,21 +44,24 @@ def verifyNumbers(numberListList): def tempTest(): - print("====================") - print("starting temperature test ") - canTest.waitForUserInput(True) - Temps = getTempOverCan() - allTemp = [] - changed = [] + while True: + print("====================") + print("starting temperature test ") + canTest.waitForUserInput(True) + Temps = getTempOverCan() + allTemp = [] + changed = [] - for temp in Temps: - allTemp += struct.unpack("> 4) * 0.0625)) - print("Interpreted temperatures:") - print(changed) + for te in allTemp: + changed.append(((te >> 4) * 0.0625)) + print("Interpreted temperatures:") + print(changed) + if canTest.waitForUserInput(True, "Repeat temperature test?") != 0: + break print("I am done with this shit") diff --git a/voltageTest.py b/voltageTest.py index 2e096a6..920ae2e 100644 --- a/voltageTest.py +++ b/voltageTest.py @@ -52,11 +52,14 @@ def verifyNumbers(numberListList): def voltagesTest(): print("====================") print("starting voltage test pls but 3.500 as reference value") - canTest.waitForUserInput(True) - voltages = getBatteryVoltageOverCan() # rausfinden welche id der Slave hat - allVoltages = [] - for volt in voltages: - allVoltages.append(struct.unpack("