dlestxetx: DLE/STX/ETX packet encoder/decoder

latest release on PyPI build & test status test coverage status

DLE/STX/ETX is a packet framing algorithm, used by some devices (such as Metlink LED passenger information displays) to transmit data as packets over a serial medium. This algorithm delimits data using DLE, STX, and ETX control codes.

Packets begin with a DLE STX sequence, follow with a byte-stuffed data stream (all DLE bytes in the data are conveyed as DLE DLE), and end with a DLE ETX sequence.

The dlestxetx module provides functions to encode data into packets:

>>> from dlestxetx import encode
>>> encode(b'\x01\x10\x05')
b'\x10\x02\x01\x10\x10\x05\x10\x03'

decode packets into data:

>>> from dlestxetx import decode
>>> decode(b'\x10\x02\x01\x10\x10\x05\x10\x03')
b'\x01\x10\x05'

and read packets directly from file objects:

>>> from dlestxetx import read
>>> packets = BytesIO(encode(b'\x04\x05\x06') + encode(b'\x07\x08\x09'))
>>> read(packets)
b'\x04\x05\x06'
>>> read(packets)
b'\x07\x08\x09'

Installation

Install this module from PyPI using pip:

pip install dlestxetx

Changes

1.0.1
Add support for Python 3.5.
1.0.0
Initial release.

License

This project is licensed under the MIT License.

Copyright (c) 2019 Alex Peters

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Index