Setting Fuel Tank Loads with SimConnect

I am working on an addon for MSFS and it involves setting some initial data,
like the tail number and fuel tank loads. I have been banging my head on my
desk all afternoon and can’t seem to get anything to work as published in the
SimConnect SDK reference. For context, I’m doing my testing against the 172
G1000. The docs say that the “FUEL TANK .* QUANTITY” numbers should be in
gallons, but the only relatively sane data I get back after poking around at
different data types in C# is some sort of 1000th of a liter? That in and of
itself is odd. Then there’s the part where I’m trying to set the level of the
tanks. Again, with the data coming back as 1000th of a liter, I am trying
everything from whole integers to decimal values, and the results are quite
erratic. Here’s the starting view with default fuel

Then if I use an INT32
data type for the Data Definition bindings and set the values on FUEL TANK
Taking a closer look at the
fuel loads: Now if I try the
same thing with the LEVEL instead of QUANTITY variables, I
see: I have played around with
the units, specifying “gallons” for the QUANTITY vars, and “percent over 100”
for the LEVEL vars, but have seen no improvement. Switching data types to use
FLOAT32 or FLOAT64 and appropriate C# data types for the bindings results in
very erratic and unreasonable numbers coming back. What am I missing? Are the
docs just wrong?

I’m still stumped on the QUANTITY values, as they’re not in gallons at all.
But I was able to get the LEVELs to work.


This is a FLOAT64. It needs to be bound to an appropriately-wide variable,
such as a double.

The only comment I can add here is that Gallons is definately correct if
programming in C/C++ and/or vb.Net. There is a possibility
that the COM wrapper might be faulty for C# but I would doubt it. You can’t go
far wrong with declaring all datatypes as FLOAT32; this will catch all
integers and also eliminate that fact that a lot of FLOAT64 returns are simply
not correct. This one is a known problem amongst the FSX/P3D developer
community and it has been there for a very long time. As Asobo are using a
variant of the FSX SimConnect, I wouldn’t think they’ve fixed it.

I got this working on WASM many times, use FUEL TANK LEFT MAIN QUANTITY with
the unit Gallons and it will work, same for the right side. Best, Rauk

Hmm, I’ll have to give that a try. When I did, though, it was doing that whole
erratic behavior. I presume it was because of data alignments not working
properly. I do know that the data is all FLOAT32 at the response from the API,
so maybe you’re right in that something in the C# implementation is breaking
it. I’ll give this a shot again next week when I have some time to poke at it.
Thanks for your input.

Raul: it works for me too for all tanks. I have an OOP setup for either
pumping fuel around tanks or dumping fuel that has worked without trouble
across both P3D and MSFS.