• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- coding: utf-8 -*-
2#
3# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7__author__ = 'nsanders@chromium.org (Nick Sanders)'
8
9import logging, os
10
11from autotest_lib.client.bin import test, utils
12from autotest_lib.client.common_lib import error
13from autotest_lib.client.cros import gpio
14
15class hardware_GPIOSwitches(test.test):
16    version = 4
17
18    def initialize(self):
19        self._gpio = gpio.Gpio(error.TestError)
20
21    def gpio_read(self, name):
22        try:
23            return self._gpio.read(name)
24        except:
25            raise error.TestError(
26                    'Unable to read gpio value "%s"\n'
27                    '測試程式無法讀取 gpio 數值 "%s"' % (name, name))
28
29    def run_once(self):
30        self._gpio.setup()
31        keyvals = {}
32        keyvals['level_recovery'] = self.gpio_read('recovery_button')
33        keyvals['level_developer'] = self.gpio_read('developer_switch')
34        keyvals['level_firmware_writeprotect'] = self.gpio_read('write_protect')
35
36        self.write_perf_keyval(keyvals)
37