1      Scope of Document

This document describes how to write udev script, when enum usb device maybe produces several interfaces(/dev/ttyUSB*),

if we want to compatible serveral usb modules, udev script is very useful.when module insert or remove, spec udev script will

be called.example: this module have four port, we can enumerated to specific devices(/dev/ttyfdti1,/dev/ttyftdi1,/dev/ttyftdi2,/dev/ttyftdi3).

#add for ftdi usb-serial

ACTION=="add",KERNELS=="1-1.4:1.0",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi0"

ACTION=="add",KERNELS=="1-1.4:1.1",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi1"

ACTION=="add",KERNELS=="1-1.4:1.2",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi2"

ACTION=="add",KERNELS=="1-1.4:1.3",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi3"

#remove for ftdi usb-serial

ACTION=="remove",KERNELS=="1-1.4:1.0",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi0"

ACTION=="remove",KERNELS=="1-1.4:1.1",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi1"

ACTION=="remove",KERNELS=="1-1.4:1.2",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi2"

ACTION=="remove",KERNELS=="1-1.4:1.3",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi3"

2      Requiremen

2.1     Function Requirement

Custom private udev rules,compatible different hardware module.

2.2     Performance Requirement

NA

3      Hardware Overview

NA

4      Functional Description

4.1     Functional Block Diagram

NA

5      Porting

5.1     System configure

Reference: https://wiki.archlinux.org/index.php/Udev_(简体中文)

https://mirrors.edge.kernel.org/pub/linux/utils/kernel/hotplug/udev/udev.html

example1:

when ec20 module be enumed, it can emum five device interfaces, /dev/tty20ec0,

/dev/tty20ec1,/dev/tty4g,/dev/tty20ec3,/dev/tty20ec4.attention to when enum /dev/tty4g interface, it will run /bin/ifup mobile script to diag-up.

If all internet access modules, its diag port was enumed to /dev/tty4g, we can compible all internet access modules in openwrt rootfs.

# add for ec20

ACTION=="add", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFiscFFipFFin00", ATTRS{bInterfaceNumber}=="00", SYMLINK="tty20ec0"

ACTION=="add", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFisc00ip00in01", ATTRS{bInterfaceNumber}=="01", SYMLINK="tty20ec1"

ACTION=="add", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFisc00ip00in02", ATTRS{bInterfaceNumber}=="02", SYMLINK="tty4g",RUN="/sbin/ifup mobile"

ACTION=="add", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFisc00ip00in03", ATTRS{bInterfaceNumber}=="03", SYMLINK="tty20ec3"

ACTION=="add", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFiscFFipFFin04", ATTRS{bInterfaceNumber}=="04", SYMLINK="tty20ec4"

# remove for ec20

ACTION=="remove", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFiscFFipFFin00", ATTRS{bInterfaceNumber}=="00", SYMLINK="tty20ec0"

ACTION=="remove", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFisc00ip00in01", ATTRS{bInterfaceNumber}=="01", SYMLINK="tty20ec1"

ACTION=="remove", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFisc00ip00in02", ATTRS{bInterfaceNumber}=="02", SYMLINK="tty4g",RUN="/sbin/ifdown mobile"

ACTION=="remove", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFisc00ip00in03", ATTRS{bInterfaceNumber}=="03", SYMLINK="tty20ec3"

ACTION=="remove", ATTRS{modalias}=="usb:v2C7Cp0125d0318dcEFdsc02dp01icFFiscFFipFFin04", ATTRS{bInterfaceNumber}=="04", SYMLINK="tty20ec4"

Example2:
        if you have two usb-serial modules, and you
want to distinguish between them, you can reference follow udev script methon:

#add
for ftdi usb-serial

ACTION=="add",KERNELS=="1-1.4:1.0",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi0"

ACTION=="add",KERNELS=="1-1.4:1.1",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi1"

ACTION=="add",KERNELS=="1-1.4:1.2",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi2"

ACTION=="add",KERNELS=="1-1.4:1.3",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi3"

#remove for ftdi usb-serial

ACTION=="remove",KERNELS=="1-1.4:1.0",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi0"

ACTION=="remove",KERNELS=="1-1.4:1.1",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi1"

ACTION=="remove",KERNELS=="1-1.4:1.2",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi2"

ACTION=="remove",KERNELS=="1-1.4:1.3",SUBSYSTEMS=="usb",DRIVERS=="ftdi_sio",SYMLINK+="ttyftdi3"

