Packet Validation - Python 2 to 3 update
In tlm.py, the validate() functions declared in the FieldDefinitions and DerivationDefinition classes need to modified to fix the 'else' statement of following block (found in both methods):
if self.enum:
if value not in self.enum.values():
valid = False
flds = (self.name, str(value))
log("%s value '%s' not in allowed enumerated values." % flds)
else:
primitive = int(self.enum.keys()[self.enum.values().index(value)])
The index() method is not a valid method on the enum object.
'self.enum' is a dict: FieldDefinition(_bytes=0, desc='Distinguishes between core and p...', dntoeu=None, enum={0: 'Core', 1: 'Payload'},
That line will have to be rewritten.
The following script will cause the problem:
import ait.core.tlm as tlm tlm_dict = tlm.getDefaultDict() ccsds_pkt_def = tlm_dict['CCSDS_HEADER'] data = bytearray(b'\x01\x02\x03\x04\x05\x06\x07') ccsds_pkt = tlm.Packet(ccsds_pkt_def, data=data) test = ccsds_pkt.validate(messages='test validate')