summaryrefslogtreecommitdiff
path: root/ebustest.py
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2010-03-27 12:34:09 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2010-03-27 12:34:09 +0000
commit94af8fbd907d32e5d95ef94ad0761945584c7472 (patch)
tree53dee86cf818f6f9aade5f31dd496906ede6aa39 /ebustest.py
parent66c211aa30bbdec61db3a45eaf0ffbc2a8cf70f8 (diff)
downloadebus-alt-94af8fbd907d32e5d95ef94ad0761945584c7472.tar.gz
ebus-alt-94af8fbd907d32e5d95ef94ad0761945584c7472.zip
bla
git-svn-id: http://10.2.2.13/svn/common/ebus@1612 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
Diffstat (limited to 'ebustest.py')
-rw-r--r--ebustest.py57
1 files changed, 15 insertions, 42 deletions
diff --git a/ebustest.py b/ebustest.py
index 908e2da..30bce73 100644
--- a/ebustest.py
+++ b/ebustest.py
@@ -177,43 +177,8 @@ class EbusBroadcast(EbusPacket):
self.length = len(data)
self.data = data
-class EbusService():
- def __init__(self,p):
- self.p = p
- def convertData2c(data):
-
- # low nibble x&0xf
- # high nibble x>>4
- """Beispiel für die Berechnung:
- if ((x & 8000h) == 8000h) // y negativ
- y = - [dez(High_Byte(!x)) 16 + dez(High_Nibble (Low_Byte (!x)))
- + (dez(Low_Nibble (Low_Byte (!x))) +1 ) / 16]
- else // y positiv
- y = dez(High_Byte(x)) 16 + dez(High_ Nibble (Low Byte (x)))
- + dez(Low_ Nibble (Low Byte (x))) / 16
- """
- #print "%s" % (formatHex(data))
- highByte = ord(data[1])
- lowByte = ord(data[0])
-
- if (0):
- #return (!highByte)*16 + (!lowByte)>>4 + (((!lowByte)&0xf)+1)/16.0
- return 0
- else:
- return highByte*16 + (lowByte>>4) + (lowByte&0xf)/16.0
-
-class EbusService5017(EbusService):
- def __init__(self,p):
- EbusPacket.__init__(self,p)
- self.parsePayload()
- def parsePayload(self):
- self.solar_pumpe = ord(p.payload[0])
- self.collektor_temperature = convertData2c(p.payload[2:4])
- self.warmwasser_temperature = convertData2c(p.payload[4:6])
- def __str__(self):
- return "Solarpumpe: %d Kollektor: %.1f°C Solarwarmwaser %.1f°C" % (self.solar_pumpe, self.collektor_temperature, self.warmwater_temperature)
-class Fetcher(asynchat.async_chat):
+class EbusReader(asynchat.async_chat):
def __init__(self):
self.buffer = ""
@@ -269,18 +234,26 @@ class Fetcher(asynchat.async_chat):
p = None
if sourceDevice[0]['type'] == 'master' and destinationDevice[0]['type'] == 'master':
p = EbusMasterMaster(source, destination, primaryCommand, secondaryCommand, payload)
- #print "payload=%s" % formatHex(payload)
+ self.handle_ebus(p)
elif sourceDevice[0]['type'] == 'master' and destinationDevice[0]['type'] == 'slave':
- p = EbusMasterSlave(source, destination, primaryCommand, secondaryCommand, payload, None)
- ###print "payload=%s" % formatHex(payload)
+ p = EbusMasterSlave(source, destination, primaryCommand, secondaryCommand, payload, None) #FIXME
+ self.handle_ebus(p)
elif sourceDevice[0]['type'] == 'master' and destinationDevice[0]['type'] == 'broadcast':
p = EbusBroadcast(source, destination, primaryCommand, secondaryCommand, payload)
+ self.handle_ebus(p)
else:
print "KOMISCHES ZEUG"
return
- if p and p.values() != dict():
- print p
+ def handle_ebus(self,ebus_packet):
+ print "unhandled ebus_packet"
+
+
+
+class MyEbusReader(EbusReader):
+ def handle_ebus(self,ebus_packet):
+ if ebus_packet.values() != dict():
+ print ebus_packet
-Fetcher()
+MyEbusReader()
asyncore.loop()