0

I've been researching for a while on how to best detect an CAN-USB device being connected and disconnected from a Linux platform (Ubuntu 12.04), but it has been slow progress. The best advice I can find out there suggests to use dbus to detect the insert/removal events. I'm in the process of compiling and installing all necessary libraries for Python 3.3 (which supports CANbus), but its taking quite a while to get all packages and libraries installed due to the sheer number of dependencies.

Can anyone recommend the simplest and easiest way to detect device insert/removal (particularly CAN-USB devices) using standard Linux libs/APIs? Is dbus the way to go?

  • Have you looked into udev instead? Depending on what exactly you need to do, that may make more sense. Also, depending on how exactly the CAN device works, entries may be made in /dev/, so you could just use inotify for that. – rm5248 Apr 04 '13 at 18:01
  • I initially ruled out udev because I've been testing with a virtual can device rather than a real device. I will fire up the real device shortly, but vcan does not appear to add an entry under /dev and is interfaced as a network socket, so it creates an entry under /sys/class/net. Using pyinotify does not work for /sys/ from my understanding (or it did not appear to work in my testing). I think I should just shutup and test more with the real device before asking dumb questions. FYI, I did finally get dbus working ok with Python and detecting the vcan device up/down events – mattlmassey Apr 06 '13 at 21:41

0 Answers0