do not run on import

old-commit-hash: 59accdd814
commatwo_master
Willem Melching 4 years ago
parent bb156e50d7
commit 116ae68bdb
  1. 26
      selfdrive/test/test_fingerprints.py
  2. 35
      tools/replay/can_replay.py
  3. 21
      tools/zookeeper/check_consumption.py
  4. 7
      tools/zookeeper/disable.py
  5. 18
      tools/zookeeper/enable_and_wait.py
  6. 8
      tools/zookeeper/ignition.py
  7. 12
      tools/zookeeper/test_zookeeper.py

@ -58,23 +58,25 @@ def check_can_ignition_conflicts(fingerprints, brands):
sys.exit(1)
fingerprints = _get_fingerprints()
fingerprints_flat = []
car_names = []
brand_names = []
for brand in fingerprints:
if __name__ == "__main__":
fingerprints = _get_fingerprints()
fingerprints_flat = []
car_names = []
brand_names = []
for brand in fingerprints:
for car in fingerprints[brand]:
fingerprints_flat += fingerprints[brand][car]
for i in range(len(fingerprints[brand][car])):
car_names.append(car)
brand_names.append(brand)
# first check if CAN ignition specific messages are unexpectedly included in other fingerprints
check_can_ignition_conflicts(fingerprints_flat, brand_names)
# first check if CAN ignition specific messages are unexpectedly included in other fingerprints
check_can_ignition_conflicts(fingerprints_flat, brand_names)
valid = True
for idx1, f1 in enumerate(fingerprints_flat):
valid = True
for idx1, f1 in enumerate(fingerprints_flat):
for idx2, f2 in enumerate(fingerprints_flat):
if idx1 < idx2 and not check_fingerprint_consistency(f1, f2):
valid = False
@ -85,9 +87,9 @@ for idx1, f1 in enumerate(fingerprints_flat):
print(', '.join("%d: %d" % v for v in sorted(f2.items())))
print("")
print("Found {0} individual fingerprints".format(len(fingerprints_flat)))
if not valid or len(fingerprints_flat) == 0:
print("Found {0} individual fingerprints".format(len(fingerprints_flat)))
if not valid or len(fingerprints_flat) == 0:
print("TEST FAILED")
sys.exit(1)
else:
else:
print("TEST SUCESSFUL")

@ -16,24 +16,6 @@ except Exception:
PandaJungle = None # type: ignore
print("Loading log...")
ROUTE = "77611a1fac303767/2020-03-24--09-50-38"
REPLAY_SEGS = list(range(10, 16)) # route has 82 segments available
CAN_MSGS = []
for i in tqdm(REPLAY_SEGS):
log_url = f"https://commadataci.blob.core.windows.net/openpilotci/{ROUTE}/{i}/rlog.bz2"
lr = LogReader(log_url)
CAN_MSGS += [can_capnp_to_can_list(m.can) for m in lr if m.which() == 'can']
# set both to cycle ignition
IGN_ON = int(os.getenv("ON", "0"))
IGN_OFF = int(os.getenv("OFF", "0"))
ENABLE_IGN = IGN_ON > 0 and IGN_OFF > 0
if ENABLE_IGN:
print(f"Cycling ignition: on for {IGN_ON}s, off for {IGN_OFF}s")
def send_thread(s, flock):
if "Jungle" in str(type(s)):
if "FLASH" in os.environ:
@ -99,4 +81,21 @@ def connect():
if __name__ == "__main__":
print("Loading log...")
ROUTE = "77611a1fac303767/2020-03-24--09-50-38"
REPLAY_SEGS = list(range(10, 16)) # route has 82 segments available
CAN_MSGS = []
for i in tqdm(REPLAY_SEGS):
log_url = f"https://commadataci.blob.core.windows.net/openpilotci/{ROUTE}/{i}/rlog.bz2"
lr = LogReader(log_url)
CAN_MSGS += [can_capnp_to_can_list(m.can) for m in lr if m.which() == 'can']
# set both to cycle ignition
IGN_ON = int(os.getenv("ON", "0"))
IGN_OFF = int(os.getenv("OFF", "0"))
ENABLE_IGN = IGN_ON > 0 and IGN_OFF > 0
if ENABLE_IGN:
print(f"Cycling ignition: on for {IGN_ON}s, off for {IGN_OFF}s")
connect()

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
import time
@ -8,19 +8,20 @@ from tools.zookeeper import Zookeeper
# Exit code: 0 -> passed
# 1 -> failed
z = Zookeeper()
if __name__ == "__main__":
z = Zookeeper()
averaging_time_s = int(sys.argv[1])
max_average_power = float(sys.argv[2])
averaging_time_s = int(sys.argv[1])
max_average_power = float(sys.argv[2])
start_time = time.time()
measurements = []
while time.time() - start_time < averaging_time_s:
start_time = time.time()
measurements = []
while time.time() - start_time < averaging_time_s:
measurements.append(z.read_power())
time.sleep(0.1)
average_power = sum(measurements)/len(measurements)
print(f"Average power: {round(average_power, 4)}W")
average_power = sum(measurements)/len(measurements)
print(f"Average power: {round(average_power, 4)}W")
if average_power > max_average_power:
if average_power > max_average_power:
exit(1)

@ -1,7 +1,8 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from tools.zookeeper import Zookeeper
z = Zookeeper()
z.set_device_power(False)
if __name__ == "__main__":
z = Zookeeper()
z.set_device_power(False)

@ -1,20 +1,22 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
import time
from tools.zookeeper import Zookeeper
z = Zookeeper()
z.set_device_power(True)
def is_online(ip):
return (os.system(f"ping -c 1 {ip} > /dev/null") == 0)
ip = str(sys.argv[1])
timeout = int(sys.argv[2])
start_time = time.time()
while not is_online(ip):
if __name__ == "__main__":
z = Zookeeper()
z.set_device_power(True)
ip = str(sys.argv[1])
timeout = int(sys.argv[2])
start_time = time.time()
while not is_online(ip):
print(f"{ip} not online yet!")
if time.time() - start_time > timeout:

@ -1,8 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
from tools.zookeeper import Zookeeper
z = Zookeeper()
z.set_device_ignition(1 if int(sys.argv[1]) > 0 else 0)
if __name__ == "__main__":
z = Zookeeper()
z.set_device_ignition(1 if int(sys.argv[1]) > 0 else 0)

@ -3,12 +3,14 @@
import time
from tools.zookeeper import Zookeeper
z = Zookeeper()
z.set_device_power(True)
i = 0
ign = False
while 1:
if __name__ == "__main__":
z = Zookeeper()
z.set_device_power(True)
i = 0
ign = False
while 1:
voltage = round(z.read_voltage(), 2)
current = round(z.read_current(), 3)
power = round(z.read_power(), 2)

Loading…
Cancel
Save