1#!/bin/bash
2# Copyright (c) 2021 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set -e
16
17IFS=$'\n'
18read_log_file="./acm_read_xts"
19pid=$(ps -ef | grep 'usb_dev_test' | grep -v grep | cut -F 2)
20if [ ! "${pid}x" == "x" ];then
21    killall usb_dev_test
22fi
23usb_dev_test -1 abc &
24cat /dev/null > $read_log_file
25while true
26do
27    lines=$(cat $read_log_file)
28    cat /dev/null > $read_log_file
29    for line in $lines
30    do
31        data=$(echo $line | grep 'XTSCHECK' | cut -F 4 | cut -d '[|]' -f 2)
32        if [ ! "${data}x" == "x" ];then
33            echo "[$(date +%s.%N)]" $data
34            usb_dev_test -2 $data
35        fi
36    done
37    sleep 0.1
38done