The simFlight Network Forums

# Conversion

## Recommended Posts

Hi Mr Dowson;

-I want to get "Bank" variable in address 057C and calculate its real value.

For example the value readed by FSUIPC is 4261094146 (in unsigned int[u32]) that is in fact -2.83921 ( Factored) or -33873150 (in int[s32]).

How can I get these values from address 057C and convert to each other.

-How can convert an unsigned int to signed or a signed to unsigned int.

grateful.

Nasser

##### Share on other sites

-I want to get "Bank" variable in address 057C and calculate its real value.

For example the value readed by FSUIPC is 4261094146 (in unsigned int[u32]) that is in fact -2.83921 ( Factored) or -33873150 (in int[s32]).

Yes, because (-33873150 * 360.0) / (65536.0 * 65536.0) = -2.8392146, as you can see with FSInterrogate, or check on an ordinary calculator.

How can I get these values from address 057C and convert to each other.

You need the FSUIPC SDK. Follow the examples for your chosen programming language to use FSUIPC_Read and FSUIPC_Process. Read 4 bytes at that offset into a signed integer. Then apply the documented formula, as used in the example above.

-How can convert an unsigned int to signed or a signed to unsigned int.

Read it directly into the appropriate type, or use a cast (in C/C++). I expect other languages have equivalent methods, though I believe you could struggle to have unsigned values in Basic. (Ugh).

Regards

Pete

##### Share on other sites

Thank you,

But what's method of direct converting 4261094146 (unsigned int[u32]) into -33873150 (in int[s32]).

And is this method correct for calculate the 4 bytes :

unsigned long value, b0, b1, b2, b3;

double db;

b3 = chBank[ 3];

b2 = chBank[ 2];

b1 = chBank[ 1];

b0 = chBank[ 0];

value = b3* 16777216+ b2* 65536+ b1* 256+ b0;

db = value* 360.0/ ( 65536.0* 65536.0);

Regards

Nasser

##### Share on other sites

But what's method of direct converting 4261094146 (unsigned int[u32]) into -33873150 (in int[s32]).

It doesn't NEED converting. It's simply interpretation! If you read it into an unsigned variable, it will appear unsigned. If you read it into a signed vaariable, it will be signed. The actual pattern of bits, the way it actually appears in the hardware, is unchanged.

And is this method correct for calculate the 4 bytes :

unsigned long value, b0, b1, b2, b3;

double db;

b3 = chBank[ 3];

b2 = chBank[ 2];

b1 = chBank[ 1];

b0 = chBank[ 0];

value = b3* 16777216+ b2* 65536+ b1* 256+ b0;

db = value* 360.0/ ( 65536.0* 65536.0);

No, no no! Only read BYTE values into Bytes. Read signed 32-bit values into an integer variable (i.e. a normal signed number in most languages)! You appear to be missing the entire point.

In other words, there's no "chBank" wanted at all. Read it into a variable such as

int nBank;

double db = nBank * 360.0/ ( 65536.0* 65536.0);

Pete

##### Share on other sites

I am very thankful for answering to my problems.

I am operating a 6DOF flight simulator thus need your guidance :

1) Which parameters or variables from FSX is necessary to get and process?

3) Any recommendation for me.

Nasser

##### Share on other sites

I am operating a 6DOF flight simulator thus need your guidance :

1) Which parameters or variables from FSX is necessary to get and process?

Well, I'm not a hardware designer, but since the main purpose of a motion base is presumably to impart the "feel" of accelerations, attitude changes, and not to actually provide the true attitude, I would have thought you'd need to be reading the assorted Accelerations available. Either read these directly from SimConnect, or via FSUIPC4. See offsets 3060-3088and 31C0-31D0.

3) Any recommendation for me.

Ask around in the cockpit builders forum here, and Google for others. Not building anything myself I'm not really familiar with any specific places. Sorry.

Regards

Pete

## Create an account

Register a new account