/
ucnl
/
AzimuthUDPRemote
Обзор
Документация
Войти
/
ucnl
/
AzimuthUDPRemote
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
Program.cs
62 строки
2 KB
Aleksandr
Add files via upload
09 сен 2025, 14:29
Не верифицирован
09 сен 2025, 14:29
291568c
Код
Авторство
О чём код?
// See https://aka.ms/new-console-template for more information using System.Net; using System.Reflection; using System.Text; using UCNLDrivers; Console.WriteLine(string.Format("{0} v{1} (C) UC&NL, unavlab.com", Assembly.GetExecutingAssembly().GetName().Name, Assembly.GetExecutingAssembly().GetName().Version)); IPEndPoint rctrl_out_endpoint = new IPEndPoint(new IPAddress(new byte[] { 255, 255, 255, 255 }), 28127); UInt16 rctrl_in_port = 28129; if (args.Length == 0) { Console.WriteLine("Usage: AzimuthUDPRemote [in_port] [out_address:port]"); } else { if (args.Length >= 1) { if (!UInt16.TryParse(args[0], out rctrl_in_port)) Console.WriteLine("Error parsing argument 1"); if (args.Length >= 2) { if (!IPEndPoint.TryParse(args[1], out rctrl_out_endpoint)) Console.WriteLine("Error parsing argument 2"); } } } Console.WriteLine("Inport: {0}, Outport: {1}", rctrl_in_port, rctrl_out_endpoint.Port); Console.WriteLine("Type \"help\" for remote commands, \"xcls\" to clear screen, \"xexit\" to exit this app"); UDPTranslator tr = new UDPTranslator(rctrl_out_endpoint.Port, new IPAddress(new byte[] { 255, 255, 255, 255 })); UDPListener lr = new UDPListener(rctrl_in_port); lr.DataReceivedHandler += (o, e) => { Console.WriteLine(Encoding.ASCII.GetString(e.Data)); }; lr.StartListen(); bool application_terminate = false; while (!application_terminate) { var line = Console.ReadLine()?.ToUpper(); if (line == "XEXIT") application_terminate = true; else if (line == "XCLS") Console.Clear(); else { if (!string.IsNullOrEmpty(line)) try { tr.Send(line); } catch (Exception ex) { Console.WriteLine(ex); } } } lr.StopListen();