blob: 87dc7a916f3a13a962e21c00980f7dd31d21edf0 [file] [log] [blame]
Norman James0ca72fb2015-11-10 10:39:36 -06001#!/usr/bin/python -u
2
3import sys
4#from gi.repository import GObject
5import gobject
6import dbus
7import dbus.service
8import dbus.mainloop.glib
9import Openbmc
10
11DBUS_NAME = 'org.openbmc.control.Fans'
12OBJ_PATH = '/org/openbmc/control/fans'
13IFACE_NAME = 'org.openbmc.control.Fans'
14
15FAN_BUS = 'org.openbmc.sensors.hwmon'
16FAN_OBJS = [
17 '/org/openbmc/sensors/speed/fan1',
18 '/org/openbmc/sensors/speed/fan2',
19 '/org/openbmc/sensors/speed/fan3',
20 '/org/openbmc/sensors/speed/fan4',
21 '/org/openbmc/sensors/speed/fan5',
22 '/org/openbmc/sensors/speed/fan6',
23]
24FAN_IFACE = 'org.openbmc.SensorValue'
25
26class FanControl(Openbmc.DbusProperties):
27 def __init__(self,bus,name):
28 Openbmc.DbusProperties.__init__(self)
29 dbus.service.Object.__init__(self,bus,name)
30 self.ObjectAdded(name,IFACE_NAME)
31 self.Set(IFACE_NAME,"floor",250)
32 self.Set(IFACE_NAME,"ceiling",255)
33 self.fan_intf = []
34 ## create interface proxies to all fans
35 for fan in FAN_OBJS:
36 print "Initializing fan: "+fan
37 obj = bus.get_object(FAN_BUS,fan)
38 fan_intf.append(dbus.Interface(obj,FAN_IFACE))
39
40 def setMax(self):
41 print "Setting fans to max"
42 for intf in self.fan_intf:
43 intf.setValue(dbus.UInt32(255))
44
45
46if __name__ == '__main__':
47
48 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
49 bus = Openbmc.getDBus()
50 name = dbus.service.BusName(DBUS_NAME,bus)
51 fan_control = FanControl(bus,OBJ_PATH)
52 mainloop = gobject.MainLoop()
53
54 print "Starting fan control"
55 fan_control.setMax()
56 mainloop.run()
57