Jump to content
The simFlight Network Forums

LUA - Public variables - VRInsight MCP


Recommended Posts

Posted

Hi all,

looking at some lua script samples regarding VRInsight MCP you can see that there is a handle named 'dev' which is used in the com.xxx functions to read or write data to the device.
Since the constant or variable 'dev' can be used as it is already valued, where is it possible to find a list of any other global variables related to VRInsight MCP device?

Thanks

Posted

The name ‘dev’ is just that. In Lua just as in any other programming language variables have names. It could just as well be named ‘Fred’ or ‘Jim’. It has the value returned bu the com.open function. That will be a number assigned by Windows for the opened device link. Next time it might be different.

Pete

Posted
43 minutes ago, Pete Dowson said:

That will be a number assigned by Windows for the opened device link. Next time it might be different.

Thank Pete, but my question is another: If 'dev' is already valued somewhere, what are the other already declared valued global variables that can be used?


For example, the code snippet below works even though I've never declared the variable 'dev'
How can my function know the value of 'dev'?  Somewhere else it must have been declared!


function  Engage_Managed_Heading_Mode ()
    -- PUSH HDG  KNOB
     ipc.control("68065", 2)
    com.write(dev, "HDG" .. "---", 8    )
    DspShow("mngd", "HDG")
end

 

Posted
53 minutes ago, grigna said:

my question is another: If 'dev' is already valued somewhere, what are the other already declared valued global variables that can be used?

'dev' only acquires a value as a result of a call to a function -- in this case some 'com.open' in your script. It is NOT a declared "global"!

53 minutes ago, grigna said:

For example, the code snippet below works even though I've never declared the variable 'dev'
How can my function know the value of 'dev'?  Somewhere else it must have been declared!

The code snippet is a function which must be called somewhere. Elsewhere in your script there must be a statement like dev = com.open and a call to your function 'Engage_Managed_Heading_Mode'!

Please don't post code "snippets" and talk about them as if they show everything!

Pete

 

 

Posted
1 hour ago, Pete Dowson said:

Please don't post code "snippets" and talk about them as if they show everything!

My apologize, maybe I was unclear. Below you can see the only code I put in the user.lua file and as you can see I haven't declared the value of 'dev' anywhere.
But I can guarantee you that the two functions combined with two buttons work correctly.
For this reason I thought that there is a global variable 'dev' declared by some other code that is not mine.

immagine.thumb.png.a5b1bfdd3ee7d15b4273d76b6f52b971.png

Posted
57 minutes ago, grigna said:

My apologize, maybe I was unclear. Below you can see the only code I put in the user.lua file and as you can see I haven't declared the value of 'dev' anywhere.
But I can guarantee you that the two functions combined with two buttons work correctly.
For this reason I thought that there is a global variable 'dev' declared by some other code that is not mine.

Please post the Lua file itself, not a picture.

Really there is no such thing as a global "dev" value. Not only that but you have no com.open in that pictured section so there can be no link to the device -- it isn't opened! And functions in Lua do NOT run themselves! They have to be called!

Therefore that is not the (complete) Lua file you are running -- NOT a picture, the file! Show me the FSUIPC log file AND the Lua file it is loading. Otherwise there is no point in this thread continuing!

Pete

 

Posted
11 minutes ago, grigna said:

Thanks Pete, I am attaching the two files you requested.

Okay. Your Lua is part of something LINDA does. It isn't logged as something being run by FSUIPC.  Whatever this fragment of Lua does is obviously embedded into the LINDA system.

What I said about "dev" as a variable, and Lua functions still applies, but your Lua fragment is inducted into whatever it is LINDA is doing.

So, since I know nothing about LINDA and cannot support it, I suggest you ask your questions of the LINDA folks.

In summary, within the FSUIPC and WideClient implementations of Lua, there are no global names or values associated with any hardware, whether it be VRInsight or not.

Pete

 

 

 

Posted

Sorry Pete,
in the meantime I looked at Linda's common.lua file and found this declaration of the variable 'dev'. It probably remains visible at my functions too.
Many thanks and sorry if i wasted your time.

 

immagine.thumb.png.024732bb445595b5735281bcd93196df.png

 

Posted
52 minutes ago, grigna said:

in the meantime I looked at Linda's common.lua file and found this declaration of the variable 'dev'. It probably remains visible at my functions too.

Yes.  For your functions to be called, the LINDA lua program must be including your Lua -- your code effectively becomes part of theirs.

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.