-
Notifications
You must be signed in to change notification settings - Fork 0
/
runme.ksh
executable file
·63 lines (53 loc) · 1.38 KB
/
runme.ksh
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
#!/bin/ksh
usage () {
echo ""
echo "Usage:"
echo "${0} <LOGI_HW_ADDR>"
echo "Example: ${0} AA:BB:CC:DD:EE"
echo ""
exit 1
}
# check for /dev/ttyACM0
check_for_ACM0=$(ls -l /dev/ttyACM0)
if [[ -z $check_for_ACM0 ]]; then
echo "Can't execute payload because dongle is not present on /dev/ttyACM0"
echo "Plug in the dongle and try again."
exit 1
fi
if [[ -z $1 ]];then
echo "No argument passed."
echo "Target device address is needed."
echo "Exiting."
usage
fi
#check the device address input
device_input=$1
#convert to upper case
device_input=$(echo $device_input | tr '[:lower:]' '[:upper:]')
check_length_device=$(echo ${#device_input})
if [[ $check_length_device = "14" ]]; then
echo ""
else
echo "The length of the device address is not correct."
usage
fi
check_colon_count_device=$(echo "${device_input}" | awk -F":" '{print NF-1}')
if [[ $check_colon_count_device = "4" ]]; then
echo ""
else
echo "The format of the device address is not correct."
usage
fi
cwd=$(dirname $0)
cwd=${cwd%/}
clear
# infinite loop needed because the yoctopuce library is not perfect
# the attached Yocto Knob is sometimes not detected
# which causes a catastrophic failure of the python script
# this dirty workaround will launch it again if it fails the first time
while true
do
# ctrl-c terminates
#$cwd/LOGITacker_button.py any $1 || break
$cwd/LOGITacker_button.py any $1
done