1import pyudev
2context = pyudev.Context()
3monitor = Monitor.from_netlink()
4# For USB devices
5monitor.filter_by(susbsytem='usb')
6# OR specifically for most USB serial devices
7monitor.filter_by(susbystem='tty')
8for action, device in monitor:
9 vendor_id = device.get('ID_VENDOR_ID')
10 # I know the devices I am looking for have a vendor ID of '22fa'
11 if vendor_id in ['22fa']:
12 print 'Detected {} for device with vendor ID {}'.format(action, vendor_id)
13
1import pyudev
2context = pyudev.Context()
3monitor = Monitor.from_netlink()
4# For USB devices
5monitor.filter_by(susbsytem='usb')
6# OR specifically for most USB serial devices
7monitor.filter_by(susbystem='tty')
8for action, device in monitor:
9 vendor_id = device.get('ID_VENDOR_ID')
10 # I know the devices I am looking for have a vendor ID of '22fa'
11 if vendor_id in ['22fa']:
12 print('Detected {} for device with vendor ID {}'.format(action, vendor_id))
13