documentation updated

This commit is contained in:
Robin Müller 2021-08-17 16:00:10 +02:00
parent 1cbd72dcfb
commit d1f4652205
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -12,24 +12,29 @@
* https://en.wikipedia.org/wiki/C0_and_C1_control_codes * https://en.wikipedia.org/wiki/C0_and_C1_control_codes
* *
* This encoder can be used to achieve a basic transport layer when using * This encoder can be used to achieve a basic transport layer when using
* char based transmission systems. * char based transmission systems. There are two implemented variants:
* The passed source stream is converted into a encoded stream by adding
* a STX marker at the start of the stream and an ETX marker at the end of
* the stream. Any STX, ETX, DLE and CR occurrences in the source stream can be
* escaped by a DLE character. The encoder also replaces escaped control chars
* by another char, so STX, ETX and CR should not appear anywhere in the actual
* encoded data stream.
* *
* When using a strictly char based reception of packets encoded with DLE, * 1. Escaped variant
*
* The encoded stream starts with a STX marker and ends with an ETX marker.
* STX and ETX occurrences in the stream are escaped and internally encoded as well so the
* receiver side can simply check for STX and ETX markers as frame delimiters. When using a
* strictly char based reception of packets encoded with DLE,
* STX can be used to notify a reader that actual data will start to arrive * STX can be used to notify a reader that actual data will start to arrive
* while ETX can be used to notify the reader that the data has ended. * while ETX can be used to notify the reader that the data has ended.
*
* 2. Non-escaped variant
*
* The encoded stream starts with DLE STX and ends with DLE ETX. All DLE occurrences in the stream
* are escaped with DLE. If the received detects a DLE char, it needs to read the next char
* and to determine whether a start (STX) or end (ETX) of a frame has been detected.
*/ */
class DleEncoder: public HasReturnvaluesIF { class DleEncoder: public HasReturnvaluesIF {
public: public:
/** /**
* Create an encoder instance with the given configuration. * Create an encoder instance with the given configuration.
* @param escapeStxEtx * @param escapeStxEtx Determines whether the algorithm works in escaped or non-escaped mode
* @param escapeCr * @param escapeCr In escaped mode, escape all CR occurrences as well
*/ */
DleEncoder(bool escapeStxEtx = true, bool escapeCr = false); DleEncoder(bool escapeStxEtx = true, bool escapeCr = false);
virtual ~DleEncoder(); virtual ~DleEncoder();
@ -62,10 +67,6 @@ public:
* @param encodedLen * @param encodedLen
* @param addStxEtx Adding STX start marker and ETX end marker can be omitted, * @param addStxEtx Adding STX start marker and ETX end marker can be omitted,
* if they are added manually * if they are added manually
* @param escapeStxEtx STX and ETX occurrences in the given source stream will be escaped and
* encoded by adding 0x40
* @param escapeCr CR characters in the given source stream will be escaped and encoded
* by adding 0x40
* @return * @return
*/ */
ReturnValue_t encode(const uint8_t *sourceStream, size_t sourceLen, ReturnValue_t encode(const uint8_t *sourceStream, size_t sourceLen,
@ -80,10 +81,6 @@ public:
* @param destStream * @param destStream
* @param maxDestStreamlen * @param maxDestStreamlen
* @param decodedLen * @param decodedLen
* @param escapeStxEtx STX and ETX characters were escaped in the encoded stream and need to
* be decoded back as well
* @param escapeCr CR characters were escaped in the encoded stream and need to
* be decoded back as well by subtracting 0x40
* @return * @return
*/ */
ReturnValue_t decode(const uint8_t *sourceStream, ReturnValue_t decode(const uint8_t *sourceStream,