thread_func.sh
1.16 KB
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
#!/bin/bash
C_LRED='\033[1;31m'
C_LGREEN='\033[1;32m'
C_LCYAN='\033[1;36m'
C_NC='\033[0m'
C_BLINK='\033[5m'
C_BOLD='\033[1m'
SUMMARY_PATH="/tmp/list"
THREAD_FUNC_NAME=""
function error_check()
{
if [ "$1" != "0" ]; then
echo -e "[${C_LRED}ERR${C_NC}]: $2" >> $SUMMARY_PATH
fi
}
function thread_evtest()
{
echo ""
echo " @@@ [${FUNCNAME}] @@@"
echo ""
THREAD_FUNC_NAME=${FUNCNAME}
evtest << EOF
1
EOF
return $?
}
function thread_tty()
{
echo ""
echo " @@@ [${FUNCNAME}] @@@"
echo ""
DEV_TTY_PATH="$2"
SEND_MESSAGE="$3"
THREAD_FUNC_NAME=${FUNCNAME}
sleep 1
echo "Send: [${SEND_MESSAGE}]"
echo "${SEND_MESSAGE}" > ${DEV_TTY_PATH}
return $?
}
function thread_rs485()
{
echo ""
echo " @@@ [${FUNCNAME}] @@@"
echo ""
DEV_RS485_PATH="$2"
SEND_MESSAGE="$3"
THREAD_FUNC_NAME=${FUNCNAME}
sleep 1
echo "Send: [${SEND_MESSAGE}]"
echo "${SEND_MESSAGE}" > ${DEV_RS485_PATH}
return $?
}
function main()
{
case $1 in
evtest)
thread_evtest
error_check $? ${COMPLETE_TEST_NAME}
;;
tty)
thread_tty $@
error_check $? ${COMPLETE_TEST_NAME}
;;
rs485)
thread_rs485 $@
error_check $? ${COMPLETE_TEST_NAME}
;;
esac
}
main $@