Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Pete,

I write a script with Visual Basic 6, and I need to write a heading in the auto Pilot Heading Display the variable is 07CC (AP Heading Value), I use this code:

Public Function set_hdgAP(numHdg As Integer) As Boolean

xResult = numHdg * 65536 / 360

Call FSUIPC_Write(&H7CC, 2, VarPtr(xResult), dwresult)

Call FSUIPC_Process(dwresult)

End Function

Example:

a = 360

Call set_hdgAP(a)

But I don’t now what happen and don’t work.

The Display doesn’t show me the heading that I insert.

I need to write a heading in the heading display of my auto pilot.

Thanks :D

Posted
[

The Display doesn’t show me the heading that I insert.

360 wasn't a good example to start with, was it? That's the same as 0 (and that's what would be written). What did you get displayed?

I don't know VB at all, so maybe someone else will help you, but one thing that would puzzle me is the absense of any definition of what "xResult" is. Shouldn't that be defined someplace?

Pete

Posted

I try whit 360°, 010°, 045°, 090°, 100°, 150°, 180°, etc… all the grades, and don’t resolve the problem, I don’t know but some one called JD helps me, when I publish the last topic, something whit Headings.

I’m making a cockpit whit 2 engineers but electrical engineers. I really need help.

Thanks for all Pete, :wink:

Posted
I try whit 360°, 010°, 045°, 090°, 100°, 150°, 180°, etc… all the grades, and don’t resolve the problem

And what results did you get? You need to talk about both inputs and outputs to a problem. You ARE using a default aircraft, aren't you? If you are trying to do with with sophisticate panels like those from PMDG, Level D and PSS you will probably never get it working as they tend to use their own autpilots, not the built-in FS one.

I don’t know but some one called JD helps me, when I publish the last topic, something whit Headings.

I'm afraid JD is away all week. Perhaps he will see your questions next week.

Have you tried using some of the facilities in FSUIPC to see what is going on? That should be your first step. Please use the Logging -- you can Log the IPC reads, and see what you are asking FSUIPC for and what it is providing.

Then, of course, there must surely be some debugging facilities in VB? I can't understand how any one ever gets a VB program working otherwise. All the code, including that inside the FSUIPC routines you are calling, is in your hands. All you need to do is find out what is wrong. You can trace it step-by-step.

Regards

Pete

Posted

Pete, about outputs and inputs, when I use any grade (360° = 0°, 010°, etc..) the result is 0, in all the cases, I reed al the SDK but I think that the problem is about the math formula, ok I don’t know with accuracy, but I try everything, and the result is the same 0.

About the aircraft I use a FS aircraft not PSS, PMDG, Level D, etcetera. Use Bombardier Lear Jet 45. But the Idea is to use the software whit Dash 8 of PSS.

If you have may be an idea, please tell me, I am creasy for the answer. Equal will repeat the process step by step…

Thanks, :?

Me..

Posted
Pete, about outputs and inputs, when I use any grade (360° = 0°, 010°, etc..) the result is 0, in all the cases, I reed al the SDK ...

I didn't suggest to read the SDK again, but to use the tools at your disposal to check what is happening, like using FSUIPC Logging, and using a Debugger for VB.

I don't understand why so many VB programmers don't seem to understand about debugging. Doesn't the VB package come with any tools for this? How do they get programs working at all?

... but I think that the problem is about the math formula, ok I don’t know with accuracy, but I try everything, and the result is the same 0.

One more thought. You said you defined xResult as

Dim xResult as Integer

Now I always assumed an Integer on a 32-bit system was 32-bits. What you are seeing might be explained if an Integer in your compiler is only 16 bits. Both numHdg and xResult would be too small for the intermediate result.

Alternatively, it would also be explained if the compiler worked backwards and divided your value by 360 before multiplying by 65536. Try forcing the order by

xResult = (numHdg * 65536) / 360

I tend to always use parentheses for such things in any case as I don't wholly trust compilers! ;-)

If you have may be an idea, please tell me, I am creasy for the answer. Equal will repeat the process step by step…

Have you any books on VB to learn more about it? It seems to me the answer is in understanding the language you use more thoroughly, and then trying to debug it correctly.

I've now really helped about as much as I can I'm afraid.

Regards

Pete

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.