Skip to content

Commit c748d99

Browse files
committed
🐛 Fix buggy vcgencmd output handling
1 parent e3ed297 commit c748d99

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

octoprint_pi_support/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,20 @@ def get_proc_dt_model():
189189
def get_vcgencmd_throttled_state(command):
190190
if __LOCAL_DEBUG:
191191
if _VCGENCMD_BROKEN:
192-
output = "VCHI initialization failed"
192+
output = ""
193+
error = "VCHI initialization failed"
193194
else:
194195
output = "throttled={}".format(
195196
next(_VCGENCMD_OUTPUT)
196197
) # mock for local debugging
198+
error = ""
197199
else:
198-
output = sarge.get_both(command, close_fds=CLOSE_FDS)
200+
output, error = sarge.get_both(command, close_fds=CLOSE_FDS)
199201

200202
if "throttled=0x" not in output:
201-
raise ValueError('Cannot parse "{}" output: {}'.format(command, output))
203+
raise ValueError(
204+
'Cannot parse "{}" output: {}'.format(command, error if error else output)
205+
)
202206

203207
value = output[len("throttled=") :].strip(" \t\r\n\0")
204208
value = int(value, 0)

0 commit comments

Comments
 (0)