0

I am trying to use the value "str(check)" returned from the function - get_reg_check_type and use it in another function - get_status_type. How can I do that?

#---- Get Register Check Type # Returns "CHECK" if register exists and is unlocked; "CHECK_NRF" if register doesn't exist or is locked

    def get_reg_check_type(self, addr, lock=definitions.LockTest.LOCK):
        check = "CHECK_NRF" # NOTE: if items (bits) are locked, check will stay set to CHECK_NRF
        for items in self.register_field_collection:
            for item in items:
                # Bit exists and is unlocked - return "CHECK"
                if (addr == item.register_address):
                    if ((lock == definitions.LockTest.LOCK) and (item.register_write_lock in [definitions.RegWriteLock.NO, definitions.RegWriteLock.FRW])) or \
                       ((lock == definitions.LockTest.A  ) and (item.register_write_lock in [definitions.RegWriteLock.NO, definitions.RegWriteLock.FRW, definitions.RegWriteLock.FRU])) or \
                       ((lock == definitions.LockTest.AB ) and (item.register_write_lock in [definitions.RegWriteLock.NO, definitions.RegWriteLock.FRW, definitions.RegWriteLock.FRU])) or \
                       ((lock == definitions.LockTest.ABC) and (item.register_write_lock in [definitions.RegWriteLock.NO, definitions.RegWriteLock.FRW, definitions.RegWriteLock.FRU, definitions.RegWriteLock.FEBU])):
                        check = "CHECK"
        return str(check)
        
    def get_status_type(self):
        if self.check = "CHECK_NRF"
            status_value = 8'h44
        else:
            status_value = 8'h40
        return status_value
3
  • These functions are within the same class? Commented Jul 30, 2020 at 23:47
  • 1
    Within your get_status_type function just call the get_reg_check_type function. check = self.get_reg_check_type(addr) Commented Jul 30, 2020 at 23:47
  • 1
    @nagyl yes, they are in same class Commented Jul 30, 2020 at 23:49

1 Answer 1

1

If these functions can be found within the same class, you can first call get_reg_check_type then get_status_type.

def get_reg_check_type(self, addr, lock=definitions.LockTest.LOCK):
        check = "CHECK_NRF" # NOTE: if items (bits) are locked, check will stay set to CHECK_NRF
        for items in self.register_field_collection:
            for item in items:
                # Bit exists and is unlocked - return "CHECK"
                if (addr == item.register_address):
                    if ((lock == definitions.LockTest.LOCK) and (item.register_write_lock in [definitions.RegWriteLock.NO, definitions.RegWriteLock.FRW])) or \
                       ((lock == definitions.LockTest.A  ) and (item.register_write_lock in [definitions.RegWriteLock.NO, definitions.RegWriteLock.FRW, definitions.RegWriteLock.FRU])) or \
                       ((lock == definitions.LockTest.AB ) and (item.register_write_lock in [definitions.RegWriteLock.NO, definitions.RegWriteLock.FRW, definitions.RegWriteLock.FRU])) or \
                       ((lock == definitions.LockTest.ABC) and (item.register_write_lock in [definitions.RegWriteLock.NO, definitions.RegWriteLock.FRW, definitions.RegWriteLock.FRU, definitions.RegWriteLock.FEBU])):
                        check = "CHECK"
        self.checked = str(check) # set the value
        
    def get_status_type(self):
        print(self.checked) # get the value
        if self.check = "CHECK_NRF"
            status_value = 8'h44
        else:
            status_value = 8'h40
        return status_value
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.