ubuntu手动添加USB转串口新设备

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

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值