X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=README.md;h=2de6895be7b3fee96d464b31c29d67016305e928;hb=10d6d4c7bd29e99c67024e8a08a2b35f8da1c4de;hp=c428cdb187ed7b43e1f6d4d8ecb2378bf617dfce;hpb=3549a33ac1d2d49c8cef0b6cf679e90f9cc3c89a;p=erlang-x-plane-data.git diff --git a/README.md b/README.md index c428cdb..2de6895 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,53 @@ X-Plane UDP data parser ======================= + +Examples +-------- + +### Receive data packet + +```erlang +{ok, Socket} = gen_udp:open(Port, [binary, {active, false}]), +{ok, {_, _, <>}} = gen_udp:recv(Socket, 0), +``` + +### Parse data packet + +```erlang +{ok, {Index, Groups}} = x_plane_data_raw:of_bin(XPlaneDataPacket), +``` + +### Access parsed data + +```erlang +% Speeds are in group 3 +{3, Speeds} = lists:keyfind(3, 1, Groups), +{ VindKias +, VindKeas +, VtrueKtas +, VtrueKtgs +, _ +, VindMph +, VtrueMphas +, VtrueMphgs +} = Speeds, + +% Pitch roll and headings values are in group 17 +{17, PitchRollHeadings} = lists:keyfind(17, 1, Groups), +{ PitchDeg +, RollDeg +, HdingTrue +, HdingMag +, _ +, _ +, _ +, _ +} = PitchRollHeadings, +``` + +Data format references +---------------------- + +- http://b58.svglobe.com/data.html +- http://www.nuclearprojects.com/xplane/xplaneref.html