Skip to content

Repository files navigation

python4yahdlc

PyPI Package Latest ReleasePyPI Package Downloads Per MonthPyPI Package Python VersionsBuild Status

python4yahdlc is a Python binding of the yahdlc library, allowing to encode and decode HDLC frames.

Dependencies

This software requires CPython, a C compiler such as Clang or GCC, a C standard library, and the Python development headers.

For example, on Alpine Linux:

apk add python3 gcc python3-dev musl-dev

Installation

From PyPI (recommended)

pip install --upgrade python4yahdlc

From sources

# This will clone only the latest stable version of python4yahdlc.
git clone --single-branch --depth=1 -b main https://github.com/SkypLabs/python4yahdlc.git
# Move into the source code directory.cd python4yahdlc
# Initialise and clone the Git sub-modules (yahdlc itself).
git submodule update --init --recursive
# Install python4yahdlc with pip.
pip install --upgrade .

Usage

To generate a new HDLC data frame:

fromyahdlcimport*frame=frame_data('hello world!')

To generate a new HDLC ACK frame with a specific sequence number:

frame=frame_data('', FRAME_ACK, 3)

The highest sequence number is 7 and the following frame types are available:

  • FRAME_DATA
  • FRAME_ACK
  • FRAME_NACK

Note that when you generate an ACK or NACK frame, the payload is useless.

To decode a received HDLC frame:

data, ftype, seq_no=get_data(frame)

For a more advanced use, take a look at the examples available in the examples folder.

Development

To set up a development environment on your local machine:

# Clone the Git repository and initialise its sub-modules.
git clone https://github.com/SkypLabs/python4yahdlc.git
cd python4yahdlc
git submodule update --init --recursive
# Create a virtual environment and activate it.
python -m venv .venv
source .venv/bin/activate
# Make sure to have the latest versions of pip and setuptools.
pip install --upgrade pip setuptools
# Install python4yahdlc in editable mode with all its optional# dependencies.
pip install -e .[examples,tests]

Licence

This project is released under the GPL version 3 licence. The yahdlc library is released under the MIT licence.

About

Python binding of the yahdlc library

Topics

Resources

Security policy

Stars

22 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages