udev

COM port detection in Linux

安稳与你 提交于 2019-12-06 14:29:15
问题 Please let me know if there is any API, system call, function (in Linux) which I can use my C program to detect a COM port dynamically, i.e., whenever a USB modem dongle is inserted in the port I will be able to detect that COM port using the API, or system call, or function in my C program. 回答1: Depending on your modem, USB serial port device may show up as /dev/ttyUSBn or /dev/ttyACMn , where n is some number starting from 0 . You can configure udev rule to automatically react on device

Udev rules are not working for libusb on Ubuntu 12.04

岁酱吖の 提交于 2019-12-06 11:27:40
问题 I'm on Ubuntu 12.04.5 LTS, x86_64. I've a usb device that uses libusb to communicate with the computer. Once I plug it into the computer and run the communication program I get the following error: libusb couldn't open USB device /dev/bus/usb/008/004: Permission denied. libusb requires write access to USB device nodes. libusb failed to find the Optotrak USB device. Are you sure you have set the udev permissions correctly? So if I chmod the /dev/bus/usb/008/004 as follows: sudo chmod 777 /dev

Getting Notified on “Ethernet cable plugged in” events in linux

社会主义新天地 提交于 2019-12-06 07:52:10
I am writing a Python Application running on linux. I want to be able to register and be notified by the system if a network cable is plugged in/ out . I am already using pyUdev (python bindings for libUdev) in order to get notified for USB plug in events. However, because the network eth0 module (for example) always remains loaded (regardless of the cable being plugged in) , I dont get the information I require. It only works for if up/down events. I have read a lot of posts on Windows WMI providing this functionality but none on linux. Am I looking in the right direction? A python way of

浅谈dbus udev udisks

本秂侑毒 提交于 2019-12-06 07:50:49
udev the workflow of udev: 启动初始化时, /dev目录使用tmpfs挂载. 然后, Udev 拷贝 /lib/udev/devices 的静态设备节点到 /dev 目录. Udev守护进程开始运行,为所有连接到系统的设备收集来自内核的uevents. Udev守护进程解析uevent数据,并且对/etc/udev/rules.d中指定的规则进行匹配. 根据指定的规则为设备创建设备节点和符号链接. Udev守护进程读取/etc/udev/rules.d/*.rules 中的规则并且保存到内存里面. Udev接收接收inotify事件,如果某个规则发生了改变,读取这些改变并更新内存副本. udev通过NetLink注册内核的设备事件,当有设备插入/拔除时,udev就会收到通知,它会从事件中所带参数和sysfs中的信息,加载适当的驱动程序,创建dev下的设备节点,使设备处于可用的状态。具体流程如下: udev通过kernel收到一个uevent,若是移除设备的uevent,则删除/dev中相应的设备文件;若是一个添加设备的uevent,则在配置文件/etc/udev/udev.conf或/lib/udev/udev.conf中查找规则文件所在目录(默认规则目录是:/lib/udev/rules.d/,客户规则目录/etc/udev/rules/(优先级最高),

how uevents get triggered in kernel

冷暖自知 提交于 2019-12-06 05:07:25
uevents has been sent from kernel space to user space through netlink socket. In kernel, there must be something trigger uevent. I guess there are two possibilities: Hardware interrupt - this means, once hardware interruption happened, kernel sends event to user space to signal that there is some events happened. software polling - this means, there is always a daemon to check these file system to see if there is anything changed. If so, then update these info to upper layer. Could anyone provide your feedback? Thanks I can't agree with you about polling. uevent is event-based, so there is no

udevadm does not show all attributes inside a docker container

时光怂恿深爱的人放手 提交于 2019-12-05 16:23:11
When I run docker container and list properties of some device with udevadm inside the container, there are only the basic information about the device. When I do the same thing on host, I can see much more. What can I do to get all the information inside the container? host$ udevadm info --query=property /dev/bus/usb/004/008 BUSNUM=004 DEVNAME=/dev/bus/usb/004/008 DEVNUM=008 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.1 DEVTYPE=usb_device DRIVER=usb ID_BUS=usb ID_MODEL=MCP2210_USB-to-SPI_Master ID_MODEL_ENC=MCP2210 USB-to-SPI Master ID_MODEL_ID=00de ID_REVISION=0002 ID_SERIAL

Create openCV VideoCapture from interface name instead of camera numbers

筅森魡賤 提交于 2019-12-05 06:38:17
The normal way to create a videocapture is this: cam = cv2.VideoCapture(n) where n corresponds to the number of /dev/video0 , dev/video1 But because I'm building a robot that uses multiple cameras for different things, I needed to make sure that it was being assigned to the correct camera, I created udev rules that created devices with symbolic links to the correct port whenever a specific camera was plugged in. They appear to be working because when I look in the /dev directory I can see the link: /dev/front_cam -> video1 However I'm not sure how to actually use this now. I thought I could

udev rule with few parent device attributes

限于喜欢 提交于 2019-12-05 02:29:37
问题 I need complex and universal udev rule to determine USB-device plugged in certain port of the any USB hub. so, i have to combine parent attributes of different layers of the device tree... I have this: $udevadm info --query=all --name=/dev/ttyUSB0 --attribute-walk looking at device '/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4:1.0/ttyUSB0/tty/ttyUSB0': KERNEL=="ttyUSB0" SUBSYSTEM=="tty" DRIVER=="" . . . looking at parent device '/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1

How to identify a disconnecting USB device using udev rules?

断了今生、忘了曾经 提交于 2019-12-04 22:59:59
问题 I have two LCD's using Xorg's xinerama feature. Each LCD screen has a touchscreen which are connected to their respective USB lines. Looking into the '/var/log/messages' file, I see the following: kernel: input: Analog Resistive as /class/input/input0 kernel: input: USB HID v1.01 Mouse [Analog Resistive] on usb-0000:00:1d.3-1 kernel: input: Analog Resistive as /class/input/input1 kernel: input: USB HID v1.01 Mouse [Analog Resistive] on usb-0000:00:1d.3-2 For some reason, at some point in time

Is it possible to expose a USB device to an LXC/Docker container?

≡放荡痞女 提交于 2019-12-04 17:53:37
问题 I have an embedded system development image contained in a Docker file. In order to flash the code I need to connect to the nodes via USB Serial (e.g. /dev/ttyACM0 ). With Docker I used the new bind mount feature to (see https://github.com/dotcloud/docker/issues/111, -b or more recently the -v option) to expose the hosts devfs to the container. However, whenever I connect ("cat /d/ttyACM0", d is the bind mount to dev) to the device I get "operation not permitted". Is it possible to not only