You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
using RJCP.IO.Ports;
|
|
using System.Collections.Generic;
|
|
|
|
namespace SerialTestApp;
|
|
|
|
internal class Program
|
|
{
|
|
public static bool QuitRequested { get; private set; }
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
while (QuitRequested == false)
|
|
{
|
|
Console.WriteLine($"----- SERIAL PROTOCOL TEST APP -----");
|
|
Console.WriteLine($"Command list:");
|
|
Console.WriteLine($"l = list ports");
|
|
Console.WriteLine($"c = connect");
|
|
Console.WriteLine($"q = quit");
|
|
|
|
var key = Console.ReadKey();
|
|
|
|
switch (key.Key)
|
|
{
|
|
// list com ports
|
|
case ConsoleKey.L:
|
|
string[] ports = SerialPortStream.GetPortNames();
|
|
Console.WriteLine($"Following ports were found: {Environment.NewLine}");
|
|
foreach (var port in ports)
|
|
{
|
|
Console.WriteLine($"-- {port}");
|
|
}
|
|
break;
|
|
|
|
case ConsoleKey.Q:
|
|
QuitRequested = true;
|
|
break;
|
|
|
|
default:
|
|
Console.WriteLine($"{Environment.NewLine}Did not recognize key.. {Environment.NewLine}");
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
} |