-
Notifications
You must be signed in to change notification settings - Fork 5
/
showsensors
102 lines (98 loc) · 2.95 KB
/
showsensors
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash -u
# Script_name : showsensors
# Author : Bert Lindeman
# Description : Show info of recognized sensors
# Version : v1.3
# Date : 2014-12-29
# Usage : showsensors
# Notes :
# Copyright : 2014 Bert Lindeman
# License : GPL-3.0+
#
#============================================================================
#
# Changelog
# Date By Description
# 20141104 BL prepare for release v1.3
# 20140924 BL allow a parameter to only show ONE sensor
# Easy to use watch and see only that sensor
# 20141229 BL o Adapt to updates in
# kernel version 3.16.1-8-ev3dev
# 20150109 BL update for 3.16.7
# o device_name -> driver_name
# 20160103 BL adapt to image 20151230 (change filenames)
#
#============================================================================
#
selectport=${1:-}
# parm1=${1:-noparm}
#
# determine which interface services what input port:
#
# IFS=$' \n' read -a sensors <<< "`echo /sys/class/msensor/sensor*/`"
IFS=$' \n' read -a sensors <<< "`echo /sys/class/lego-sensor/sensor*/`"
#
hits=0
#
for i in "${!sensors[@]}" # ! walk the indexes
do
# echo -e "Process $i \"${sensors[$i]}\""
if [ -e "${sensors[$i]}" ]; then
cd "${sensors[$i]}"
if [ "$#" == 0 ] || [ "$selectport" == "`cat address`" ]; then
#cat address
#cat units
#cat address
#cat bin_data
#cat bin_data_format
#cat command
#cat commands
#cat decimals
#cat device_name
#cat mode
#cat modes
#cat num_values
#cat value0
#cat value1
#cat value2
#cat value3
#cat value4
#cat value5
#cat value6
#cat value7
# nxt-i2c cat fw_version
# nxt-12c cat poll_ms
cat commands 2>/dev/null
RC="$?"
if [ "${RC}" == "0" ]; then
# echo "commands implemented"
cmd="`cat commands`"
else
# echo "commands returned RC=${RC}"
cmd="not implemented"
fi
echo -e "Process $i `pwd`"
# echo -e " sensor $i device_name: `cat device_name` on port `cat address` "
echo -e " sensor $i driver_name: `cat driver_name` on port `cat address` "
echo -e "address: `cat address`"
echo -e "mode: `cat mode`"
echo -e "modes: `cat modes`"
echo -e "commands: ${cmd}"
echo -e "decimals: `cat decimals`"
echo -e "num_values: `cat num_values`"
num_values="`cat num_values`"
for (( v=0; v<$num_values; v++ ))
do
echo -e "value$v: `cat value$v`"
done
echo -e "units: `cat units`"
echo -e "uevent: \n`cat uevent` \n\n"
hits=1
fi
else
echo -e "Expected path \"${sensors[$i]}\" does not exist"
fi
done
if [ $hits == 0 ];then
echo -e "Requested sensor on port $selectport not available"
fi