summaryrefslogtreecommitdiff
path: root/ebustest.py
diff options
context:
space:
mode:
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()