summaryrefslogtreecommitdiff
path: root/ebustest.py
diff options
context:
space:
mode:
Diffstat (limited to 'ebustest.py')
-rw-r--r--ebustest.py51
1 files changed, 37 insertions, 14 deletions
diff --git a/ebustest.py b/ebustest.py
index e9b7d2e..d6f84fd 100644
--- a/ebustest.py
+++ b/ebustest.py
@@ -3,7 +3,7 @@ import asynchat
import asyncore
import socket
import sys
-import json
+#import json
# Master-Master
# 1 quell
# 1 ziel
@@ -36,12 +36,21 @@ deviceDescription = [
{'address':0xf1, 'type':'master', 'description':'Heizungsregler #10'},
{'address':0x50, 'type':'slave', 'description':'Mischer 1'},
{'address':0x51, 'type':'slave', 'description':'Mischer 2'},
+ {'address':0x90, 'type':'slave', 'description':'Raumgeräte/Fernsteller 1'},
+ {'address':0x90, 'type':'slave', 'description':'Raumgeräte/Fernsteller 2'},
{'address':0xfe, 'type':'broadcast', 'description':'Broadcast'},
]
packetDescription = [
- {'primary':0x7, 'secondary':0x9, 'name':'UNKNOWN'},
- {'primary':0x14, 'secondary':0x7, 'name':'UNKNOWN'},
+ # Service 0x05 (Brennersteuerbefehle)
+ {'primary':0x5, 'secondary':0x3, 'name':'Betriebsdaten des Feuerungsautomaten an den Regler Block1'},
+ {'primary':0x5, 'secondary':0x7, 'name':'Betriebsdaten des Reglers an den Feuerungsautomaten'},
+ # Service 0x07 (Systemdatenbefehle)
+ {'primary':0x7, 'secondary':0x0, 'name':'Datum/Zeit - Meldung eines eBUS Masters'},
+ {'primary':0x7, 'secondary':0x4, 'name':'Identifikation'},
+ # Service 0x08 (Reglerbefehle)
+ {'primary':0x8, 'secondary':0x0, 'name':'Sollwertübertragung des Reglers an andere Regler'},
+
# Response
#p[0] = Einheit (1=>Liter, 2=>Kubik)
#p[1] = 10^0
@@ -73,31 +82,35 @@ class EbusPacket(object):
desc = filter(lambda p: p['primary'] == self.primary_command \
and p['secondary'] == self.secondary_command, packetDescription)
if len(desc) > 0:
- return desc[0]['name']
+ return desc[0]['name']
else:
return "UNKNOWN"
def __str__(self):
- return "<%-18s name=\"%-15s\" source=\"%s\" destination=\"%s\" primary=0x%x secondary=0x%x>" % \
+ return "<%-18s name=\"%-15s\" source=\"%s\" destination=\"%s\" primary=0x%x secondary=0x%x length=0x%x>" % \
(self.__class__.__name__, self.name(), getDsc(self.source), getDsc(self.destination), \
- self.primary_command, self.secondary_command)
+ self.primary_command, self.secondary_command, self.length)
class EbusMasterMaster(EbusPacket):
def __init__(self, source, destination, primary_command, secondary_command, data):
EbusPacket.__init__(self, source, destination, primary_command, secondary_command)
- self.data = data
+ self.length = len(data)
+ self.data = data
+
class EbusMasterSlave(EbusPacket):
def __init__(self, source, destination, primary_command, secondary_command, request, response):
EbusPacket.__init__(self, source, destination, primary_command, secondary_command)
- self.request = request
+ self.length = len(request)
+ self.request = request
self.response = response
class EbusBroadcast(EbusPacket):
def __init__(self, source, destination, primary_command, secondary_command, data):
EbusPacket.__init__(self, source, destination, primary_command, secondary_command)
- self.data = data
+ self.length = len(data)
+ self.data = data
@@ -142,18 +155,27 @@ class Fetcher(asynchat.async_chat):
print "Unvollständige Daten"
return
- primaryCommand = ord(data[3])
- secondaryCommand = ord(data[4])
- payloadLength = ord(data[5])
- payload = data[6:6+payloadLength]
+ primaryCommand = ord(data[2])
+ secondaryCommand = ord(data[3])
+ payloadLength = ord(data[4])
+ payload = data[5:6+payloadLength]
+ #delete 0x50 packets for devel
+ if (primaryCommand == ord("\x50")):
+ return
+ #print "PR SC NN D0 D1 D2 D3 D4 D5 D6 D7 ..."
+ #print "%.2x" % (primaryCommand,)
+ #print "%.2x %.2x %.2x %s" % (primaryCommand,secondaryCommand,payloadLength,"bla")
+ #print "%.2x %.2x %.2x %s" % (primaryCommand,secondaryCommand,payloadLength,formatHex(payload))
+
p = None
if sourceDevice[0]['type'] == 'master' and destinationDevice[0]['type'] == 'master':
p = EbusMasterMaster(source, destination, primaryCommand, secondaryCommand, payload)
print p
print "payload=%s" % formatHex(payload)
elif sourceDevice[0]['type'] == 'master' and destinationDevice[0]['type'] == 'slave':
- p = EbusMasterSlave(source, destination, primaryCommand, secondaryCommand, None, None)
+ p = EbusMasterSlave(source, destination, primaryCommand, secondaryCommand, payload, None)
print p
+ print "payload=%s" % formatHex(payload)
elif sourceDevice[0]['type'] == 'master' and destinationDevice[0]['type'] == 'broadcast':
p = EbusBroadcast(source, destination, primaryCommand, secondaryCommand, payload)
print p
@@ -161,6 +183,7 @@ class Fetcher(asynchat.async_chat):
else:
print "KOMISCHES ZEUG"
return
+ print ""
Fetcher()
asyncore.loop()