Skip to content

Instantly share code, notes, and snippets.

@raumi75
Created February 14, 2023 15:46
Show Gist options
  • Save raumi75/f4614ed9e0b8f9fec71e0d55e7862048 to your computer and use it in GitHub Desktop.
Save raumi75/f4614ed9e0b8f9fec71e0d55e7862048 to your computer and use it in GitHub Desktop.
Output vcgencmd get_throttled in human readable form for raspberrypi
#!/bin/bash
# Based on
# https://github.com/mschlenstedt/Loxberry/issues/952#issuecomment-496220904
# extended SOFT_TEMP_LIMIT
#Flag Bits
UNDERVOLTED=0x1
CAPPED=0x2
THROTTLED=0x4
SOFT_TEMP_LIMIT=0x8
HAS_UNDERVOLTED=0x10000
HAS_CAPPED=0x20000
HAS_THROTTLED=0x40000
HAS_SOFT_TEMP_LIMIT=0x80000
#Text Colors
GREEN=`tput setaf 2`
RED=`tput setaf 1`
NC=`tput sgr0`
#Output Strings
GOOD="${GREEN}NO${NC}"
BAD="${RED}YES${NC}"
#Get Status, extract hex
STATUS=$(vcgencmd get_throttled)
STATUS=${STATUS#*=}
echo -n "Status: "
(($STATUS!=0)) && echo "${RED}${STATUS}${NC}" || echo "${GREEN}${STATUS}${NC}"
echo "Undervolted:"
echo -n " Now: "
((($STATUS&UNDERVOLTED)!=0)) && echo "${BAD}" || echo "${GOOD}"
echo -n " Run: "
((($STATUS&HAS_UNDERVOLTED)!=0)) && echo "${BAD}" || echo "${GOOD}"
echo "Throttled:"
echo -n " Now: "
((($STATUS&THROTTLED)!=0)) && echo "${BAD}" || echo "${GOOD}"
echo -n " Run: "
((($STATUS&HAS_THROTTLED)!=0)) && echo "${BAD}" || echo "${GOOD}"
echo "Frequency Capped:"
echo -n " Now: "
((($STATUS&CAPPED)!=0)) && echo "${BAD}" || echo "${GOOD}"
echo -n " Run: "
((($STATUS&HAS_CAPPED)!=0)) && echo "${BAD}" || echo "${GOOD}"
echo "Soft Temp Limit :"
echo -n " Now: "
((($STATUS&SOFT_TEMP_LIMIT)!=0)) && echo "${BAD}" || echo "${GOOD}"
echo -n " Run: "
((($STATUS&HAS_SOFT_TEMP_LIMIT)!=0)) && echo "${BAD}" || echo "${GOOD}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment