[Tfug] Language wars ( was Language choices )
Ronald Sutherland
rsutherland at epccs.com
Fri Nov 3 21:27:00 MST 2006
Damd .. I like it .. thanks for the idea, also a ipmi.write() that needs
to make a byte list form a string .. crap now I have to change some test
programs and sneak it in under some unrelated change notice .. I'm
kidding on the last bit BTW.
IPMI is a standard by Intel for communication between chips or devices
related to mother boards, it includes power supplies and a lot of stuff
I did not bother to read about.
I2C is a electrical communication bus standard first released by
Philips, its actually very odd .. past 17 years.
The conversion value is a constant held by the IPMI device, it is used
to convert a digital to analog (DAC) reading into a real world value. In
this case Amps. So if I want to know how much current my motherboard's
power supply is providing
ipmi_atx = IPMI(ATX_I2C_ADDR)
ipmi_atx.write(READ12V_I_CONV) # command to read convention value for
12V source current.
current_convention = float(ipmi_atx.read())
ipmi_atx.write(READ12V_I)
current = int(ipmi_atx.read()) * current_convention
The conversion value is stuffed in the device by manufacture. As a EE
I'm mostly tempted to type I in place of current since that is the
normal way its show, but is the ISO auditor or customer gonna get it...
hmm... I'd hope the customer would, but thats because I'm expecting
buyers of power supply's to know something about them and why should
that be true? And just in case it confuses ATX is type of power supply
in my PC .. its just a random association. Also EE's should use I'd and
I'm when using I for current .. another random idea, but not so good.
Stephen Hooper wrote:
> On 11/3/06, Tim Ottinger <tottinge at gmail.com> wrote:
>
>>> ByteList = readIPMI(4)
>>> IConv = struct.unpack('f',struct.pack('BBBB', ByteList[3], ByteList[2],
>>> ByteList[1], ByteList[0]))[0]
>>>
>> Right. Better to have that buried in a named function (explanatory
>> function).
>> Maybe "current_conversion_value = power_supply.current_conversion_value();"
>>
>>
>>
>
> Seems like it would make a nice class:
>
> class IPMI:
> def init(self,hwaddr,word = ""):
> self.__hwaddr = hwaddr
> self.__word = word
>
> def read(self):
> bytes = # do read from hardware
> word = "".join([chr(byte) for byte in reversed(bytes)]
> return IPMI(self.__hwaddr,word)
>
> def __float__(self):
> return struct.unpack("f",self.__word))[0]
>
> def __int__(self):
> return struct.unpack("L",self.__word))[0]
>
> def __hex__(self):
> return long.__hex__(self,int(self))
>
> ... etc ..
>
> Then you could just do:
>
> ipmi1 = IPMI(foo_addr)
> IConv = float(ipmi.read())
>
> Or even make it iteratable...
>
> _______________________________________________
> Tucson Free Unix Group - tfug at tfug.org
> Subscription Options:
> http://www.tfug.org/mailman/listinfo/tfug_tfug.org
>
>
More information about the tfug
mailing list