Giter Site home page Giter Site logo

nubilapardus / pyarinc429 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aeroneous/pyarinc429

0.0 0.0 0.0 13 KB

Discover PyARINC429, a simple Python module for encoding and decoding ARINC 429 digital information.

License: MIT License

Python 100.00%

pyarinc429's Introduction

PyARINC429

PyARINC429 provides object types used for organizing and interpreting digital information as specified by the ARINC 429 data protocol. It supports basic encoding, decoding, and validation for Binary Coded Decimal (BCD), Binary Number Representation (BNR), and discrete word types. It also supports mixed BCD/discrete and BNR/discrete data.

PyARINC429 was developed using Python 3.5.

Example Usage

BCD

>>> word = arinc429.Word()
>>> word.label = 0o1
>>> encoded_vhf1_freq = arinc429.BCD(121.5, resolution=0.1)
>>> bit_field = arinc429.DataField(11, 29, encoded_vhf1_freq)
>>> bit_field
DataField(lsb=11, msb=29, data=BCD(value=121.5, resolution=0.1))
>>> word.set_bit_field(*bit_field)
>>> print(word)
Label=0o1, SDI=0, Data=0x1215, SSM=0, Parity=0
>>> decoded_vhf1_freq = arinc429.BCD.decode(word.data, word.ssm, 0.1)
>>> print(decoded_vhf1_freq)
121.5

BNR

>>> word = arinc429.Word()
>>> word.label = 0o400
ValueError: Label must be >= 0o0 and <= 0o377: 0o400
>>> word.label = 0o2
>>> encoded_pitch = arinc429.BNR(90, 0.043945313)
>>> encoded_pitch
BNR(value=89.956055711, resolution=0.043945313)
>>> bnr_bit_field = arinc429.DataField(13, 29, encoded_pitch)
>>> disc_bit_field = arinc429.DataField(11, 12, arinc429.Discrete(1))
>>> word.set_bit_field(*bnr_bit_field)
>>> print(word)
Label=0o1, SDI=0, Data=0x1ffc, SSM=0, Parity=1
>>> word.set_bit_field(*disc_bit_field)
>>> print(word)
Label=0o1, SDI=0, Data=0x1ffd, SSM=0, Parity=0
>>> arinc429.BNR.decode(word.get_bit_field(bnr_bit_field.lsb, bnr_bit_field.msb), 17, 0.043945313)
BNR(value=89.956055711, resolution=0.043945313)

Discrete

>>> word = arinc429.Word()
>>> word.label = 0o3
>>> encoded_mode = arinc429.Discrete(6)
>>> bit_field = arinc429.DataField(11, 12, encoded_mode)
>>> word.set_bit_field(*bit_field)
arinc429.arinc429.FieldOverflowError: 0x6 overflows 2 bit(s)
>>> bit_field = arinc429.DataField(11, 13, encoded_mode)
>>> bit_field
DataField(lsb=11, msb=13, data=Discrete(value=0x6))
>>> word.set_bit_field(*bit_field)
>>> print(word)
Label=0o3, SDI=0, Data=0x6, SSM=0, Parity=0
>>> decoded_mode = arinc429.Discrete.decode(word.data)
>>> print(decoded_mode)
6

pyarinc429's People

Contributors

aeroneous avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.