コード例 #1
0
  @Override
  public boolean isReseted(IByteQueue byteQueue) {
    if (byteQueue.size() < 2) return false;

    byte firstByteInQueue = byteQueue.deque();
    byte secondByteInQueue = byteQueue.deque();

    return firstByteInQueue == ACK && secondByteInQueue == HEALTH_PING;
  }
コード例 #2
0
 private void ensureNextByteIs(byte expected) {
   byte nextByte = byteQueueToParse.deque();
   if (nextByte != expected) {
     throw new RuntimeException(
         String.format("Parse error. Expected: %02X, Found: %02X", expected, nextByte));
   }
 }
コード例 #3
0
  @Override
  public boolean isInitialized(IByteQueue byteQueue) {
    if (byteQueue.size() < 1) return false;

    byte firstByteInQueue = byteQueue.deque();

    return firstByteInQueue == ACK;
  }
コード例 #4
0
  private byte[] parseDataBytes(int dataSize) {
    byte[] dataBytes = new byte[dataSize];

    for (int pos = 0; pos < dataSize; pos++) {
      dataBytes[pos] = byteQueueToParse.deque();
    }

    return dataBytes;
  }
コード例 #5
0
  private int parseAddress() {
    byte highByte = byteQueueToParse.deque();
    byte lowByte = byteQueueToParse.deque();

    return getAddressFrom(highByte, lowByte);
  }
コード例 #6
0
 private int parseDataSize() {
   return byteQueueToParse.deque();
 }