ubuntu添加USB转串口
sudo /sbin/modprobe usbserial
echo 067b 23c3 > /sys/bus/usb-serial/drivers/generic/new_id
如果是脚本运行用户只要插上USB后,./autoInstall.sh就可以一键加载usb驱动
参考脚本如下:
autoInstall.sh代码:
#!/bin/bash
vid=067b
pid=23c3
function getRealPvid
{
check_results=`lsusb|grep "Spreadtrum Communications Inc."`
while [ -z "$check_results" ]
do
echo "32 module is not inserted"
sleep 1s
check_results=`lsusb|grep "Spreadtrum Communications Inc."`
done
echo "check_results is :$check_results"
vid=`echo $check_results | cut -d ' ' -f 6|cut -d ':' -f 1`
pid=`echo $check_results | cut -d ' ' -f 6|cut -d ':' -f 2`
echo $vid
echo $pid
}
function writePvid
{
check_usb=`lsmod|grep "usbserial*"`
if [ -z "$check_usb" ]
then
sudo /sbin/modprobe usbserial
fi
echo $vid $pid > /sys/bus/usb-serial/drivers/generic/new_id
files=$(ls /dev/ttyUSB* 2> /dev/null | wc -l);
if [ "$files" != "0" ]
then
echo "32 module ready!"
else
echo "32 module not ready,please check!"
fi
}
getRealPvid
writePvid