47 lines
1.8 KiB
C#
47 lines
1.8 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.IO.Ports;
|
|
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
|
|
|
|
namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
|
|
{
|
|
/// <inheritdoc />
|
|
public class IrdaSerialPort : BaseSerialPort
|
|
{
|
|
/// <inheritdoc />
|
|
public IrdaSerialPort(String ident, SerialPort serialPort, TransmitPortSettings setting)
|
|
: base(ident, serialPort, setting)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
/// <remarks date="2018-Mar-15" author="T.Wiedebusch">
|
|
/// - Initial
|
|
/// </remarks>
|
|
/// <remarks date="2019-Aug-07" author="T.Wiedebusch">
|
|
/// - wakeup burst pattern changed from 2 times 0xF0 to 4 times 0x01,
|
|
/// - required delay from 500µs to 1ms between wakeup burst and data.
|
|
/// </remarks>
|
|
/// <remarks date="2022-Mar-03" author="T.Wiedebusch">
|
|
/// - Generated the required delay with an 8 Byte pattern, as MOXA interface collects data
|
|
/// and sends it in one burst, meaning it sends the wake up and payload without delay.
|
|
/// So including a pattern instead will force this delay. At 115.200 kBit/s a Byte of 8 Bit
|
|
/// one start and one stop step resulting in 10 bits with a Byte length of 86.8 µs. An 8
|
|
/// Byte pattern will generate a 694 µs delay.
|
|
/// </remarks>
|
|
protected override void SpecificPortWrite(Byte[] tx)
|
|
{
|
|
//send wake up burst
|
|
var wakeUpBurst = new Byte[] { 0x01, 0x01, 0x01, 0x01 };
|
|
PhysicalWrite(wakeUpBurst);
|
|
|
|
//delay at least 500 µs
|
|
var delayPattern = new Byte[] { 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F };
|
|
PhysicalWrite(delayPattern);
|
|
|
|
//send the IrDA record
|
|
PhysicalWrite(tx);
|
|
}
|
|
}
|
|
}
|