Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fphammerle/python-manchester-code

Python library to encode & decode data as Manchester code
https://github.com/fphammerle/python-manchester-code

encoding phase-encoding radio-frequency telecommunication transmission

Last synced: about 2 months ago
JSON representation

Python library to encode & decode data as Manchester code

Awesome Lists containing this project

README

        

# manchester-code

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![CI Pipeline Status](https://github.com/fphammerle/python-manchester-code/workflows/tests/badge.svg)](https://github.com/fphammerle/python-manchester-code/actions)
[![Last Release](https://img.shields.io/pypi/v/manchester-code.svg)](https://pypi.org/project/manchester-code/#history)
[![Compatible Python Versions](https://img.shields.io/pypi/pyversions/manchester-code.svg)](https://pypi.org/project/manchester-code/)
[![DOI](https://zenodo.org/badge/292872290.svg)](https://zenodo.org/badge/latestdoi/292872290)

Python library to encode & decode data as [Manchester code](https://en.wikipedia.org/wiki/Manchester_code)

## Setup

```sh
$ pip3 install --user --upgrade manchester-code
```

## Usage

0-bits translate to low-high, 1-bits to high-low (G. E. Thomas convention).

```python
from manchester_code import encode, decode, decode_bits

manchester_code = encode([0b00001111, 0b01101001])
print(''.join(f'{m:08b}' for m in manchester_code))
# 01010101101010100110100110010110

encode(b'msg')
# b'i\xa6jZij'

decode([0b01010101, 0b10101010, 0b01101001, 0b10010110])
# 0000111101101001

decode(b'ieiVjeiV')
# b'data'

list(decode_bits([False, True, True, False]))
# [False, True]

list(decode_bits([0, 1, 1, 0, 0, 1, 0, 1]))
# [False, True, False, False]
```