Ralph wrote: ↑Sat Feb 13, 2021 6:13 am
tostring() ? Or wasn't that what you mean?
Hi no not that easy Ralph.
I have this xplane dataref. sim/cockpit2/tcas/targets/modeS_id int[64] y integer 24bit (0-16777215 or 0 - 0xFFFFFF) unique ID of the airframe. This is also known as the ADS-B "hexcode"
How to convert this to text??
I did try and look it up. This does not work so I am sure I am way off.
local hex_to_char = {}
for idx = 0, 255 do
hex_to_char[("%02X"):format(idx)] = string.char(idx)
hex_to_char[("%02x"):format(idx)] = string.char(idx)
end
ICAO 24-bit address
Mode S equipped aircraft are assigned a unique ICAO 24-bit address or (informally) Mode-S "hex code" upon national registration and this address becomes a part of the aircraft's Certificate of Registration. Normally, the address is never changed, however, the transponders are reprogrammable and, occasionally, are moved from one aircraft to another (presumably for operational or cost purposes), either by maintenance or by changing the appropriate entry in the aircraft's Flight management system.
There are 16,777,214 (224-2) unique ICAO 24-bit addresses (hex codes) available.[4][5] The ICAO 24-bit address can be represented in three digital formats: hexadecimal, octal, and binary. These addresses are used to provide a unique identity normally allocated to an individual aircraft or registration.
As an example, following is the ICAO 24-bit address assigned to the Shuttle Carrier Aircraft with the registration N905NA:[6][7]
Hexadecimal: AC82EC
Octal: 53101354
Binary: 101011001000001011101100 (Note: occasionally, spaces are added for visual clarity, thus 1010 1100 1000 0010 1110 1100 {Hex big endian} and 001 101 110 100 000 100 110 101 {Octal little endian})
Decimal: 11305708
These are all the same 24-bit address of the Shuttle Carrier Aircraft, represented in different numeral systems (see above).[Codebox=text file=Untitled.txt][/Codebox]
This has been about for ages so it's not specifically an ADSB thing. Normally you apply to your local regulator everytime a new aircraft is about to be added to the register and they issue the hex code.
You may not also know that each code starts with the a unique id for the country of origin. so all aircraft registered in the same country tend to begin with the same first 2 hex characters.
Back to your need. Are you wanting to convert the xplane INT value into the 6 digit hex code and then display using string?
Last edited by Sling on Sat Feb 13, 2021 10:18 am, edited 1 time in total.
This has been about for ages so it's not specifically an ADSB thing. Normally you apply to your local regulator everytime a new aircraft is about to be added to the register and they issue the hex code.
You may not also know that each code starts with the a unique id for the country of origin. so all aircraft registered in the same country tend to begin with the same first 2 hex characters.
Back to your need. Are you wanting to convert the xplane INT value into the 6 digit hex code and then convert to a string?
Tony,
I am on the Map Traffic page. The G1000 has an option to add the "Flight ID"
This dataref I hope will do that. I could just display the dataref value but I think that this dataref , once converted will return the aircraft ID.
This might have implications if plugin Traffic is in place. It is a writable dataref so I would thing those plugins do that.
Keith Baxter wrote: ↑Sat Feb 13, 2021 10:20 am
I am on the Map Traffic page. The G1000 has an option to add the "Flight ID"
This dataref I hope will do that. I could just display the dataref value but I think that this dataref , once converted will return the aircraft ID.
If i'm not mistaken the flight ID is not automatically the ICAO code. This is the same option you get in modern transponders. From memory you can normally tell it to use the ICAO (which it will already know from its installation settings) or enter your own ID. That could be tail number or as the name suggests a flight ID number. This can be used for commercial ops when a flight ID is used. Pilots do not enter the ICAO hex code as its tied to the airframe and is a maintenance function anyhow.
Keith Baxter wrote: ↑Sat Feb 13, 2021 10:20 am
I am on the Map Traffic page. The G1000 has an option to add the "Flight ID"
This dataref I hope will do that. I could just display the dataref value but I think that this dataref , once converted will return the aircraft ID.
If i'm not mistaken the flight ID is not automatically the ICAO code. This is the same option you get in modern transponders. From memory you can normally tell it to use the ICAO (which it will already know from its installation settings) or enter your own ID. That could be tail number or as the name suggests a flight ID number. This can be used for commercial ops when a flight ID is used. Pilots do not enter the ICAO hex code as its tied to the airframe and is a maintenance function anyhow.
Tony,
Yes I understand all that.
I will look at the code you posted just now.
I am not sure but I think that dataref is used by the likes of vatsim etc. So that must have some common interpretation.
I am on this page so It is important to understand the data and future offerings.
NOTE TO THOSE NOT AWARE: All graphics in this image are done in canvas_draw()
The advisory flight ID I am referring to is the one bottom right traffic indicator. This is visible by choice within the map menu setup.
So it is important to work properly.
Somehow surprised that this has not come up before. @Ralph@Sling Is this a first for someone using AM ??
As i said in my previous post that is a flight id and not the 6 digit hex code. In the case you posted it's the tail number. I'm not sure that there is a generic dataref(s) for the flight id of other aircraft. If you don't have data you can't populate the field.
As i said in my previous post that is a flight id and not the 6 digit hex code. In the case you posted it's the tail number. I'm not sure that there is a generic dataref(s) for the flight id of other aircraft. If you don't have data you can't populate the field.
[/quote]
Tony,
Yes it is a flight ID of the airframe.
I do not believe that LR would create such a dataref if it was merely a numeric reference.
In DatarefTool type in "tcas mode" and you should get two datarefs. These are the ID/(flight ID) of the Al aircraft from what you selected in here....
Tony I say this because for each airframe added or subtracted in the above menu, the dataref [i] value within those daterefs change indicating a ID of sorts.
I will pop LR a note to inquire
Keith
Attachments
Last edited by Keith Baxter on Sat Feb 13, 2021 2:51 pm, edited 1 time in total.