| 1 | [![Build Status](https://travis-ci.org/ibnfirnas/erlang-x_plane_data.svg?branch=master)](https://travis-ci.org/ibnfirnas/erlang-x_plane_data) |
| 2 | |
| 3 | X-Plane UDP data parser |
| 4 | ======================= |
| 5 | |
| 6 | Example |
| 7 | ------- |
| 8 | |
| 9 | ```erlang |
| 10 | main(Port) -> |
| 11 | {ok, Socket} = gen_udp:open(Port, [binary, {active, false}]), |
| 12 | {ok, {_, _, <<XPlaneDataPacket/binary>>}} = gen_udp:recv(Socket, 0), |
| 13 | {ok, {Index, Groups}} = x_plane_data_raw:of_bin(XPlaneDataPacket), |
| 14 | |
| 15 | % Speeds are in group 3 |
| 16 | {3, Speeds} = lists:keyfind(3, 1, Groups), |
| 17 | { VindKias |
| 18 | , VindKeas |
| 19 | , VtrueKtas |
| 20 | , VtrueKtgs |
| 21 | , _ |
| 22 | , VindMph |
| 23 | , VtrueMphas |
| 24 | , VtrueMphgs |
| 25 | } = Speeds, |
| 26 | |
| 27 | % Pitch roll and headings values are in group 17 |
| 28 | {17, PitchRollHeadings} = lists:keyfind(17, 1, Groups), |
| 29 | { PitchDeg |
| 30 | , RollDeg |
| 31 | , HdingTrue |
| 32 | , HdingMag |
| 33 | , _ |
| 34 | , _ |
| 35 | , _ |
| 36 | , _ |
| 37 | } = PitchRollHeadings, |
| 38 | |
| 39 | ... |
| 40 | ``` |
| 41 | |
| 42 | Data format references |
| 43 | ---------------------- |
| 44 | |
| 45 | - http://b58.svglobe.com/data.html |
| 46 | - http://www.nuclearprojects.com/xplane/xplaneref.html |