Example #1
0
    def load_wrapper(self, wrapper_version='6.1t.4'):
        import os.path
        from unit_tests import check_house_keeping_voltages, UnexpectedHousekeeping
        from fpesocketconnection import TimeOutError
        fpe_wrapper_bin = os.path.join(self._dir, "MemFiles",
                                       "FPE_Wrapper-{version}.bin".format(version=wrapper_version))

        assert os.path.isfile(fpe_wrapper_bin), "Wrapper does not exist for version {}".format(wrapper_version)
        status = self.frames_running_status
        try:
            self.frames_running_status = False
            self.cmd_hsk(retries=1)
            check_house_keeping_voltages(self)
            return "House keeping reports sane values for reference voltages," \
                   " *NOT* loading wrapper (tried to load version {})".format(wrapper_version)
        except (UnexpectedHousekeeping, TimeOutError):
            self.cmd_rst(upload=False, sanity_checks=False)
            # assert "Cam FPGA done." in self.cmd_fpga_rst(), "Could not reset the FPGA"
            assert "Resetting Cam FPGA" in self.cmd_fpga_rst(), "Could not reset the FPGA"
            assert self.upload_fpe_wrapper_bin(fpe_wrapper_bin), "Could not load wrapper: {}".format(fpe_wrapper_bin)
            assert self.cmd_rst(upload=True, sanity_checks=False), "Could not reset camera"
            # Set the housekeeping memory to the identity map
            assert self.upload_housekeeping_memory(
                binary_files.write_hskmem(
                    house_keeping.identity_map)), "Could not load house keeping memory: {}".format(house_keeping_memory)
            # Set the operating parameters to their defaults
            assert self.ops.reset_to_defaults(), "Could not send operating parameters"
            check_house_keeping_voltages(self)
            return "Wrapper version {} loaded successfully".format(wrapper_version)
        finally:
            self.frames_running_status = status
Example #2
0
 def cam_reset(self, upload=True, sanity_checks=True):
     """Reset the camera after running frames"""
     from unit_tests import check_house_keeping_voltages, UnexpectedHousekeeping
     from fpesocketconnection import TimeOutError
     if self._reset_in_progress:
         return False
     self._reset_in_progress = True
     self.cam_stop_frames()
     assert 'FPE Reset complete' in self.connection.send_command(
         'camrst',
         reply_pattern='FPE Reset complete'), "Could not successfully issue camera reset command"
     # Clear cam_control
     self.control_status = 1
     status = self.control_status
     assert status is 0, "camera control status memory could not zeroed, was 0x{}".format(hex(status))
     if sanity_checks or upload:
         register_memory = os.path.join(self._dir, 'MemFiles', 'Reg.bin')
         assert self.upload_register_memory(register_memory), \
             'Could not load register memory: {}'.format(register_memory)
         # Set the housekeeping memory to the identity map
         house_keeping_memory = binary_files.write_hskmem(house_keeping.identity_map)
         assert self.upload_housekeeping_memory(house_keeping_memory), \
             "Could not load house keeping memory: {}".format(house_keeping_memory)
     if sanity_checks:
         # Try checking the housekeeping memory.  If it's bad, give reloading the wrapper
         try:
             check_house_keeping_voltages(self)
         except (TimeOutError, UnexpectedHousekeeping):
             self._reset_in_progress = False
             self.load_wrapper()
     self._reset_in_progress = False
     return True
Example #3
0
File: fpe.py Project: TESSUser/FPE
    def __init__(self, number, FPE_Wrapper_version=None, debug=False, check_hk=True):
        from fpesocketconnection import FPESocketConnection
        from unit_tests import check_house_keeping_voltages
        import os
        import time

        # First sanity check: ping the observatory simulator
        if not self.ping():
            raise Exception("Cannot ping 192.168.100.1")
        self._debug = debug
        self.fpe_number = number
        self.connection = FPESocketConnection(5554 + number, self._debug)

        # Second sanity check: get the observatory simulator version
        try:
           version = self.version
           if self._debug:
              print version
        except Exception as e:
           raise type(e)("Could not read Observatory Simulator version... {0}\n".format(str(e)) + 
                         "Are you sure you firmware for the Observatory Simulator is properly installed?")
           

        self._dir = os.path.dirname(os.path.realpath(__file__))
        # Default memory configuration files
        self._program_file = os.path.join(self._dir, "..", "data", "files", "default_program.fpe")
        self.register_memory = os.path.join(self._dir, "MemFiles", "Reg.bin")

        # Set the House Keeping and Operating Parameters
        self.hsk_byte_array = house_keeping.identity_map
        self.ops = OperatingParameters(self)

        # Load the wrapper.  First check if loading the wrapper is *necessary* by checking reference values on housekeeping channels
        if FPE_Wrapper_version != None:
            try:
                check_house_keeping_voltages(self)
                if self._debug:
                    print "House keeping reports sane values for reference voltages, *NOT* loading wrapper"
            except:
                fpe_wrapper_bin = os.path.join(self._dir, "MemFiles",
                                               "FPE_Wrapper-{version}.bin".format(version=FPE_Wrapper_version))
                self.upload_fpe_wrapper_bin(fpe_wrapper_bin)

        self.upload_register_memory(self.register_memory)
        self.upload_housekeeping_memory(
            binary_files.write_hskmem(self.hsk_byte_array))
        self.ops.send()
        self.load_code()

        time.sleep(.01) # Need to wait for 1/100th of a sec for the box to catch up with us

        # Run sanity checks on the FPE to make sure basic functions are working (if specified)
        if check_hk:
            check_house_keeping_voltages(self)
