// read get the data from a given register
489123
func (m *MCP23017Driver) read(reg uint8) (val uint8, err error) {
	buf := []byte{0}
	if _, err := m.connection.Write([]uint8{reg}); err != nil {
		return val, err
	}
	bytesRead, err := m.connection.Read(buf)
	if err != nil {
		return val, err
	}
	if bytesRead != 1 {
		err = ErrNotEnoughBytes
		return
	}
	if debug {
		log.Printf("reading: MCP address: 0x%X, register:0x%X,value: 0x%X\n", m.GetAddressOrDefault(mcp23017Address), reg, buf)
	}
	return buf[0], nil
}
288147
func (c *meteredConn) Read(b []byte) (n int, err error) {
	n, err = c.Conn.Read(b)
	ingressTrafficMeter.Mark(int64(n))
	c.lock.RLock()
	if c.trafficMetered {
		c.ingressMeter.Mark(int64(n))
	}
	c.lock.RUnlock()
	return n, err
}
141213
func (p *parser) read() {
	p.pt.offset += p.pt.w
	rn, n := utf8.DecodeRune(p.data[p.pt.offset:])
	p.pt.rn = rn
	p.pt.w = n
	p.pt.col++
	if rn == '\n' {
		p.pt.line++
		p.pt.col = 0
	}

	if rn == utf8.RuneError && n == 1 { // see utf8.DecodeRune
		if !p.allowInvalidUTF8 {
			p.addErr(errInvalidEncoding)
		}
	}
}
243141
func (ar *AnsiReader) Read(b []byte) (int, error) {
	return ar.file.Read(b)
}
77061
func (f *woFile) Read(p []byte) (n int, err error) {
	return 0, ErrWriteOnly
}
53872
func (r *reader) read() error {
	n, err := r.r.Read(r.b)
	if err != nil {
		return trace.Wrap(err)
	}
	if n < 1 {
		return trace.Errorf("unexpected error, read 0 bytes")
	}

	switch r.b[0] {
	case OKByte:
		return nil
	case WarnByte, ErrByte:
		r.s.Scan()
		if err := r.s.Err(); err != nil {
			return trace.Wrap(err)
		}
		return trace.Errorf(r.s.Text())
	}
	return trace.Errorf("unrecognized command: %#v", r.b)
}
1236607
func (d *ADS1x15Driver) Read(channel int, gain int, dataRate int) (value float64, err error) {
	if err = d.checkChannel(channel); err != nil {
		return
	}
	mux := channel + 0x04

	return d.rawRead(mux, gain, dataRate)
}
384816
func (i *UI) read(opts *readOptions) (string, error) {
	i.once.Do(i.setDefault)

	// sigCh is channel which is watch Interruptted signal (SIGINT)
	sigCh := make(chan os.Signal, 1)
	signal.Notify(sigCh, os.Interrupt)
	defer signal.Stop(sigCh)

	var resultStr string
	var resultErr error
	doneCh := make(chan struct{})

	go func() {
		defer close(doneCh)

		if opts.mask {
			f, ok := i.Reader.(*os.File)
			if !ok {
				resultErr = fmt.Errorf("reader must be a file")
				return
			}

			i.mask, i.maskVal = opts.mask, opts.maskVal
			resultStr, resultErr = i.rawRead(f)
		} else {
			line, err := i.bReader.ReadString('\n')
			if err != nil && err != io.EOF {
				resultErr = fmt.Errorf("failed to read the input: %s", err)
			}

			resultStr = strings.TrimSuffix(line, LineSep)
			// brute force for the moment
			resultStr = strings.TrimSuffix(line, "\n")
		}
	}()

	select {
	case <-sigCh:
		return "", ErrInterrupted
	case <-doneCh:
		return resultStr, resultErr
	}
}
1287525
func Read(f *os.File) (string, error) {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, os.Interrupt)
	defer signal.Stop(ch)

	// Run the actual read in a go-routine so that we can still detect signals
	var result string
	var resultErr error
	doneCh := make(chan struct{})
	go func() {
		defer close(doneCh)
		result, resultErr = read(f)
	}()

	// Wait on either the read to finish or the signal to come through
	select {
	case <-ch:
		return "", ErrInterrupted
	case <-doneCh:
		return removeiTermDelete(result), resultErr
	}
}
232099
func (rd *Reader) Read(b []byte) (n int, err error) {
	if rd.nb == 0 {
		return 0, io.EOF
	}
	if int64(len(b)) > rd.nb {
		b = b[0:rd.nb]
	}
	n, err = rd.r.Read(b)
	rd.nb -= int64(n)

	return
}
233929
func (c *IdleTimingConn) Read(b []byte) (int, error) {
	c.closeMutex.RLock()
	n, err := c.doRead(b)
	c.closeMutex.RUnlock()
	return n, err
}
748964
func (ar *Reader) Read(b []byte) (n int, err error) {
	if ar.nb == 0 {
		// file consumed
		return 0, io.EOF
	}

	if int64(len(b)) > ar.nb {
		b = b[0:ar.nb]
	}
	n, err = ar.r.Read(b)
	ar.nb -= int64(n)

	if err == io.EOF && ar.nb > 0 {
		err = io.ErrUnexpectedEOF
	}
	ar.err = err
	return
}
414475
func (m *Merger) Read() (rec *sam.Record, err error) {
	if len(m.readers) == 0 {
		return nil, io.EOF
	}
	if m.less == nil {
		return m.cat()
	}
	return m.nextBySortOrder()
}
826011
func (file *File) Read(buf []byte) (int, error) {
	n, err := file.ReadAt(buf, int64(file.offset))
	if err == nil {
		file.offset += uint64(n)
	}

	return n, err
}
680404
func (rwops *RWops) Read(buf []byte) (n int, err error) {
	return rwops.Read2(buf, 1, uint(len(buf)))
}
228705
func (d *MCP3004Driver) Read(channel int) (result int, err error) {
	if channel < 0 || channel > MCP3004DriverMaxChannel-1 {
		return 0, errors.New("Invalid channel for read")
	}

	tx := make([]byte, 3)
	tx[0] = 0x01
	tx[1] = byte(8+channel) << 4
	tx[2] = 0x00

	rx := make([]byte, 3)

	err = d.connection.Tx(tx, rx)
	if err == nil && len(rx) == 3 {
		result = int((rx[1]&0x3))<<8 + int(rx[2])
	}

	return result, err
}
103423
func Read(c context.Context, b []byte) (n int, err error) {
	return io.ReadFull(Get(c), b)
}