Raspberry Pi – Device hooks
Raspberry Pi and some connected USB are fine… but not if one or more devices are adressed on another /dev/device on a reboot, your program may break due to not find the correct device.
Create Symlinks using PID/VID
This only works if you do not have exactly the same devices on the Pi, thus for example we have a touchschreen (display and HID input device) and barcode reader (HID input device)
So the above configuration creates for the HID devices:
/dev/input/event1
and
/dev/input/event2
and a framebuffer for the displaylink screen
/dev/fb1
but wich is wich /input/event? and after next reboot…wich device is initialized first?
Now…to hook your devices you can use lsusb to view a list with corresponding vid/pid:
1 2 3 |
Bus 001 Device 007: ID 17e9:03f9 DisplayLink Bus 001 Device 005: ID 04e7:1080 Elo TouchSystems Bus 001 Device 008: ID 1eab:1a22 Bar code reader |
To create symlinks (aka shortcuts) you can edit the file /etc/udev/rules.d/10-local.rules
1 2 3 |
ACTION=="add", ATTRS{idVendor}=="17e9", ATTRS{idProduct}=="03f9", SYMLINK+="dlink" ACTION=="add", ATTRS{idVendor}=="04e7", ATTRS{idProduct}=="1080", SYMLINK+="dtouch" ACTION=="add", ATTRS{idVendor}=="1eab", ATTRS{idProduct}=="1a22", SYMLINK+="barread" |
after a reboot there are symlinks created in the /dev folder wich you can use now too:
Display link: /dev/dlink
Display touch:/dev/dtouch
Barcode reader:/dev/barread