-
Notifications
You must be signed in to change notification settings - Fork 5
/
showactivity
71 lines (66 loc) · 2.26 KB
/
showactivity
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
#!/bin/bash -u
# Script_name : showactivity
# Author : Bert Lindeman
# Description : Let the rightside green EV3-led blink depending on I/O activiy
# Version : v1.3
# Date : 2014-11-04
# Usage : showactivity
# Notes : No parameters used nor checked
# Copyright : 2014 Bert Lindeman
# License : GPL-3.0+
#
#============================================================================
#
# Changelog
# Date By Description
# 20141104 BL prepare for release v1.3
# 20140826 BL o Add script header
# o No longer show triggers of the leds (confusing)
# 20141202 BL Set mmc0 trigger to outA for PF-leds
# 20150114 BL adapt for kernel 3.16.7-ckt3-ev3dev1
# 20150116 BL use /usr/local/bin/tryPF to add leds on outA
# 20160103 BL adapt to image 20151230 (change filenames)
#
#============================================================================
#
#
# Assign "non-cron" if ENVIRONMENT is unset or null, and thus prevent error "variable unbound":
: "${ENVIRONMENT:=non-cron}"
#
#
# set right green led to show I/O activity:
echo mmc0 > /sys/class/leds/ev3\:right\:green\:ev3dev/trigger
sleep 0.25s
echo 1 > /sys/class/leds/ev3\:right\:green\:ev3dev/brightness
sleep 0.25s
#
#
. /usr/local/bin/bert_ev3dev_functions
portletter="A"
port="out${portletter}"
# verify there is NO MOTOR on port outA
findmotorctl "${port}"
if listcontains "${SEENPORT}" "outA" ; then
if [ "$ENVIRONMENT" == "non-cron" ]; then
echo "Motor present on ${port}: no action"
exit
fi
else
if [ "${CURMOTOR}" == "???????" ]; then
if [ "$ENVIRONMENT" == "non-cron" ]; then
echo "OK, no motor on ${port}: is outA already \"led\"?"
fi
if [ ! -e /sys/class/leds/ev3\:\:outA/trigger ]; then
if [ "$ENVIRONMENT" == "non-cron" ]; then
echo "Field trigger on outA does not exist yet: Add PF led on port outA"
fi
/usr/local/bin/tryPF outA led
fi
fi
fi
if [ -w /sys/class/leds/ev3\:\:outA/trigger ]; then
if [ "$ENVIRONMENT" == "non-cron" ]; then
echo "set \"/sys/class/leds/ev3\:\:outA/trigger\" to \"mmc0\" "
fi
echo mmc0 > /sys/class/leds/ev3\:\:outA/trigger
fi