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

23 lines
451 B
C#
Raw Normal View History

2012-03-03 10:50:54 +01:00
using System;
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
{
2022-10-03 17:25:19 +02:00
var serialPort = new SerialPort("com7") { UseRts = HsOutput.Online };
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
}