read data on the IN endpoint associated to the HID interface
335022
def read(self, timeout=1.0):
        
        start = time()
        while len(self.rcv_data) == 0:
            if time() - start > timeout:
                # Read operations should typically take ~1-2ms.
                # If this exception occurs, then it could indicate
                # a problem in one of the following areas:
                # 1. Bad usb driver causing either a dropped read or write
                # 2. CMSIS-DAP firmware problem cause a dropped read or write
                # 3. CMSIS-DAP is performing a long operation or is being
                #    halted in a debugger
                raise Exception("Read timed out")
        return self.rcv_data.popleft()
700955
def readpartial(maxlen, outbuf = nil)
      return socket.read_nonblock(maxlen, outbuf)
    rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::ECONNRESET
      if wait_readable(read_timeout)
        retry
      else
        raise Timeout, "Could not read from #{host}:#{port} in #{read_timeout} seconds"
      end
    end
1168135
def enumerate(cls):
        
        devices = {}
        for d in hid.enumerate(0, 0):
            vendor_id = d['vendor_id']
            product_id = d['product_id']
            serial_number = d['serial_number']
            interface_number = d['interface_number']
            path = d['path']

            # HIDAPI on Mac cannot detect correct HID interfaces, so device with
            # DebugLink doesn't work on Mac...
            if devices.get(serial_number) != None and devices[serial_number][0] == path:
                raise Exception("Two devices with the same path and S/N found. This is Mac, right? :-/")

            if (vendor_id, product_id) in DEVICE_IDS:
                devices.setdefault(serial_number, [None, None, None])
                if is_normal_link(d):
                    devices[serial_number][0] = path
                elif is_debug_link(d):
                    devices[serial_number][1] = path
                else:
                    raise Exception("Unknown USB interface number: %d" % interface_number)

        # List of two-tuples (path_normal, path_debuglink)
        return list(devices.values())
604172
public void readData(DataInput din) throws IOException {
        function = din.readUnsignedShort();
        data = (short)(din.readShort() & 0xFFFF);
    }
203625
def get_usage_string(self):
        
        if self.string_index:
            usage_string_type = c_wchar * MAX_HID_STRING_LENGTH
            # 128 max string length
            abuffer = usage_string_type()
            hid_dll.HidD_GetIndexedString(
                self.hid_report.get_hid_object().hid_handle,
                self.string_index,
                byref(abuffer), MAX_HID_STRING_LENGTH-1 )
            return abuffer.value
        return ""
186941
private int readPlaintextData(final ByteBuffer dst) {
        final int sslRead;
        final int pos = dst.position();
        if (dst.isDirect()) {
            sslRead = SSL.readFromSSL(ssl, bufferAddress(dst) + pos, dst.limit() - pos);
            if (sslRead > 0) {
                dst.position(pos + sslRead);
            }
        } else {
            final int limit = dst.limit();
            final int len = min(maxEncryptedPacketLength0(), limit - pos);
            final ByteBuf buf = alloc.directBuffer(len);
            try {
                sslRead = SSL.readFromSSL(ssl, memoryAddress(buf), len);
                if (sslRead > 0) {
                    dst.limit(pos + sslRead);
                    buf.getBytes(buf.readerIndex(), dst);
                    dst.limit(limit);
                }
            } finally {
                buf.release();
            }
        }

        return sslRead;
    }
299198
public String getDatacenter(InetAddress endpoint)
    {
        String[] info = getEndpointInfo(endpoint);
        assert info != null : "No location defined for endpoint " + endpoint;
        return info[0];
    }
219565
protected static List<EndpointInfo> extractEndpointInfo(EndpointPart root) {
        List<EndpointInfo> endpoints = new ArrayList<EndpointInfo>();

        root.extractEndpointInfo(endpoints, "");

        return endpoints;
    }
342474
def get_data(self, size=None, addr=None):
        '''
        
        '''
        # readback memory offset
        if addr is None:
            addr = self._mem_bytes

        if size and self._mem_bytes < size:
            raise ValueError('Size is too big')

        if size is None:
            return self._intf.read(self._conf['base_addr'] + self._spi_mem_offset + addr, self._mem_bytes)
        else:
            return self._intf.read(self._conf['base_addr'] + self._spi_mem_offset + addr, size)
15076
def connect(self):
        """"""
        transport = self._defs.find_device()
        if not transport:
            raise interface.NotFoundError('{} not connected'.format(self))

        log.debug('using transport: %s', transport)
        for _ in range(5):  # Retry a few times in case of PIN failures
            connection = self._defs.Client(transport=transport,
                                           ui=self.ui,
                                           state=self.__class__.cached_state)
            self._verify_version(connection)

            try:
                connection.ping(msg='', pin_protection=True)  # unlock PIN
                return connection
            except (self._defs.PinException, ValueError) as e:
                log.error('Invalid PIN: %s, retrying...', e)
                continue
            except Exception as e:
                log.exception('ping failed: %s', e)
                connection.close()  # so the next HID open() will succeed
                raise
