summaryrefslogtreecommitdiff
path: root/test.py
blob: 292ac423f58113ce6737c24ed3d022c0387933bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env python2.5
import os
from lxml import objectify
from lxml import etree
class EbusProtocol:
    doc = objectify.parse(open(
            os.path.join( os.path.dirname(__file__), "ebus/ebus_specification.xml")))

    @staticmethod
    def get_packet(primary, secondary):
        return (EbusProtocol.doc.xpath("/ebus/packets/packet[@primary=$primary and @secondary=$secondary]",
            primary=primary,secondary=secondary) or [None])[0]

p=EbusProtocol.get_packet("0x05","0x07")
for field in p.fields.iterchildren():
    print field.tag,field.get("name"), "l"