#!/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 $@