Created
February 6, 2012 00:52
-
-
Save basicxman/1748699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| startSequence = [0x0D, 0x0E, 0x7E] | |
| expectedByte = 0 | |
| packetByteCount = 0 | |
| currentPacketID = 0 | |
| dataSize = 0 | |
| loop: | |
| byte = getByte() | |
| if byte == startSequence[expectedByte]: | |
| expectedByte += 1 | |
| if expectedByte == startSequence.size: | |
| packet = new Packet | |
| packetByteCount = 0 | |
| expectedByte = 0 | |
| continue | |
| if packetByteCount == 0: | |
| currentPacketID = byte | |
| else if packetByteCount == 1: | |
| dataSize = byte | |
| else if packetByteCount == dateSize + 3: | |
| # At the trailer byte | |
| if checksumIsCorrect(): | |
| processPacket() | |
| else: | |
| packet.push(byte) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment