Skip to content

A python package intended for visualizing digital data line coding, generating parity bits and detecting errors in parity encoded binary data

License

Notifications You must be signed in to change notification settings

RapidCompiler/pydigital

Repository files navigation

PyDigital

PyPI version PyPI - Python Version PyPI - Status License: MIT

This python package PyDigital provides visual representations of digital data line coding 📈 as well as generation of parity bits 🔢 and error detection for binary data.

The package can be used to prototype and visualize digital data transmission using the various line coding plots and the parity encoding and decoding functionalities.

If you like the package, feel free to 🌟 the repo and contribute to it! Also find us on Twitter @PyDigital.

Installation

Install using pip with the command

$ pip install pydigital

Usage

Line Coding

from pydigital import LineCoding

lc = LineCoding()

# Plots differential manchester line coding for the binary string
lc.diffmanchester('10010110')

❗ All line coding methods accept parameters in the form of strings, and arrays/tuples of integers/strings.

Different line coding techniques are available, all of which are listed below.

Method Return Type
unipolar_nrz (binary_string_literal) Plots input binary data in Unipolar NRZ
unipolar_rz (binary_string_literal) Plots input binary data in Unipolar RZ
polar_nrz (binary_string_literal) Plots input binary data in Polar NRZ
polar_nrzl (binary_string_literal) Plots input binary data in Polar NRZL
polar_nrzi (binary_string_literal) Plots input binary data in Polar NRZI
polar_rz (binary_string_literal) Plots input binary data in Polar RZ
bipolar_nrz (binary_string_literal) Plots input binary data in Bipolar NRZ
bipolar_rz (binary_string_literal) Plots input binary data in Bipolar RZ
pseudoternary (binary_string_literal) Plots input binary data in Pseudoternary
manchester_ieee (binary_string_literal) Plots input binary data in IEEE Manchester
manchester_gethomas (binary_string_literal) Plots input binary data in G.E.Thomas Manchester
diffmanchester (binary_string_literal) Plots input binary data in Differential Manchester

Parity Encoding and Decoding

from pydigital import ParityEncDec

pr = ParityEncDec()

vrc = pr.encode_vrc(['10110', '10100'])
print("VRC :", vrc[0])
print("DATA TRANSMITTED :", vrc[1])
# VRC : 10
# DATA TRANSMITTED : 101101 101000
        
vrc = pr.decode_vrc('101101 101000', 5, 2, 2)
print(vrc)
# THE DATA TRANSMITTED IS CORRECT

❗ Binary data are passed as string literals. Spaces are optional.

Encoding and decoding methods for four different types of parity techniques are given below.

Method Return Type
encode_lrc ([binary_string_literals]) Array [LRC Bits, LRC Encoded Data]
encode_vrc ([binary_string_literals]) Array [VRC Bits, VRC Encoded Data]
encode_crc (binary_string_literal, crc_key_string_literal) Array [CRC Bits, CRC Encoded Data]
encode_checksum ([binary_string_literals]) Array [Checksum Bits, Checksum Encoded Data]
decode_lrc (binary_string_literal, bits_per_data_string, number_of_data_strings, return_type) Boolean, Decoded Data, or Text
decode_vrc (binary_string_literal, bits_per_data_string, number_of_data_strings, return_type) Boolean, Decoded Data, or Text
decode_crc (binary_string_literal, crc_key_string_literal, return_type) Boolean, Decoded Data, or Text
decode_checksum (binary_string_literal, bits_per_data_string, number_of_data_strings, return_type) Boolean, Decoded Data, or Text

Development

To contribute to the package, first clone the repository and cd into it.

$ git clone https://github.com/RapidCompiler/pydigital.git
$ cd pydigital

Make changes inside the pydigital folder located in the src directory. You can then test this functionality either by creating a test file and importing the methods into it or by installing the package on your computer.

Create a virtual environment and activate it before you install the package locally.

$ python -m virtualenv env
$ env\Scripts\activate
$ pip install .

Run the pip install . command in the main project directory.

This project does not have a setup.py file and hence cannot be installed in the editable mode.

Issues

You can report bugs and suggest improvements on this repository's issue tracker

License

Designed and published with ♥ by Prathish K V (@prathishkv) and Sanjay S (@rapidcompiler) under MIT License

About

A python package intended for visualizing digital data line coding, generating parity bits and detecting errors in parity encoded binary data

Resources

License

Stars

Watchers

Forks

Packages

No packages published