using System; using System.Collections.Generic; using Xylem.Common.Hardware.Interfaces.Ports.PortCore; namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol { public class RfidTransmitProtocol : UartTransmitProtocol { //use the UART transmit protocol sync byte wrapped to RFID protocol private const Byte ProtSyncByte = 0x5B; private const UInt16 ProtAddLength = 1; private readonly UInt16? _protLengthIndex = 1; //this will be used if RFID protocol has been extracted from RfidComPort //private const Byte ProtSyncByte = 0x01; //private const UInt16 ProtAddLength = 1; //private readonly UInt16? _protLengthIndex = 3; private const Int32 DefaultResponseTimeoutMs = 1550; private Int32 _responseTimeoutMs = DefaultResponseTimeoutMs; /// public override void SetResponseTimeout(Int32 responseTimeoutMs) { _responseTimeoutMs = responseTimeoutMs; } /// public override void SetDefaultResponseTimeout() { _responseTimeoutMs = DefaultResponseTimeoutMs; } private const UInt32 BaudRate = 9600; private readonly UInt32? _receiveBufferFlushThreshold = null; public RfidTransmitProtocol(String portName) : base (portName) { } public override TransmitPortSettings GetTransmitPortSettings() { return new TransmitPortSettings(ProtSyncByte, _protLengthIndex, ProtAddLength, _responseTimeoutMs, BaudRate, _receiveBufferFlushThreshold); } public override List SpecificCrcCalc() { //returns an empty list of bytes to avoid filling of CRC in advance to the CRC calculation, //because the RFID does not use the CRC filled up with 0x00, 0x00 to calculate itself return new List(); } } }