Beispiel #1
0
    def disarm(self):
        """
        Disarm the hardware watchdog

        Returns:
            A boolean, True if watchdog is disarmed successfully, False
            if not
        """
        if self.is_armed():
            # Disable WD
            io_reg_write(self.io_resource, self.wd_status_offset,
                         self.wd_disable)
            self.armed_time = 0
            self.timeout = 0
            return True

        return False
Beispiel #2
0
    def set_status_led(self, color):
        """ 
        Set system LED status based on the color type passed in the argument.
        Argument: Color to be set
        Returns:
          bool: True is specified color is set, Otherwise return False
        """

        if color not in list(self.SYSLED_COLOR_TO_REG.keys()):
            return False

        if(not hwaccess.io_reg_write(self.io_res, self.sysled_offset, self.SYSLED_COLOR_TO_REG[color])):
            return False
        self.sys_ledcolor = color
        return True
Beispiel #3
0
    def arm(self, seconds):
        """
        Arm the hardware watchdog with a timeout of <seconds> seconds.
        If the watchdog is currently armed, calling this function will
        simply reset the timer to the provided value. If the underlying
        hardware does not support the value provided in <seconds>, this
        method should arm the watchdog with the *next greater*
        available value.

        Returns:
            An integer specifying the *actual* number of seconds the
            watchdog was armed with. On failure returns -1.
        """
        timer_offset = -1
        for key, timer_seconds in enumerate(self.TIMERS):
            if seconds > 0 and seconds <= timer_seconds:
                timer_offset = key
                seconds = timer_seconds
                break

        if timer_offset == -1:
            return -1

        wd_timer_val = io_reg_read(self.io_resource, self.wd_timer_offset)

        if wd_timer_val != timer_offset:
            self.disarm()
            io_reg_write(self.io_resource, self.wd_timer_offset, timer_offset)

        if self.is_armed():
            # Setting the WD timer punch
            io_reg_write(self.io_resource, self.wd_timer_punch_offset,
                         self.wd_punch_enable)
            self.armed_time = self._get_time()
            self.timeout = seconds
            return seconds
        else:
            # Enable WD
            io_reg_write(self.io_resource, self.wd_status_offset,
                         self.wd_enable)
            self.armed_time = self._get_time()
            self.timeout = seconds
            return seconds