Jump to content
The simFlight Network Forums

FSUIPC offset 0570


Recommended Posts

Can anyone give me a code example of setting the altitude at offset 0570 using Visual Basic 6.0? I have searched the forum and found fragments of issues regarding offset 0570, but not a single complete example. Any help would be appreciated.

I am using slew mode and have resolved the lat/long problem I was having. But, now when I attempt to set the aircraft altitude, it sits on the ground (at the current elevation) and does not change no matter what I write to that location. So, I am not sure if I am using the correct variable declaration, and/or equation.

Link to comment
Share on other sites

So, I am not sure if I am using the correct variable declaration, and/or equation.

Why not show the code you have? I don't know VB so I cannot construct a compilable example for you, but i can probably spot the error in your code.

Note that (like the latitude and longitude) it is a 64-bit (8-byte) integer, and the value is in units of 1/4294967296ths of a metre (4294967296 = 65526 x 65536). For a value accurate to a metre you can instead just write the number of metres to the 32-bit (4 byte) value at offset 0574 (the upper half of the 64-bit number). The lower 32 bits are the fractions of a metre.

Pete

Link to comment
Share on other sites

Thanks Pete,

Well...I'm not sure what I did exactly, but it is now working. I am using FSX to playback data captured from a CAE Boeing 737-800 used by the FAA in research. So I am real happy that I was able to playback data from a multi-million dollar device using FSUIPC. :-)

Link to comment
Share on other sites

well, I had it working and then I screwed something up. Here is my code:

Dim dwResult As Long

Dim x As Long

Dim pitch As Long

Dim bank As Long

Dim heading As Long

Dim PitchRate As Integer

Dim YawRate As Integer

Dim RollRate As Integer

Dim TempAlt As Long

PitchRate = 16384

YawRate = 0

RollRate = 0

dlat = rc!RUPLAT

dlon = rc!RUPLON

x = dlat * 10001750 / 90

FSUIPC_Write &H564, 4, VarPtr(x), dwResult

x = dlon * 65536 * 65536 / 360

FSUIPC_Write &H56C, 4, VarPtr(x), dwResult

'===============write the pitch/bank/heading values=============

pitch = rc!VTHETADG * 65536 * 65536 / 360

bank = -rc!VPHIDG * 65536 * 65536 / 360

heading = rc!VPSIDG * 65536 * 65536 / 360

FSUIPC_Write &H578, 4, VarPtr(pitch), dwResult

FSUIPC_Write &H57C, 4, VarPtr(bank), dwResult

FSUIPC_Write &H580, 4, VarPtr(heading), dwResult

'================================================================

'set the yaw roll and pitch rates to 0

FSUIPC_Write &H5E4, 2, VarPtr(RollRate), dwResult

FSUIPC_Write &H5E6, 2, VarPtr(YawRate), dwResult

FSUIPC_Write &H5EE, 2, VarPtr(PitchRate), dwResult

'=================write the altitude=============================

TempAlt = Val(rc!VHH)

TempAlt = (TempAlt / 3.28084) * 65536

FSUIPC_Write &H574, 4, VarPtr(TempAlt), dwResult

FSUIPC_Process dwResult

Everything is working except the altitude.

Link to comment
Share on other sites

well, I had it working and then I screwed something up. Here is my code:

TempAlt = (TempAlt / 3.28084) * 65536

FSUIPC_Write &H574, 4, VarPtr(TempAlt), dwResult

...

Everything is working except the altitude.

Why are you multiplying the number of metres by 65536? The upper 32-bits, i.e. the integer starting at 0574, is the whole number of metres. You are setting an impossible altitude (for FS, that it. You might get that high in X-Plane).

Is a metre good enough accuracy for what you need? Mind you, I see you are approximating the Lat/Lons too.

Regards

Pete

Link to comment
Share on other sites

Pete,

I am hoping you can tell what I NEED to store in the memory location. Simply storing the actual meters at 0574 is not working.

