NASA-AMMOS / NASA-AMMOS/AIT-Core

Packet Validation - Python 2 to 3 update

Open
#457 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
56
Forks
35
Avg merge
1d 20h
Merged PRs (30d)
3

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in _tlm.py with the validate() methods in FieldDefinitions and DerivationDefinition, then reproduce the failure using the Python script in the issue. Update the invalid enum lookup in both methods so packet validation completes, and verify that the supplied CCSDS packet validates without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.