Openwrt Udev Configure(3)的更多相关文章

  1. Openwrt WiFi Configure(1)

    1      Scope of Document This document describes how to custom wifi option 2      Requiremen 2.1     ...

  2. Openwrt VLAN Configure(2)

    1      Scope of Document This document describes vlan design on nodewrt2p 2      Requiremen 2.1     ...

  3. [Openwrt 项目开发笔记]:Openwrt平台搭建(一)补遗

    [Openwrt项目开发笔记]系列文章传送门:http://www.cnblogs.com/double-win/p/3888399.html 正文: 昨晚上熬夜写了[Openwrt项目开发笔记]:O ...

  4. [Openwrt 项目开发笔记]:Openwrt平台搭建(一)

    [Openwrt项目开发笔记]系列文章传送门:http://www.cnblogs.com/double-win/p/3888399.html 正文: 最近开始着手进行Openwrt平台的物联网网关设 ...

  5. openwrt 添加 应用(luci-application)

    openwrt 添加应用的几个步骤如下: (1)在目录 ./feeds/luci/applications 下添加要增加的应用,譬如 "luci-test" (2)里面应该包含以下 ...

  6. [Openwrt 项目开发笔记]:Openwrt必要设置(二)

    [Openwrt项目开发笔记]系列文章传送门:http://www.cnblogs.com/double-win/p/3888399.html 正文: 前面的两篇blog中,我将如何搭建Openwrt ...

  7. ASP.NET Core 选项模式源码学习Options Configure(一)

    前言 ASP.NET Core 后我们的配置变得更加轻量级了,在ASP.NET Core中,配置模型得到了显著的扩展和增强,应用程序配置可以存储在多环境变量配置中,appsettings.json用户 ...

  8. udev规则(转)

    Writing udev rules by Daniel Drake (dsd)Version 0.74 The most recent version of this document can al ...

  9. 搭建OpenWrt开发环境(包括编译过程)

    OpenWrt是一个高度模块化.高度自动化的嵌入式linux发行版,其编译和安装过程比普通的linux发行版而言,要简单太多了.如果您是新手,您那恐惧的心大可放到肚子里,呵呵.对于新手来说最麻烦的恐怕 ...

随机推荐

  1. vijos & codevs 能量项链 - 动态规划

    描述 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数.并且,对于相邻的两颗珠子,前一颗珠子的尾标记一定等于 ...

  2. Java实现心跳机制

    一.心跳机制简介 在分布式系统中,分布在不同主机上的节点需要检测其他节点的状态,如服务器节点需要检测从节点是否失效.为了检测对方节点的有效性,每隔固定时间就发送一个固定信息给对方,对方回复一个固定信息 ...

  3. P3066 [USACO12DEC]逃跑的BarnRunning Away From

    目录 题目 思路 错误&&注意 代码 题目 luoguP3066 思路 虽说这个题目有多种做法,但 左偏树算法: 我们发现这个合并的时候并不好合并,因为存的值不是固定的 那我们是不是可 ...

  4. 【文件readonly异常】异常退出编译文件,再次进入提示readonly

    1.对于同一个文件如果上次已经打开,而未关闭的情况下,又打开该文件进行编辑时,会出现如下提醒: 这是由于已经打开但未闭关的文件,会在其目录下出现一个.swp的文件,由于是属于隐藏文件,可以用命令l.  ...

  5. opencv-python 学习初探2 去图片水印

    我要去除的水印是红色的.网上已经有很不错的帖子,我就不贴自己的代码了.留个指路自己以后查资料. 大概的思路就是用颜色拾取工具,拾取水印颜色,分析了图片,找到规律.比如我的图片水印是红色的,红色差不多g ...

  6. 使用Docfx生成项目文档

    使用docfx.console生成本项目的文档 使用docfx.console生成其他项目的文档 直接使用docfx.exe生成项目文档 指定配置文档模板   文档地址:http://gitlab.l ...

  7. DPDK的安装与绑定网卡

    DPDK的安装有两种方法: 第一种是使用dpdk/tools/setup.sh选择命令字来安装:第二种是自己手动安装.为了更好地熟悉DPDK,我使用第二种方法. 0.设定环境变量 export RTE ...

  8. 又见链表 --- 另一种Creat方式与反转

    链表 作为一种数据结构,链表以其方便的增删查改功能,实现了无数经典有用的程序. 在之前的帖子里,我构建链表的方式是建立一个不储存数据的head节点,然后通过一边输入数据一边建立结点的方式构建整个链表. ...

  9. kaggle CTR预估

    参考涛哥之前做过的CTR预估project,学习下CTR预估的相关知识:http://blog.csdn.net/hero_fantao/article/category/6877765 目标:本周末 ...

  10. DEV-C++设置C++11标准

    DEV-C++默认的标准是C++98,改成C++11的方法如下: Tools -> Compiler Options -> Setting -> Code Generation -& ...