@@ -11,11 +11,11 @@ class Vcgencmd:
11
11
def __init__ (self ):
12
12
# TODO: add a "vcgencmd run" check and first time its called we should check what commands are supported
13
13
# TODO: allow specifying where vcgencmd lives.
14
- pass
14
+ self . vcgen_command = "vcgencmd"
15
15
16
16
def get_cpu_temp (self , fahrenheit = False ):
17
17
"""Get the cpu temperature of the soc, optionally request output in fahrenheit"""
18
- lines = subprocess .check_output (["vcgencmd" , "measure_temp" ])
18
+ lines = subprocess .check_output ([self . vcgen_command , "measure_temp" ])
19
19
temp = float (self ._parse_lines (lines )['temp' ][:- 2 ])
20
20
21
21
if fahrenheit :
@@ -26,8 +26,8 @@ def get_cpu_temp(self, fahrenheit=False):
26
26
def get_ram_split (self ):
27
27
"""Get the ram split between cpu/gpu this returns a dict"""
28
28
29
- lines_arm = subprocess .check_output (["vcgencmd" , "get_mem" , "arm" ])
30
- lines_gpu = subprocess .check_output (["vcgencmd" , "get_mem" , "gpu" ])
29
+ lines_arm = subprocess .check_output ([self . vcgen_command , "get_mem" , "arm" ])
30
+ lines_gpu = subprocess .check_output ([self . vcgen_command , "get_mem" , "gpu" ])
31
31
arm = self ._parse_lines (lines_arm )['arm' ]
32
32
gpu = self ._parse_lines (lines_gpu )['gpu' ]
33
33
return {
@@ -39,7 +39,7 @@ def measure_volts(self, type="core"):
39
39
"""Measures the volts on parts of the chip"""
40
40
41
41
if type in ["core" , "sdram_c" , "sdram_i" , "sdram_p" ]:
42
- lines = subprocess .check_output (["vcgencmd" , "measure_volts" , type ])
42
+ lines = subprocess .check_output ([self . vcgen_command , "measure_volts" , type ])
43
43
data = self ._parse_lines (lines )
44
44
return float (data ['volt' ][:- 1 ])
45
45
else :
@@ -48,27 +48,27 @@ def measure_volts(self, type="core"):
48
48
def measure_clock (self , type ):
49
49
"""Returns the clock speed in Hz of various parts of the chip"""
50
50
if type in ["arm" , "core" , "h264" , "isp" , "v3d" , "uart" , "pwm" , "emmc" , "pixel" , "vec" , "hdmi" , "dpi" ]:
51
- line = subprocess .check_output (["vcgencmd" , "measure_clock" , type ])
51
+ line = subprocess .check_output ([self . vcgen_command , "measure_clock" , type ])
52
52
return self ._parse_line_get_value (line )
53
53
else :
54
54
raise ValueError ("Type must be on of arm, core, h264, isp, v3d, uart, pwm, emmc, pixel, vec, hdmi, dpi" )
55
55
56
56
def is_codec_available (self , codec ):
57
57
"""Returns whether the codec is available on the Raspberry Pi"""
58
58
if codec in ["H264" , "MPG2" , "WVC1" , "MPG4" , "MJPG" , "WMV9" ]:
59
- line = subprocess .check_output (["vcgencmd" , "codec_enabled" , codec ])
59
+ line = subprocess .check_output ([self . vcgen_command , "codec_enabled" , codec ])
60
60
return (self ._parse_line_get_value (line ) == "enabled" )
61
61
else :
62
62
raise ValueError ("Codec must be one of H264, MPG2, WVC1, MPG4, MJPG, WMV9" )
63
63
64
64
def get_version (self ):
65
65
"""Gets the version string of the firmware"""
66
- return subprocess .check_output (["vcgencmd" , "version" ]).decode ("utf-8" ).rstrip ()
66
+ return subprocess .check_output ([self . vcgen_command , "version" ]).decode ("utf-8" ).rstrip ()
67
67
68
68
def set_display_power (self , power ):
69
69
"""Sets the display power of the Raspberry Pi, warning setting this to 0 will disable video output"""
70
70
if power in [0 , 1 ]:
71
- subprocess .check_output (["vcgencmd" , "display_power" , str (power )])
71
+ subprocess .check_output ([self . vcgen_command , "display_power" , str (power )])
72
72
else :
73
73
raise ValueError ("Power must be either 0 or 1" )
74
74
0 commit comments