An integer in VB is 4 bytes. I have tried saving the integer of my altitude (in feet) * .3048 in memory location 0574.

For instance, my initial altitude is 2027.48 feet.

2027.48 * .3048 is:

617.975904 meters.

If I stored the integer of 618 at 0574, the plane still sits on the ground while its moving.

Link to comment
Share on other sites

I am hoping you can tell what I NEED to store in the memory location. Simply storing the actual meters at 0574 is not working.

You are making an error then. You have not shown me any good code yet.

Try using the tools available to check your work. The FSUIPC Logging facilities can log what you are really writing. You can also test the exact same action using FSInterrogate.

An integer in VB is 4 bytes. I hav
e tried saving the integer of my altitude (in feet) * .3048 in memory location 0574.

For instance, my initial altitude is 2027.48 feet.

2027.48 * .3048 is:

617.975904 meters.

If I stored the integer of 618 at 0574, the plane still sits on the ground while its moving.

You are certainly making an error then. As I say, please use the tools available to debug your work. If you don't understand what you then see in the Log, show it to me.

Regards

Pete

Link to comment
Share on other sites

The biggest difficulty with VB 6.0 is it does not support 64 bit variables. The currency type is the only thing that can be used. I did find an example in the VB folder of your SDK that references the Fake64bit function. I will have to experiment with that. I am also wondering if the offset that says the aircraft is in flight or on the ground could be causing a problem as well. I had this whole project working earlier and the result was really exciting. But I failed to save it for some silly reason and once I reopened the project, the code that was working was gone.

You may or may not remember, but a few years ago I had a motorcycle wreck and it did wreak havoc on my memory abilities. So I appreciate your patience and understanding. :-)

Link to comment
Share on other sites

The biggest difficulty with VB 6.0 is it does not support 64 bit variables. The currency type is the only thing that can be used.

Many VB6 users seems to find Currency as being sufficient for this. I know it sounds strange, but if it is really a 64-bit integer as has been stated several times by others (including, in your Lat/Lon thread, the expert Paul Henty, author of the .Net DLL interface for FSUIPC available from the stickies at the top of the Forum.)

Googling VB6 and 64-bit I also find several other confirmations of this:

http://vb.mvps.org/hardcore/html/largeirrency.htm

http://bytes.com/topic/visual-basic/anstegers-vb6 (but this one says Currency can't handle max values? Something to do with x 10000?)

http://www.vbforfree.com/?p=260

You could try searching for help like this. I really neither know VB enough to help nor do I have enough time these two weeks -- I'm on holiday later next week for a while and have a lot to finish up before then. Google is your friend for problems like this.Or changing to a decent language. ;-)

I did find an example in the VB folder of your SDK that references the Fake64bit function.

No idea about that, sorry.

I am also wondering if the offset that says the aircraft is in flight or on the ground could be causing a problem as well.

No, it cannot be, it is only a flag set by FS according to whether the aircraft is on the ground or not.

Where's the log of IPC writes showing what you are, or are not, writing to 0574?

Regards

Pete

Link to comment
Share on other sites

thanks Pete, I'll keep digging. I too have been searching Google for examples of setting the altitude at offset 0570.

It is easy to use 0570. That isn't a problem. Even writing a 32-bit Metres value to 0574 is not a problem. You need to Google for more help using VB6 and in particular "Currency", not 0570 where it would be pointless.

None of this explains your error in writing a simple 32-bit integer to 0574, which is really really easy. Since you won't show your code and won't even try using the Logging, I don't see much more point in you posting further here, do you? If you really want help please try your end too.

Pete

Link to comment
Share on other sites

Pete,

I did post my code. What do you think that was?

And I have been using FSInterrogate to examine what is possibly happening. I've tried using INTEGERs, DOUBLES, SINGLES, CURRENCY and the like. I've tried writing to both 0570 and 0574 in every possible configuration I can muster. And you are right, this should not be that difficult. A 4 byte variable will be 32 bit. But yet, writing to that offset does nothing. Simply converting my feet to meters and storing that into a variable does not work either.

