Jump to content
The simFlight Network Forums

Request for offset - multiple Master Batteries


Djeez

Recommended Posts

These is an offset for the Master Battery (0x3102) but MSFS2020 supports multiple batteries, such as in the default C172 (standby battery) or SR22 (master battery 2).

When inspecting the log when toggling the switches I see

(0x000102c1), Param= 2 (0x00000002) TOGGLE_MASTER_BATTERY

  (note the parameter 2) 

I could use the ipc.control with parameter 2 in my Lua script but I also need to know the state of the switch. 

The MSFS2020 SDK documentation shows that the

image.thumb.png.2129f1889bb0b10471f077f0f97d6cac.png

SimVar needs an index so presumably this means that read and write access to all batteries is possible.

My request is to make these settings available as offsets, or one offset with multiple independent bits set for every battery.

Thanks!

-Emile van Gerwen.

Link to comment
Share on other sites

Hi Emile,

I am reluctant to change the functionality of the existing master battery offset, 0x3102. However, I could add a new bitwise offset that would hold and change the state of the different indexed batteries. However, there is an issue with this. The problem is that if I request the ELECTRICAL MASTER BATTERY simvar for indices > 1 and only one battery is available, this will not produce an error but will flood the MSFS logging console with error messages, making the logging console impossible to use. This was an issue when I recently added offsets for FUELSYSTEM PUMP ACTIVE and FUELSYSTEM PUMP SWITCH for indices up to 16. To get around this, I added a new ini parameter NumberOfPumps that controls how many indices of these simvars are requested. This applies to all aircraft, so it is not an ideal solution, but there is no way that I know of to determine the actual number of pumps available, and for this update there would be no way to know the number of batteries available, and so there is a similar issue.

Not sure what to do about this at the moment - I will have a think about this....

However, there may be an alternative solution. For example, in the C172 there is a lvar XMLVAR_BatterySTBY_SwitchState. You could add this lvar to a free FSUIPC offset (using the lvarst-to-offsets functionality) and read the state of the standby battery from that. If the lvar is writeable, you can then also write to the offset to switch the standby battery on and off. The same or a similar lvar may also be available in the SR22, although I haven't checked this.

I am planning on going through the MSFS documentation on available simvars (and events) this week (hopefully!), to see what new simvars and events are available.
I will consider this request again once I have done this.

Regards,

John

Link to comment
Share on other sites

10 minutes ago, John Dowson said:

For example, in the C172 there is a lvar XMLVAR_BatterySTBY_SwitchState.

No, sorry I was mistaken. This lvar doesn't exist for those aircraft. It appeared that they did, but that was because I had the FBW A320 installed in my Community folder and I had forgotten top remove this before checking.

John

Link to comment
Share on other sites

Thanks John. Getting errors on non-existent batteries and no way of knowing the number of batteries seems like a bad interface design on MSFS part. I appreciate you looking into this. Did you report this to the SDK team and would it help if I (also) report this?

-Emile.

Link to comment
Share on other sites

What you could do is provide an offset in which I can write in how many batteries I am interested. Since I know which plane is loaded, I set the number of batteries accordingly and it would be my responsibility to set the correct number. The default being 0 so that the bitwise offset is not populated when not requested. This is quite a hack and I can understand you are not fond of such a solution but honestly I don't think we can expect a solution from the SDK team at Asobo in short term.

-Emile.

 

 

Link to comment
Share on other sites

  • 4 weeks later...

Hi @Djeez / Emile,

I have now added the functionality to allow the user to add any simvar to a free user offset. I will release this at the weekend, but I have attached a beta below if you would like to test.
To use this, create a file called myOffsets.txt and add the following content:

Quote

// offset, size, simvar, type, units [, w]
0x66C0, 1, ELECTRICAL MASTER BATTERY:2,I32, Bool, w

This will add the simvar  ELECTRICAL MASTER BATTERY:2 to offset 0x66C0 as 1 byte, for both reading and writing. Please change the offset to a free user offset if already using that one.

Cheers,

John

FSUIPC7.exe

Link to comment
Share on other sites

This works great and is a very nice feature to have.

I assume the myOffsets.txt is read during the FSUIPC startup? For development it would be convenient to have a reload myOffsets menu item in the FSUIPC7 interface just as there is one for the WASM reload.

-Emile.

Link to comment
Share on other sites

1 hour ago, Djeez said:

I assume the myOffsets.txt is read during the FSUIPC startup?

Not exactly - it is read the first time a simconnect connection is established.

1 hour ago, Djeez said:

For development it would be convenient to have a reload myOffsets menu item in the FSUIPC7 interface just as there is one for the WASM reload.

No, that is not going to happen - lots of complications to do that, just not worth it as it only takes a few seconds to restart FSUIPC7 (you don't need to restart MSFS).

John

Edited by John Dowson
corrected
Link to comment
Share on other sites

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.