Skip to main content

package Documentation Status codecov PyPI version

DLE Encoder for Python

This encoder provides a simple ASCII transport layer for serial data. It uses the C0 and C1 ASCII control characters for this. You can find a corresponding C++ implementation here. This encoder supports two modes:

Escaped mode

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 while ETX can be used to notify the reader that the data has ended.

Example:

[0, STX, DLE] -> [STX, 0, 0, DLE, STX + 0x40, DLE, DLE, ETX]

Non-escaped mode

The encoded stream starts with DLE STX and ends with DLE ETX. All DLE occurrences in the stream are escaped with DLE. If the receiver detects a DLE char, it needs to read the next char to determine whether a start (STX) or end (ETX) of a frame has been detected.

Example:

[0, STX, DLE] -> [DLE, STX, 0, DLE, STX, DLE, DLE, DLE, ETX]

Install

You can install this package from PyPI

Linux:

python3 -m pip install dle-encoder

Windows:

py -m pip install dle-encoder

Examples

import dle_encoder

encoder = dle_encoder.DleEncoder()
test_array = bytearray([1, 2, 3])
encoded = encoder.encode(test_array)
retval, decoded, bytes_decoded = encoder.decode(encoded)

print(test_array)
print(encoded)
print(decoded)

The non-escaped mode can be used by passing escape_stx_etc=False to the DleEncoder constructor.

License

Copyright 2019-2021 Robin Mueller, KSat e.V. Stuttgart

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for dle-encoder 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dle-encoder 0.2.3
File Size Uploaded
dle-encoder-0.2.3.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dle-encoder 0.2.3
File Interpreter ABI Platform
dle_encoder-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 21.0 kB

Release files / dle-encoder-0.2.3.tar.gz

Download URL dle-encoder-0.2.3.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
62d4a3ed40e7a842b5a7d62f223bae4e922d71be1908c41b852f33d3060382b0
BLAKE2b-256 checksum
How to use checksums
e9fd50d5de267254ec350f19d1b701cb55f64e20a42ec7e3ce0335588962c210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.6

Release files / dle_encoder-0.2.3-py3-none-any.whl

Download URL dle_encoder-0.2.3-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b161cebdd7dc68b158eb88eb15030bf2b2cd935fd409e2ef2e18fb9a4ccf3c0e
BLAKE2b-256 checksum
How to use checksums
28d505563af74b2dd91b219e1912742fd3691658cfed37a84bd22d83a349664c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page