STX/ETX Packet Protocol Library (stxetx.c)
[General Libraries]
- Overview
- This library provides functions needed to transmit and receive STX/ETX packets over any interface which can send and receive bytes. STX/ETX is a simple packet protocol for serial data streams and offers packetization, type tagging, and checksum protection for user data. Common uses of STX/ETX might include radio communications were it can improve data reliability over lossy channels. STX/ETX may also be used effectively anywhere multiple access to the communication medium is required. The packets can be made to contain destination addresses or routing information as well as data.
- STX/ETX Details
- STX/ETX is a simple packet protocol that can be wrapped around user data for one or more of the following reasons: 1. packetization is needed
- Using packets can be helpful if your data naturally forms little "bunches" or if different types of data must be sent over the same channel (a serial cable, for example). If your data forms "bunches", you can send user data inside STX/ETX packets with a predetermined structure, like an array of A/D conversion results. If you need a way to tell the receiver what kind of data you're sending, you can use the TYPE field in the STX/ETX packet. 2. error checking is needed
- STX/ETX packets will add a checksum to your data. This allows the receiver to verify that data was received correctly and is error-free. Packets which are corrupted in transmission and fail the the checksum test are automatically discarded. Error checking is especially useful when the data transmission channel is unreliable or noisy (examples: radio, infrared, long cables, etc)
STX/ETX packets have the following structure:
[STX][status][type][length][user data...][checksum][ETX]
All fields are 1 byte except for user data which may be 0-255 bytes. Uppercase fields are constant (STX=0x02, ETX=0x03), lowercase fields vary. The length field is the number of bytes in the user data area. The checksum is the 8-bit sum of all bytes between but not including STX/ETX.
Generated on Tue Sep 20 03:11:45 2005 for Procyon AVRlib by
1.4.2