And if you don't know anything about VB, how can you conclude I should use a 'decent language'? VB is an extremely powerful language, and I have been using it since 1991. I am well versed in the language, and that is not where the breakdown is.

Also, BTW, your comment about the inflight or onground variable is incorrect. According to your documentation, you write a 0 for in-flight, or a 1 for on-ground at offset 055C for your initial position.

Link to comment
Share on other sites

I did post my code. What do you think that was?

Not the code which you said "stored the integer of 618 at 0574". The last code you posted had that glaring error in it which I pointed out:

TempAlt = (TempAlt / 3.28084) * 65536

FSUIPC_Write &H574, 4, VarPtr(TempAlt), dwResult

Please refer back through the thread. You seem to be mixing yourself up!

And if you don't know anything about VB, how can you conclude I should use a 'decent language'? VB is an extremely powerful language, and I have been using it since 1991. I am well versed in the language, and that is not where the breakdown is.

I'm sorry, but you are wrong. You are making a mistake, and you are not helping yourself. And I long-ago concluded that VB is an awful language, from many interactions like these from folks who get lost in its lack of abilities, as it lacks many essential programming things, like unsigned integers, which causes awful problems with technical interfaces like those to FS.

If you are such an expert in VB I would have thought that you would have debugged your way out of your problems many hours ago, if not days!

Also, BTW, your comment about the inflight or onground variable is incorrect. According to your documentation, you write a 0 for in-flight, or a 1 for on-ground at offset 055C for your initial position.

That is not the "on ground" flag which is at 0366. That is a special part of a completely new facility in FSX to set all of the values -- optionally Speed (starting at 0558), and always including all of Lat Lon Alt Pitch Bank Heading all in one single FSUIPC_Write -- i.e. as a complete structure. It is clearly documented, and operates the "INITIAL POSITION" facility in FSX. It is no use for moving aircraft around, only for setting things up initially. Please do read more carefully!

I have tried to be patient, and provide as much help as I can in the circumstances, but it seems to me that in fact the patience is more lacking at your end. If you cannot do the simple things I suggest I don't see any point in continuing here. Do you?

Pete

Link to comment
Share on other sites

Thanks Pete, I have it all working now. It seems once the aircraft was off the ground, then the values I passed to 0570 started working.

I came to you hoping you would simply tell me how to correct my error, not simply point it out. I knew something was wrong and sought your guidance to correct it. Simply insulting my choice of programming language, and your assumption that I am simply ignoring the documentation, and just downright rude responses are not beneficial to anyone. So, I was able to ascertain the problem and correct on my own. And since you yourself have declared you are not a VB programmer, then please refrain from such judgements about the langauge. There isn't a program I have yet to create that can't be accomplished as well or as fast as VB. That is my opinion. I'm not going to sit here and put down other language products, that is not what I came here seeking.

So enjoy your holiday, no need for any further response.

Link to comment
Share on other sites

I came to you hoping you would simply tell me how to correct my error, not simply point it out. I knew something was wrong and sought your guidance to correct it.

Yes, and I did so for the only piece of code you posted for me to look at. I would also have done so for any other sample, but you never posted anything else as i asked, nor did you bother to do the Logging which would have told me what you were doing wrong in a way much more clearer to me, seeing as I don't use VB.

It seems once the aircraft was off the ground, then the values I passed to 0570 started working.

That should not be necessary. I can write to 0570 or 0574 here, using something as simple as the facilities in FSInterrogate, and the aircraft will go to that altitude. There is nothing keeping it on the ground if you don't want it there.

downright rude responses

I'm sorry you see them like that, but if you do come asking for help and then don't bother to help the person who's trying to help you by supplying information, and in fact apparently ignoring requests for information, then really I think it is you who is being rude. Please review this thread properly, actually reading it as you don't seem to have been doing, and you'll certainly see that this is the truth of it.

Please never bother coming back if you don't want me to help in the ways I know how.

Pete

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.