WRITING AN EMBEDDED APPLICATION LOADER
6
LZT 123 8094 R1A
2.3 Subsequent packets
The basic format of the packets are X modem protocol,
the script is downloaded in raw ASCII format with no
interpretation required. It is upto the user application to
remove any comments, redundant prtf statements, etc.
2.3.1 Xmodem-CRC Protocol (CCITT)
The Download of scripts with the AT*E2APD command
uses the Xmodem-CRC protocol.
The following terms are simply ASCII codes:
• SOH = chr(1) = CTRL-A = Start of header
• EOT = chr(4) = CTRL-D = End of Transmission
• ACK = chr(6) = CTRL-F = Positive
Acknowledgement
• NAK = chr(21) = CTRL-U = Negative
Acknowledgement
• CAN = chr(24) = CTRL-X = Cancel
In order to send the file, the application must first divide it
into 128 byte packets. Bytes 0-127 of the file make up the
first packet, bytes 128-255 make up the second packet,
etc.
The packet number sent is simply the number of the
packet (packet number starts at 0 at beginning of
transmission). If the packet number is greater than 255,
then subtract 256 repeatedly until the number is between
0 and 255. For example, if you were sending packet 731,
then you would send 731 - 256 - 256 = 219.
The 1's complement of a byte is simply 255 minus the
byte. For example, if you had to take the 1's complement
of 142, the answer would be 255 - 142 = 113.
2.3.1.1 Cyclic Redundancy Check
In X-Modem CRC, it is also referred to as CRC-16 since
there are 16 bits (1 word) at the end of the block that
contain the CRC. This 1 word (2 byte) CRC replaces the 1
byte checksum in X-Modem. In this implementation the
CCITT polynomial is used to generate the CRC - X16 +
X12 + X5 + 1.
CRC-16 guarantees detection of all single and double bit
errors, all errors with an odd number of bits and over
99.9969% of all burst errors.