Return the USB device's serial number string descriptor.

        This property will cause some USB traffic the first time it is accessed
        and cache the resulting value for future use.
507902
def serial_number(self):
        
        if self._serial_number is None:
            self._serial_number = util.get_string(self, self.iSerialNumber)
        return self._serial_number
51150
def _hardware_count(self):
        
        return self._counts.get("hardware") + self._counts.get("serial") + self._counts.get("mbed")
1137104
def InternalRecv(self):
    """"""
    first_read = self.InternalReadFrame()
    first_packet = UsbHidTransport.InitPacket.FromWireFormat(self.packet_size,
                                                             first_read)

    data = first_packet.payload
    to_read = first_packet.size - len(first_packet.payload)

    seq = 0
    while to_read > 0:
      next_read = self.InternalReadFrame()
      next_packet = UsbHidTransport.ContPacket.FromWireFormat(self.packet_size,
                                                              next_read)
      if self.cid != next_packet.cid:
        # Skip over packets that are for communication with other clients.
        # HID is broadcast, so we see potentially all communication from the
        # device.  For well-behaved devices, these should be BUSY messages
        # sent to other clients of the device because at this point we're
        # in mid-message transit.
        continue

      if seq != next_packet.seq:
        raise errors.HardwareError('Packets received out of order')

      # This packet for us at this point, so debit it against our
      # balance of bytes to read.
      to_read -= len(next_packet.payload)

      data.extend(next_packet.payload)
      seq += 1

    # truncate incomplete frames
    data = data[0:first_packet.size]
    return (first_packet.cmd, data)
834513
def _normalized_serial(self):
        
        if self._serial is None:
            return None
        normalized_serial = self._serial.replace(' ', '_')
        normalized_serial = normalized_serial.replace(':', '-')
        return normalized_serial
184525
def num_devices(self):
        
        c_count = c_uint()
        _check_return(_NVML.get_function(
            "nvmlDeviceGetCount_v2")(byref(c_count)))
        return c_count.value
430272
def get_tc_device(self):
        

        if self.direction == TrafficDirection.OUTGOING:
            return self.device

        if self.direction == TrafficDirection.INCOMING:
            return self.ifb_device

        raise ParameterError(
            "unknown direction", expected=TrafficDirection.LIST, value=self.direction
        )
756462
def devid(self):
        
        d = self.device
        vend_id = d.get('ID_VENDOR_ID')
        model_id = d.get('ID_MODEL_ID')
        return (vend_id, model_id)
637295
def get_gateway_id(self):
        """"""
        info = next(serial.tools.list_ports.grep(self.port), None)
        return info.serial_number if info is not None else None
886202
def _find_devices(serial=None):
    
    ret = []

    if pyusb1:
        for d in usb.core.find(idVendor=0x1915, idProduct=0x7777, find_all=1,
                               backend=pyusb_backend):
            if serial is not None and serial == d.serial_number:
                return d
            ret.append(d)
    else:
        busses = usb.busses()
        for bus in busses:
            for device in bus.devices:
                if device.idVendor == CRADIO_VID:
                    if device.idProduct == CRADIO_PID:
                        if serial == device.serial_number:
                            return device
                        ret += [device, ]

    return ret
589376
def mps_device_name():
    
    lib = _load_tcmps_lib()
    if lib is None:
        return None

    n = 256
    c_name = (_ctypes.c_char * n)()
    ret = lib.TCMPSMetalDeviceName(_ctypes.byref(c_name), _ctypes.c_int32(n))
    if ret == 0:
        return _decode_bytes_to_native_string(c_name.value)
    else:
        return None
499324
def get_device_name(file_name, sys_obj_id, delimiter=":"):
    

    try:
        with open(file_name, "rb") as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=delimiter)
            for row in csv_reader:
                if len(row) >= 2 and row[0] == sys_obj_id:
                    return row[1]
    except IOError:
        pass  # file does not exists

    return sys_obj_id
460001
def get_ip_addr(self) -> str:
        ''''''
        output, _ = self._execute(
            '-s', self.device_sn, 'shell', 'ip', '-f', 'inet', 'addr', 'show', 'wlan0')
        ip_addr = re.findall(
            r"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b", output)
        if not ip_addr:
            raise ConnectionError(
                'The device is not connected to WLAN or not connected via USB.')
        return ip_addr[0]
1176353
def get_serialnumber(self):
        
        command = const.CMD_OPTIONS_RRQ
        command_string = b'~SerialNumber\x00'
        response_size = 1024
        cmd_response = self.__send_command(command, command_string, response_size)
        if cmd_response.get('status'):
            serialnumber = self.__data.split(b'=', 1)[-1].split(b'\x00')[0]
            serialnumber = serialnumber.replace(b'=', b'')
            return serialnumber.decode() # string?
        else:
            raise ZKErrorResponse("Can't read serial number")
286480
def _dfs_usb_info(obj, parents):
    
    output = {}
    if (
        "BSD Name" in obj
        and obj["BSD Name"].startswith("disk")
        and mbed_volume_name_match.search(obj["IORegistryEntryName"])
    ):
        disk_id = obj["BSD Name"]
        usb_info = {"serial": None}
        for parent in [obj] + parents:
            if "USB Serial Number" in parent:
                usb_info["serial"] = parent["USB Serial Number"]
                break
        output[disk_id] = usb_info
    for child in obj.get("IORegistryEntryChildren", []):
        output.update(_dfs_usb_info(child, [obj] + parents))
    return output
741314
def get_physical_descriptor(self):
        
        raw_data_type = c_ubyte * 1024
        raw_data = raw_data_type()
        if hid_dll.HidD_GetPhysicalDescriptor(self.hid_handle,
            byref(raw_data), 1024 ):
            return [x for x in raw_data]
        return []
429718
def device_characteristics_str(self, indent):
        
        s = "{}\n".format(self.label)
        s += indent + "MAC Address: {}\n".format(self.mac_addr)
        s += indent + "IP Address: {}\n".format(self.ip_addr)
        s += indent + "Port: {}\n".format(self.port)
        s += indent + "Power: {}\n".format(str_map(self.power_level))
        s += indent + "Location: {}\n".format(self.location)
        s += indent + "Group: {}\n".format(self.group)
        return s
817317
def get_manufacturer_string(self):
        
        self._check_device_status()
        str_p = ffi.new("wchar_t[]", 255)
        rv = hidapi.hid_get_manufacturer_string(self._device, str_p, 255)
        if rv == -1:
            raise IOError("Failed to read manufacturer string from HID "
                          "device: {0}".format(self._get_last_error_string()))
        return ffi.string(str_p)