63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.IO.Ports;
|
|
using NLog;
|
|
using NLog.Config;
|
|
using Xylem.Common.Hardware.Interfaces.Ports.SerialPorts;
|
|
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
|
|
using Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol;
|
|
|
|
namespace Xylem.Common.Ui.IrdaFunctionalTestApp
|
|
{
|
|
internal class Program
|
|
{
|
|
private static readonly Lazy<ILogger> Logger = new Lazy<ILogger>(() =>
|
|
{
|
|
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Genesis", "NlogConfig.xml");
|
|
return new LogFactory(new XmlLoggingConfiguration(path)).GetCurrentClassLogger();
|
|
});
|
|
private static IrdaSerialPort _irdaComPort;
|
|
|
|
private static readonly SerialPort SerialPortSetup = new SerialPort
|
|
{
|
|
PortName = "COM55",
|
|
BaudRate = 115200,
|
|
Handshake = Handshake.None,
|
|
Parity = Parity.None,
|
|
StopBits = StopBits.One,
|
|
DataBits = 8
|
|
};
|
|
|
|
|
|
private static readonly String Ident = $"Port:{SerialPortSetup.PortName}, Protocol:Request, Type:IrDA -";
|
|
|
|
private static void Main()
|
|
{
|
|
var transmit = new IrdaTransmitProtocol(SerialPortSetup.PortName);
|
|
|
|
_irdaComPort = new IrdaSerialPort(Ident, SerialPortSetup, transmit.GetTransmitPortSettings());
|
|
_irdaComPort.OnRawRecordReceived += delegate (Object o, BasePortDataEventArgs rawMsg)
|
|
{
|
|
FillDecodingBuffer(rawMsg);
|
|
};
|
|
|
|
Byte command = 0x09;
|
|
Byte []payload = {0x0D, 0x0F, 0x00, 0x00, 0x00, 0x00 };
|
|
var txBuffer = transmit.DecodeDataForPhysicalLayer(Ident, command, payload);
|
|
|
|
_irdaComPort.Open();
|
|
|
|
_irdaComPort.PortWrite(txBuffer.ToArray());
|
|
|
|
Console.ReadLine();
|
|
_irdaComPort.Dispose();
|
|
|
|
}
|
|
|
|
private static void FillDecodingBuffer(BasePortDataEventArgs rawMsg)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|