readData -- input the Modbus message from din. If there was a header,
such as for Modbus/TCP, it will have been read already.
@throws java.io.IOException If the data cannot be read
175816
public void readData(DataInput din) throws IOException {
        byteCount = din.readByte();
        status = din.readUnsignedShort();
        eventCount = din.readUnsignedShort();
        messageCount = din.readUnsignedShort();

        events = new byte[byteCount - 6];

        if (events.length > 0) {
            din.readFully(events, 0, events.length);
        }
    }
389706
public void setData(InputStream in) throws IOException {
        m_dirty = true;
        FileOutputStream out = new FileOutputStream(m_dataFile);
        byte[] buf = new byte[4096];
        int i = 0;
        m_size = 0;
        while ((i = in.read(buf)) != -1) {
            m_size += i;
            out.write(buf, 0, i);
        }
        in.close();
        out.close();
    }
580678
public void readHeader(HttpInputStream in)
        throws IOException
    {
        _state=__MSG_BAD;
        log.warn(LogSupport.NOT_IMPLEMENTED);
    }
1195821
public void readData(BufferedReader in) throws IOException {
    final String SEEN = "SEEN";
    String line;
    int lineNum = 1;
    // all lines have one tagging with raw count per line
    line = in.readLine();
    Pattern p = Pattern.compile("^smooth\\[([0-9])\\] = (.*)$");
    while (line != null && line.length() > 0) {
      try {
        Matcher m = p.matcher(line);
        if (m.matches()) {
          int i = Integer.parseInt(m.group(1));
          smooth[i] = Double.parseDouble(m.group(2));
        } else {
          // split on spaces, quote with doublequote, and escape with backslash
          String[] fields = StringUtils.splitOnCharWithQuoting(line, ' ', '\"', '\\');
          // System.out.println("fields:\n" + fields[0] + "\n" + fields[1] +
          // "\n" + fields[2] + "\n" + fields[3] + "\n" + fields[4]);
          boolean seen = fields[3].equals(SEEN);
          addTagging(seen, new IntTaggedWord(fields[2], fields[0], wordIndex, tagIndex), Double.parseDouble(fields[4]));
        }
      } catch (RuntimeException e) {
        throw new IOException("Error on line " + lineNum + ": " + line, e);
      }
      lineNum++;
      line = in.readLine();
    }
    initRulesWithWord();
  }
