OLD | NEW |
---|---|
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import logging, os |
6 | |
7 from autotest_lib.client.bin import test, utils | 6 from autotest_lib.client.bin import test, utils |
8 from autotest_lib.client.common_lib import error | 7 from autotest_lib.client.common_lib import error |
9 | 8 |
9 | |
10 class hardware_tsl2563(test.test): | 10 class hardware_tsl2563(test.test): |
11 """ | 11 """ |
12 Test the TSL2560/1/2/3 Light Sensor device. | 12 Test the TSL2560/1/2/3 Light Sensor device. |
13 Failure to find the device likely indicates the kernel module is not loaded. | 13 Failure to find the device likely indicates the kernel module is not loaded. |
14 Or it could mean an i2c_adapter was not found for it. To spoof one: | 14 Or it could mean the I2C probe for the device failed because of an incorrect |
15 echo tsl2563 0x29 > /sys/class/i2c-adapter/i2c-0/new_device | 15 I2C address or bus specification. |
16 This will also automatically load the module. | 16 The upscript /etc/init/powerd.conf should properly load the driver so that |
17 we can find its files in /sys/class/iio/device0/. | |
17 """ | 18 """ |
18 version = 1 | 19 version = 1 |
19 | 20 |
20 preserve_srcdir = True | 21 def run_once(self): |
22 try: | |
23 lux_out = utils.read_one_line('/sys/class/iio/device0/lux') | |
24 except: | |
25 raise error.TestFail('The tsl2563 driver is not ' | |
26 'exporting its lux file') | |
27 lux = int(lux_out) | |
28 if lux < 0: | |
bfreed
2010/08/06 18:03:01
Testing shows I can get values over 64K. In looki
| |
29 raise error.TestFail('Invalid tsl2563 lux string (%s)' % lux_out) | |
30 logging.debug("tsl2563 lux value is %d", lux) | |
21 | 31 |
22 def setup(self): | |
23 os.chdir(self.srcdir) | |
24 utils.system('make') | |
25 | |
26 | |
27 def run_once(self): | |
28 tsl_test_cmd = os.path.join(self.srcdir, "tsl2563tst") | |
29 utils.system(tsl_test_cmd) | |
OLD | NEW |