PyARINC429 is a maintained fork of the original work by Jason Hodge:
https://github.com/aeroneous/PyARINC429
The library provides Python types for encoding and decoding ARINC 429 words:
- BCD
- BNR
- Discrete fields
- Mixed BCD/discrete and BNR/discrete fields
- Bit‑field extraction and validation
- Parity computation
- Label bit‑reversal
- Optional label metadata
- A builder for constructing words
The library targets Python 3.12 and uses type annotations.
git clone https://github.com/yourusername/PyARINC429
cd PyARINC429
pip install .Install test dependencies:
pip install .[test]Run tests:
pytestarinc429/
word.py
bitfields.py
errors.py
builder.py
definitions.py
datatypes/
base.py
bcd.py
bnr.py
discrete.py
Represents a 32‑bit ARINC 429 word.
Parity is recomputed when any bit‑field is written.
Properties:
- label — octal label (0o000–0o377), bit‑reversed on write
- sdi — Source/Destination Identifier (2 bits)
- data — bits 11–29 (19 bits)
- ssm — Sign/Status Matrix (2 bits)
- parity — computed from bits 1–31
- parity_type — ODD_PARITY or EVEN_PARITY
- parity_ok — parity check result
- raw — underlying integer value
Methods:
- get_bit_field(lsb, msb)
- set_bit_field(lsb, msb, value)
- from_int(value, parity_type)
- to_int()
- copy()
- with_fields(label=..., sdi=..., data=..., ssm=...)
- as_dict()
Parity notes:
parity_typecontrols whether the word uses odd or even parity. The libraryparity_typecontrols whether the word uses odd or even parity. The library computes and updates the parity bit automatically whenever a bit field is written (viaset_bit_field). Useparity_okto validate the stored parity against the computed value.Word.validate()performs a parity check and will raise if the parity bit does not match the configuredparity_type.
WordBuilder parity:
- Use
WordBuilder.parity_type(Word.EVEN_PARITY)to fluently set parity when constructing words.
Data field integer semantics:
- Conversions using
int(...)on data-field objects now return the encoded integer payload (the on-wire integer), whilefloat(...)/str(...)and thedecodedproperty continue to expose the semantic decoded value. This makesint(BNR|BCD|Discrete)safe to pass intoset_bit_fieldand aligns the types across data-field classes.
Label metadata:
definitions.pyexposesLabelDefinitionand sample equipment dictionaries (EQUIP_ADC,EQUIP_IRS). These provide optional metadata (name, type, resolution, unit) that can be used by higher-level decoding helpers. The package does not automatically applyLabelDefinitionwhen decoding words — use the metadata as guidance for whichDataFieldType(BNR,BCD,Discrete) to use when interpreting thedataandssmfields.
Fluent builder for constructing words:
from arinc429.builder import WordBuilder
w = (
WordBuilder()
.label(0o123)
.sdi(1)
.data(0x55AA)
.ssm(2)
.build()
)Constructor:
BCD(value, resolution)Attributes:
- decoded
- encoded
- resolution
- sign
Methods:
- decode(bcd_value, bcd_sign, resolution)
- copy()
- with_resolution(new_resolution)
- as_dict()
Constructor:
BNR(value, resolution)Attributes:
- decoded
- encoded
- resolution
Methods:
- decode(bnr_value, bit_length, resolution)
- copy()
- with_resolution(new_resolution)
- as_dict()
Constructor:
Discrete(value)Attributes:
- decoded
- encoded
Methods:
- decode(value)
- copy()
- as_dict()
Optional label metadata:
LabelDefinition(name, type, resolution, unit=None)
EQUIP_ADC
EQUIP_IRSSplits a byte stream into ARINC 429 words using control labels.
Encodes a byte stream into Williamsburg block‑transfer words.
Reassembles Williamsburg frames into a byte stream.
word = arinc429.Word()
word.label = 0o1
encoded = arinc429.BCD(121.5, resolution=0.1)
word.set_bit_field(11, 29, encoded)
decoded = arinc429.BCD.decode(word.data, word.ssm, 0.1)word = arinc429.Word()
word.label = 0o2
encoded = arinc429.BNR(90, 0.043945313)
word.set_bit_field(13, 29, encoded)
word.set_bit_field(11, 12, arinc429.Discrete(1))
decoded = arinc429.BNR.decode(
word.get_bit_field(bnr_field.lsb, bnr_field.msb),
17,
0.043945313
)word = arinc429.Word()
word.label = 0o3
encoded = arinc429.Discrete(6)
word.set_bit_field(11, 13, encoded)
decoded = arinc429.Discrete.decode(word.data)The package exports both WilliamsburgTransmitter and WilliamsburgReceiver at
the package root for convenience. These helpers implement a simple SOF/DATA/EOF
block transfer framing for packing small byte streams into ARINC 429 words.
Example (transmit + receive):
from arinc429 import WilliamsburgTransmitter, WilliamsburgReceiver
tx = WilliamsburgTransmitter()
words = tx.encode(b"HELLO")
rx = WilliamsburgReceiver()
result = None
for w in words:
out = rx.process_word(w)
if out is not None:
result = out
assert result == b"HELLO"Decoding with label metadata:
from arinc429 import Word
from arinc429.definitions import EQUIP_ADC, decode_word
w = Word()
w.label = 0o203 # Pressure Altitude in EQUIP_ADC
# assume `w.data` contains encoded BNR for 100 feet
decoded = decode_word(w, EQUIP_ADC)
if decoded is not None:
data_field, definition = decoded
print(definition.name, float(data_field))
else:
# handle missing metadata gracefully
print("No label metadata; decode manually using BNR/BCD/Discrete")Or using the Word helper:
from arinc429 import Word
from arinc429.definitions import EQUIP_ADC
w = Word()
try:
decoded = w.decode_by_label(EQUIP_ADC)
except KeyError:
# Missing label metadata
decoded = None
if decoded:
print(float(decoded))Using Word.validate() without raising exceptions:
w = Word()
errors = w.validate(raise_on_error=False)
if errors:
print("Validation issues:", errors)