Jump to content
The simFlight Network Forums

Recommended Posts

Posted

My first post here, so firstly a huge thanks to Pete and the wider FS dev community for some really great work over the years.

My issue:

I'm pulling apart D.J.Ault's RMU/K8055 USB I/O board interface source code (written in C) to assign the digital inputs as a rudder/aileron trim controls. I have to go the long way round as the Velleman K8055 board is not an HID USB device. So i've copied some functioning code and replaced the variables but every time i compile i get a warning "'FSUIPC_Read' makes pointer from integer without a cast"

Using FS interrogate, the aileron trim position/control appears to be a signed short var. so i've added a signed short var at the top to the code called "aileron_trim". NB: I have also tried setting the var as an int and other variables but the result is the same.

so here's D.J.'s original code that enables the digital input to adjust the AP heading.

SetCurrentDevice( 1 );

if( ReadDigitalChannel( 1 ) == 1) //check if heading minus pressed

{

if(step_increase1 <= 20) { step_increase1+=1; Sleep( 50 ); }

else if(step_increase1 <= 100) step_increase1+=5;

else if(step_increase1 > 100 ) step_increase1+=20;

if(!FSUIPC_Read(0x07CC, 2, &heading, &dwResult) || !FSUIPC_Process(&dwResult)) connect_to_sim(); //read current heading

heading-=(int)150+step_increase1;

if( !FSUIPC_Write(0x07CC, 2, &heading, &dwResult)) connect_to_sim();

p = 1;

}

And here's my attempt to get a digital input to adjust the aileron trim

else if( ReadDigitalChannel( 2 ) == 1) //check if aileron R plus pressed

{

if(step_increase1 <= 20) { step_increase1+=1; Sleep( 50 ); }

else if(step_increase1 <= 100) step_increase1+=5;

else if(step_increase1 > 100 ) step_increase1+=20;

if(!FSUIPC_Read (0x0C02, 2, aileron_trim, &dwResult) || !FSUIPC_Process(&dwResult)) connect_to_sim(); //read current heading <==this is the error line

aileron_trim+=(signed short)150+step_increase1;

if ( !FSUIPC_Write(0x0C02, 2, &aileron_trim, &dwResult)) connect_to_sim();

p = 1;

}

any tips or pointers to a beginner's tutorial would be much appreciated

Thnx

Posted
here's D.J.'s original code that enables the digital input to adjust the AP heading.

if(!FSUIPC_Read(0x07CC, 2, &heading, &dwResult) || !FSUIPC_Process(&dwResult)) connect_to_sim(); //read current heading

And did that compile without an error? What is "heading" defined as?

And here's my attempt to get a digital input to adjust the aileron trim

if(!FSUIPC_Read (0x0C02, 2, aileron_trim, &dwResult) || !FSUIPC_Process(&dwResult)) connect_to_sim(); //read current heading[/b] <==this is the error line

It fails because "aileron_trim" is a number, a value, and you are asking FSUIPC_Read to place a value into it! Values cannot be placed into values, only into memory. You missed off the "&" -- please see that in the original: ("&heading"). The prefix & tells the compiler you want the address of the variable -- in other words a pointer.

Best if you have a little reference book to C syntax. You would have seen this very quickly. Either that, or perhaps take a little more care when copying code? ;-)

Regards

Pete

Posted

ah haa! thanks heaps pete for your swift response, i realised my mistake a quarter of the way through reading your post.

Well i said i was a novice so i guess i just learnt programming lesson 101.

thanks again!

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.