Patrick Bellasi | d95e98d | 2015-12-04 13:00:46 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Copyright (C) 2015, ARM Limited and contributors. |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | # not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # |
Patrick Bellasi | 0f8ac68 | 2015-10-12 11:29:40 +0100 | [diff] [blame] | 19 | |
| 20 | SYSFS_BASE="/sys/devices/12c60000.i2c/i2c-4/i2c-dev/i2c-4/device/" |
| 21 | SYSFS_ARM=$SYSFS_BASE"/4-0040" |
| 22 | SYSFS_KFC=$SYSFS_BASE"/4-0045" |
| 23 | |
| 24 | if [ $# -lt 2 ]; then |
| 25 | echo "Usage: $0 samples period_s [arm|kfc]" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | SAMPLES=$1 |
| 30 | PERIOD=$2 |
| 31 | DEVICE=${3:-"arm"} |
| 32 | |
| 33 | case $DEVICE in |
| 34 | "arm") |
| 35 | SYSFS_ENABLE=$SYSFS_ARM"/enable" |
| 36 | SYSFS_W=$SYSFS_ARM"/sensor_W" |
| 37 | ;; |
| 38 | "kfc") |
| 39 | SYSFS_ENABLE=$SYSFS_KFC"/enable" |
| 40 | SYSFS_W=$SYSFS_KFC"/sensor_W" |
| 41 | ;; |
| 42 | esac |
| 43 | |
| 44 | echo "Samping $SAMPLES time, every $PERIOD [s]:" |
| 45 | echo " $SYSFS_W" |
| 46 | |
| 47 | rm samples_w.txt 2>/dev/null |
| 48 | echo 1 > $SYSFS_ENABLE |
| 49 | sleep 1 |
| 50 | |
| 51 | while [ 1 ]; do |
| 52 | sleep $PERIOD |
| 53 | cat $SYSFS_W >> samples_w.txt |
| 54 | SAMPLES=$((SAMPLES-1)) |
| 55 | [ $SAMPLES -eq 0 ] && break |
| 56 | done |
| 57 | |
| 58 | echo 0 > $SYSFS_ENABLE |