From 6c70cfa0ce3a9843e9865ed5aff7766f634c21dc Mon Sep 17 00:00:00 2001 From: George Hotz Date: Wed, 20 Apr 2022 12:15:11 -0700 Subject: [PATCH] precise power measurement script old-commit-hash: 3b2421baa04be3e2408e5177248a31689c244107 --- .../hardware/tici/precise_power_measure.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 selfdrive/hardware/tici/precise_power_measure.py diff --git a/selfdrive/hardware/tici/precise_power_measure.py b/selfdrive/hardware/tici/precise_power_measure.py new file mode 100755 index 0000000000..f1fb254b26 --- /dev/null +++ b/selfdrive/hardware/tici/precise_power_measure.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +import numpy as np +from common.realtime import Ratekeeper + +if __name__ == '__main__': + RATE = 123 + print("measuring for 5 seconds at %dhz 3 times" % RATE) + rk = Ratekeeper(RATE, print_delay_threshold=None) + + for _ in range(3): + pwrs = [] + for _ in range(RATE*5): + with open("/sys/bus/i2c/devices/0-0040/hwmon/hwmon1/power1_input") as f: + pwrs.append(int(f.read()) / 1000.) + rk.keep_time() + print("mean %.2f std %.2f" % (np.mean(pwrs), np.std(pwrs))) +