![](/img/trans.png)
[英]How to let linux(raspberry) run python script when plugin power?
[英]Check from Python script Raspberry´s power status
是否有与屏幕上的黄色闪电或红色 PWR LED 闪烁的等效项,可以从 Python 脚本中使用它来了解 Raspberry 是否存在电源问题?
谢谢!
在@MarkSetchell 的帮助下(谢谢!),这是有效的。 我已经在 RPI 3B+ 上对其进行了测试,但存在一些电源问题:
import subprocess
pt = subprocess.Popen(['/opt/vc/bin/vcgencmd', 'get_throttled'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
(res,err) = pt.communicate()
res = res.decode().split("=")[1]
res = res.rstrip("\n")
print ("Current Power Issues? = ",(int(res,0) & 0x01) == 0x01)
print ("Any Power issues before? = ",(int(res,0) & 0x50000) == 0x50000)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.