Jump to content
Sign in to follow this  
Guest CaptnKebec

Programmers help needed

Recommended Posts

Guest CaptnKebec

Hi everyone,I'm programming a little apps using FSUIPC to read and writes values for the avionics stack.The reading is OK and increasing COM value is OK too, but when decreasing, the value keep circling in a 6 loop.Ex. 9093, 9092, 9091, 9090, 9089, 9088 and then 9093 instead of 9087!!The program work as follow:1- read com1 value and put result in a variable2- decrease the variable value3- writes the variable value to com1.The program is in VB but any instructions in C would work OK.Any clues why it works for increasing and not decreasing??Thanks for any help

Share this post


Link to post
Share on other sites
Guest spiliot_

According to FSUIPC manual for offset 311A (a two byte value), "COM1 standby frequency (FS2002 only), 4 digits in BCD format. A frequency of 123.45 is represented by 0x2345. The leading 1 is assumed."So 9093 is frequency 190.93? It makes no sense. What type is the variable you're using to hold the value?

Share this post


Link to post
Share on other sites
Guest CaptnKebec

The numbers I gave are in decimal if you convert them to hex you will get the right frequency.By the way I found the problem, if I read the value, convert it to hexadecimal, increase or decrease the value then reconvert it to decimal and write the result to FSUIPC it works!That's weird if I read the value, increase or decrease and write it back to FSUIPC I get strange behaviors, that's probably got something to do with how VB handles the variable pointers.Well I don't care know, I found a workaround and it's OK now.Thanks anyway

Share this post


Link to post
Share on other sites
Guest spiliot_

>that's probably got something to do with how VB handles the variable>pointers.Actually it has something to do with the way YOU handle the variable (it depends on how it is defined, i.e. an integer, byte, etc)! VB can guess on the type of arithmetic function you want to perform if you let it (it is done by default) and does the necessery convertions but that doesn't mean it will always work as YOU want.>Well I don't care know, I found a workaround and it's OK now.True.

Share this post


Link to post
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
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...