Creating a new directory in /dev using udev rule
Try "synch!synchmess"
as the last arg to dev_create()
; reference:
lists.kernelnewbies.org
Also see this item on Stack Overflow
udev rules, mkdir
Create device symlink with udev based on device response, not udev device info
Blindly chatting on a serial port automatically the moment it is connected to the computer is quite a scary thing to do. Are you sure you want to do this? First of all it will take some time, which will delay the appearance of the device node if udev has to wait for a result before creating it. If the device happens to be powered off or its serial port is disconnected then you won't be able to name it properly (and you will need to have a timeout to detect this). Finally, if another device besides one of the ones you expect is connected, you may be sending it garbage that has unintended consequences.
You might consider relying on the adaptors' serial numbers to tell them apart, and associate each adaptor to an external device in a consistent fashion. If your adaptors even have real serial numbers instead of placeholder strings like 00000000 then you are already lucky!
Nevertheless, this is how you would do it.
As you suspected, you can't use RUN
, because that's too late, the device node has already been created. You have to use PROGRAM
. In your program you are going to have to create the device node yourself using mknod
because udev hasn't done it yet. You should create a temporary node in a temporary location and destroy it before your program exits.
### Create the temporary device node in /tmp
device="/tmp/udev_device_guesser.$$"
# Note: mknod does not appear to be vulnerable to a symlink attack
mknod "$device" c "$MAJOR" "$MINOR"
### Use this device node to query what's attached to the serial port
insert your code here
### Get rid of the temporary node
rm -f "$device"
exit 0
How to find reasons why an udev rule is not applied?
For the udev
rule/ect/udev/rules.d/99-bizrfid.rules
I would add the SUBSYSTEM
:
ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="09d8", ATTRS{idProduct}=="0420", SYMLINK+="ttyMyDevice"
You could add also ATTRS{manufacturer}==
, but idVendor
and idProduct
are sufficient.
Otherwise it looks correct and the test run creates the symlink:
creating link '/dev/ttyMyDevice' to '/dev/ttyACM0'
set up device for development (???????????? no permissions)
What works for me is to kill and start the adb server again. On linux: sudo adb kill-server
and then sudo adb start-server
. Then it will detect nearly every device out of the box.
How do I set up udev rules for debugging a physical android device with Android Studio?
be aware that it might report different IDs, depending on the current USB mode of the device.
therefore it's important is to enable USB debugging first ...
and then use lsusb
in order to obtain the vendor & product IDs ...
Bus 001 Device 070: ID 18d1:4ee7 Google Inc.
the culprit might be the vendor ID, where 12d1
is Huawei - and 18d1
is Google.
... whatever lsusb
outputs goes to udev
rules:
# angler (Nexus 6P)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", MODE="0600", OWNER="yourusername"
then run:
sudo udevadm control --reload-rules
Related Topics
Set Preferred Listen Address in Weblogic 11G
Generic Printing Using a Usb Port
Fork, Execlp and Kill. Zombie Process
Bash - While Read Line from File Print First and Second Column
How to Configure/Make/Install Against an Older Version of a Library
Linux Kill Process Using Timeout in Milliseconds
Is The Program 'Yes' Used for Anything Significant
Timeouting a While Loop in Linux Shell Script
Errors While Trying to Build Gdb for Arm
Starting with Kde Frameworks 5 and Qt Creator
Error While Trying to Run Make Command
Passing a Command with Arguments as a String to Docker Run
Brother Ql-720Nw Specifying Media Size Seems Ignored
Case Statement in a While Loop, Shell Scripting
How to Search The Content of a PDF File in Linux Shell Script
Posix: Pipe Syscall in Freebsd Vs Linux
How to Get The File System Type for Syscall.Mount() Programmatically