예제 #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();
 }