Пример #1
0
def comports():
    # Scan for all iokit serial ports
    services = GetIOServicesByType('IOSerialBSDClient')
    ports = []
    serial_interfaces = scan_interfaces()
    for service in services:
        # First, add the callout device file.
        device = get_string_property(service, "IOCalloutDevice")
        if device:
            info = list_ports_common.ListPortInfo(device)
            # If the serial port is implemented by IOUSBDevice
            usb_device = GetParentDeviceByType(service, "IOUSBDevice")
            if usb_device:
                # fetch some useful informations from properties
                info.vid = get_int_property(usb_device, "idVendor",
                                            kCFNumberSInt16Type)
                info.pid = get_int_property(usb_device, "idProduct",
                                            kCFNumberSInt16Type)
                info.serial_number = get_string_property(
                    usb_device, "USB Serial Number")
                info.product = get_string_property(usb_device,
                                                   "USB Product Name") or 'n/a'
                info.manufacturer = get_string_property(
                    usb_device, "USB Vendor Name")
                locationID = get_int_property(usb_device, "locationID",
                                              kCFNumberSInt32Type)
                info.location = location_to_string(locationID)
                info.interface = search_for_locationID_in_interfaces(
                    serial_interfaces, locationID)
                info.apply_usb_info()
            ports.append(info)
    return ports
Пример #2
0
 def comports():
     """scan for available ports. return a list of device names."""
     devices = glob.glob('/dev/tty*')
     return [list_ports_common.ListPortInfo(d) for d in devices]
Пример #3
0
 def comports():
     devices = glob.glob('/dev/cua*[!.init][!.lock]')
     return [list_ports_common.ListPortInfo(d) for d in devices]
Пример #4
0
 def comports():
     devices = glob.glob('/dev/ttyS*')
     return [list_ports_common.ListPortInfo(d) for d in devices]