-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpiodriverRun.sh
88 lines (84 loc) · 1.76 KB
/
gpiodriverRun.sh
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
#!/bin/bash
DRIV_NAME=GpioDriverMod.ko
KERN_LOG=/var/log/kern.log
if [ $# -ge 1 ]; then
if [ $1 -eq 0 ]; then
echo "Log dump:"
dmesg
exit
fi
fi
if [ $# -le 1 ]; then
echo "Provide execution mode"
echo "Parameter 1:"
echo " > 0 : dmesg"
echo " > 1 : Load module"
echo " > 2 : Unload module"
echo " > 3 : Load and unload moule"
echo "Parameter 2:"
echo " > 0 : desable tail"
echo " > 1 : enable tail"
elif [ $1 -eq 1 ]; then
insmod $DRIV_NAME
if [ $? -eq 0 ]; then
echo "Module loaded"
else
if [ $2 -eq 1 ]; then
tail $KERN_LOG
fi
echo "FAIL"
exit
fi
if [ $2 -eq 1 ]; then
tail $KERN_LOG
fi
elif [ $1 -eq 2 ]; then
rmmod $DRIV_NAME
if [ $? -eq 0 ]; then
echo "Module unloaded"
else
if [ $2 -eq 1 ]; then
tail $KERN_LOG
fi
echo "FAIL"
exit
fi
if [ $2 -eq 1 ]; then
tail $KERN_LOG
fi
elif [ $1 -eq 3 ]; then
insmod $DRIV_NAME
if [ $? -eq 0 ]; then
echo "Module loaded"
else
if [ $2 -eq 1 ]; then
tail $KERN_LOG
fi
echo "FAIL"
exit
fi
rmmod $DRIV_NAME
if [ $? -eq 0 ]; then
echo "Module unloaded"
else
if [ $2 -eq 1 ]; then
tail $KERN_LOG
fi
echo "FAIL"
exit
fi
if [ $2 -eq 1 ]; then
tail $KERN_LOG
fi
else
echo "Invalid mode!"
echo "Provide execution mode"
echo "Parameter 1:"
echo " > 0 : dmesg"
echo " > 1 : Load module"
echo " > 2 : Unload module"
echo " > 3 : Load and unload moule"
echo "Parameter 2:"
echo " > 0 : desable tail"
echo " > 1 : enable tail"
fi