Dear all,
I recently stumbled over the following “server exception 19” issue when spitting one of my request data structures into two distinct structures:
Initially I had:
struct MyStruct {
...
double foo;
int32 bar;
int32 barfoo;
double foobar;
...
};
(the ‘int32’ data type here shall illustrate a 32bit integer value, the double type is 64bit)
And the struct was properly declared (registered) with SimConnect:
...
SimConnect_AddToDataDefinition(handle, MY_STRUCT_DEF, SimVar::Foo, "Percent", ::SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(handle, MY_STRUCT_DEF, SimVar::Bar, "Percent", ::SIMCONNECT_DATATYPE_INT32);
SimConnect_AddToDataDefinition(handle, MY_STRUCT_DEF, SimVar::BarFoo, "Percent", ::SIMCONNECT_DATATYPE_INT32);
SimConnect_AddToDataDefinition(handle, MY_STRUCT_DEF, SimVar::FooBar, "Percent", ::SIMCONNECT_DATATYPE_FLOAT64);
....
Note that the variables before and after are also 64bit in size, and the two 32bit integers also add up to 64bit in total size.
(The fact that I placed them “next to each other” was not totally coincidental, in order for the compiler to be able to properly align the members to 64bit - but the fact that I had an even number of int32 values was coincidental).
So this was working as expected, for both reading and writing this struct.
However after the split into two distinct request structures I had e.g.:
struct MyStruct {
...
double foo;
int32 bar;
};
So the last member is only 32bit in size (and the only int32 value in that particular record), and hence the total size of the struct is not a multiple of 64bit. While reading this struct was returning the expected results I got a server exception with number 19 when trying to write (= send to FS2020) this struct.
According to
the “number 19 exception” indicates an “invalid data size”.
And indeed, when I simply change the integer to a 64bit integer (and the corresponding SimConnect type to SIMCONNECT_DATATYPE_INT64):
struct MyStruct {
...
double foo;
int64 bar;
};
then - lo and behold - the write request is successfully executed.
I did not find any specific mentioning of the requirement that request records must have a size a multiple of 64bit (8 byte):
But conveniently all examples that I came across seem to use double values. In fact, SIMCONNECT_DATATYPE_FLOAT64 is the default data type, when not specified otherwise.
So while reading records with SIMCONNECT_DATATYPE_INT32 seems to work setting them does fail with an “invalid size” (19) exception. Unless the INT32s add up to a multiple of 64bit, or so it seems.
I do have a working solution (by making all data align to 64bit respectively by using int64 - even for a silly Boolean variable) but am still curious what is going on here respectively if someone found some documentation which would explain the observed behaviour?