Example #4
0
File: fpe.py Project: ebokhour/FPE
    def __init__(self, number, FPE_Wrapper_version="6.1.1", debug=False, preload=False, hsk_byte_array=house_keeping.identity_map):
        from fpesocketconnection import FPESocketConnection
        from unit_tests import check_house_keeping_voltages
        import os
        import time
        if not self.ping():
            raise Exception("Cannot ping 192.168.100.1")
        self._debug = debug
        self.fpe_number = number
        self.connection = FPESocketConnection(5554 + number, self._debug)
        self._dir = os.path.dirname(os.path.realpath(__file__))

        # Default memory configuration files
        self.fpe_wrapper_bin = os.path.join(self._dir, "MemFiles",
                                            "FPE_Wrapper-{version}.bin".format(version=FPE_Wrapper_version))

        self._program_file = os.path.join(self._dir, "..", "data", "files", "default_program.fpe")

        # TODO: Sunset this
        self.register_memory = os.path.join(self._dir, "MemFiles", "Reg.bin")

        # Set the House Keeping and Operating Parameters
        self.hsk_byte_array = hsk_byte_array
        self.ops = OperatingParameters(self)

        self._safe_to_load_FPE = None

        if preload:
            self.upload_fpe_wrapper_bin(self.fpe_wrapper_bin)
        self.upload_register_memory(self.register_memory)
        self.upload_housekeeping_memory(
            binary_files.write_hskmem(self.hsk_byte_array))
        self.ops.send()
        self.load_code()

        # Run sanity checks on the FPE to make sure basic functions are working
        time.sleep(.01) # Need to wait for 1/100th of a sec for prince charming
        check_house_keeping_voltages(self)
Example #5
0
 def load_wrapper(self,
                  fpe_wrapper_binary=None,
                  wrapper_version='6.2.4',
                  force=False,
                  dhu_reset=False):
     """
     Load an FPGA wrapper.  Checks to see if housekeeping is reporting sane values
     :type wrapper_version: str
     :param fpe_wrapper_binary: A string containing a file name, if None is provided then wrapper_version is used
     :param wrapper_version: A string containing the version of the wrapper to be used, defaults to '6.1t.5'
     :param force: A Boolean, which flags whether the wrapper should be (re)installed even if it is already installed
     :param dhu_reset: A Boolean, which flags whether the DHU should be reset
     :return: A string saying the status of the loaded wrapper
     """
     import os.path
     from unit_tests import check_house_keeping_voltages, UnexpectedHousekeeping
     from fpesocketconnection import TimeOutError
     if self._loading_wrapper is True:
         return "Already in the process of trying to load the wrapper, not proceeding"
     try:
         self._loading_wrapper = True
         frames_status = self.frames_running_status
         if fpe_wrapper_binary is None:
             fpe_wrapper_binary = os.path.join(self._dir, "MemFiles",
                                               "FPE_Wrapper-{version}.bin".format(version=wrapper_version))
         if not os.path.isfile(fpe_wrapper_binary):
             # Maybe we specified a version instead of a real file? No harm in trying...
             file_name = os.path.join(self._dir, "MemFiles",
                                      "FPE_Wrapper-{version}.bin".format(version=fpe_wrapper_binary))
             if os.path.isfile(file_name):
                 fpe_wrapper_binary = file_name
         assert os.path.isfile(fpe_wrapper_binary), "Wrapper file '{}' does not exist".format(fpe_wrapper_binary)
         if self.frames_running_status is True \
                 and force is not True \
                 and dhu_reset is not True:
             return "Frames are reporting to be running, *NOT* loading wrapper (tried to load '{}')".format(
                 fpe_wrapper_binary)
         if force or dhu_reset:
             raise ForcedWrapperLoad()
         self.frames_running_status = False
         self.cam_hsk(retries=1)
         check_house_keeping_voltages(self)
         return "House keeping reports sane values for reference voltages," \
                " *NOT* loading wrapper (tried to load {})".format(fpe_wrapper_binary)
     except (ForcedWrapperLoad, UnexpectedHousekeeping, TimeOutError):
         if dhu_reset is True:
             self.dhu_reset()
         self.cam_reset(upload=False, sanity_checks=False)
         self.cam_fpga_rst()
         self.upload_fpe_wrapper_bin(fpe_wrapper_binary)
         # Reset the camera again, which uploads the register memory but doesn't check if housekeeping is sane
         self.cam_reset(upload=True, sanity_checks=False)
         # Set the housekeeping memory to the identity map
         house_keeping_memory = binary_files.write_hskmem(house_keeping.identity_map)
         assert self.upload_housekeeping_memory(house_keeping_memory), \
             "Could not load house keeping memory: {}".format(house_keeping_memory)
         # Reset the camera again, this time checking that housekeeping is reporting sane values
         # self.cam_reset(upload=True, sanity_checks=True)
         # Set the operating parameters to their defaults
         assert self.ops.reset_to_defaults(), "Could not send default operating parameters"
         # Check the house keeping is porting sane values (since we are paranoid)
         check_house_keeping_voltages(self)
         return "Wrapper {} loaded successfully".format(fpe_wrapper_binary)
     finally:
         self.frames_running_status = frames_status
         self._loading_wrapper = False
