Skip to content
Snippets Groups Projects
Commit d0a45048 authored by jkerdreu's avatar jkerdreu
Browse files

Review Mael changes to cEMI santify check


git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2198 b32b6428-25c9-4566-ad07-03861ab6144f
parent f5a947ee
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,8 @@ class KNXcEMI:
def parse(self,buf):
bytes_ = bytearray(buf)
if len(bytes_) < 17:
#MC if len(bytes_) < 17:
if len(bytes_) < 16:
raise KNXcEMIException("Packet to short %d" % len(bytes_))
self.pkt = bytes_
......@@ -70,13 +71,15 @@ class KNXcEMI:
#self.data # 0x81 => write 1 / 0x80=> write 0 / 0x0 => read / 0x40 => response
def check_sanity(self):
if self.header_lenght != 0x6 : raise KNXcEMIException("Wrong header size")
if self.version != 0x10: raise KNXcEMIException("Wrong version")
if self.service != bytearray([0x05,0x30]): raise KNXcEMIException("Wrong service")
if self.msg_code != 0x29 : raise KNXcEMIException("Wrong msg_code")
if self.ctr_field1 != 0xbc : raise KNXcEMIException("Wrong ctr_field1")
if self.ctr_field2 not in [0xe0,0xd0,0xc0]: raise KNXcEMIException("Wrong ctr_field2 0x%x" % self.ctr_field2)
#if self.npdu_lenght != 0x01 : raise KNXcEMIException("Wrong npdu_lenght")
if self.header_lenght != 0x06 : raise KNXcEMIException("Wrong header size 0x%x" % self.header_lenght)
if self.version != 0x10: raise KNXcEMIException("Wrong version 0x%x" % self.version)
if self.service != bytearray([0x05,0x30]): raise KNXcEMIException("Wrong service 0x%x 0x%x" % self.service[0] % self.service[1])
if self.msg_code != 0x29 : raise KNXcEMIException("Wrong msg_code 0x%x" % self.msg_code)
if self.ctr_field1 not in [0xbc,0xb0] : raise KNXcEMIException("Wrong ctr_field1 0x%x" % self.ctr_field1)
# JKX: ctr_field2 shoub in [0xe0,0xd0,0xc0] but Mael fix that to:
if self.ctr_field2 not in [0xe0,0xd0,0xc0,0xb0,0x40,0x50]: raise KNXcEMIException("Wrong ctr_field2 0x%x" % self.ctr_field2)
# JKX : how could this arrive ?
#if self.npdu_lenght != 0x01 : raise KNXcEMIException("Wrong npdu_lenght 0x%x" % self.npdu_lenght)
@property
def total_lenght(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment