Commit 9165ab6e authored by Mikhail Karpenko's avatar Mikhail Karpenko

Check 10389 presence in tempmon

parent 5c39c2aa
...@@ -62,6 +62,7 @@ class temp_monitor(): ...@@ -62,6 +62,7 @@ class temp_monitor():
out_path_prefix, out_fnames): out_path_prefix, out_fnames):
self.is_fan_on = False self.is_fan_on = False
self.is_vp5_enabled = False self.is_vp5_enabled = False
self.is_10389_present = True
self.ctrl_path_prefix = ctrl_path_pref self.ctrl_path_prefix = ctrl_path_pref
self.ctrl_fnames = ctrl_file_names self.ctrl_fnames = ctrl_file_names
self.hwmon_path_prefix = hwmon_path_pref self.hwmon_path_prefix = hwmon_path_pref
...@@ -107,13 +108,16 @@ class temp_monitor(): ...@@ -107,13 +108,16 @@ class temp_monitor():
return False return False
for key, val in self.ctrl_fnames.items(): for key, val in self.ctrl_fnames.items():
if not os.access(self.ctrl_path_prefix + val, F_OK): if not os.access(self.ctrl_path_prefix + val, F_OK):
if key == "gpio_fn":
self.is_10389_present = False
else:
print "Failed to open sysfs file: '%s%s'" % (self.ctrl_path_prefix, val) print "Failed to open sysfs file: '%s%s'" % (self.ctrl_path_prefix, val)
return False return False
return True return True
def shutdown(self): def shutdown(self):
""" """
Turn system off. This function will be called continuously until the system is turn off. Turn system off. This function will be called continuously until the system is turned off.
""" """
subprocess.call(["/sbin/shutdown", "-hP", "now"]) subprocess.call(["/sbin/shutdown", "-hP", "now"])
...@@ -123,20 +127,26 @@ class temp_monitor(): ...@@ -123,20 +127,26 @@ class temp_monitor():
@param ctrl: can be "on" or "off" to turn fan on or off @param ctrl: can be "on" or "off" to turn fan on or off
""" """
if ctrl is "on": if ctrl is "on":
with open(self.ctrl_path_prefix + self.ctrl_fnames["vp5_en_fn"], "r+") as f:
""" check if +5V is active and turn it on if it is not (it should not happen) """ """ check if +5V is active and turn it on if it is not (it should not happen) """
with open(self.ctrl_path_prefix + self.ctrl_fnames["vp5_en_fn"], "r+") as f:
channels = f.read() channels = f.read()
if channels.find("vp5") == -1: if channels.find("vp5") == -1:
f.write("vp5") f.write("vp5")
f.flush() f.flush()
if self.is_10389_present:
with open(self.ctrl_path_prefix + self.ctrl_fnames["gpio_fn"], 'w') as f: with open(self.ctrl_path_prefix + self.ctrl_fnames["gpio_fn"], 'w') as f:
f.write(self.fan_cmd["fan_cmd_on"]) f.write(self.fan_cmd["fan_cmd_on"])
f.flush() f.flush()
self.is_fan_on = True self.is_fan_on = True
elif ctrl is "off": elif ctrl is "off":
if self.is_10389_present:
with open(self.ctrl_path_prefix + self.ctrl_fnames["gpio_fn"], 'w') as f: with open(self.ctrl_path_prefix + self.ctrl_fnames["gpio_fn"], 'w') as f:
f.write(self.fan_cmd["fan_cmd_off"]) f.write(self.fan_cmd["fan_cmd_off"])
f.flush() f.flush()
else:
with open(self.ctrl_path_prefix + self.ctrl_fnames["vp5_dis_fn"], 'w') as f:
f.write("vp5")
f.flush()
self.is_fan_on = False self.is_fan_on = False
else: else:
print "'%s': unrecognized command: '%s'" % (__name__, ctrl) print "'%s': unrecognized command: '%s'" % (__name__, ctrl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment