簡體   English   中英

從 Python 腳本中檢查 Raspberry 的電源狀態

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM