Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Lear FMS Transponder overwrites Prepar3d offset

Featured Replies

Bought Learjet FMS expansion pack recently. I use Pilot2ATC function "Copilot sets transponder" but it seems not to work.
A small Test-LUA shows me that P3D Dword offset 0x0354 is overwritten by the new expan pack "digital transponder" as the focus gets on the outer transponder knob.

I searched for a LVAR containing the squawk code of the "digital transponder" but no luck.

So how can I modify the squawk code of the "digital transponder" e.g. by a LUA script ?
Or is it possible to get some kind of fix that the transponder reads offset 0x0354 before writing to it to allow other utilities to set this "digital transponder" ?

3 hours ago, QuaxTheSnoopie said:

I searched for a LVAR containing the squawk code of the "digital transponder" but no luck.

The Lvars for the 4 digital transponder digits are (L:Digit1, enum), (L:Digit2, enum), (L:Digit3, enum), and (L:Digit4, enum).

So, just for example, this little Lua script will load the transponder code 6543 into the digital transponder:

ipc.writeLvar("L:Digit1", 6)
ipc.writeLvar("L:Digit2", 5)
ipc.writeLvar("L:Digit3", 4)
ipc.writeLvar("L:Digit4", 3)

Al

  • Author

Just to finish: short LUA "Lear35A_SyncXPDR.lua" works for me, I start it automatically by my FSUIPC profile for the Lear FMS:

-- 23.07.23/AH Learjet 35A FMS Synchronize "Digital Transponder" to P3D internal transponder
--
--	Flysimware Learjet 35A FMS Expansion Pack delivers a new "Digital Transponder" that synchronizes in a one-way fashion
--	the P3D internal transponder. This leads to a conflict with Pilot2ATC's "Copilot sets Squawk" option (overwriting the latter)
--	
--	This script starts by FSUIPC.ini [Auto] or [Auto.<profile>] Section, it could be started manually by FSUIPC button definition.
--		[Profile.Flysimware_Learjet35A_FMS]
--		1=Learjet 35A FMS N548PA
--		[Auto.Flysimware_Learjet35A_FMS]
--		1=LUA Lear35A_SyncXPDR
 
--	The Script's main procedure starts the sync function every 10.000 ms (or another value in variable cycletime)
--
--  The function LearSyncXpndr reads Digital Transponders LVARs and, if not existing, terminates itself (no Lear FMS aircraft)
--	The P3D internal transponder Squawk (2 bytes BCD coded at offset 0x0354) is divided into its nibbles (halfbytes)
--	They have to be combined digit by digit to a decimal number to compare (BCD x01200 = decimal 4608 <> decimal 1200)
--	If the Squawks are different, the Digital Transponder Squawk is set according to P3D internal Squawk.
--
--	It's a compromise:
--  On one site, manual setting of Digital Transponder is possible:
--  even if P3D internal transponder changes, there's a 10 seconds gap until the function runs again
--	On the other site if a tool like Pilot2ATC sets the P3D internal transponder and there's no focus in VC on the Digital Transponder
--	(knobs not activated by clicking on them), this script sets Digital Transponder accordingly after max. 10 seconds.

--
-- Sync function, called by main entry's event.timer every 10 seconds
--
function LearSyncXpndr(CurrentTime)
-- Get "Digital Transponder" Squawk Code
  DIGSQ1=ipc.readLvar("L:Digit1")
  DIGSQ2=ipc.readLvar("L:Digit2")
  DIGSQ3=ipc.readLvar("L:Digit3")
  DIGSQ4=ipc.readLvar("L:Digit4")
-- Check if "L:Digit..." LVARs were returned, if not: no Lear FMS - end timer procedure
  if DIGSQ1 == nil or DIGSQ2 == nil or DIGSQ3 == nil or DIGSQ4 == nil then
    ipc.display("LUA only for Flysimware Learjet 35A with FMS (L:Digit... undefined)")
	ipc.sleep(2000)
	ipc.exit()
  end
-- Combine Digital Transponder Squawk digits to decimal number
  DIGSQ=(DIGSQ1 * 1000) + (DIGSQ2 * 100) + (DIGSQ3 * 10) + DIGSQ4
-- Get P3D BCD-coded Squawk Code and extract nibbles (halfbytes)
-- we need them to build a decimal compare number and to set Digital Transponder if not equal
  XPNDR=ipc.readUW(0x0354)
  XPNDR1=logic.Shr(XPNDR,12)		-- get first nibble by shift right 12 bits
  XPNDR1=logic.And(XPNDR1,15)		-- and leave only rightmost four bits
  XPNDR2=logic.Shr(XPNDR,8)		-- get second nibble by shift right 8 bits
  XPNDR2=logic.And(XPNDR2,15)		-- and leave only rightmost four bits
  XPNDR3=logic.Shr(XPNDR,4)		-- get third nibble by shift right 4 bits
  XPNDR3=logic.And(XPNDR3,15)		-- and leave only rightmost four bits
  XPNDR4=logic.And(XPNDR,15)		-- get fourth nibble: leave only rightmost four bits
-- Combine P3D internal transponder digits to decimal number
  XPNDRDEC=(XPNDR1 * 1000) + (XPNDR2 * 100) + (XPNDR3 * 10) + XPNDR4
-- If Digital Transponder Squawk and P3D-internal Squawk are not equal: set "Digital Transponder"
  if DIGSQ ~= XPNDRDEC then
-- Set Digital Transponder Squawk to P3D Squawk 
    ipc.WriteLvar("L:Digit1", XPNDR1)
    ipc.WriteLvar("L:Digit2", XPNDR2)
    ipc.WriteLvar("L:Digit3", XPNDR3)
    ipc.WriteLvar("L:Digit4", XPNDR4)
  end

-- just for debugging: show nibbles in hex  
--  XPNDR1X=string.format("%x", XPNDR1)
--  XPNDR2X=string.format("%x", XPNDR2)
--  XPNDR3X=string.format("%x", XPNDR3)
--  XPNDR4X=string.format("%x", XPNDR4)
--  ipc.display("P3D XPD: " .. XPNDR1 .. "-" .. XPNDR2 .. "-" .. XPNDR3 .. "-" .. XPNDR4 .. ".") 
--  ipc.sleep(1000)
--  XPNDRX=string.format("%x", XPNDR)
--  ipc.display("P3D XPX: " .. XPNDR1X .. "-" .. XPNDR2X .. "-" .. XPNDR3X .. "-" .. XPNDR4X .. ".") 
--  ipc.sleep(1000)
--  ipc.display("P3D XP: " .. XPNDRX .. " (BCD !) DigXP: " .. DIGSQ)

end

--
-- Main Entry, called by FSUIPC.ini LUA entry in Section "[Auto]" or "[Auto.<profilename>]"
--
cycletime=10000
event.timer(cycletime, "LearSyncXpndr")
ipc.display ("Started Lear 35A Digital Transponder sync every " .. cycletime .. "ms")
ipc.sleep(1000)

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.