slave-testbench-23/tempTest.py

61 lines
1.4 KiB
Python
Raw Normal View History

2023-04-01 18:53:28 +02:00
import time
import can
import canTest
import struct
bustype = 'socketcan'
channel = 'can0'
def getTempOverCan():
bus = can.Bus(channel=channel, interface=bustype)
message = can.Message(arbitration_id=0x002, data=[3, 0, 0, 0, 0, 0, 0], is_extended_id=False)
bus.send(message)
voltages = []
runtime = 2
begin = 0
for msg in bus:
print(msg.data)
voltages.append(msg.data)
print("begin {}".format(begin))
begin = begin + 1
if(begin > runtime):
return voltages
def verifyNumbers(numberListList):
zeroCount = 0
max = 0
min = 1000000
for numberList in numberListList:
print("Temperatures {}".format(numberList))
for number in numberList:
if number < min:
min = number
elif number > max :
max = number
print("Temperatures {}".format())
print("The biggest difference tmep was max{} and min{}".format((max), (min)))
def tempTest():
print("starting temperature test ")
canTest.waitForUserInput(True)
Temps = getTempOverCan()
allTemp = []
changed = []
for temp in Temps:
allTemp.append(struct.unpack("<HHHH", temp)) #Format anpassen
print("all Number")
print(allTemp)
for te in allTemp:
for con in te:
changed.append(((con/16)*0.0625))
print(changed)
print("I am done with this shit")