From 593b2d6c315daf299ad542bf41413e5b5551b020 Mon Sep 17 00:00:00 2001 From: manya Date: Sat, 11 Jul 2015 00:05:23 +0200 Subject: [PATCH] Update OAPMessage.py There is a problem with the initialization of self.value as a TLVShort and self.sample_count as a TLVByte for digital channels in the Sensor class. The digital channels send 2 bytes for sample count and 1 byte for value that is why OAPMessage.TLV.parse_value(val_str) fails to parse the value tag () as it runs out of bounds. --- SmartMeshSDK/protocols/oap/OAPMessage.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SmartMeshSDK/protocols/oap/OAPMessage.py b/SmartMeshSDK/protocols/oap/OAPMessage.py index 319f1e9..df36f8a 100644 --- a/SmartMeshSDK/protocols/oap/OAPMessage.py +++ b/SmartMeshSDK/protocols/oap/OAPMessage.py @@ -147,6 +147,12 @@ def __init__(self, addr): self.sample_count = TLVByte(2) self.data_format = TLVByte(3) self.value = TLVShort(4) + + if(self.addr[0]==2): + self.sample_count = TLVShort(2) #As the notifications from digital channels generate 2 bytes for sample count + self.value = TLVByte(4) #and one byte for value + #If this change is not made OAPMessage.TLV.parse_value(val_str) fails to parse + #the value tag () as it runs out of bounds. self.tags = [ self.enable, self.rate, self.sample_count,