I have home made device that connects via USB port and I have made a c++ program for data acquisition from that device. I have modified the /etc/udev/rules.d/50-ttyusb.rules
so that the device has read/write permissions when pluged. Now I would also like that when I plug-in the device my program (named SQM_ver2
) would automatically run. How can I do this?
The socket assigned to device is ttyACM0
. Using Ubuntu 14.04.
lsusb
output for the device:
Bus 003 Device 005: ID ffff:0005
Edit:
I have modified my rules file as proposed by @steeldriver but it did not work. Note that my program uses Terminal window to output the data. I have always run it from Terminal but now it should open a Terminal by itself. Here I add also the relevant lines in /var/log/syslog
file when the device is pluged-in:
Jun 1 22:21:04 user-Lenovo-G50-45 kernel: [267790.078011] usb 3-1.4: new full-speed USB device number 8 using ehci-pci
Jun 1 22:21:04 user-Lenovo-G50-45 kernel: [267790.187324] usb 3-1.4: New USB device found, idVendor=ffff, idProduct=0005
Jun 1 22:21:04 user-Lenovo-G50-45 kernel: [267790.187339] usb 3-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 1 22:21:04 user-Lenovo-G50-45 kernel: [267790.187347] usb 3-1.4: Product: USBSerial
Jun 1 22:21:04 user-Lenovo-G50-45 kernel: [267790.187353] usb 3-1.4: Manufacturer: LPCUSB
Jun 1 22:21:04 user-Lenovo-G50-45 kernel: [267790.187359] usb 3-1.4: SerialNumber: DEADC0DE
Jun 1 22:21:04 user-Lenovo-G50-45 kernel: [267790.188792] cdc_acm 3-1.4:1.0: ttyACM0: USB ACM device
Jun 1 22:21:04 user-Lenovo-G50-45 mtp-probe: checking bus 3, device 8: "/sys/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1.4"
Jun 1 22:21:04 user-Lenovo-G50-45 mtp-probe: bus: 3, device: 8 was not an MTP device
Edit 2:
Here is how my rules file looks now:
KERNEL=="ttyUSB[0-9]*",MODE="0666"
KERNEL=="ttyACM[0-9]*",MODE="0666",RUN+="/usr/bin/gnome-terminal"
Is there an error? Instead of my program SQM_ver2
I have tried only to open Terminal, but it does not work. The permissions are set correctly, so the 50-ttyusb.rules
file works at least for that part. Also, looking at my 50-ttyusb.rules
file I think that now all devices that I connect and they get assigned ttyUSB
or ttyACM
socket will have read/write permissions (and the program SQM_ver2
would start). I should probably ask another question on how to set permissions for only this device (probably it should compare idVendor
and idProduct
?).
0 Answers