• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS20 Altitude Hold doesn't work on A320 Neo V2

Messages
2
Country
india
from SimConnect import *
import serial
import time

PORT = "COM8"
BAUD = 9600

print("Starting Airbus FCU bridge...")
print("Opening serial:", PORT)

ser = serial.Serial(
PORT,
BAUD,
timeout=1,
dsrdtr=False,
rtscts=False
)

ser.setDTR(False)
ser.setRTS(False)
time.sleep(2)
ser.reset_input_buffer()

print("Serial ready")

print("Connecting to MSFS...")
sm = SimConnect()
ae = AircraftEvents(sm)

def safe_find(name):
try:
ev = ae.find(name)
# some SimConnect wrappers return an object even on unknown names; print to help debug
print(f"[SimConnect] tried find('{name}') -> {type(ev).__name__}")
return ev
except Exception as e:
print(f"[SimConnect] find('{name}') failed: {e}")
return None
#INSTRUMENT_FCU_ALT_Pull_Set
#INSTRUMENT_FCU_ALT_Push_Set
#INSTRUMENT_FCU_ALT_Inc
#INSTRUMENT_FCU_ALT_Dec
# core inc/dec events (keep as before but wrapped)
#inc_event = safe_find("AP_ALT_VAR_INC") or (lambda *a, **k: None)
#dec_event = safe_find("AP_ALT_VAR_DEC") or (lambda *a, **k: None)
#alt_hold_on = safe_find("INSTRUMENT_FCU_ALT_Pull_Set") or (lambda *a, **k: None)
#alt_hold_off = safe_find("INSTRUMENT_FCU_ALT_Push_Set") or (lambda *a, **k: None)

alt_inc = ae.find("AP_ALT_VAR_INC")
alt_dec = ae.find("AP_ALT_VAR_DEC")
alt_push = ae.find("AP_ALT_HOLD")
alt_pull = ae.find("AP_ALT_HOLD")

print("Connected. Waiting for encoder input...\n")

while True:
try:
raw = ser.readline()

if raw:
line = raw.decode("utf-8", errors="ignore").strip()

print(f"[ESP] {line}")

if line == "ALT:+100":
print(" -> Increasing selected altitude")
alt_inc()


elif line == "ALT:-100":
print(" -> Decreasing selected altitude")
alt_dec()
elif line == "ALT:MANAGED":
print(" -> Airbus ALT MANAGED (Push)")
#alt_pull()
event_id = sm.map_to_sim_event('FSUIPC.H:INI_FCU_ALT_PULL')
event_value = 1
sm.send_event(event_id, event_value)
elif line == "ALT:SELECTED":
print(" -> Airbus ALT SELECTED (Pull)")
#alt_push()
event_id = sm.map_to_sim_event('FSUIPC.H:INI_FCU_ALT_PUSH')
event_value = 1
sm.send_event(event_id, event_value)

except Exception as e:
print("ERROR:", e)
time.sleep(1)


several things that i attempted to get the altitude mode set to selected/managed didn't work. any thoughts? This is python code.
 
Try using dotNet or C++. SimConnect was never designed to be used with Python and although many people have tried creating a Python interface, no-one has completely succeeded.
 
Back
Top