{"id":17483476,"url":"https://github.com/xandkar/erlang-x-plane-data","last_synced_at":"2025-03-28T14:14:06.370Z","repository":{"id":35657497,"uuid":"39932546","full_name":"xandkar/erlang-x-plane-data","owner":"xandkar","description":"X-Plane UDP data parser for Erlang","archived":false,"fork":false,"pushed_at":"2020-01-05T06:16:44.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T03:06:29.906Z","etag":null,"topics":["erlang","x-plane"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xandkar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-30T05:15:28.000Z","updated_at":"2020-01-05T06:16:47.000Z","dependencies_parsed_at":"2022-08-17T20:41:14.448Z","dependency_job_id":null,"html_url":"https://github.com/xandkar/erlang-x-plane-data","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xandkar%2Ferlang-x-plane-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xandkar%2Ferlang-x-plane-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xandkar%2Ferlang-x-plane-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xandkar%2Ferlang-x-plane-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xandkar","download_url":"https://codeload.github.com/xandkar/erlang-x-plane-data/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246042013,"owners_count":20714147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erlang","x-plane"],"created_at":"2024-10-19T00:05:34.032Z","updated_at":"2025-03-28T14:14:06.343Z","avatar_url":"https://github.com/xandkar.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/xandkar/erlang-x-plane-data.svg?branch=master)](https://travis-ci.org/xandkar/erlang-x-plane-data)\n\nX-Plane UDP data parser\n=======================\n\n![Data output in the cockpit](screenshot.png)\n\nExamples\n--------\n\n### Receive data packet\n\n```erlang\n{ok, Socket} = gen_udp:open(Port, [binary, {active, false}]),\n{ok, {_, _, \u003c\u003cXPlaneDataPacket/binary\u003e\u003e}} = gen_udp:recv(Socket, 0),\n```\n\n### Parse data packet\n\n```erlang\n{ok, {64=Index, GroupsRaw}=DataRaw} = x_plane_data_raw:of_bin(XPlaneDataPacket),\n```\n\n### Access parsed data\n\n#### Raw\n\nAt this stage, only the structure of the packet was parsed. No attempts at\ninterpreting the values have been made:\n\n```erlang\n% Speeds are in group 3\n{3, Speeds} = lists:keyfind(3, 1, GroupsRaw),\n{ VindKias\n, VindKeas\n, VtrueKtas\n, VtrueKtgs\n, _\n, VindMph\n, VtrueMphas\n, VtrueMphgs\n} = Speeds,\n\n% Pitch roll and headings values are in group 17\n{17, PitchRollHeadings} = lists:keyfind(17, 1, GroupsRaw),\n{ PitchDeg\n, RollDeg\n, HdingTrue\n, HdingMag\n, _\n, _\n, _\n, _\n} = PitchRollHeadings,\n```\n\n#### Named\n\nHere we identify what each of the numbered groups mean in a given X-Plane\nversion. Right now only X-Plane 10 (packet index 64) is supported and I only\nidentified 3 groups so far:\n\n| packet index | group index | group name           |\n|--------------|-------------|----------------------|\n| 64           | 3           | `speeds`             |\n| 64           | 17          | `pitch_roll_heading` |\n| 64           | 20          | `lat_lon_alt`        |\n\nUnidentified groups (with index other than what is listed above) will be\nabsent from the list of named groups (think of `x_plane_data_named:of_raw/1` as\na filter), so you'll have to access their raw version, if needed.\n\n##### Identify\n```erlang\n{ok, {x_plane_data_v10, GroupsNamed}} = x_plane_data_named:of_raw(DataRaw),\n```\n\n##### Access\n```erlang\n-include_lib(\"x_plane_data/include/x_plane_data_group_speeds.hrl\").\n{speeds, #x_plane_data_group_speeds\n    { vind_kias   = VindKias\n    , vind_keas   = VindKeas\n    , vtrue_ktas  = VtrueKtas\n    , vtrue_ktgs  = VtrueKtgs\n    , vind_mph    = VindMph\n    , vtrue_mphas = VtrueMphas\n    , vtrue_mphgs = VtrueMphgs\n    }\n} = lists:keyfind(speeds, 1, GroupsNamed),\n\n...\n\n-include_lib(\"x_plane_data/include/x_plane_data_group_pitch_roll_heading.hrl\").\n{pitch_roll_heading, #x_plane_data_group_pitch_roll_heading\n    { pitch_deg  = PitchDeg\n    , roll_deg   = RollDeg\n    , hding_true = HdingTrue\n    , hding_mag  = HdingMag\n    }\n} = lists:keyfind(pitch_roll_heading, 1, GroupsNamed),\n\n...\n\n-include_lib(\"x_plane_data/include/x_plane_data_group_lat_lon_alt.hrl\").\n{lat_lon_alt, #x_plane_data_group_lat_lon_alt\n    { lat_deg   = LatDeg\n    , lon_deg   = LonDeg\n    , alt_ftmsl = AltFtmsl\n    , alt_ftagl = AltFtagl\n    , on_runwy  = OnRunwy\n    , alt_ind   = AltInd\n    , lat_south = LatSouth\n    , lon_west  = LonWest\n    }\n} = lists:keyfind(lat_lon_alt, 1, GroupsNamed),\n```\n\nPacket structure\n----------------\n\n```erlang\n\u003c\u003c\"DATA\", PacketIndex:8/integer, Groups/binary\u003e\u003e,\n\u003c\u003c GroupIndex:32/little-integer\n , GroupValue1:32/little-float\n , GroupValue2:32/little-float\n , GroupValue3:32/little-float\n , GroupValue4:32/little-float\n , GroupValue5:32/little-float\n , GroupValue6:32/little-float\n , GroupValue7:32/little-float\n , GroupValue8:32/little-float\n , GroupsRest/binary\n\u003e\u003e = Groups,\n```\n\nWhere `PacketIndex` indicates something like a schema version, i.e. what each\nof the numbered groups means. For example, in X-Plane 10, packet index is 64\n(character `\"@\"`) and group 3 contains speed data, in which the 8 group values\nare:\n\n| Location | Label         | Description |\n|----------|---------------|-------------|\n|    1     | `vind_kias`   | Velocity indicated, in knots indicated airspeed. |\n|    2     | `vind_keas`   | Velocity indicated, in knots equivalent airspeed (the calibrated airspeed corrected for adiabatic compressible flow at the craft's current altitude). |\n|    3     | `vtrue_ktas`  | Velocity true (the speed of the craft relative to undisturbed air), in knots true airspeed. |\n|    4     | `vtrue_ktgs`  | Velocity true, in knots true ground speed. |\n|    5     |               | Unused. Contains a dummy value. |\n|    6     | `vind_mph`    | Velocity indicated, in miles per hour. |\n|    7     | `vtrue_mphas` | Velocity true, in miles per hour airspeed. |\n|    8     | `vtrue_mphgs` | Velocity true, in miles per hour ground speed. |\n\n\nReferences\n----------\n\n- `X-Plane_10_manual.pdf` (distributed with X-Plane 10)\n- http://b58.svglobe.com/data.html\n- http://www.nuclearprojects.com/xplane/xplaneref.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxandkar%2Ferlang-x-plane-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxandkar%2Ferlang-x-plane-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxandkar%2Ferlang-x-plane-data/lists"}