Jump to content
The simFlight Network Forums

Recommended Posts

Posted (edited)

Hello Searching from long time for solutions. 
QW787 inputs are drived by linda but searchin way to light up indicator LED for example AP Master switch led witch lvar is QW_ap_master_l it can have value 0 off or 1 on
Trying to make read of lvar state and storage it in 66C0 offset but without any success. Maybe someone have solution for that and can help with few lines of code.
I made some script

function QW_AP_MASTER_I (66C0, 0)
ap_master_l = ipc.readLvar("L:QW_ap_master_l")
ipc.writeUB(0x66C0, ap_master_l)
return
end



event.Lvar("L:QW_ap_master_l",0, "AP_MASTER_I")

But im not a programmer and it doenst work

Edited by crazylynx
Posted
12 minutes ago, crazylynx said:

made some script


function QW_AP_MASTER_I (66C0, 0)
ap_master_l = ipc.readLvar("L:QW_ap_master_l")
ipc.writeUB(0x66C0, ap_master_l)
return
end



event.Lvar("L:QW_ap_master_l",0, "AP_MASTER_I")

But im not a programmer and it doenst work

You called the function "QW_AP_MASTER_I", which is okay. but then your event.Lvar calls it "AP_MASTER_I". You missed off the "QW_" bit!

Additionally your function definition: function QW_AP_MASTER_I (66C0, 0)  contains actual values as parameters. They need to be names of values you might then use. For example:

function QW_AP_MASTER_I (offset, val)

what then happens is that the "Offset" parameter will becone 0x66C0 (or whatever other offset you might call the function for), and, more importantly, the val parameter will be the value you want to use.

Then these next lines:
ap_master_l = ipc.readLvar("L:QW_ap_master_l")
ipc.writeUB(0x66C0, ap_master_l)

simplify down to just:

ipc.writeUB(0x66C0, val)

Oh, and you don't need the return either. The return will occur at the end.

So, the fully corrected Lua looks like:

function QW_AP_MASTER_I (offs, val)
ipc.writeUB(0x66C0, val)
end

event.Lvar("L:QW_ap_master_l",0, "QW_AP_MASTER_I")

One last thing.  When a Lua plug-in doesn't work, do look at the reports in the FSUIPC LOG file, in your Modules folder. Any errors like these will be logged including the line number in your Lua file.

Pete

 

 

Posted (edited)

Thank You very much for answer !

Ok i think its doesnt work log console shows READ0[14144]  66C0,   2 bytes: 00 00 and soent show any change of state does it work in loop?

I thin QW 787 doesnt send state change to fsuipc offset

 

Kind regards

Edited by crazylynx
Posted

The 0 in your event call isn’t valid. Does the log show an error? Minimum time for scanning is 100. Use something like 250. Sorry I didn’t spot that before.

Use the Log Lvars Lua plug-in to check whether your Lvar is changing.

Pete

 

Posted (edited)

Thank You Pete for Your support !

function QW_ap_master_l (offs, val)
ipc.writeUB(0x66C0, val)

end
function at_mode (offs, val)
ipc.writeUB(0x66C1, val)

end
function QW_MCP_L_MFD_L_GREEN (offs, val)
ipc.writeUB(0x66C2, val)

end

event.Lvar("L:QW_ap_master_l",100, "QW_ap_master_l")
event.Lvar("L:at_mode",100, "at_mode")
event.Lvar("L:QW_MCP_L_MFD_L_GREEN",100, "QW_MCP_L_MFD_L_GREEN")

i choosed 3 outputs copied form QW sim builders manual is this correct ?

Edited by crazylynx
Posted

Hi,

as Pete pointed out you use a zero value in the event call that isn't valid. But seems you didn't changed that!

As the manual as well clearly describes

Quote

event.Lvar("lvarname", interval, "function-name")

The interval is in milliseconds and has a minimum value of 100. it is not optional.

Thomas

Posted
54 minutes ago, crazylynx said:

i choosed 3 outputs copied form QW sim builders manual is this correct ?

I've no idea. You need to check what the LVars are doing by using the Log LVars lua plug-in. That will show the LVar names exactly as they should be, and their values, changing in real time.

Pete

 

Posted

Where can i find this plugin?

 

Ok works !
i have in console such a readout 
READ0[7332]  66C0,   8 bytes: 02 02 01 00 00 00 00 00
i dont know why it returns 02 instead of 01 but works so not a problem.

code i used
 

function QW_ap_master_l (offs, val)
ipc.writeUB(0x66C0, val)

end

function at_mode (offs, val)
ipc.writeUB(0x66C1, val)

end

function QW_MCP_L_MFD_L_GREEN (offs, val)
ipc.writeUB(0x66C2, val)

end


event.Lvar("L:QW_ap_master_l",100, "QW_ap_master_l")
event.Lvar("L:at_mode",100, "at_mode")
event.Lvar("L:QW_MCP_L_MFD_L_GREEN",100, "QW_MCP_L_MFD_L_GREEN")

Led works correct everything fine so the time to build MCP 🙂 Thanks again for help

Posted
4 minutes ago, crazylynx said:

Where can i find this plugin?

In the example Lua plug-ins ZIP file in your FSUIPC Documents folder. The ones supplied are also listed in the Lua documentation, also in the FSUIPC Documents folder. In fact all the FSUIPC documentation is in that folder.

Pete

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.