|
From: <ni...@us...> - 2010-11-22 14:57:39
|
Revision: 149
http://openautomation.svn.sourceforge.net/openautomation/?rev=149&view=rev
Author: nilss1
Date: 2010-11-22 14:57:33 +0000 (Mon, 22 Nov 2010)
Log Message:
-----------
if something not int is send to DPT1 send its length == 1
Modified Paths:
--------------
PyWireGate/trunk/knx_connector/DPT_Types.py
Modified: PyWireGate/trunk/knx_connector/DPT_Types.py
===================================================================
--- PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-22 14:56:25 UTC (rev 148)
+++ PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-22 14:57:33 UTC (rev 149)
@@ -172,7 +172,10 @@
return int(raw[0]) & 0x1
def encodeDPT1(self,val):
- return int(val) & 0x1
+ ## if wrong Type send length of the element so that an empty string or list is 0
+ if type(val) in [str,unicode,list]:
+ val = len(val)
+ return int(val <> 0) & 0x1
def decodeDPT2(self,raw):
## 2 Bit Control
@@ -497,9 +500,6 @@
if __name__ == "__main__":
dpttypes = dpt_type(False)
- #print dpttypes.decode([24,88],dptid=9)
- #print dpttypes.decode([1],dptid=1)
- #print dpttypes.decode([35,76,58],dptid=16)
print dpttypes.encode(15.5,dptid=14)
print dpttypes.decode([0, 0, 6, 14],dptid=14)
print dpttypes.decode([65, 120, 0, 0],dptid=14)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|