ctrl: introduce constant for TRAP id

Use it for TRAP message parsing and generation.

Change-Id: I0381eb60d10e7278b966464add79772a9f7c8118
This commit is contained in:
Max 2018-11-26 11:48:04 +01:00
parent 735d5b4165
commit 04e7c64902
1 changed files with 3 additions and 2 deletions

View File

@ -43,6 +43,7 @@ class IPA(object):
CTRL_REP = 'REPLY' CTRL_REP = 'REPLY'
CTRL_ERR = 'ERR' CTRL_ERR = 'ERR'
CTRL_TRAP = 'TRAP' CTRL_TRAP = 'TRAP'
CTRL_TRAP_ID = 0
def _l(self, d, p): def _l(self, d, p):
""" """
@ -250,7 +251,7 @@ class Ctrl(IPA):
if s == self.CTRL_GET + '_' + self.CTRL_REP: if s == self.CTRL_GET + '_' + self.CTRL_REP:
return i, v, None return i, v, None
(s, i, var, val) = data.split(' ', 3) (s, i, var, val) = data.split(' ', 3)
if s == self.CTRL_TRAP and i != '0': if s == self.CTRL_TRAP and int(i) != self.CTRL_TRAP_ID:
return i, None, None return i, None, None
return i, var, val return i, var, val
@ -267,7 +268,7 @@ class Ctrl(IPA):
""" """
Make TRAP message with given (vak, val) pair Make TRAP message with given (vak, val) pair
""" """
return self.add_header("%s 0 %s %s" % (self.CTRL_TRAP, var, val)) return self.add_header("%s %d %s %s" % (self.CTRL_TRAP, self.CTRL_TRAP_ID, var, val))
def cmd(self, var, val=None): def cmd(self, var, val=None):
""" """