Пример #1
0
 def list_devices(self):
     if os.name == 'posix':
         iterator = sorted(serial_list_ports.grep('tty'))
     else:
         iterator = sorted(serial_list_ports.grep(''))
     for port, desc, hwid in iterator:
         print "%-20s" % (port,)
         print "    desc: %s" % (desc,)
         print "    hwid: %s" % (hwid,)
Пример #2
0
 def match_device(self, search_regex):
     matched_ports = serial_list_ports.grep(search_regex)
     if matched_ports:
         for match_tuple in matched_ports:
             if match_tuple:
                 return match_tuple[0]
     print "No serial port match for anything like: " + search_regex
     return None