Jump to content
The simFlight Network Forums

best way to read several l:vars from external PYTHON software


Recommended Posts

Hello,

In the accesibility software I'm developing, I've been asked to interface with A2A aircraft. Many of the specific settings that A2A uses can be accessed with local panel variables.

My question is, what's the best way to do this? I need to be able to read several variables from the sim and then pass the data to my software, I assume with a fsuipc offset? I may also need to write variables, based on user input from my software.

I know I can do a direct read of an l:var with fsuipc offsets, but I can't quite work out how to do it with the pyuipc module in python. I've also read that this can be slow, especially if I'm reading a lot of variables.

Is it best to do this with a lua script and then just write the data to some of the user defined offsets that my software can then read?

I assume that someone will need a registered FSUIPC version for a lua script to work, correct?

Any pointers would be apreciated.

 

 

Link to post
Share on other sites
9 minutes ago, Jason Fayre said:

Is it best to do this with a lua script and then just write the data to some of the user defined offsets that my software can then read?

I don't know what you can and cannot do with Python, so I can't advise. Possibly you'd get more relevant help from someone who knows Python if you posted again with Python mentioned in the thread title.

From, say, a C or C++ perspective it would be far easier to do it through the offset facilities at 0D70 / 0D60. Those still involve specifying a user offset for the result.

12 minutes ago, Jason Fayre said:

I assume that someone will need a registered FSUIPC version for a lua script to work, correct?

Yes, Lua plug-ins need a registered install.

Pete

 

Link to post
Share on other sites

Thanks pete.

I know how to write to offsets using Python, but I'm having some trouble understanding what to write/read to offset 0d6c. I understand that the user offset I want to store the data in from the l:var is in the low 16 bits, but what do I store in the high 16 bits?

I've read the documentation, I'm just not totally understanding how this works.

 

 

 

 

Link to post
Share on other sites

Sorry, one more question, and I apoligize if this is a dumb newbie question.

What format am I writing 0d6c in? I know 0d70 is a null-terminated string.

IN the python module, I need to specify the format of each read/write. For 32-bit values, I only have the option of a signed or unsigned value. I can also specify the number of bytes to be written for a string.

Here is the section out of the pyuipc readme, if that helps at all:

  'data' should be a list of tuples of two items. The first item of
  each tuple should be an offset to read or write. The second item
  denotes the type of the value to be read from or written into the
  offset. it should be either a string or an integer. If it is a
  string, it denotes a type of a fixed size:

  - b: a 1-byte unsigned value, to be converted into a Python int
  - 😄 a 1-byte signed value, to be converted into a Python int
  - h: a 2-byte signed value, to be converted into a Python int
  - H: a 2-byte unsigned value, to be converted into a Python int
  - d: a 4-byte signed value, to be converted into a Python int
  - u: a 4-byte unsigned value, to be converted into a Python long
  - l: an 8-byte signed value, to be converted into a Python long
  - L: an 8-byte unsigned value, to be converted into a Python long
  - f: an 8-byte floating point value, to be converted into a Python double

  If the second item is an integer, it denotes a string. If the value
  is positive, the string is of a fixed length with no zero
  terminator. If the value is negative, its absolute value is the
  maximal length of the string, but the string itself is zero
  terminated.
 

 

 

 

Link to post
Share on other sites
27 minutes ago, Jason Fayre said:

but what do I store in the high 16 bits?

The variable format required (0-7), depending how you want it, as listed in the documentation :-- 

 

This offset value only occupies the low 16-bits (LOWORD) of
the 32-bit value. The high part specifies the value format.
Assuming the offset is ‘nnnn’, the options are:
0x0nnnn for 64-bit double (as before)
0x1nnnn for 32-bit float (FLT)
0x2nnnn for 32-bit signed integer (SD)
0x3nnnn for 32-bit unsigned integer (UD)
0x4nnnn for 16-bit signed integer (SW)
0x5nnnn for 16-bit unsigned integer (UW)
0x6nnnn for 8-bit signed integer (SB)
0x7nnnn for 8-bit unsigned integer (UB)

Sorry, can you tell us what is confusing you about that?

Pete

 

Link to post
Share on other sites
53 minutes ago, Jason Fayre said:

What format am I writing 0d6c in?

Well, the offset number is hexadecimal. The encoding for the type of number you want is 0-7 which can be decimal or octal or hexadecimal, AND the documentation actually shows you "0x0nnnn" (for example) for a double format value. The "0x" stands for hexadecimal in C and C++. So I think hexadecimal would be good -- certainly the most obvious and easiest.

Pete

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • 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.