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):
print "Failed to open sysfs file: '%s%s'" % (self.ctrl_path_prefix, val) if key == "gpio_fn":
return False self.is_10389_present = False
else:
print "Failed to open sysfs file: '%s%s'" % (self.ctrl_path_prefix, val)
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":
""" 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: 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) """
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()
with open(self.ctrl_path_prefix + self.ctrl_fnames["gpio_fn"], 'w') as f: if self.is_10389_present:
f.write(self.fan_cmd["fan_cmd_on"]) with open(self.ctrl_path_prefix + self.ctrl_fnames["gpio_fn"], 'w') as f:
f.flush() f.write(self.fan_cmd["fan_cmd_on"])
f.flush()
self.is_fan_on = True self.is_fan_on = True
elif ctrl is "off": elif ctrl is "off":
with open(self.ctrl_path_prefix + self.ctrl_fnames["gpio_fn"], 'w') as f: if self.is_10389_present:
f.write(self.fan_cmd["fan_cmd_off"]) with open(self.ctrl_path_prefix + self.ctrl_fnames["gpio_fn"], 'w') as f:
f.flush() f.write(self.fan_cmd["fan_cmd_off"])
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