예제 #1
0
    def get_status_led(self):
        """
        Gets the current system LED color

        Returns:
            A string that represents the supported color
        """
        val = hwaccess.io_reg_read(self.io_res, self.sysled_offset)
        if val != -1:
            return self.REG_TO_SYSLED_COLOR.get(val)
        return self.sys_ledcolor
예제 #2
0
    def is_armed(self):
        """
        Retrieves the armed state of the hardware watchdog.

        Returns:
            A boolean, True if watchdog is armed, False if not
        """
        # Getting the WD Enable/Disable status
        # 0 - Disabled WD
        # 1 - Enabled WD
        wd_status = io_reg_read(self.io_resource, self.wd_status_offset)
        return bool(wd_status)
예제 #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