3 Star 1 Fork 1

liuliu9520/tinycom

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tinycom_cfg.sh 3.47 KB
一键复制 编辑 原始数据 按行查看 历史
liuyajun 提交于 2020-03-18 14:03 +08:00 . initial version v1.0 --powered by liuyajun
#!/bin/bash
#
# tinycom_cfg.sh
#
# tinycomcfg tinytmp
# tinycom_device_tmp tinycom_speed_tmp tinycom_file_tmp
# --powered by liuyajun(20200316)
#################################################################
device=""
speed=""
filelist=()
selstr=""
curpath=`cd $(dirname $0); pwd -P`
#${var:0:5}
####################
while read line
do
if [ "$device" == "" ];then
device=$line
continue
fi
if [ "$speed" == "" ];then
speed=$line
continue
fi
cnt=${#filelist[@]}
filelist[$cnt]=$line
done < $curpath/tinycomcfg
####################
function fun-device
{
#dialog --textbox ad_seria_com_cfg 20 80
dialog --backtitle "Tinycom configuration:" --ok-label Ok --cancel-label Cancel \
--title "Slect the SCI device:" --fselect $device 7 100 2>$curpath/tinycom_device_tmp
line=""
read line < $curpath/tinycom_device_tmp
if [ $line != "" ];then
device=$line
fi
rm -rf $curpath/tinycom_device_tmp
}
####################
function fun-speed
{
dialog --backtitle "Tinycom configuration:" --ok-label Ok --cancel-label Cancel --title "SCI speed:" \
--inputbox "Please input SCI speed" 7 40 2>$curpath/tinycom_speed_tmp
line=""
read line < $curpath/tinycom_speed_tmp
if [ $line != "" ];then
speed=$line
fi
rm -rf $curpath/tinycom_speed_tmp
}
####################
function fun-addfile
{
dialog --backtitle "Tinycom configuration:" --ok-label Ok --cancel-label Cancel \
--title "Pick one file:" --fselect "$HOME/" 7 100 2>$curpath/tinycom_file_tmp
line=""
read line < $curpath/tinycom_file_tmp
if [ $line != "" ];then
cnt=${#filelist[@]}
filelist[$cnt]=$line
fi
rm -rf $curpath/tinycom_file_tmp
}
####################
function fun-delfile
{
# filelist selstr DEL_FILE_$i ${var:0:5}
dialog --backtitle "Tinycom configuration:" --ok-label Ok --cancel-label Cancel \
--yesno "Are you sure you want to delete this file from the file list?\n[$selstr] : ${filelist[${selstr:9}]}" 20 60
if [ $? -eq 0 ]
then
for((i = ${selstr:9}; i < ${#filelist[@]}-1; i++))
do
filelist[$i]=${filelist[$i+1]}
done
unset filelist[$(expr ${#filelist[@]} - 1)]
fi
}
####################
while [ 1 ]
delfilelist=""
for((i = 0; i < ${#filelist[@]}; i++))
do
if [ ! -z ${filelist[$i]} ]
then
delfilelist="$delfilelist DEL_FILE_$i ${filelist[$i]} "
fi
done
do
dialog --backtitle "Tinycom configuration:" --clear --ok-label Ok --cancel-label Cancel \
--menu "Tinycom:(MOUSE TAB ^ v < > ENTER)" 20 60 12 Device: "$device" Speed: "$speed" ADD_FILE "" $delfilelist Exit "" 2>$curpath/tinytmp
if [ $? -eq 1 ]
then
break 1
fi
selstr=$(cat $curpath/tinytmp)
case $selstr in
Device:)
fun-device ;;
Speed:)
fun-speed ;;
ADD_FILE)
fun-addfile ;;
Exit)
#save VARs to "tinycomcfg"
rm -rf $curpath/tinycomcfg
touch $curpath/tinycomcfg
echo $device>>$curpath/tinycomcfg
echo $speed>>$curpath/tinycomcfg
for((i = 0; i < ${#filelist[@]}; i++))
do
if [ ! -z ${filelist[$i]} ]
then
echo ${filelist[$i]}>>$curpath/tinycomcfg
fi
done
break 1 ;;
*)
fun-delfile ;;
esac
done
rm -rf $curpath/tinytmp
clear
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/liuliu9520/tinycom.git
git@gitee.com:liuliu9520/tinycom.git
liuliu9520
tinycom
tinycom
master

搜索帮助