Serial Port Complete - Latest Microcontroller projects

(lily) #1

Chapter 2


can add the values represented by each pair of characters. Intel Hex and Motor-
ola S-Record are two data formats that uses checksums on ASCII Hex data.
The cyclic redundancy check (CRC) method uses more complex calculations to
obtain checksum values. Protocols that use CRC values include the file-transfer
protocols Kermit, XModem, YModem, and ZModem.
Hash values are very secure checksums produced by message detection code
(MDC) hash functions. To use hash values, the sender and receiver must share a
key, which is a value used in creating the hash value and in verifying the
received data.
A computer that receives data with a checksum can repeat the calculation to
obtain the checksum. If the checksum doesn’t match the expected value, the
computer knows it didn’t receive the same data the transmitting computer sent.
A computer that detects an error can notify the sending computer so it can try
again or take other action. After a number of unsuccessful tries, the transmit-
ting computer can give up, display an error message, or sound an alarm as
needed. A checksum adds little overhead to large data blocks.
A receiving computer should also know what to do if a message is shorter than
expected or if expected data or an end-of-message code doesn’t arrive. Instead of
waiting forever, the software should eventually time out and can attempt to
notify the sending computer if needed.
In another form of error checking, the transmitter sends each message twice
and the receiver verifies that the message is the same both times. Of course this
means each message takes twice as long to transmit. Sending duplicate data can
be useful when sending occasional, short bursts of data in an environment
prone to errors. Many infrared data links use this method.
Free download pdf