odwdinc / Python-SimConnect

Python interface for MSFS2020 SimConnect.dll

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to Get Aircraft Transponder Code

t-jones14 opened this issue · comments

commented

transponder = aq.get("TRANSPONDER_CODE") print("Transponder Code: ", transponder)

returns

Transponder Code: None

commented

UPDATE: All good. Turns out it was returning a float. If you convert to int and use hex() all good. See following:
transponder = hex(int(aq.get("TRANSPONDER_CODE:1")))
returns 0x4044 (which is the correct transponder code)
Now clean the result: print("Transponder Code: ", transponder.lstrip("0x"))
==========================
Okay, I've gotten somewhere.

I didn't realize there was an index to the variable. By updating to the following:

transponder = aq.get("TRANSPONDER_CODE:1")

I am returned with "16452.0" - however, the transponder code is set to "4044"

What am I missing?

commented

All good. Turns out it was returning a float. If you convert to int and use hex() all good. See following:
transponder = hex(int(aq.get("TRANSPONDER_CODE:1")))
returns: 0x4044
which is the correct transponder code
Now clean the result: print("Transponder Code: ", transponder.lstrip("0x"))