code: def auto_detect_serial_unix(preferred_list=['*']):
      '''try to auto-detect serial ports on unix'''
      import glob
      glist = glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob('/dev/serial/by-id/*')
      ret = []
      others = []
      # try preferred ones first
      for d in glist:
          matches = False
          for preferred in preferred_list:
              if fnmatch.fnmatch(d, preferred):
                  matches = True
          if matches:
              ret.append(SerialPort(d))
          else:
              others.append(SerialPort(d))
      if len(ret) > 0:
          return ret
      ret.extend(others)
      return ref auto_detect_serial_unix(preferred_list=['*']):
      '''try to auto-detect serial ports on unix'''
      import glob
      glist = glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob('/dev/serial/by-id/*')
      ret = []
      others = []
      # try preferred ones first
      for d in glist:
          matches = False
          for preferred in preferred_list:
              if fnmatch.fnmatch(d, preferred):
                  matches = True
          if matches:
              ret.append(SerialPort(d))
          else:
              others.append(SerialPort(d))
      if len(ret) > 0:
          return ret
      ret.extend(others)
      return ret
docs: try to auto-detect serial ports on unix