trx_toolkit/data_if.py: fix: handle encoding exceptions

Change-Id: I78163d41be3a912da1dd8c0543b1c3af3a0649fa
Related: OS#4681
This commit is contained in:
Vadim Yanitskiy 2020-07-27 02:58:13 +07:00
parent 129c976c3a
commit 4e4babc7db
1 changed files with 8 additions and 2 deletions

View File

@ -105,8 +105,14 @@ class DATAInterface(UDPLink):
return msg
def send_msg(self, msg, legacy = False):
# Validate and encode TRXD message
payload = msg.gen_msg(legacy)
try:
# Validate and encode TRXD message
payload = msg.gen_msg(legacy)
except ValueError as e:
log.error("Failed to encode a TRX2L1 message ('%s') "
"due to error: %s" % (msg.desc_hdr(), e))
# TODO: we may want to send a NOPE.ind here
return
# Send message
self.send(payload)