diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-05-28 18:41:04 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-06-10 18:06:59 -0400 |
commit | 40a360c2a4feef97a8f7041e655b2a42e51e0224 (patch) | |
tree | 75dfea3064d7c3243788c72cb9f30e2ce6241dea /pyipmitest | |
parent | a73122191a7aba80f97332687a2e03cfb0336981 (diff) | |
download | talos-skeleton-40a360c2a4feef97a8f7041e655b2a42e51e0224.tar.gz talos-skeleton-40a360c2a4feef97a8f7041e655b2a42e51e0224.zip |
Reorganize directory structure
Moving to directory per-application layout. This facilitates
building single applications which is useful in the Yocto build
environment since different applications satisfy different OpenBMC
build requirements.
A number of issues are also addressed:
- All applications were pulling in libsystemd and the gdbus libs
irrespective of whether or not they were needed.
- gpio.o duplicated in every application - moved to libopenbmc_intf
- Added install target
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'pyipmitest')
l--------- | pyipmitest/Makefile | 1 | ||||
-rw-r--r-- | pyipmitest/ipmi_debug.py | 99 | ||||
l--------- | pyipmitest/setup.cfg | 1 | ||||
-rw-r--r-- | pyipmitest/setup.py | 6 |
4 files changed, 107 insertions, 0 deletions
diff --git a/pyipmitest/Makefile b/pyipmitest/Makefile new file mode 120000 index 0000000..76a90fc --- /dev/null +++ b/pyipmitest/Makefile @@ -0,0 +1 @@ +../Makefile.python
\ No newline at end of file diff --git a/pyipmitest/ipmi_debug.py b/pyipmitest/ipmi_debug.py new file mode 100644 index 0000000..0fc6a86 --- /dev/null +++ b/pyipmitest/ipmi_debug.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python + +import sys +import subprocess +import dbus +import string +import os +import fcntl +import glib +import gobject +import dbus.service +import dbus.mainloop.glib + +DBUS_NAME = 'org.openbmc.HostIpmi' +OBJ_NAME = '/org/openbmc/HostIpmi/1' + +def header(seq, netfn, lun, cmd): + return ( + 'seq: 0x%02x\nnetfn: 0x%02x\n\nlun: 0x%02d\ncmd: 0x%02x\n') % ( + seq, netfn, lun, cmd) + + +def print_request(seq, netfn, lun, cmd, data): + str = header(seq, netfn, lun, cmd) + str += 'data: [%s]' % ', '.join(['0x%02x' % x for x in data]) + print str + +def print_response(seq, netfn, lun, cmd, cc, data): + str = header(seq, netfn, lun, cmd) + str += 'cc: 0x%02x\ndata: [%s]' % ( + cc, ', '.join(['0x%02x' % x for x in data]) + ) + print str + +class IpmiDebug(dbus.service.Object): + def __init__(self,bus,name): + dbus.service.Object.__init__(self,bus,name) + + @dbus.service.signal(DBUS_NAME, "yyyyay") + def ReceivedMessage(self, seq, netfn, lun, cmd, data): + print "IPMI packet from host:" + print_request(seq, netfn, lun, cmd, data) + + @dbus.service.method(DBUS_NAME, "yyyyyay", "x") + def sendMessage(self, seq, netfn, lun, cmd, ccode, data): + print "IPMI packet sent to host:" + print_response(seq, netfn, lun, cmd, ccode, data) + return 0 + + @dbus.service.method(DBUS_NAME) + def setAttention(self): + print "IPMI SMS_ATN set" + +class ConsoleReader(object): + def __init__(self, ipmi_obj): + self.buffer = '' + self.seq = 0 + self.ipmi_obj = ipmi_obj + flags = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL) + flags |= os.O_NONBLOCK + fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, flags) + glib.io_add_watch(sys.stdin, glib.IO_IN, self.io_callback) + + def io_callback(self, fd, condition): + chunk = fd.read() + for char in chunk: + self.buffer += char + if char == '\n': + self.line(self.buffer) + self.buffer = '' + + return True + + def line(self, data): + s = data.split(' ') + if len(s) < 2: + print "Not enough bytes to form a valid IPMI packet" + return + try: + data = [int(c, 16) for c in s] + except ValueError: + return + self.seq += 1 + self.ipmi_obj.ReceivedMessage(self.seq, data[0], 0, data[1], data[2:]) + +def main(): + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + bus = dbus.SystemBus() + name = dbus.service.BusName(DBUS_NAME, bus) + obj = IpmiDebug(bus, OBJ_NAME) + mainloop = gobject.MainLoop() + r = ConsoleReader(obj) + + print ("Enter IPMI packet as hex values. First three bytes will be used" + "as netfn and cmd.\nlun will be zero.") + mainloop.run() + +if __name__ == '__main__': + sys.exit(main()) diff --git a/pyipmitest/setup.cfg b/pyipmitest/setup.cfg new file mode 120000 index 0000000..29939b5 --- /dev/null +++ b/pyipmitest/setup.cfg @@ -0,0 +1 @@ +../setup.cfg
\ No newline at end of file diff --git a/pyipmitest/setup.py b/pyipmitest/setup.py new file mode 100644 index 0000000..37957b8 --- /dev/null +++ b/pyipmitest/setup.py @@ -0,0 +1,6 @@ +from distutils.core import setup + +setup(name='pyipmitest', + version='1.0', + scripts=['ipmi_debug.py'], + ) |