3

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?).

  • 2
    It should be possible to add a RUN action to your rule (of the form RUN+="/path/to/SQM_ver2"). Did you try that? If so, what happened? – steeldriver Jun 01 '16 at 09:49
  • No I did not try this. I will report when I finish to work. – NonStandardModel Jun 01 '16 at 10:10
  • I have tried to add RUN to rule but nothing happened. Maybe because my SQM program needs terminal for output? I have edited my question to add syslog output. – NonStandardModel Jun 01 '16 at 20:24
  • @NonStandardModel, Could you try combine my answer on your other question with the one here https://askubuntu.com/questions/625243/how-to-execute-c-program-whenever-a-usb-flash-drive-is-inserted/625705#625705 . then write answer if it works for you otherwise update the question. Let me know. BTW, it is not possible to start a GUI in such confined process of udev, it is only short/quick configuration scripts or programs. (no daemons, no GUI,no interactive CLI ) – user.dz Jun 08 '16 at 04:00

0 Answers0