Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packet Validation - Python 2 to 3 update #457

Open
JimHofman opened this issue Oct 12, 2022 · 0 comments
Open

Packet Validation - Python 2 to 3 update #457

JimHofman opened this issue Oct 12, 2022 · 0 comments

Comments

@JimHofman
Copy link

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant