本文整理了Java中com.zsmartsystems.zigbee.transport.ZigBeePort.read()
方法的一些代码示例,展示了ZigBeePort.read()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZigBeePort.read()
方法的具体详情如下:
包路径:com.zsmartsystems.zigbee.transport.ZigBeePort
类名称: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;
}
内容来源于网络,如有侵权,请联系作者删除!