mirror of
https://github.com/HEYAHONG/ExtBoard-001.git
synced 2025-05-08 07:35:58 +08:00
添加blk_detect
This commit is contained in:
parent
318b27f536
commit
af0e480bb8
@ -1,3 +1,4 @@
|
||||
- [usb_detect](usb_detect):通过USB检测ExtBoard-001.
|
||||
- [serialport_detect](serialport_detect):检测ExtBoard-001的Console串口(由DAPLink提供)。
|
||||
- [blk_detect](blk_detect):在Linux检测ExtBoard-001的DAPLink的块设备(虚拟U盘)。
|
||||
|
||||
|
11
SOFT/blk_detect/ReadMe.md
Normal file
11
SOFT/blk_detect/ReadMe.md
Normal file
@ -0,0 +1,11 @@
|
||||
# 说明
|
||||
|
||||
本程序主要用于检测ExtBoard-001的DAPLink虚拟的块设备。
|
||||
|
||||
采用Linux的sysfs检测。
|
||||
|
||||
# 截图
|
||||
|
||||
## ubuntu测试(Core固件编号001)
|
||||
|
||||

|
56
SOFT/blk_detect/blk_detect.sh
Executable file
56
SOFT/blk_detect/blk_detect.sh
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
function CheckTool
|
||||
{
|
||||
[ -n "$1" ] ||
|
||||
{
|
||||
echo -e "CheckTool 参数错误!!";
|
||||
return 255;
|
||||
};
|
||||
ToolPath=`which $1`;
|
||||
[ -e "$ToolPath" ] ||
|
||||
{
|
||||
echo -e "$1 不存在,请先安装此工具!!!";
|
||||
return 255;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
CheckTool find
|
||||
[ $? -eq 0 ] || exit
|
||||
CheckTool xargs
|
||||
[ $? -eq 0 ] || exit
|
||||
CheckTool dirname
|
||||
[ $? -eq 0 ] || exit
|
||||
CheckTool cat
|
||||
[ $? -eq 0 ] || exit
|
||||
CheckTool readlink
|
||||
[ $? -eq 0 ] || exit
|
||||
|
||||
#判断sysfs
|
||||
SYSFS_BLOCK="/sys/class/block/"
|
||||
[ -d "${SYSFS_BLOCK}" ] || SYSFS_BLOCK="/sys/block"
|
||||
[ -d "${SYSFS_BLOCK}" ] || exit
|
||||
|
||||
|
||||
for i in `find /sys/block/ |xargs realpath`
|
||||
do
|
||||
DIR=`dirname "$i"`
|
||||
DEVNAME=`realpath --relative-to="${DIR}" "${i}"`
|
||||
if [ -b "/dev/${DEVNAME}" ]
|
||||
then
|
||||
while [ "/" != "${DIR}" ]
|
||||
do
|
||||
if [ -e "${DIR}/manufacturer" ] && [ -e "${DIR}/product" ]
|
||||
then
|
||||
if [ "HYH" == `cat "${DIR}/manufacturer"` ] && [ "ExtBoard-001" == `cat "${DIR}/product"` ]
|
||||
then
|
||||
echo "Found ExtBoard-001 DAPLink Block /dev/${DEVNAME}"
|
||||
fi
|
||||
DIR="/"
|
||||
fi
|
||||
DIR=`dirname ${DIR}`
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
BIN
SOFT/blk_detect/blk_detect_001_ubuntu.png
Normal file
BIN
SOFT/blk_detect/blk_detect_001_ubuntu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 128 KiB |
Loading…
x
Reference in New Issue
Block a user