Example #6
0
 def load_wrapper(self,
                  fpe_wrapper_binary=None,
                  wrapper_version='6.2.3',
                  force=False,
                  dhu_reset=False):
     """
     Load an FPGA wrapper.  Checks to see if housekeeping is reporting sane values
     :type wrapper_version: str
     :param fpe_wrapper_binary: A string containing a file name, if None is provided then wrapper_version is used
     :param wrapper_version: A string containing the version of the wrapper to be used, defaults to '6.1t.5'
     :param force: A Boolean, which flags whether the wrapper should be (re)installed even if it is already installed
     :param dhu_reset: A Boolean, which flags whether the DHU should be reset
     :return: A string saying the status of the loaded wrapper
     """
     import os.path
     from unit_tests import check_house_keeping_voltages, UnexpectedHousekeeping
     from fpesocketconnection import TimeOutError
     if self._loading_wrapper is True:
         return "Already in the process of trying to load the wrapper, not proceeding"
     try:
         self._loading_wrapper = True
         frames_status = self.frames_running_status
         if fpe_wrapper_binary is None:
             fpe_wrapper_binary = os.path.join(
                 self._dir, "MemFiles", "FPE_Wrapper-{version}.bin".format(
                     version=wrapper_version))
         if not os.path.isfile(fpe_wrapper_binary):
             # Maybe we specified a version instead of a real file? No harm in trying...
             file_name = os.path.join(
                 self._dir, "MemFiles", "FPE_Wrapper-{version}.bin".format(
                     version=fpe_wrapper_binary))
             if os.path.isfile(file_name):
                 fpe_wrapper_binary = file_name
         assert os.path.isfile(
             fpe_wrapper_binary), "Wrapper file '{}' does not exist".format(
                 fpe_wrapper_binary)
         if self.frames_running_status is True \
                 and force is not True \
                 and dhu_reset is not True:
             return "Frames are reporting to be running, *NOT* loading wrapper (tried to load '{}')".format(
                 fpe_wrapper_binary)
         if force or dhu_reset:
             raise ForcedWrapperLoad()
         self.frames_running_status = False
         self.cam_hsk(retries=1)
         check_house_keeping_voltages(self)
         return "House keeping reports sane values for reference voltages," \
                " *NOT* loading wrapper (tried to load {})".format(fpe_wrapper_binary)
     except (ForcedWrapperLoad, UnexpectedHousekeeping, TimeOutError):
         if dhu_reset is True:
             self.dhu_reset()
         self.cam_reset(upload=False, sanity_checks=False)
         self.cam_fpga_rst()
         self.upload_fpe_wrapper_bin(fpe_wrapper_binary)
         # Reset the camera again, which uploads the register memory but doesn't check if housekeeping is sane
         self.cam_reset(upload=True, sanity_checks=False)
         # Set the housekeeping memory to the identity map
         house_keeping_memory = binary_files.write_hskmem(
             house_keeping.identity_map)
         assert self.upload_housekeeping_memory(house_keeping_memory), \
             "Could not load house keeping memory: {}".format(house_keeping_memory)
         # Reset the camera again, this time checking that housekeeping is reporting sane values
         # self.cam_reset(upload=True, sanity_checks=True)
         # Set the operating parameters to their defaults
         assert self.ops.reset_to_defaults(
         ), "Could not send default operating parameters"
         # Check the house keeping is porting sane values (since we are paranoid)
         check_house_keeping_voltages(self)
         return "Wrapper {} loaded successfully".format(fpe_wrapper_binary)
     finally:
         self.frames_running_status = frames_status
         self._loading_wrapper = False