summaryrefslogtreecommitdiff
path: root/ebus
diff options
context:
space:
mode:
Diffstat (limited to 'ebus')
-rw-r--r--ebus/model/__init__.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/ebus/model/__init__.py b/ebus/model/__init__.py
index 1e2d080..f6a44b9 100644
--- a/ebus/model/__init__.py
+++ b/ebus/model/__init__.py
@@ -36,12 +36,16 @@ class Data2c(DataField):
+ dez(Low_ Nibble (Low Byte (x))) / 16
"""
def value(self,data):
- highByte = ord(data[self.offset+1])
- lowByte= ord(data[self.offset])
+ lowByte = ord(data[self.offset])
+ highByte = ord(data[self.offset+1])
+ n_highByte = 0xff ^ highByte
+ n_lowByte = 0xff ^ lowByte
+ n_lowByteHighNibble = n_lowByte >> 4
+ n_lowByteLowNibble = 0x0f & n_lowByte
if (0x8000 & (highByte<<8 | lowByte)) == 0x8000:
- return (-1) * ( (0xff^highByte)*16 + (0xff^(lowByte>>4)) + (0x0ff^(0xf&lowByte) + 1)/16.0 )
+ return (-1) * ( (n_highByte<<4 + n_lowByteHighNibble + (n_lowByteLowNibble+1)) / 16.0 )
else:
- return highByte*16 + (lowByte>>4) + (lowByte&0xf)/16.0
+ return highByte*16 + (lowByte>>4) + (0x0f & lowByte)/16.0
class Data2b(DataField):
"""
@@ -52,9 +56,11 @@ class Data2b(DataField):
"""
def value(self,data):
highByte = ord(data[self.offset+1])
- lowByte= ord(data[self.offset])
+ lowByte = ord(data[self.offset])
+ n_highByte = 0xff ^ highByte
+ n_lowByte = 0xff ^ lowByte
if (0x8000 & (highByte<<8 | lowByte)) == 0x8000:
- return (-1) * ((0xff^highByte) + (0xff^lowByte+1)/256.0)
+ return (-1) * (n_highByte + (n_lowByte+1)/256.0)
else:
return highByte + lowByte/256.0