• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Reading heading data

Public latitude As Double
Public longitude As Double
Public altitude As Double

End Structure

The 'add to data definition...(I had to comment out the "title" request line and re-number the others. 0,1,2. I then substituted "Latitude" and "degrees" with things like "airspeed indicated" "Knots" which worked fine. If I used "Com active frequency:1" "frequency BCD16" it would not work wether I used float64, int64, sting, or any other selection)

No, but for those you not only have to specify "INT32" to SimConnect, but you need to declare your data in the structure correctly too. If you leave it as "Double" you are reading simply fixed point data as floating point, and naturally getting wrong results.

Can't you declare data as an integer or similar (sorry, I don't know VB). i.e. something like

Public com1freq As Integer

Just look up the types of variables you have available.

I do have a registered copy of FSUIPC and know that the values can be obtained...

The logging and monitoring facilities work with unregistered copies too.

Regards

Pete
 
I got it working guys. Thank you for all of your help.

Every bit of documentation I have (Which is poor for managed data) was telling me to use "COM ACTIVE FREQUENCY:1" along with "Frequency BCD16".

When I saw the reference to KHz in your post Denial I decided to try it. "COM ACTIVE FREQUENCY:1" along with "KHz" works perfectly (without a decimal point, but I can work on that)

Pete... I will experiment further and try to get rid of the float values in favor of int16 etc.

Thanks for saving me from the doghouse guys... Wife says if I'm not goig to fret about this stuff any longer I can stay inside!

PS... the program auto connects to FSX (no connect button) so be sure FSX is running prior to starting


If anyone is interested, my program is located Here

It's no more than a radio stack with com 1 and 2 and nav 1 and 2 at this point. The same as what you would find on the fsx screen. Now that this portion is done though, I can add adf and autopilot etc and program phidgets to work with it as an external radio stack.

PS... the program auto connects, so be sure FSX is running prior to starting
 
Last edited:
If I switched those to "COM STANDBY FREQUENCY" "Frequency BCD16" I get a reading of 10128.00 when the com is on 127.90 and a reading of 10112.00 when the com is on 127.80

That's correct, then.

10128 is $2790 in hex, which is exactly right for BCD16 formet. As I said long ago, in fact. 127.90 is encoded as $2790. The initial 1 is assumed (as it is always there, for both COM and NAV).

Similarly 10112 is $2780 giving 127.80.

I thought I explained the encoding to you a few days ago. It is also explained in the FSUIPC SDK.

Regards

Pete
 
Every bit of documentation I have (Which is poor for managed data) was telling me to use "COM ACTIVE FREQUENCY:1" along with "Frequency BCD16".

Which is most certainly correct and the most efficient. The frequencies are stored in BCD16 internally to FS, so it saves conversion to use the FS format.

When I saw the reference to KHz in your post Denial I decided to try it. "COM ACTIVE FREQUENCY:1" along with "KHz" works perfectly (without a decimal point, but I can work on that)

You are making FS work harder, that's all.

Pete... I will experiment further and try to get rid of the float values in favor of int16 etc.

Well, INT32.

I don't see why there's any "work" involved, let alone harder. Surely VB supports ordinary integers? Floating point representations are a relatively new thing, popular because modern processors handle them efficiently now. But computers since the dawn of time (well, almost <G>) have had ordinary "numbers" -- integers. Haven't you used VB with ordinary numbers? They are used for loop counters, all sorts of things. Surely you don't use floating point for everything? I don't understand the difficulty you get into on this.

Pete
 
HI Pete;

I just tried everything again and switched from float64 to int32. All it would give me is 0's. My own knowledge base is limited when it comes to programing. I basically just started all this out of curiosity to see if I could write a program in VB Express to communicate directly with Simconnect.

10128 is $2790 in hex
Thats one of the areas I haven't learned much about. converting 10128 once i had received it was confusing me as I didn't understand that it needed to be converted, nor did I uderstand how the conversion process should/would take place.

As I learn more about Simconnect, VB, and programming itself I'll probably make a lot of changes/improvements, but for now it's all just messin around to 'see if I can'.

The help that both you and Denial have provided is appreciated. I have about three pages of notes as the result of your input, and it's all going to help my learning process.

Thanks again
Daryl
 
Last edited:
I just tried everything again and switched from float64 to int32. All it would give me is 0's.

Probably because you are reading it as a double not as an integer. You have to define the location your reading it into to match. Same as how you defined "string" for a "string" -- you didn't read the string as a floating point number, now, did you?!

Thats one of the areas I haven't learned much about. converting 10128 once i had received it was confusing me as I didn't understand that it needed to be converted, nor did I uderstand how the conversion process should/would take place.

"BCD" means "binary coded decimal". It is actually already decoded in a more efficient manner. Your method, getting a floating point (or even integer) value in KHz might seem to make it easy, but this is only because you are then using a rather large library function to convert it to character format -- converting binary to decimal then characters.

BCD converts to decimal character form in a few very processor-efficient logical steps. Look:

123.45 is encoded as $2345 in BCD16.

That is, in binary: 0010 0011 0100 0101 (Each digit in hexc represents exactly 4 bits in binary).

Now the decimal character "0", in hex is $30, and the numerics "1" to "9" are incremental from that. So you can simply take a 4-bit digit from the BCD16 value, e.g. the 5 (binary 0101), add the charact '0', and get the character '5', directly. No library function, no long conversions.

Say the BCD16 for COM1 is in integer "nCom1". This bit of C code (sorry, I don't know the VB equivalent) would print the actual frequency in decimal:

printf("1%c%c.%c%c", // This is a formatting string meaning 1 then a character, then ... etc)

(nCom1 >> 12) + '0', // This shifts the BCD16 value to thev right 12 bits, so that the value left is from the top (left-most) 4 bits, then adds the '0' to get the correct character value

((nCom1 >> 8) & 15) + '0', // Same for the next 4 bits, but now we have to eliminate the bits above the 4. the and with 15 does this -- 15 is 1111 in binary, so selecting just 4 bits

((nCom1 >> 4) & 15) + '0', // The third digit, same way

(nCom1 & 15) + '0'); // and the last, needing no shifting as it is already in the right place.

Regards

Pete
 
Back
Top