Files
sunnypilot/selfdrive/debug/internal/sounds/test_sound_stability.py
Adeeb Shihadeh 312b681a46 cereal cleanup part 2 (#20092)
* car stuff

* thermal

* Revert "car stuff"

This reverts commit 77fd1c65ebd01abfa8493ae12c9e6b14f7ada976.

* panda state

* camera stuff

* start deg

* most is building

* builds

* planner + controls run

* fix up paramsd

* cleanup

* process replay passes

* fix webcam build

* camerad

* no more frame

* thermald

* ui

* paramsd

* camera replay

* fix long tests

* fix camerad tests

* maxSteeringAngle

* bump cereal

* more frame

* cereal master
2021-02-16 21:39:32 -08:00

46 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import subprocess
import time
import datetime
import random
from common.basedir import BASEDIR
import cereal.messaging as messaging
if __name__ == "__main__":
sound_dir = os.path.join(BASEDIR, "selfdrive/assets/sounds")
sound_files = [f for f in os.listdir(sound_dir) if f.endswith(".wav")]
play_sound = os.path.join(BASEDIR, "selfdrive/ui/test/play_sound")
print("disabling charging")
os.system('echo "0" > /sys/class/power_supply/battery/charging_enabled')
os.environ["LD_LIBRARY_PATH"] = ""
sm = messaging.SubMaster(["deviceState"])
FNULL = open(os.devnull, "w")
start_time = time.time()
while True:
volume = 15
n = random.randint(5, 10)
procs = []
for _ in range(n):
sound = random.choice(sound_files)
p = subprocess.Popen([play_sound, os.path.join(sound_dir, sound), str(volume)], stdout=FNULL, stderr=FNULL)
procs.append(p)
time.sleep(random.uniform(0, 0.75))
time.sleep(random.randint(0, 5))
for p in procs:
p.terminate()
sm.update(0)
s = time.time() - start_time
hhmmss = str(datetime.timedelta(seconds=s)).split(".")[0]
print("test duration:", hhmmss)
print("\tbattery percent", sm["deviceState"].batteryPercent)