[PATCH skeleton] skeleton: fixed hard-coding for master OCC hwmon sysfs path
Andrew Jeffery
andrew at aj.id.au
Mon Feb 22 22:19:45 AEDT 2016
Hi Yi Li,
On Mon, 2016-02-22 at 08:42 +0000, Yi TZ Li wrote:
> Hi Andrew,
>
> Thank you for the comment.
>
> After some thoughts I would like to abandon this patch, since
> sensor_manager2.py will be invoked before OCC becomes active.
> So searching hwmon sysfs for "user_powercap" attribute will always
> fail, since only after OCC becomes active, the OCC hwmon sysfs
> attributes can be created.
>
> I will resubmit a patch.
>
> For your comments, please see bellow:
>
> -----"openbmc" <openbmc-bounces+shliyi=cn.ibm.com at lists.ozlabs.org> wrote: -----
>
> >To: OpenBMC Patches <openbmc-patches at stwcx.xyz>,
> >openbmc at lists.ozlabs.org
> >From: Andrew Jeffery
> >Sent by: "openbmc"
> >Date: 02/22/2016 09:33AM
> >Subject: Re: [PATCH skeleton] skeleton: fixed hard-coding for master
> >OCC hwmon sysfs path
> >
> >Hi Yi Li,
> >
> >On Fri, 2016-02-19 at 13:10 -0600, OpenBMC Patches wrote:
> >> From: Yi Li <adamliyi at msn.com>
> >>
>
> >> > > obj_path = OBJ_PATH+"/host/PowerCap"
> >> > > sensor_obj = Sensors.PowerCap(bus,obj_path)
> >> -> > ## hwmon3 is default for master OCC on Barreleye.
> >> -> > ## should rewrite sensor_manager to remove hardcode
> >> -> > sensor_obj.sysfs_attr =
> >"/sys/class/hwmon/hwmon3/user_powercap"
> >> +> > ## scan hwmon sysfs for master occ's user_powercap attribute
> >> +> > for pcap_file in
> >glob.glob('/sys/class/hwmon/*/user_powercap'):
> >> +> > > occ_i2c_dev = os.path.dirname(pcap_file)+'/device'
> >> +> > > occ_i2c_dev =
> >os.path.realpath(occ_i2c_dev).split('/').pop()
> >> +> > > # master OCC address
> >> +> > > if occ_i2c_dev == '3-0050':
> >> +> > > > sensor_obj.sysfs_attr = pcap_file
> >
> >Have you tested the code in the for loop? Because running the body in
> >a
> >Python shell doesn't give me confidence the if-condition will ever be
> >satisfied:
> >
>
> The skeleton creates sensors in the order following BMC states, see
> Barreleye.py.
> When I did test, I manually booted the host. But when obmc actually
> boots, sensor_manger2.py will be invoked before OCC becomes active.
> "glob.glob()" search will return empty list.
>
> I will need to fix this.
>
> > andrew at keelia :~$ python
> > Python 2.7.10 (default, Oct 14 2015, 16:09:02)
> > [GCC 5.2.1 20151010] on linux2
> > Type "help", "copyright", "credits" or "license" for more
> >information.
> > >>> import os
> > >>> pcap_file = "/sys/class/hwmon/hwmon3/user_powercap"
> >>>> os.path.dirname(pcap_file)+"/device"
> >'/sys/class/hwmon/hwmon3/device'
> >>>> os.path.realpath(_).split('/')
> >['', 'sys', 'class', 'hwmon', 'hwmon3', 'device']
> >>>> _.pop()
> >'device'
> >>>>
> >
> >I can't see how occ_i2c_dev will ever take the value '3-0050'? Are we
> >missing additional globbing and/or reading of files?
> >
>
> "os.path.realpath()" will resolve the symbol link to real file path,
> e.g:"/sys/class/hwmon3/device", the real path will be
> e.g:"/sys/class/i2c-adaptor/... ... /3-0050".
Ah, yes - thanks for the gentle to read the docs before opening my
mouth!
>
> >> root_sensor.add(obj_path,sensor_obj)
> >
> >Have you given consideration to what should be done if the
> >if-condition
> >in the for loop above never fires? Is it still valid to add
> >sensor_obj?
> >
>
> Yes. In Sensor.py, I assigned a default path to "sysfs_attr"
>
> "CONTROL_IFACE = 'org.openbmc.Control'
> class PowerCap(VirtualSensor):
> def __init__(self, bus, name):
> VirtualSensor.__init__(self, bus, name)
> SensorValue.setValue(self, 0)
> self.sysfs_attr = "/sys/class/hwmon/hwmon3/user_powercap"
> "
No worries. I'm still coming up to speed with the codebase(s), so
thanks for taking the time to respond.
Andrew
>
> Thanks,
> -Yi
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160222/f614dd24/attachment.sig>
More information about the openbmc
mailing list