Match and print full values in the test.
[erlang-x-plane-data.git] / README.md
index 8092061..2de6895 100644 (file)
--- a/README.md
+++ b/README.md
@@ -3,6 +3,49 @@
 X-Plane UDP data parser
 =======================
 
+Examples
+--------
+
+### Receive data packet
+
+```erlang
+{ok, Socket} = gen_udp:open(Port, [binary, {active, false}]),
+{ok, {_, _, <<XPlaneDataPacket/binary>>}} = 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
 ----------------------
This page took 0.024214 seconds and 4 git commands to generate.