@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; }
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)); } }
@Override public boolean isInitialized(IByteQueue byteQueue) { if (byteQueue.size() < 1) return false; byte firstByteInQueue = byteQueue.deque(); return firstByteInQueue == ACK; }
private byte[] parseDataBytes(int dataSize) { byte[] dataBytes = new byte[dataSize]; for (int pos = 0; pos < dataSize; pos++) { dataBytes[pos] = byteQueueToParse.deque(); } return dataBytes; }
private int parseAddress() { byte highByte = byteQueueToParse.deque(); byte lowByte = byteQueueToParse.deque(); return getAddressFrom(highByte, lowByte); }
private int parseDataSize() { return byteQueueToParse.deque(); }