735308
function(ip, options) {
    var modbus = this;
    modbus.ip = ip;
    modbus.openFlag = false;
    modbus.callback = null;
    modbus._transactionIdWrite = 1;

    // options
    if (typeof options === "undefined") options = {};
    modbus.port = options.port || MODBUS_PORT;

    // internal buffer
    modbus._buffer = Buffer.alloc(0);

    // handle callback - call a callback function only once, for the first event
    // it will triger
    var handleCallback = function(had_error) {
        if (modbus.callback) {
            modbus.callback(had_error);
            modbus.callback = null;
        }
    };

    // create a socket
    modbus._client = new net.Socket();
    if (options.timeout) this._client.setTimeout(options.timeout);

    // register the port data event
    modbus._client.on("data", function onData(data) {
        // add data to buffer
        modbus._buffer = Buffer.concat([modbus._buffer, data]);

        modbusSerialDebug({
            action: "receive tcp rtu buffered port",
            data: data,
            buffer: modbus._buffer
        });

        // check if buffer include a complete modbus answer
        var bufferLength = modbus._buffer.length;

        // check data length
        if (bufferLength < MIN_MBAP_LENGTH) return;

        // check buffer size for MAX_BUFFER_SIZE
        if (bufferLength > MAX_BUFFER_LENGTH) {
            modbus._buffer = modbus._buffer.slice(-MAX_BUFFER_LENGTH);
            bufferLength = MAX_BUFFER_LENGTH;
        }

        // check data length
        if (bufferLength < MIN_MBAP_LENGTH + EXCEPTION_LENGTH) return;

        // loop and check length-sized buffer chunks
        var maxOffset = bufferLength - MIN_MBAP_LENGTH;
        for (var i = 0; i <= maxOffset; i++) {
            modbus._transactionIdRead = modbus._buffer.readUInt16BE(i);
            var protocolID = modbus._buffer.readUInt16BE(i + 2);
            var msgLength = modbus._buffer.readUInt16BE(i + 4);
            var cmd = modbus._buffer[i + 7];

            modbusSerialDebug({
                protocolID: protocolID,
                msgLength: msgLength,
                bufferLength: bufferLength,
                cmd: cmd
            });

            if (
                protocolID === 0 &&
                cmd !== 0 &&
                msgLength >= EXCEPTION_LENGTH &&
                i + MIN_MBAP_LENGTH + msgLength <= bufferLength
            ) {
                // add crc and emit
                modbus._emitData(i + MIN_MBAP_LENGTH, msgLength);
                return;
            }
        }
    });

    this._client.on("connect", function() {
        modbus.openFlag = true;
        handleCallback();
    });

    this._client.on("close", function(had_error) {
        modbus.openFlag = false;
        handleCallback(had_error);
    });

    this._client.on("error", function(had_error) {
        modbus.openFlag = false;
        handleCallback(had_error);
    });

    this._client.on("timeout", function() {
        // modbus.openFlag is left in its current state as it reflects two types of timeouts,
        // i.e. 'false' for "TCP connection timeout" and 'true' for "Modbus response timeout"
        // (this allows to continue Modbus request re-tries without reconnecting TCP).
        modbusSerialDebug("TcpRTUBufferedPort port: TimedOut");
        handleCallback(new Error("TcpRTUBufferedPort Connection Timed Out"));
    });

    /**
     * Check if port is open.
     *
     * @returns {boolean}
     */
    Object.defineProperty(this, "isOpen", {
        enumerable: true,
        get: function() {
            return this.openFlag;
        }
    });

    EventEmitter.call(this);
}
636237
public static SubscriberState read(DataInput dataInput) throws IOException {
        return SubscriberState.builder().isMaster(dataInput.readBoolean()).serverState(dataInput.readUTF())
                        .totalUpdates(dataInput.readInt()).streamId(dataInput.readInt()).build();
    }
422585
public void readData(DataInput input) throws IOException {
        readReference = input.readUnsignedShort();
        readCount = input.readUnsignedShort();
        writeReference = input.readUnsignedShort();
        writeCount = input.readUnsignedShort();
        int byteCount = input.readUnsignedByte();

        if (nonWordDataHandler == null) {
            byte buffer[] = new byte[byteCount];
            input.readFully(buffer, 0, byteCount);

            int offset = 0;
            registers = new Register[writeCount];

            for (int register = 0; register < writeCount; register++) {
                registers[register] = new SimpleRegister(buffer[offset], buffer[offset + 1]);
                offset += 2;
            }
        }
        else {
            nonWordDataHandler.readData(input, writeReference, writeCount);
        }
    }
174184
protected ModbusResponse readResponseIn() throws ModbusIOException {
        boolean done;
        ModbusResponse response;
        int dlength;

        try {
            do {
                // 1. read to function code, create request and read function
                // specific bytes
                synchronized (byteInputStream) {
                    int uid = readByte();

                    if (uid != -1) {
                        int fc = readByte();
                        byteInputOutputStream.reset();
                        byteInputOutputStream.writeByte(uid);
                        byteInputOutputStream.writeByte(fc);

                        // create response to acquire length of message
                        response = ModbusResponse.createModbusResponse(fc);
                        response.setHeadless();

                        /*
                         * With Modbus RTU, there is no end frame. Either we
                         * assume the message is complete as is or we must do
                         * function specific processing to know the correct
                         * length. To avoid moving frame timing to the serial
                         * input functions, we set the timeout and to message
                         * specific parsing to read a response.
                         */
                        getResponse(fc, byteInputOutputStream);
                        dlength = byteInputOutputStream.size() - 2; // less the crc
                        if (logger.isDebugEnabled()) {
                            logger.debug("Response: {}", ModbusUtil.toHex(byteInputOutputStream.getBuffer(), 0, dlength + 2));
                        }
                        byteInputStream.reset(inBuffer, dlength);

                        // check CRC
                        int[] crc = ModbusUtil.calculateCRC(inBuffer, 0, dlength); // does not include CRC
                        if (ModbusUtil.unsignedByteToInt(inBuffer[dlength]) != crc[0] || ModbusUtil.unsignedByteToInt(inBuffer[dlength + 1]) != crc[1]) {
                            logger.debug("CRC should be {}, {}", crc[0], crc[1]);
                            throw new IOException("CRC Error in received frame: " + dlength + " bytes: " + ModbusUtil.toHex(byteInputStream.getBuffer(), 0, dlength));
                        }
                    }
                    else {
                        throw new IOException("Error reading response");
                    }

                    // read response
                    byteInputStream.reset(inBuffer, dlength);
                    response.readFrom(byteInputStream);
                    done = true;
                }
            } while (!done);
            return response;
        }
        catch (IOException ex) {
            // FIXME: This printout is wrong when reading response from other slave
            throw new ModbusIOException("I/O exception - failed to read response for request [%s] - %s", ModbusUtil.toHex(lastRequest), ex.getMessage());
        }
    }
