You just bought a new input device like barcode scanner, proximity card reader with USB port. And you want expose only its data to a file or send to server for processing ? But it acts like a keyboard, type the characters then trigger
This tutorial can help you make a program can exclusive receive input data from the device and don’t affect to another program.
The program is written in Python and can run on almost Linux system (Ubuntu desktop, Raspberry Pi, Arduino, etc..)
On a Debian compatible OS:
apt-get install python-dev python-pip gcc
On a Redhat compatible OS:
yum install python-devel python-pip gcc
On Arch Linux and derivatives:
pacman -S core/linux-api-headers python-pip gcc
evdev package via
sudo pip install evdev
Copy this file and save as
sudo python main.py
Then enter your event id of device based on device name in devices list. If you want exclusive access to that device (means no application can’t access and read the input data), press
0 to accept or deny.
This is my result, I opened the
gedit and typed a paragragh but no character appears in Editor, but they’re shown in the terminal.
You can rewrite the code to send data to web server
sudo pip install requests
You can read more about evdev API here
- cover photo from blog.pepperl-fuchs.us