From a4f8f588042d707947fe64896e71a35365f37f2a Mon Sep 17 00:00:00 2001 From: Luke Else Date: Thu, 17 Feb 2022 16:36:55 +0000 Subject: [PATCH] Created basic listener for Xplane 11 --- .vscode/launch.json | 26 ++++++++++++++++++++++++++ .vscode/tasks.json | 41 +++++++++++++++++++++++++++++++++++++++++ Program.cs | 24 ++++++++++++++++++++++-- 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8436135 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/net6.0/EFBTracker.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "externalTerminal", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..44578a1 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/EFBTracker.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/EFBTracker.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/EFBTracker.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Program.cs b/Program.cs index 3751555..80c2736 100644 --- a/Program.cs +++ b/Program.cs @@ -1,2 +1,22 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +using System.Net; +using System.Net.Sockets; +using System.Text; + +bool done = false; +int listenPort = 49003; +using(UdpClient listener = new UdpClient(listenPort)) +{ + IPEndPoint listenEndPoint = new IPEndPoint(2130706433, listenPort); + while(!done) + { + byte[] receivedData = listener.Receive(ref listenEndPoint); + + Console.Clear(); + Console.WriteLine("Received broadcast message from client {0}", listenEndPoint.ToString()); + + Console.WriteLine("Decoded data is:"); + //Console.WriteLine(Encoding.ASCII.GetString(receivedData)); + Console.WriteLine(BitConverter.ToString(receivedData)); + + } +}