310932
void readBytes(byte[] buffer, long bytesToRead) throws IOException {
        if (commPort != null && commPort.isOpen()) {
            int cnt = commPort.readBytes(buffer, bytesToRead);
            if (cnt != bytesToRead) {
                throw new IOException("Cannot read from serial port - truncated");
            }
        }
        else {
            throw new IOException("Comm port is not valid or not open");
        }
    }
477482
@Override
  public void readHeader(byte[] data) {
    if(ByteArrayUtil.readInt(data, 0) != FILE_VERSION) {
      throw new RuntimeException("PersistentPageFile version does not match!");
    }

    this.pageSize = ByteArrayUtil.readInt(data, 4);
  }
103362
public void handleData(String data) {
		if (data == null) return;
		text = data;
		sendEvent(new TextInputEvent(this.user, getPayload(), data));
		if (handler != null)
			handler.onType(data);
	}
400498
public void readData(DataInput din) throws IOException {
        // skip all following bytes
        int length = getDataLength();
        for (int i = 0; i < length; i++) {
            din.readByte();
        }
    }
828501
@Override
  public void readSessionData() {
    this.dispatcher.execute(this.userService.isCurrentUserLoggedIn(),
        new AbstractSimpleRestCallback<GwtpSpringSession<T>, Boolean, HttpMessages>(this, this) {

          @Override
          public void onSuccess(final Boolean presult) {
            if (BooleanUtils.isTrue(presult)) {
              // we do have a logged in user, read it
              GwtpSpringSession.this.dispatcher.execute(
                  GwtpSpringSession.this.userService.getCurrentUser(),
                  new AbstractSimpleRestCallback<GwtpSpringSession<T>, T, HttpMessages>(
                      GwtpSpringSession.this, GwtpSpringSession.this) {

                    @Override
                    public void onSuccess(final T presult) {
                      GwtpSpringSession.this.setUser(presult);
                    }
                  });
            } else {
              GwtpSpringSession.this.setUser(null);
            }
          }

        });
  }
604172
public void readData(DataInput din) throws IOException {
        function = din.readUnsignedShort();
        data = (short)(din.readShort() & 0xFFFF);
    }
538216
function _checkData(modbus, buf) {
    // check buffer size
    if (buf.length !== modbus._length && buf.length !== 5) {
        modbusSerialDebug({ action: "length error", recive: buf.length, expected: modbus._length });

        return false;
    }

    // check buffer unit-id and command
    return (buf[0] === modbus._id &&
        (0x7f & buf[1]) === modbus._cmd);
}
841040
@Override
    public int read() throws IOException {
        final int c = super.read();
        if (c >= 0)
            dataLength++;
        checkLength(c == -1);
        return c;
    }
1271425
@Override
	public void read(final DataInput in) throws IOException {
		int size = in.readInt();
		this.map.clear();

		try {
			for (; size > 0; size--) {
				final K key = this.keyClass.newInstance();
				final V val = this.valueClass.newInstance();
				key.read(in);
				val.read(in);
				this.map.put(key, val);
			}
		} catch (final InstantiationException e) {
			throw new RuntimeException(e);
		} catch (final IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}