Commit | Line | Data |
---|---|---|
3549a33a SK |
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 | ======================= | |
d014d93e | 5 | |
25c95554 SK |
6 | Examples |
7 | -------- | |
8 | ||
9 | ### Receive data packet | |
10 | ||
11 | ```erlang | |
12 | {ok, Socket} = gen_udp:open(Port, [binary, {active, false}]), | |
13 | {ok, {_, _, <<XPlaneDataPacket/binary>>}} = gen_udp:recv(Socket, 0), | |
14 | ``` | |
15 | ||
16 | ### Parse data packet | |
17 | ||
18 | ```erlang | |
19 | {ok, {Index, Groups}} = x_plane_data_raw:of_bin(XPlaneDataPacket), | |
20 | ``` | |
21 | ||
22 | ### Access parsed data | |
64c0d81f SK |
23 | |
24 | ```erlang | |
25c95554 SK |
25 | % Speeds are in group 3 |
26 | {3, Speeds} = lists:keyfind(3, 1, Groups), | |
27 | { VindKias | |
28 | , VindKeas | |
29 | , VtrueKtas | |
30 | , VtrueKtgs | |
31 | , _ | |
32 | , VindMph | |
33 | , VtrueMphas | |
34 | , VtrueMphgs | |
35 | } = Speeds, | |
36 | ||
37 | % Pitch roll and headings values are in group 17 | |
38 | {17, PitchRollHeadings} = lists:keyfind(17, 1, Groups), | |
39 | { PitchDeg | |
40 | , RollDeg | |
41 | , HdingTrue | |
42 | , HdingMag | |
43 | , _ | |
44 | , _ | |
45 | , _ | |
46 | , _ | |
47 | } = PitchRollHeadings, | |
64c0d81f SK |
48 | ``` |
49 | ||
d014d93e SK |
50 | Data format references |
51 | ---------------------- | |
52 | ||
53 | - http://b58.svglobe.com/data.html | |
54 | - http://www.nuclearprojects.com/xplane/xplaneref.html |