gpt4 book ai didi

com.zsmartsystems.zigbee.transport.ZigBeePort.read()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:47:33 26 4
gpt4 key购买 nike

本文整理了Java中com.zsmartsystems.zigbee.transport.ZigBeePort.read()方法的一些代码示例,展示了ZigBeePort.read()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZigBeePort.read()方法的具体详情如下:
包路径:com.zsmartsystems.zigbee.transport.ZigBeePort
类名称:ZigBeePort
方法名:read

ZigBeePort.read介绍

[英]Read a value from the port. This should block until a byte is available.
[中]从端口读取一个值。这会一直阻塞,直到有一个字节可用。

代码示例

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

int val = serialPort.read();

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

while (!close) {
  try {
    int val = port.read();
    if (val == ZToolPacket.START_BYTE) {

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * TODO implement as class that extends inputstream?
 * <p/>
 * This method reads bytes from the underlying input stream and performs the following tasks: keeps track of how
 * many bytes we've read, un-escapes bytes if necessary and verifies the checksum.
 */
@Override
public int read() throws IOException {
  int b = port.read();
  if (b == -1) {
    throw new ZToolParseException("Read -1 from input stream while reading packet!");
  }
  bytesRead++;
  // when verifying checksum you must add the checksum that we are verifying
  // when computing checksum, do not include start byte; when verifying, include checksum
  checksum.addByte(b);
  // log.debug("Read byte " + ByteUtils.formatByte(b) + " at position " + bytesRead + ", data length is " +
  // this.length.getLength() + ", #escapeBytes is " + escapeBytes + ", remaining bytes is " +
  // this.getRemainingBytes());
  if (this.getFrameDataBytesRead() >= (length + 1)) {
    // this is checksum and final byte of packet
    done = true;
    // log.debug("Checksum byte is " + b);
    /*
     * if (!checksum.verify()) {/////////////Maybe expected in ZTool is 0x00, not FF//////////////////// throw
     * new ZToolParseException("Checksum is incorrect.  Expected 0xff, but got " + checksum.getChecksum()); }
     */
  }
  return b;
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com