linux下实现兼容EC20和Air720两种4G模块拨号脚本

           linux下实现兼容EC20和Air720两种4G模块拨号脚本     前面我们已经在imx6ull上成功移植了EC20和Air720这两种4G模块,这两种模块有以下的不同:         EC20产生的节点为/dev/ttyU...

  linux下实现兼容EC20和Air720两种4G模块拨号脚本

    前面我们已经在imx6ull上成功移植了EC20和Air720这两种4G模块,这两种模块有以下的不同:

        EC20产生的节点为/dev/ttyUSB0-3,而Air720产生的节点为/dev/ttyUSB1-4;

        EC20的拨号命令为:/etc/ppp/quectel/quectel-pppd.sh,而Air720的拨号命令为:pppd call air720-ppp;

    可以看到,两中模块的拨号脚本是完全不同的。

    在实际应用中,可能会使用两种模块中的一种,但不确定是使用哪一种,我们希望只使用一个命令就可以实现拨号,因此需要一个兼容性脚本来实现。

    在修改驱动的时候,我们在drivers/usb/serial/option.c中添加了如下形式的代码:

       { USB_DEVICE(0x2C7C, 0x0125) }, //EC20

                        ...

       { USB_DEVICE(0x1286, 0x4e3d) }, //Air720

      这里面的两个数被作为模块的ID号,通过ID号可以识别是哪个USB设备,这两个ID号在系统中解释为idProduct和idVendor:

attachments-2020-04-sEi175Oj5e846d3e971ff.png

    因此,我们可以在系统中通过读取这两个ID号来判断当前使用的是EC20还是Air720。       

     if [ -f "/sys/bus/usb/devices/2-1/bConfigurationValue" ]; then

                idVendor=$(cat /sys/bus/usb/devices/2-1/idVendor)

                idProduct=$(cat /sys/bus/usb/devices/2-1/idProduct)

                #this is Air720

                if [ "$idVendor" = "1286" ] && [ "$idProduct" = "4e3d" ] ; then

                    echo "4G model is Air720"

                #this is EC20

                elif [ "$idVendor" = "2c7c" ] && [ "$idProduct" = "0125" ] ; then

                     echo "4G model is EC20"

                fi

        fi

    如果是EC20,我们就使用/etc/ppp/quectel/quectel-pppd.sh来拨号,如果是Air720,就使用pppd call air720-ppp来拨号。
    if [ -f "/sys/bus/usb/devices/2-1/bConfigurationValue" ]; then
        idVendor=$(cat /sys/bus/usb/devices/2-1/idVendor)
        idProduct=$(cat /sys/bus/usb/devices/2-1/idProduct)
        #this is Air720
        if [ "$idVendor" = "1286" ] && [ "$idProduct" = "4e3d" ] ; then
            echo "4G model is Air720"
            /etc/ppp/quectel/quectel-pppd.sh
        #this is EC20
        elif [ "$idVendor" = "2c7c" ] && [ "$idProduct" = "0125" ] ; then
            echo "4G model is EC20"
            pppd call air720-ppp
        fi
    fi

  • 发表于 2020-04-01 19:23
  • 阅读 ( 1426 )
  • 分类:i.MX6ULL

0 条评论

请先 登录 后评论
ronnie
ronnie

11 篇文章

作家榜 »

  1. BBelephant 13 文章
  2. ronnie 11 文章
  3. FU 9 文章
  4. toca 4 文章
  5. 大飞 3 文章
  6. Vivek 3 文章
  7. jack-fang 2 文章
  8. Bin 1 文章