
The packet reading function is
get_packet (). It looks for a well formed
packet, beginning with '$', with '#' at the end of data and a valid
2 byte checksum (see Figure 2.2 in Section 2.3 for packet representation
details).
If a valid packet is found, '+' is returned using
put_rsp_char () (see Section 4.5.3.1) and the packet is returned as a pointer
to a struct rsp_buf. Otherwise '-' is
returned and the loop repeated to get a new packet (presumably
retransmitted by the client).
The buffer is statically allocated within
get_packet (). This is acceptable, since
two received packets cannot be in use simultaneously.
In general errors are silently ignored (the connection could be poor
quality). However bad checksums are noted in a warning message. In
the event of end of file being encountered,
get_packet () returns immediately with
NULL as result.
