Nefarius.Peripherals.Serial.../PInvokeSerialPort.Sample/Program.cs

24 lines
459 B
C#
Raw Normal View History

2012-03-03 10:50:54 +01:00
using System;
2024-07-13 15:53:59 +02:00
2022-10-03 17:25:19 +02:00
using Nefarius.Peripherals.SerialPort;
2012-03-03 10:50:54 +01:00
2022-10-03 17:25:19 +02:00
namespace PInvokeSerialPort.Sample;
internal class Program
2012-03-03 10:50:54 +01:00
{
2022-10-03 17:25:19 +02:00
private static void Main(string[] args)
2012-03-03 10:50:54 +01:00
{
2024-07-13 15:53:59 +02:00
SerialPort serialPort = new SerialPort("com5") { UseRts = HsOutput.Online };
2022-10-03 17:25:19 +02:00
serialPort.DataReceived += x =>
2012-03-03 10:50:54 +01:00
{
2022-10-03 17:25:19 +02:00
Console.Write($"{x:X2} ");
};
serialPort.Open();
serialPort.Write("START\r\n");
Console.ReadKey();
2012-03-03 10:50:54 +01:00
}
2022-10-03 17:25:19 +02:00
}