DoyleChris98 Posted January 17, 2015 Share Posted January 17, 2015 I am using Microsoft Flight Simulator and 2 programs on it called Simconnect and Websimconnect. FSX <-> Simconnect <-> Websimconnect <-> Webpage Its designed to control things in FSX from a Webpage. One thing it can do is display Radio frequencies and interact with them. The problem is when simconnect reads the radio there not in MHz or KHz, there in BCD16, BCD32, and BCO16. Mainly i want to figure out the BCO16 (binary coded octal 16), how to take BCO16 and convert it to a 4 digit Integer for the Transponder. Transponder is a 4 digit code that each digit runs between 0-7 so 0000-7777. but unlike Binary Base2 or Decimal Base10. BCO16 acts like base 16 instead of base8. So once you got to 0010 it is 16 in BCO16 0100 is 256 and 1000 is 4096. I know i need to use parseInt and to convert the number but not sure what the code hast to be. I know i need to take each digit and parse it out. This is the code to Convert the COM frequency from XXX.XX to BCD format. After the 1 is dropped from the Com freq. var bcd = (parseInt(n1.charCodeAt(0) - 0x30 )<<12) + (parseInt(n1.charCodeAt(1) - 0x30 )<<8) + (parseInt(n2.charCodeAt(0) - 0x30 )<<4) + parseInt(n2.charCodeAt(1) - 0x30 ) but im not sure how to do the BCO16 conversion and i was wondering if somebody could explain it to me. I dont expect it to be done for me but show me how to do it so i can learn it. Link to comment Share on other sites More sharing options...
Ingolme Posted January 17, 2015 Share Posted January 17, 2015 Javascript has its own internal Number type which is 32-bit float. Numbers can be treated as integer but I'm not sure if it actually casts to an integer type internally or it's just operating with whole numbers. It sounds like BCO16 is just a hexadecimal number. You can use the .toString() method on a Javascript number to represent in a different format. However, it's a string, a series of characters, and needs to be cast to a number again if you want to operate with it. // Represent num as a hexadecimal number (base 16)var num = 520;var result = num.toString(16); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now