SXXXXXXX_PyBusMonitor1553/tests/test_b3_pack.py
2026-01-07 10:41:14 +01:00

29 lines
764 B
Python

import struct
import sys, os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'pybusmonitor1553')))
from Grifo_E_1553lib.messages.tws_status_and_targets import TwsStatusAndTargets0102
def dump_message_words(msg):
b = bytes(msg)
nwords = len(b)//2
le = struct.unpack("<%dH" % nwords, b)
be = struct.unpack(">%dH" % nwords, b)
print(f"msg len={len(b)} bytes, words={nwords}")
print("LE words:", [hex(x) for x in le])
print("BE words:", [hex(x) for x in be])
return le, be
def main():
m = TwsStatusAndTargets0102()
try:
m.track_id_of_tws_tracked_target_01_02.track_01_id.raw = 0x55
except Exception:
pass
dump_message_words(m)
if __name__ == '__main__':
main()