2de6895be7b3fee96d464b31c29d67016305e928
[erlang-x-plane-data.git] / README.md
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 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
23
24 ```erlang
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,
48 ```
49
50 Data format references
51 ----------------------
52
53 - http://b58.svglobe.com/data.html
54 - http://www.nuclearprojects.com/xplane/xplaneref.html
This page took 0.041422 seconds and 4 git commands to generate.