622582
private boolean readSend(InH3 hIn,
                           OutboxAmp outbox,
                           HeadersAmp headers)
      throws IOException
  {
    MethodRefHamp methodHamp = null;
    
    try {
      methodHamp = readMethod(hIn);
    } catch (Throwable e) {
      log.log(Level.FINER, e.toString(), e);
      
      skipArgs(hIn);
      
      return true;
    }

    MethodRefAmp method = methodHamp.getMethod();
    
    //ClassLoader loader = method.getService().getManager().getClassLoader();
    ClassLoader loader = methodHamp.getClassLoader();
    Thread thread = Thread.currentThread();
    thread.setContextClassLoader(loader);
    // XXX: _serializer.setClassLoader(loader);

    Object []args = readArgs(methodHamp, hIn);

    if (log.isLoggable(_logLevel)) {
      log.log(_logLevel, this + " send-r " + method.getName() + debugArgs(args)
                + " {to:" + method + ", " + headers + "}");
    }
    
    // XXX: s/b systemMailbox
    SendMessage_N sendMessage
      = new SendMessage_N(outbox,
                          headers, 
                          method.serviceRef(), method.method(),
                          args);
    
    long timeout = 1000L; // mailbox delay timeout

    try {
      //sendMessage.offer(timeout);
      //sendMessage.offerQueue(timeout);
      //        // sendMessage.getWorker().wake();
      sendMessage.offer(timeout);
    } catch (Throwable e) {
      log.fine(e.toString());
      
      if (log.isLoggable(Level.FINEST)) {
        log.log(Level.FINEST, e.toString(), e);
      }
    }
    
    return true;
  }
999408
def write_data(self, buf):
        
        result = self.devh.controlMsg(
            usb.ENDPOINT_OUT + usb.TYPE_CLASS + usb.RECIP_INTERFACE,
            usb.REQ_SET_CONFIGURATION, buf, value=0x200, timeout=50)
        if result != len(buf):
            raise IOError('pywws.device_libusb.USBDevice.write_data failed')
        return True
925605
def read_tx_body(ptr, tx):
    
    _obj = {"ins": [], "outs": [], 'locktime': None}

    # number of inputs
    ins = read_var_int(ptr, tx)

    # all inputs
    for i in range(ins):
        _obj["ins"].append({
            "outpoint": {
                "hash": read_bytes(ptr, tx, 32)[::-1],
                "index": read_as_int(ptr, tx, 4)
            },
            "script": read_var_string(ptr, tx),
            "sequence": read_as_int(ptr, tx, 4)
        })

    # number of outputs
    outs = read_var_int(ptr, tx)

    # all outputs
    for i in range(outs):
        _obj["outs"].append({
            "value": read_as_int(ptr, tx, 8),
            "script": read_var_string(ptr, tx)
        })

    return _obj
194704
function readBlobData(body, type, asBlob, callback) {
  if (asBlob) {
    if (!body) {
      callback(pouchdbBinaryUtils.blob([''], {type: type}));
    } else if (typeof body !== 'string') { // we have blob support
      callback(body);
    } else { // no blob support
      callback(pouchdbBinaryUtils.base64StringToBlobOrBuffer(body, type));
    }
  } else { // as base64 string
    if (!body) {
      callback('');
    } else if (typeof body !== 'string') { // we have blob support
      pouchdbBinaryUtils.readAsBinaryString(body, function (binary) {
        callback(pouchdbBinaryUtils.btoa(binary));
      });
    } else { // no blob support
      callback(body);
    }
  }
}
1055737
function Temper1Connector() {
  // Options
  this.options = {
    // Decimal ID of the USB vendor 
    vendorID : 3141, 
    // Decimal ID of the USB product
    productID : 29697,
    // Decimal value of the USB interface
    interfaceValue : 1,

    // Command: Read data
    read  : [1, 128, 51, 1, 0, 0, 0, 0]
  };

  // Messages 
  this.messages = {
    connected : 'connected',
    notConnected : 'not connected',
    success : 'success',
    notSupported : 'not supported',
    errorNoDevice : 'Cannot write to HID device'
  };

  // Array of devices
  this.devices = null;

  // A single device
  // @TODO [TimPietrusky] - Allow more devices
  this.device = null;
}
490327
def get_device_path(h_info, interface_data, ptr_info_data = None):
    "
    required_size = c_ulong(0)

    dev_inter_detail_data         = SP_DEVICE_INTERFACE_DETAIL_DATA()
    dev_inter_detail_data.cb_size = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)

    # get actual storage requirement
    SetupDiGetDeviceInterfaceDetail(h_info, byref(interface_data),
            None, 0, byref(required_size),
            None)
    ctypes.resize(dev_inter_detail_data, required_size.value)

    # read value
    SetupDiGetDeviceInterfaceDetail(h_info, byref(interface_data),
            byref(dev_inter_detail_data), required_size, None,
            ptr_info_data)

    # extract string only
    return dev_inter_detail_data.get_string()
37683
def _paloadstr(ins):
    ''' 
    '''
    output = _paddr(ins.quad[2])

    output.append('call __ILOADSTR')
    output.append('push hl')
    REQUIRES.add('loadstr.asm')

    return output