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() # set a few example fields try: m.valitidy_word_and_hpt_identifier.raw = 0x8000 except Exception: pass dump_message_words(m) if __name__ == '__main__': main()