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 1 month ago
JSON representation
Python library to encode & decode data as Manchester code
- Host: GitHub
- URL: https://github.com/fphammerle/python-manchester-code
- Owner: fphammerle
- License: gpl-3.0
- Created: 2020-09-04T14:44:00.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-19T14:28:23.000Z (about 2 months ago)
- Last Synced: 2025-05-01T06:03:19.710Z (about 1 month ago)
- Topics: encoding, phase-encoding, radio-frequency, telecommunication, transmission
- Language: Python
- Homepage: https://pypi.org/project/manchester-code/
- Size: 540 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: COPYING
Awesome Lists containing this project
README
# manchester-code
[](https://github.com/psf/black)
[](https://github.com/fphammerle/python-manchester-code/actions)
[](https://pypi.org/project/manchester-code/#history)
[](https://pypi.org/project/manchester-code/)
[](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_bitsmanchester_code = encode([0b00001111, 0b01101001])
print(''.join(f'{m:08b}' for m in manchester_code))
# 01010101101010100110100110010110encode(b'msg')
# b'i\xa6jZij'decode([0b01010101, 0b10101010, 0b01101001, 0b10010110])
# 0000111101101001decode(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]
```