# Packet input processing

When using the SFB packet reflex system, arriving packets are read into memory automatically, and are 'dispatched' to the sketch for processing.

So in the common case, by the time the sketch becomes involved, a packet-read-from-a-face is already complete and sitting in memory, ready to be accessed however the sketch wishes to do so.

Basic functions for accessing received packets:

- packetLength() The number of bytes in a packet
- packetSource() The face (e.g., NORTH) from which a packet was received.
- packetRead() Read a number or byte from a packet in a variety of format specified by a code.
- packetReadEOF() Have we read to the end of the packet?
- zpacketPrefix() Does the given packet begin with the given string?

Intermediate functions for accessing received packets:

- packetScanf() Read from the packet according to the specified format.
- packetCursor() The index of the next byte-to-be-read within the packet.
- packetReread() Reset the packetCursor() back to the beginning (or elsewhere), allowing (portions of) the packet to be read again.

Advanced, low-level, or internal functions for accessing received packets:

- packetReadLength() The number of bytes that can still be read from the packet
- packetCheckByteValid() See if packet ends with a valid 'check byte'.
- packetFlags() Access the flags of packet.
- packetReadPacket() Read a nested subpacket from inside another packet
- packetReadCheckByte() Read a check byte, that can only appear at the end of a packet.