MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

Posts: 6
Hi all,

I found this awesome lua script here that records the offset states.

my problem is I am noticing an obvious delay in the master caution warning blinking on my LED vs the virtual cockpit master caution blink.

I can see from my mobiflight that that readings are in sync with FSUIPC and is displayed on my LED. However as said the virtual cockpit is consistent and not delayed and holding pauses...

any suggestion to how I can fix it?

video here:]

script used here:
local UB = {r=ipc.readUB,w=ipc.writeUB} -- 1 Byte Int
local UW = {r=ipc.readUW,w=ipc.writeUW} -- 2 Byte Int
local UD = {r=ipc.readUD,w=ipc.writeUD} -- 4 Byte Int
local FLT = {r=ipc.readFLT,w=ipc.writeFLT} -- 4 Byte Float
local DBL = {r=ipc.readDBL,w=ipc.writeDBL} -- 8 Byte Float
local STR = {r=ipc.readSTR,w=ipc.writeSTR} -- String

local EN1 = "66C0" -- master offset enable

local R = 0
local W = 1

	Every entry in lvar_list corresponds to one offset.
	How to build an entry:
	{"offset", mode, {enable_switches}, {lvars}}
	- offset = fsuipc offset (between 0x66C0 and 0x66FF)
	- mode is either R or W. R means only read from lvar
	and W means only write to lvar. (e.g. an LED displaying
	the flaps status is R. A switch that extends the gear
	is W.)
	- enable_switches = list of offsets which all have to
	be set to 1 otherwise the line gets ignored. This is useful
	for shared cockpit so that if you are not in charge of the
	buttons your switches won't override the switches of the 
	other pilot.
	-- lvars = list of lvars that get the same value written to.
	You should only use one lvar when mode=R.
local lvar_list = {
	{"66C0", R, {}, UB, { "ASCRJ_GSC_MASTER_CAUT_ON" }}

-- set this to true if you want to force your own switch positions on start
local initialized = false

while true do
	for _,v in pairs(lvar_list) do
		local offset = v[1]
		local mode = v[2]
		local enable_offsets = v[3]
		local offset_type = v[4]
		local lvars = v[5]
		-- check all enable switches are set
		local enabled = true
		for _, enable_offset in pairs(enable_offsets) do
			local val = ipc.readUB(enable_offset)
			if val == 0 then
				enabled = false
		if enabled == true then -- skip line if disabled
			if initialized == true and mode == W then -- write mode			
				-- read offset
				local offset_val = offset_type.r(offset)
				-- update lvars
				for _, lvar in pairs(lvars) do
					ipc.writeLvar(lvar, offset_val)
			else -- read mode
				-- read lvars
				local lvar_val = ipc.readLvar(lvars[1])
				-- update offset
				offset_type.w(offset, lvar_val)
	initialized = true
[Last edited by, 2019-05-13 14:13]
2019-05-13 12:25