udev

How do I trigger a udev rule?

和自甴很熟 提交于 2019-12-24 08:51:03
问题 I have a barcode scanner, and I would like to run a script when I connect it. With the command udevadm info -ap /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.0/tty/ttyACM0 I get information about the device. Here is an excerpt: looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5': KERNELS == "2-1.5" SUBSYSTEMS == "usb" DRIVERS == "usb" ATTRS {authorized} == "1" ... Now I've created a new file under / etc / udev / rules /: rzha097: /etc/udev/rules.d # cat 90

Files within Docker bind mount directory not updating

允我心安 提交于 2019-12-24 04:44:08
问题 I am using docker bind mount to map the host /dev/serial/ folder generated by Ubuntu (which contains identifying symlinks to serial devices such as /dev/ttyUSB0 ). The full docker container run command I am using is docker run -d --restart always --privileged=true -v /dev/serial:/dev/serial DOCKER_IMAGE_NAME This works fine at first run, however if the serial device is disconnected and reconnected, the symlinks are recreated. This change does not propagate into the docker container and

Listen for harware change events from the linux kernel or udev

早过忘川 提交于 2019-12-22 08:00:05
问题 I need to run some code on storage device mounting and unmounting. How can i listen for these events on linux? I was thinking on adding some udev rules to run some script (any know-how in this matter is appreciated). But I would much rather listen for events from the kernel in some netlink socket with my daemon (just like udev does) or something like that. 回答1: You can use libudev or the more convenient, glib based gudev to monitor udev events in C. 回答2: You have to listen to the "uevent"

How to run Python script on USB flash-drive insertion

徘徊边缘 提交于 2019-12-21 04:34:06
问题 My goal is to run a Python script on USB flash-drive insertion. I have written a udev rule and a shell script that is called in that rule. udev rule: /etc/udev/rules.d/10-usb.rules KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", RUN+="/home/Hypotheron/Desktop/script.sh" script.sh: #!/bin/sh echo 'Hello, world.' > /home/Hypotheron/Desktop/foo.txt #/home/Hypotheron/Desktop/job.py & exit The first line of my Python file is: #!/usr/bin/python I also did these following commands:

How to know which device is connected in which /dev/ttyUSB port

那年仲夏 提交于 2019-12-20 19:11:12
问题 I am using two Wavecom 16-port modems. When I attach the modems to my system, I am able to list of all the /dev/ttyUSB port names, but also I want to know, which modem is containing ports 0 to 16 and which one is containing ports 17 to 32? The modems may be attached and removed many times in a single day, so I also want to keep logs when modems get disconnected and connected again. Any idea how to do so using c/c++/php script/node.js ? 回答1: You can get this information from the sys filesystem

How to know which device is connected in which /dev/ttyUSB port

前提是你 提交于 2019-12-20 19:11:04
问题 I am using two Wavecom 16-port modems. When I attach the modems to my system, I am able to list of all the /dev/ttyUSB port names, but also I want to know, which modem is containing ports 0 to 16 and which one is containing ports 17 to 32? The modems may be attached and removed many times in a single day, so I also want to keep logs when modems get disconnected and connected again. Any idea how to do so using c/c++/php script/node.js ? 回答1: You can get this information from the sys filesystem

How to get notifications for SD card events?

北城以北 提交于 2019-12-18 03:42:01
问题 I want to check the presence of an SD card, and receive notifications for SD card add/remove. So far I have used libudev , and I've made a small application which listens for SD card events. The code is listed below: #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stddef.h> #include <errno.h> #include <sys/time.h> //debug -> remove me #include <libudev.h> #define ADD_FILTER "add" #define REMOVE_FILTER "remove" #define SUBSYSTEM_FILTER "block" #define

python udisks - enumerating device information

人走茶凉 提交于 2019-12-17 19:24:05
问题 It's apparently possible to get a lot of info relating to attached disks using the udisks binary: udisks --show-info /dev/sda1 udisks is apparently just enumerating the data which is available udev. Is it possible to get this information using python? say for example if i just wanted to retrieve the device serial, mount point and size. 回答1: You can use Udisks via dbus directly in python. import dbus bus = dbus.SystemBus() ud_manager_obj = bus.get_object("org.freedesktop.UDisks", "/org

Bash script to detect when my USB is plugged in and to then sync it with a Directory

我只是一个虾纸丫 提交于 2019-12-17 17:45:22
问题 Is there a Bash script and/or daemon that I can write that will detect a specific USB drive and then sync that drive with a directory? 回答1: For future reference, here's how to run a bash script upon detection of a USB drive. Connect your device and run lsusb to retrieve the device's info. You should see something similar to this: $ lsusb Bus 002 Device 039: ID 0bc2:2100 Seagate RSS LLC In this case, the vendor ID of the device is 0bc2 and the product ID is 2100. Now you can create your UDEV

Ubuntu下adb的使用及常见问题处理

半城伤御伤魂 提交于 2019-12-17 17:04:05
一、如何使用 adb 1、adb工具的安装 方案一:使用ubuntu系统自带的安装包 sudo apt-get install android-tools-adb 或者 sudo apt-get install adb 方案二:使用Android源码编译生成的adb文件 Android 源码编译完成之后,会在编译过的项目目录下 ./out/host/linux-x86/bin/ 生成 adb 文件,需要将其拷贝到系统的 /usr/bin 目录下,并更改权限。 sudo cp /home/apuser/code/out/host/linux-x86/bin/adb /usr/bin sudo chmod a+x /usr/bin/adb 说明:这个 adb 文件也可以在 android-sdk-linux 下的 platform-tools 目录下找到。 2 、检查是否安装成功 在终端运行 adb help 或者 adb 查看 adb 是否安装成功。 adb help 或者 adb 正常情况下,可看到adb的版本信息,以及adb支持的相关指令和说明。 3、创建设备USB专用VID mkdir ~/.android echo 0x1782 > ~/.android/adb_usb.ini 可以查看 /home/apuser/.android/adb_usb.ini 是否生成成功