Remove named groups and simplify raw data usage.
[erlang-x-plane-data.git] / README.md
CommitLineData
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
3X-Plane UDP data parser
4=======================
d014d93e 5
64c0d81f
SK
6Example
7-------
8
9```erlang
64c0d81f
SK
10main(Port) ->
11 {ok, Socket} = gen_udp:open(Port, [binary, {active, false}]),
12 {ok, {_, _, <<XPlaneDataPacket/binary>>}} = gen_udp:recv(Socket, 0),
07ba60a5
SK
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,
64c0d81f
SK
38
39 ...
40```
41
d014d93e
SK
42Data format references
43----------------------
44
45- http://b58.svglobe.com/data.html
46- http://www.nuclearprojects.com/xplane/xplaneref.html
This page took 0.018788 seconds and 4 git commands to generate.