- Messages
- 2
- Country

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.
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.
