-- 04.08.24/AH A2A Bendix-King DME KN62A FREQ (standalone) doesn't work reliable -- -- A2A Bendix-King DME KN62A, delivered by C172 Trainer and PA28 doesn't work reliable in standalone mode -- So I created this script that reads Prepar3D offsets of NAV2 (as there is no NAV3) and -- shows the DME values in a small window -- -- to be done: -- Define button to call script -- Init NAVout="- no NAV state -" DME1out="NAV1 inactive or no DME" DME2out="NAV2 inactive or no DME" -- NAV1mask=18 -- NAVstate bit mask : NAV1 good and has DME = 2^1+ 2^5 = 2 + 16 = 18 NAV2mask=36 -- NAVstate bit mask : NAV2 good and has DME = 2^2 + 2^6 = 4 + 32 = 36 -- offset 0x3300 Additional radio and autopilot status indicators (read only access). Allocation by bits which are set when true.: -- Bit 0 = least significant (value 1), 1 = good NAV1, 2 = good NAV2, 4 = NAV1 has DME, 5 = NAV2 has DME NAVstate=ipc.readUW(0x3300) NAV1bits=logic.And(NAVstate,NAV1mask) -- NAV1 good and has DME = 2^1 + 2^5 = 2 + 16 = 18 NAV2bits=logic.And(NAVstate,NAV2mask) -- NAV2 good and has DME = 2^2 + 2^6 = 4 + 32 = 36 NAVout="NAV-State: " .. NAVstate .. " " .. " NAV1bits: " .. NAV1bits .. " NAV2bits: " .. NAV2bits .. " " if NAV1bits == NAV1mask then -- offset 0xc4d NAV1 code flags, bits used as follows: 0 = DME available (bit 3 "No signal available" seems not related to DME) DME1byte=ipc.readUB(0xc4d) DME1avail=logic.And(DME1byte,1) -- mask bit 0 "DME avail" = 2^0 = 1. Bit 3 "No signal available" seems related to VOR/OBS only if DME1avail == 1 then -- offset 0xc29 DME1 distance "DME1 distance as character string, either “nn.n” or “nnn.” (when > 99.9 nm). -- The 5th character may be a zero or a space. Don’t rely on it." DME1dist=ipc.readSTR(0xc29,4) -- offset 0xc2e DME1 speed as character string, “nnn” followed by either space then zero or just zero DME1speed=ipc.readSTR(0xc2E,3) -- DME1out="NAV1 DME Speed: " .. DME1speed .. " kts Dist: " .. DME1dist .. " nm " else DME1out="NAV1 without DME" .. " " end end if NAV2bits == NAV2mask then -- offset 0xc70 NAV2 code flags, bits used as follows: 0 = DME available (bit 3 "No signal available" seems not related to DME) DME2byte=ipc.readUB(0xc70) DME2avail=logic.And(DME2byte,1) -- mask bit 0 "DME avail" = 2^0 = 1. Bit 3 "No signal available" seems related to VOR/OBS only if DME2avail == 1 then -- offset 0xc33 DME2 distance as character string, either “nn.n” or “nnn.” (when > 99.9 nm). -- The 5th character may be a zero or a space. Don’t rely on it. DME2dist=ipc.readSTR(0xc33,4) -- offset 0xc38 DME2 speed as character string, “nnn” followed by either space then zero or just zero DME2speed=ipc.readSTR(0xc38,3) DME2out="NAV2 DME Speed: " .. DME2speed .. " kts Dist: " .. DME2dist .. " nm " else DME2out="NAV2 without DME" .. " " end end -- DEBUG -- ipc.lineDisplay(NAVout,1) -- ipc.lineDisplay(DME1dbg,2) -- ipc.lineDisplay(DME2dbg,3) ipc.lineDisplay(DME1out,1) ipc.lineDisplay(DME2out,2) ipc.sleep(3000)