Poseidon DLL - Comunication Implementation - not finall
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using GlobalIPerlUtility;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace NfcC7_DLL.Tests.NfcHanler;
|
||||
|
||||
[TestClass]
|
||||
[TestSubject(typeof(MeterTestHatLink))]
|
||||
public class MeterTestHatLinkTest
|
||||
{
|
||||
|
||||
[TestMethod]
|
||||
public void Open_Test()
|
||||
{
|
||||
MeterTestHatLink meterTestHatLink = new MeterTestHatLink("COM5");
|
||||
meterTestHatLink.Open();
|
||||
Assert.IsTrue(meterTestHatLink.IsConnected);
|
||||
meterTestHatLink.Close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.IO.Ports;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using NfcC7_DLL.NfcHanler;
|
||||
|
||||
namespace NfcC7_DLL.Tests.NfcHanler;
|
||||
|
||||
[TestClass]
|
||||
[TestSubject(typeof(SERIAL_Driver))]
|
||||
public class SERIAL_DriverTest
|
||||
{
|
||||
private readonly byte[] Open =
|
||||
{ 107 ,128 ,1 ,16 ,0 ,48 ,0 ,71 ,108 ,111 ,98 ,97 ,108 ,73 ,80 ,101 ,114
|
||||
,108 ,85 ,116 ,105 ,108 ,105 ,116 ,121 ,0 ,0 ,39 ,215 };
|
||||
private readonly byte[] CommDeviceSessionEnd = { 0x6B, 0x61, 0x00, 0x10, 0x05, 0x31, 0x00, 0x1F, 0x29, 0xF9, 0xC5 };
|
||||
|
||||
private readonly byte[] ProductDetails =
|
||||
{ 107, 48, 1, 16, 3, 33, 1, 2, 107, 144, 0, 0, 17, 64, 5, 0, 2, 4, 96, 98, 66, 4, 165, 100 };
|
||||
|
||||
private readonly byte[] ProductDetails2 =
|
||||
{ 107, 48, 1, 16, 3, 33, 1, 2, 107, 144, 0, 0, 17, 64, 5, 0, 2, 4, 96 };
|
||||
|
||||
string com = "COM5";
|
||||
int baudrate = 57600;
|
||||
int dataBits = 8;
|
||||
Parity parity = Parity.None;
|
||||
StopBits stopbits = StopBits.Two;
|
||||
int readTimeout = 5000;
|
||||
int writeTimeout = 1000;
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessage_Test()
|
||||
{
|
||||
|
||||
byte[] message = Open;
|
||||
byte[] bytesReceived;
|
||||
|
||||
SERIAL_Driver driver = new SERIAL_Driver();
|
||||
bool isopen = driver.OpenConnection(com,baudrate, dataBits,parity,stopbits,readTimeout,writeTimeout);
|
||||
Assert.IsTrue(isopen);
|
||||
driver.SendMessage(message, message.Length);
|
||||
//Assert.IsTrue(driver.GetRawData().Length == 0);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
string response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
|
||||
message = CommDeviceSessionEnd;
|
||||
driver.SendMessage(message, message.Length);
|
||||
|
||||
driver.Close();
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessage_TestGetSerialNo()
|
||||
{
|
||||
|
||||
byte[] message = Open;
|
||||
byte[] bytesReceived;
|
||||
|
||||
SERIAL_Driver driver = new SERIAL_Driver();
|
||||
bool isopen = driver.OpenConnection(com,baudrate, dataBits,parity,stopbits,readTimeout,writeTimeout);
|
||||
Assert.IsTrue(isopen);
|
||||
driver.SendMessage(message, message.Length,readTimeout);
|
||||
//Assert.IsTrue(driver.GetRawData().Length == 0);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
if (bytesReceived[0] == 0xFF)
|
||||
Console.WriteLine("Error message: {0}", driver.ErrorMessage);
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
string response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
|
||||
// --- Get Serial No ---
|
||||
message = ProductDetails;
|
||||
driver.SendMessage(message, message.Length,readTimeout);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
if (bytesReceived[0] == 0xFF)
|
||||
Console.WriteLine("Error message: {0}", driver.ErrorMessage);
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
|
||||
// --- Get Serial No ---
|
||||
message = ProductDetails2;
|
||||
driver.SendMessage(message, message.Length,readTimeout);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
if (bytesReceived[0] == 0xFF)
|
||||
Console.WriteLine("Error message: {0}", driver.ErrorMessage);
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
|
||||
|
||||
message = CommDeviceSessionEnd;
|
||||
driver.SendMessage(message, message.Length);
|
||||
|
||||
driver.Close();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,4 +14,34 @@
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.IO.Ports" Version="10.0.0-rc.1.25451.107" />
|
||||
<PackageReference Include="System.Security.Cryptography.Cng" Version="5.0.0" />
|
||||
<PackageReference Include="System.Threading" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="NA2WNFC">
|
||||
<HintPath>NfcHanler\NfcReaderLibrary\NA2WNFC.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OBIDISC4NET">
|
||||
<HintPath>NfcHanler\NfcReaderLibrary\OBIDISC4NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OBIDISC4NETnative">
|
||||
<HintPath>NfcHanler\NfcReaderLibrary\OBIDISC4NETnative.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OBIDISC4NET_API">
|
||||
<HintPath>NfcHanler\NfcReaderLibrary\OBIDISC4NET_API.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<HintPath>..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<HintPath>..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Sensus">
|
||||
<HintPath>NfcHanler\FieldLogicLibrary\Sensus.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.CommunicationDevices;
|
||||
using Sensus.Protocols.FlexNet.Serial;
|
||||
using Sensus.Protocols.FlexNet.Serial.FNv2;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
using Serial = Sensus.Protocols.FlexNet.Serial;
|
||||
using Sensus.Protocols;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
using System.ComponentModel;
|
||||
using Sensus.Protocols.FlexNet.Transactions;
|
||||
using Sensus.Protocols.SensusRF;
|
||||
using System.Windows.Markup;
|
||||
using NA2WNFC;
|
||||
using NfcC7_DLL.NfcHanler;
|
||||
using NfcC7_DLL.NfcHanler.Protocols;
|
||||
using NfcC7_DLL.NfcHanler.Utils;
|
||||
using Log = NfcC7_DLL.NfcHanler.Utils.Log;
|
||||
|
||||
namespace GlobalIPerlUtility
|
||||
{
|
||||
class CmdLinkGen2Link : ISerialConnection, IDisposable
|
||||
{
|
||||
private SerialManager serialManager = null;
|
||||
private UInt16 sessionId = 0;
|
||||
|
||||
public CmdLinkGen2Link(string comPortString)
|
||||
{
|
||||
serialManager = new SerialManager(comPortString);
|
||||
}
|
||||
|
||||
public bool IsConnected { get { return (serialManager != null ? serialManager.FactoryUart.IsConnected : false); } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposing)
|
||||
{
|
||||
// eventThread.Abort();
|
||||
}
|
||||
}
|
||||
private BackgroundWorker openBackgroundWorker;
|
||||
|
||||
private void OpenDoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
bool isOpen = false;
|
||||
|
||||
// windowViewModel.IsBusy = true;
|
||||
|
||||
Log.Write("Opening connection on " + serialManager.ComPortString + "." + System.Environment.NewLine);
|
||||
|
||||
try
|
||||
{
|
||||
serialManager.Open();
|
||||
|
||||
if (serialManager.FactoryUart.IsConnected)
|
||||
{
|
||||
serialManager.FactoryUart.MessageReceived += MessageReceived;
|
||||
|
||||
CommDeviceSessionOpen commDeviceSessionOpen = new CommDeviceSessionOpen();
|
||||
commDeviceSessionOpen.HostParsed = "GlobalIPerlUtility";
|
||||
NA2WSerialFrame response = SendNa2wSerial(commDeviceSessionOpen, true);
|
||||
|
||||
isOpen = (response != null);
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
serialManager.Close();
|
||||
serialManager = null;
|
||||
|
||||
Log.Write("CLII session open failed. Is device CLII?" + System.Environment.NewLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
String version = "Unknown version ";
|
||||
String frequencySupport = "unknown frequency (Update CommandLink II firmware)";
|
||||
|
||||
NetworkResponse networkResponse = (NetworkResponse)response.Payload;
|
||||
|
||||
if (networkResponse.Payload is Sensus.Protocols.FlexNet.FNv2.CommDeviceSessionBegin)
|
||||
{
|
||||
var sessionBegin = (Sensus.Protocols.FlexNet.FNv2.CommDeviceSessionBegin)networkResponse.Payload;
|
||||
|
||||
version = String.Format("{0}{1}.{2}.{3}", (sessionBegin.ProductVersionBeta ? "B" : "R"), sessionBegin.ProductVersionMajor, sessionBegin.ProductVersionMinor, sessionBegin.ProductVersionPatch);
|
||||
}
|
||||
else if (networkResponse.Payload is Sensus.Protocols.FlexNet.FNv2.CommDeviceSessionBeginV1)
|
||||
{
|
||||
var sessionBegin = (Sensus.Protocols.FlexNet.FNv2.CommDeviceSessionBeginV1)networkResponse.Payload;
|
||||
|
||||
version = String.Format("{0}{1}.{2}.{3}", (sessionBegin.ProductVersionBeta ? "B" : "R"), sessionBegin.ProductVersionMajor, sessionBegin.ProductVersionMinor, sessionBegin.ProductVersionPatch);
|
||||
|
||||
// Look at FW version number to determine if prototype hardware.
|
||||
if (sessionBegin.ProductVersionMajor >= 2)
|
||||
{
|
||||
// Read Radio variant tag (CLII tag 0x39).
|
||||
ParameterReadCommand parameterReadCommand = new ParameterReadCommand(0, 0x39);
|
||||
// Response code (0x10) is not same as read.
|
||||
response = SendNa2wSerial(parameterReadCommand, 0x10);
|
||||
|
||||
if (response != null) // NA2W Serial ParameterData message
|
||||
{
|
||||
networkResponse = (NetworkResponse)response.Payload;
|
||||
|
||||
byte[] payload = networkResponse.Payload.ToBytes();
|
||||
|
||||
// NA2WSerialParameterData parameterData = (NA2WSerialParameterData)e.Frame.Payload;
|
||||
// if (parameterData.TagMap == 0x00)
|
||||
if (payload[0] == 0x00)
|
||||
{
|
||||
// byte[] tlvArray = parameterData.TlvArray;
|
||||
// if (tlvArray[0] == 0x39)
|
||||
if (payload[1] == 0x39)
|
||||
{
|
||||
// byte variantValue = tlvArray[2];
|
||||
byte variantValue = payload[3];
|
||||
|
||||
if (variantValue == 2)
|
||||
{
|
||||
frequencySupport = "900 MHz";
|
||||
}
|
||||
else if (variantValue == 4)
|
||||
{
|
||||
frequencySupport = "400 MHz";
|
||||
}
|
||||
else if (variantValue == 6)
|
||||
{
|
||||
frequencySupport = "868 MHz";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log.Write("CLII session opened: " + version + " supporting " + frequencySupport + "." + System.Environment.NewLine);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Write("Serial port open failed. Check device." + System.Environment.NewLine);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
isOpen = false;
|
||||
serialManager = null;
|
||||
|
||||
Log.Write("Serial port open failed (" + ex.ToString() + ")." + System.Environment.NewLine);
|
||||
}
|
||||
|
||||
e.Result = isOpen;
|
||||
|
||||
if (isOpen)
|
||||
{
|
||||
serialManager.FactoryUart.MessageReceived += SerialMessageReceived;
|
||||
}
|
||||
|
||||
// windowViewModel.IsBusy = false;
|
||||
}
|
||||
|
||||
private void OpenRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
// windowViewModel.IsOpen = (bool)e.Result;
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
// openBackgroundWorker = new BackgroundWorker();
|
||||
// openBackgroundWorker.DoWork += new DoWorkEventHandler(OpenDoWork);
|
||||
// openBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OpenRunWorkerCompleted);
|
||||
|
||||
// openBackgroundWorker.RunWorkerAsync();
|
||||
OpenDoWork(this, new DoWorkEventArgs(this));
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
CommDeviceSessionClose commDeviceSessionClose = new CommDeviceSessionClose();
|
||||
commDeviceSessionClose.SessionID = sessionId;
|
||||
SendNa2wSerial(commDeviceSessionClose, false);
|
||||
|
||||
serialManager.Close();
|
||||
serialManager = null;
|
||||
|
||||
Log.Write("CLII session closed." + System.Environment.NewLine);
|
||||
}
|
||||
|
||||
public event EventHandler<ReceptionEventArgs<ISerialMessageFrame>> MessageReceived;
|
||||
|
||||
public event EventHandler<EventArgs> Disconnected;
|
||||
|
||||
public ClassicSerialMessageFrame SendFlexNetSerial(ISerialCommandFrame cmd, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private byte transactionId = 0;
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommand cmd, bool responseExpected)
|
||||
{
|
||||
NA2WSerialFrame cmdFrame = new NA2WSerialFrame(cmd);
|
||||
INetworkLayer networkLayer = cmdFrame.Unwrap<INetworkLayer>();
|
||||
networkLayer.PWNs.Set(new TransactionPWN() { TransactionID = transactionId++ });
|
||||
cmdFrame.Bake();
|
||||
|
||||
// LogOutgoing(cmdFrame);
|
||||
|
||||
return serialManager.SendNa2wSerial(cmdFrame, responseExpected);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
// Route command through Hat's NFC
|
||||
return SendNa2wSerial(cmdFrame, responseExpected);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected)
|
||||
{
|
||||
SerialTransmitCommandV1 serialTransmitCommandV1 = new SerialTransmitCommandV1();
|
||||
cmdFrame.Bake();
|
||||
serialTransmitCommandV1.Payload = new Frame(cmdFrame.ToBytes());
|
||||
serialTransmitCommandV1.PortId = 0x02;
|
||||
serialTransmitCommandV1.Bake();
|
||||
|
||||
return SendNa2wSerial(serialTransmitCommandV1, responseExpected);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommand cmd, byte responseCommandCode)
|
||||
{
|
||||
NA2WSerialFrame cmdFrame = new NA2WSerialFrame(cmd);
|
||||
INetworkLayer networkLayer = cmdFrame.Unwrap<INetworkLayer>();
|
||||
networkLayer.PWNs.Set(new TransactionPWN() { TransactionID = transactionId++ });
|
||||
cmdFrame.Bake();
|
||||
|
||||
// LogOutgoing(cmdFrame);
|
||||
|
||||
return serialManager.SendNa2wSerial(cmdFrame, responseCommandCode);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, byte responseCommandCode)
|
||||
{
|
||||
return serialManager.SendNa2wSerial(cmdFrame, responseCommandCode);
|
||||
}
|
||||
|
||||
void SerialMessageReceived(object sender, ReceptionEventArgs<ISerialMessageFrame> args)
|
||||
{
|
||||
ISerialMessageFrame message = args.Frame;
|
||||
bool pushMessageUp = false;
|
||||
|
||||
// LogIncoming(message);
|
||||
|
||||
if (message.Payload is UnknownResponse)
|
||||
{
|
||||
UnknownResponse unknownResponse = message.Unwrap<UnknownResponse>();
|
||||
|
||||
if (unknownResponse.CommandCode == 0x21)
|
||||
{
|
||||
// Serial Receive - extract and push up frame in payload
|
||||
byte[] newFrame = unknownResponse.ToBytes();
|
||||
try
|
||||
{
|
||||
NA2WSerialFrame na2wSerialFrame = NA2WSerialFrame.Parse(newFrame, 10, (uint)newFrame.Length - 10);
|
||||
args.Frame = na2wSerialFrame;
|
||||
message = na2wSerialFrame;
|
||||
pushMessageUp = true;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
if (message.Payload is UnknownMessage)
|
||||
{
|
||||
UnknownMessage unknownMessage = message.Unwrap<UnknownMessage>();
|
||||
|
||||
if (unknownMessage.CommandCode == 0x21)
|
||||
{
|
||||
// Serial Receive - extract and push up frame in payload
|
||||
byte[] newFrame = unknownMessage.ToBytes();
|
||||
try
|
||||
{
|
||||
NA2WSerialFrame na2wSerialFrame = NA2WSerialFrame.Parse(newFrame, 10, (uint)newFrame.Length - 10);
|
||||
args.Frame = na2wSerialFrame;
|
||||
message = na2wSerialFrame;
|
||||
pushMessageUp = true;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
else if (message.Payload is CommDeviceSessionBegin)
|
||||
{
|
||||
CommDeviceSessionBegin commDeviceSessionBegin = (CommDeviceSessionBegin)message.Payload;
|
||||
sessionId = commDeviceSessionBegin.SessionID;
|
||||
}
|
||||
else if (message.Payload is CommDeviceSessionBeginV1)
|
||||
{
|
||||
CommDeviceSessionBeginV1 commDeviceSessionBegin = (CommDeviceSessionBeginV1)message.Payload;
|
||||
sessionId = commDeviceSessionBegin.SessionID;
|
||||
}
|
||||
else if (message.Payload is SerialEventNotification)
|
||||
{
|
||||
SerialEventNotification serialEventNotification = (SerialEventNotification)message.Payload;
|
||||
if (serialEventNotification.EventMap == 0x00) // CmdLinkII
|
||||
{
|
||||
Frame notification = (Frame)(serialEventNotification.Payload);
|
||||
byte[] notificationBytes = notification.ToBytes();
|
||||
|
||||
SByte idNum = notificationBytes.Read<SByte>((0 * 8) + 0, 8);
|
||||
// UInt64 timeStamp = notificationBytes.Read<UInt64>((1 * 8) + 0, 64);
|
||||
// UInt16 numDataBytes = notificationBytes.Read<UInt16>((9 * 8) + 0, 16);
|
||||
// UInt16 eventDataLength = (UInt16)((numDataBytes <= notificationBytes.Length - 11) ? numDataBytes : (notificationBytes.Length - 11));
|
||||
// byte[] eventData = new byte[eventDataLength];
|
||||
// Array.Copy(notificationBytes, 11, eventData, 0, eventDataLength);
|
||||
|
||||
if (idNum == 5) // ButtonClick
|
||||
{
|
||||
NfcCommand_InventoryRead nfcCommand = new NfcCommand_InventoryRead();
|
||||
SendNa2wSerial(nfcCommand, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (message.Payload is NfcCommandResponse)
|
||||
{
|
||||
NfcCommandResponse commandResponse = (NfcCommandResponse)message.Payload;
|
||||
|
||||
String dataString = "";
|
||||
bool readNDef = false;
|
||||
|
||||
if (0x00 == commandResponse.SubCommand)
|
||||
{
|
||||
dataString = "Inventory -> Status = " + String.Format("{0:X2}", commandResponse.Status) + System.Environment.NewLine;
|
||||
readNDef = (0x00 == commandResponse.SubCommand);
|
||||
}
|
||||
else if (0x01 == commandResponse.SubCommand)
|
||||
{
|
||||
dataString = "NDEF Read -> Status = " + String.Format("{0:X2}", commandResponse.Status) + System.Environment.NewLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataString = "Unknown -> Status = " + String.Format("{0:X2}", commandResponse.Status) + System.Environment.NewLine;
|
||||
}
|
||||
|
||||
byte[] data = commandResponse.AdditionalData;
|
||||
if ((data != null) && (data.Length > 0))
|
||||
{
|
||||
int numberOfBytes = data.Length;
|
||||
uint index = 0;
|
||||
|
||||
while (numberOfBytes > 16)
|
||||
{
|
||||
byte[] lineData = data.Read<byte[]>(index * 8, 16 * 8);
|
||||
|
||||
dataString += lineData.ToHexString() + System.Environment.NewLine;
|
||||
|
||||
index += 16;
|
||||
numberOfBytes -= 16;
|
||||
}
|
||||
|
||||
if (numberOfBytes > 0)
|
||||
{
|
||||
byte[] lineData = data.Read<byte[]>(index * 8, (uint)(8 * numberOfBytes));
|
||||
|
||||
dataString += lineData.ToHexString();
|
||||
}
|
||||
|
||||
if (0x00 == commandResponse.SubCommand)
|
||||
{
|
||||
dataString += System.Environment.NewLine + System.Environment.NewLine + "----" + System.Environment.NewLine;
|
||||
// AdditionData[0] is tag ID
|
||||
// AdditionData[1 - 8] is UUID
|
||||
// AdditionalData[9 - 28] is UUID String
|
||||
dataString += System.Text.Encoding.ASCII.GetString(commandResponse.AdditionalData, 9, 20);
|
||||
}
|
||||
else if (0x01 == commandResponse.SubCommand)
|
||||
{
|
||||
dataString += System.Environment.NewLine + System.Environment.NewLine + "----" + System.Environment.NewLine;
|
||||
dataString += System.Text.Encoding.ASCII.GetString(commandResponse.AdditionalData, 0, commandResponse.AdditionalData.Length);
|
||||
|
||||
ndefData = commandResponse.AdditionalData;
|
||||
NdefMessage ndefMessage = new NdefMessage(ndefData);
|
||||
foreach(NdefRecord record in ndefMessage.recordList)
|
||||
{
|
||||
if (record.RecordType == NdefRecord.SensusNdefRecordType.ProductDetailsRecord)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProductDetailsRecord pdRecord = new ProductDetailsRecord(record.Payload.GetRawData());
|
||||
nfcTargetDetails = new NfcTargetDetails()
|
||||
{
|
||||
DeviceId = System.Text.Encoding.ASCII.GetString(pdRecord.ID1.ToArray()).Split(':')[1].Trim(),
|
||||
ProductType = System.Text.Encoding.ASCII.GetString(pdRecord.ProductType.ToArray()).Split(':')[1].Trim(),
|
||||
ProductVersion = System.Text.Encoding.ASCII.GetString(pdRecord.ProductTypeVersion.ToArray()).Split(':')[1].Trim(),
|
||||
};
|
||||
NfcTagDetected = true; // This uses nfcTargetDetails.
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log.Write(dataString);
|
||||
|
||||
if (readNDef)
|
||||
{
|
||||
NfcCommand_NdefRead nfcCommand = new NfcCommand_NdefRead();
|
||||
SendNa2wSerial(nfcCommand, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pushMessageUp = true;
|
||||
}
|
||||
|
||||
if (pushMessageUp)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.MessageReceived.Raise(this, args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Write(String.Format("MessageReceived event handler threw: {0}", ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool nfcTagDetected;
|
||||
private byte[] rmaData;
|
||||
private byte[] ndefData;
|
||||
private NfcTargetDetails nfcTargetDetails;
|
||||
|
||||
public bool NfcTagDetected
|
||||
{
|
||||
get
|
||||
{
|
||||
return nfcTagDetected;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != nfcTagDetected)
|
||||
{
|
||||
nfcTagDetected = value;
|
||||
OnTagEvent(new TagEventArgs() { Present = value });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<TagEventArgs> TagEvent;
|
||||
|
||||
public byte[] NDEF { get { return ndefData; } }
|
||||
|
||||
public byte[] RMA { get { return rmaData; } }
|
||||
|
||||
public NfcTargetDetails NfcTargetDetails { get { return nfcTargetDetails; } }
|
||||
|
||||
protected virtual void OnTagEvent(TagEventArgs e)
|
||||
{
|
||||
EventHandler<TagEventArgs> handler = TagEvent;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
sensus.dll originates from Release build of Sensus.Windows in CommandLinkII branch of git@bitbucket.org:xyleminc/utils.git.
|
||||
|
||||
Version of assembly adds 100 to major to indicate FW team special build.
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,64 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(DataReportRequest_ModuleStatistics._Code, DataReportRequest_ModuleStatistics._Version)]
|
||||
public class DataReportRequest_ModuleStatistics : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 7;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x14;
|
||||
public const byte _Version = 1; // Version is overlays ReportId. ReportId = 1 is ModuleStatistics.
|
||||
|
||||
public DataReportRequest_ModuleStatistics() : base(_Size) { Version = _Version; }
|
||||
|
||||
public DataReportRequest_ModuleStatistics(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { Version = _Version; }
|
||||
|
||||
public static EventReadV0 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<EventReadV0>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
public byte ReportId { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
public UInt16 ModuleId { get { return Buffer.Read<UInt16>((Offset + 1) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 16); } }
|
||||
public UInt16 ByteOffset { get { return Buffer.Read<UInt16>((Offset + 3) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 16); } }
|
||||
public UInt16 ByteCount { get { return Buffer.Read<UInt16>((Offset + 5) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 5) * 8 + 0, 16); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(DataReportRequest_StatisticsOverview._Code, DataReportRequest_StatisticsOverview._Version)]
|
||||
public class DataReportRequest_StatisticsOverview : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 1;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x14;
|
||||
public const byte _Version = 0; // Version is overlays ReportId. ReportId = 0 is StatisticsOverview.
|
||||
|
||||
public DataReportRequest_StatisticsOverview() : base(_Size) { Version = _Version; }
|
||||
|
||||
public DataReportRequest_StatisticsOverview(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { Version = _Version; }
|
||||
|
||||
public static EventReadV0 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<EventReadV0>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
public byte ReportId { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(EngineeringTestCommand._Code, EngineeringTestCommand._Version)]
|
||||
public class EngineeringTestCommand : Envelope<IFrame>, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 2;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xFA;
|
||||
public const byte _Version = 0x00;
|
||||
|
||||
public EngineeringTestCommand() : base(_Size, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public static EngineeringTestCommand Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Envelope<IFrame>.Parse<EngineeringTestCommand>(buffer, offset, 0, 0, length);
|
||||
}
|
||||
|
||||
protected override UInt32 Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
UInt32 headerSize = PayloadOffset;
|
||||
PayloadLength = wholeMessageLength - headerSize;
|
||||
return headerSize;
|
||||
}
|
||||
|
||||
protected override IFrame ParsePayload(byte[] buffer, UInt32 offset)
|
||||
{
|
||||
return FlexNetFrame.Parse(buffer, offset);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
if ((Payload != null) && (typeof(T).IsAssignableFrom(Payload.GetType())))
|
||||
return (T)Payload;
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public EngineeringTestCommand(IFrame frame) : base(_Size, 0)
|
||||
{
|
||||
Payload = frame;
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
PayloadLength = (null != Payload) ? Payload.Length : 0;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return _Version; } }
|
||||
|
||||
public byte ProductType { get { return header.Read<byte>(0 * 8 + 0, 8); } set { header.Write(value, 0 * 8 + 0, 8); } }
|
||||
|
||||
public byte TestCommand { get { return header.Read<byte>(1 * 8 + 0, 8); } set { header.Write(value, 1 * 8 + 0, 8); } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadOffset { get { return _Size; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(EventReadV0._Code, EventReadV0._Version)]
|
||||
public class EventReadV0 : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 10;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x12;
|
||||
public const byte _Version = 0;
|
||||
|
||||
public EventReadV0() : base(_Size) { Version = _Version; }
|
||||
|
||||
public EventReadV0(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { }
|
||||
|
||||
public static EventReadV0 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<EventReadV0>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
public UInt64 Time { get { return Buffer.Read<UInt64>((Offset + 1) * 8 + 0, 64); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 64); } }
|
||||
public byte NumberOfEvents { get { return Buffer.Read<byte>((Offset + 9) * 8 + 0, 7); } set { Buffer.Write(value, (Offset + 9) * 8 + 0, 7); } }
|
||||
public bool ReadAfterTime { get { return Buffer.Read<bool>((Offset + 9) * 8 + 7, 1); } set { Buffer.Write(value, (Offset + 9) * 8 + 7, 1); } }
|
||||
}
|
||||
|
||||
public class EventReadV1 : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 6;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x12;
|
||||
public const byte _Version = 1;
|
||||
|
||||
public EventReadV1() : base(_Size) { Version = _Version; }
|
||||
|
||||
public EventReadV1(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { }
|
||||
|
||||
public static EventReadV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<EventReadV1>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
public UInt32 Time { get { return Buffer.Read<UInt32>((Offset + 1) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 32); } }
|
||||
public byte NumberOfEvents { get { return Buffer.Read<byte>((Offset + 5) * 8 + 0, 7); } set { Buffer.Write(value, (Offset + 5) * 8 + 0, 7); } }
|
||||
public bool ReadAfterTime { get { return Buffer.Read<bool>((Offset + 5) * 8 + 7, 1); } set { Buffer.Write(value, (Offset + 5) * 8 + 7, 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_EngineeringAsk._Code, FactoryTestCommand_EngineeringAsk._Version)]
|
||||
public class FactoryTestCommand_EngineeringAsk : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 14;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x04; // Use Test Command field value
|
||||
|
||||
public FactoryTestCommand_EngineeringAsk() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_EngineeringAsk(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public static FactoryTestCommand_EngineeringAsk Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_EngineeringAsk>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 1) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 32); } }
|
||||
|
||||
public byte Duration { get { return Buffer.Read<byte>((Offset + 5) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 5) * 8 + 0, 8); } }
|
||||
|
||||
public UInt16 TransceiverPower { get { return Buffer.Read<UInt16>((Offset + 6) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 6) * 8 + 0, 16); } }
|
||||
|
||||
public UInt16 HighBitFemPower { get { return Buffer.Read<UInt16>((Offset + 8) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 8) * 8 + 0, 16); } }
|
||||
|
||||
public UInt16 LowBitFemPower { get { return Buffer.Read<UInt16>((Offset + 10) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 10) * 8 + 0, 16); } }
|
||||
|
||||
public UInt16 AttenuatorPower { get { return Buffer.Read<UInt16>((Offset + 12) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 12) * 8 + 0, 16); } }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_EngineeringCw._Code, FactoryTestCommand_EngineeringCw._Version)]
|
||||
public class FactoryTestCommand_EngineeringCw : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 12;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x00; // Use Test Command field value
|
||||
|
||||
public FactoryTestCommand_EngineeringCw() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_EngineeringCw(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public static FactoryTestCommand_EngineeringCw Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_EngineeringCw>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 1) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 32); } }
|
||||
|
||||
public byte Duration { get { return Buffer.Read<byte>((Offset + 5) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 5) * 8 + 0, 8); } }
|
||||
|
||||
public UInt16 TransceiverPower { get { return Buffer.Read<UInt16>((Offset + 6) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 6) * 8 + 0, 16); } }
|
||||
|
||||
public UInt16 FemPower { get { return Buffer.Read<UInt16>((Offset + 8) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 8) * 8 + 0, 16); } }
|
||||
|
||||
public UInt16 AttenuatorPower { get { return Buffer.Read<UInt16>((Offset + 10) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 10) * 8 + 0, 16); } }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_EngineeringFcc._Code, FactoryTestCommand_EngineeringFcc._Version)]
|
||||
public class FactoryTestCommand_EngineeringFcc : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 13;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x01; // Use Test Command field value
|
||||
|
||||
public FactoryTestCommand_EngineeringFcc() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_EngineeringFcc(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public static FactoryTestCommand_EngineeringFcc Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_EngineeringFcc>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public byte Modulation { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 6); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 6); } }
|
||||
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 32); } }
|
||||
|
||||
public byte Duration { get { return Buffer.Read<byte>((Offset + 6) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 6) * 8 + 0, 8); } }
|
||||
|
||||
public UInt16 TransceiverPower { get { return Buffer.Read<UInt16>((Offset + 7) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 7) * 8 + 0, 16); } }
|
||||
|
||||
public UInt16 FemPower { get { return Buffer.Read<UInt16>((Offset + 9) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 9) * 8 + 0, 16); } }
|
||||
|
||||
public UInt16 AttenuatorPower { get { return Buffer.Read<UInt16>((Offset + 11) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 11) * 8 + 0, 16); } }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_FactoryReset._Code, FactoryTestCommand_FactoryReset._Version)]
|
||||
public class FactoryTestCommand_FactoryReset : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 8;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x05;
|
||||
|
||||
public FactoryTestCommand_FactoryReset() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_FactoryReset(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public static FactoryTestCommand_FactoryReset Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_FactoryReset>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
public byte ProductType { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
public UInt32 ResetFlags { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 32); } }
|
||||
public UInt16 ResetDelay { get { return Buffer.Read<UInt16>((Offset + 6) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 6) * 8 + 0, 16, null, true); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_FrequencyCount._Code, FactoryTestCommand_FrequencyCount._Version)]
|
||||
public class FactoryTestCommand_FrequencyCount : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 5;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x07;
|
||||
|
||||
public FactoryTestCommand_FrequencyCount() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_FrequencyCount(Func<byte[]> buffer, Func<uint> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
|
||||
public static FactoryTestCommand_FrequencyCount Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_FrequencyCount>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public UInt32 Reserved { get { return Buffer.Read<UInt32>((Offset + 1) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 32); } }
|
||||
} // end class
|
||||
} // end namespace
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_LockDebugInterface._Code, FactoryTestCommand_LockDebugInterface._Version)]
|
||||
public class FactoryTestCommand_LockDebugInterface : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 1;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x08;
|
||||
|
||||
public FactoryTestCommand_LockDebugInterface() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_LockDebugInterface(Func<byte[]> buffer, Func<uint> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
|
||||
public static FactoryTestCommand_LockDebugInterface Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_LockDebugInterface>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
} // end class
|
||||
} // end namespace
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_NfcControl._Code, FactoryTestCommand_NfcControl._Version)]
|
||||
public class FactoryTestCommand_NfcControl : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 2;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x09;
|
||||
|
||||
public enum _NfcCommand
|
||||
{
|
||||
NormalOperation = 0x00,
|
||||
SegmentsOff = 0x01,
|
||||
SegmentsOn = 0x02,
|
||||
EvenSegmentsOn = 0x03,
|
||||
OddSegmentsOn = 0x04,
|
||||
ArbitrarySegments = 0x05,
|
||||
DisplayPowerOff = 0x06,
|
||||
TestSequence = 0x07,
|
||||
}
|
||||
|
||||
public FactoryTestCommand_NfcControl() : base(_Size)
|
||||
{
|
||||
Version = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_NfcControl(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
Version = _Version;
|
||||
}
|
||||
|
||||
public static FactoryTestCommand_NfcControl Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_NfcControl>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte NfcCommand { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_RegulatoryCw._Code, FactoryTestCommand_RegulatoryCw._Version)]
|
||||
public class FactoryTestCommand_RegulatoryCw : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 8;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x02; // Use Test Command field value
|
||||
|
||||
public FactoryTestCommand_RegulatoryCw() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_RegulatoryCw(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public static FactoryTestCommand_RegulatoryCw Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_RegulatoryCw>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 1) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 32); } }
|
||||
|
||||
public byte Duration { get { return Buffer.Read<byte>((Offset + 5) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 5) * 8 + 0, 8); } }
|
||||
|
||||
public Int16 PowerLevel { get { return Buffer.Read<Int16>((Offset + 6) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 6) * 8 + 0, 16); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_RegulatoryFcc._Code, FactoryTestCommand_RegulatoryFcc._Version)]
|
||||
public class FactoryTestCommand_RegulatoryFcc : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 9;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x03; // Use Test Command field value
|
||||
|
||||
public FactoryTestCommand_RegulatoryFcc() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_RegulatoryFcc(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public static FactoryTestCommand_RegulatoryFcc Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_RegulatoryFcc>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public byte Modulation { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 6); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 6); } }
|
||||
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 32); } }
|
||||
|
||||
public byte Duration { get { return Buffer.Read<byte>((Offset + 6) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 6) * 8 + 0, 8); } }
|
||||
|
||||
public Int16 PowerLevel { get { return Buffer.Read<Int16>((Offset + 7) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 7) * 8 + 0, 16); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestCommand_SampleRfSignal._Code, FactoryTestCommand_SampleRfSignal._Version)]
|
||||
public class FactoryTestCommand_SampleRfSignal : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 8;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF9;
|
||||
public const byte _Version = 0x06;
|
||||
|
||||
public FactoryTestCommand_SampleRfSignal() : base(_Size)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public FactoryTestCommand_SampleRfSignal(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
TestCommand = _Version;
|
||||
}
|
||||
|
||||
public static FactoryTestCommand_SampleRfSignal Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestCommand_SampleRfSignal>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte TestCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
public RadioReceiveDataRate DataRate { get { return Buffer.Read<RadioReceiveDataRate>((Offset + 1) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 4); } }
|
||||
public byte Reserved1 { get { return Buffer.Read<byte>((Offset + 1) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 1) * 8 + 4, 4); } }
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 32); } }
|
||||
public byte Sensitivity { get { return Buffer.Read<byte>((Offset + 6) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 6) * 8 + 0, 8); } }
|
||||
public byte Samples { get { return Buffer.Read<byte>((Offset + 7) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 7) * 8 + 0, 8); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FactoryTestOpen._Code, FactoryTestOpen._Version)]
|
||||
public class FactoryTestOpen : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 2;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF8;
|
||||
public const byte _Version = 0;
|
||||
|
||||
public FactoryTestOpen() : base(_Size) { }
|
||||
|
||||
public FactoryTestOpen(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { }
|
||||
|
||||
public static FactoryTestOpen Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FactoryTestOpen>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
public byte SleepTime { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8, null, true); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
using Sensus.Protocols.FlexNet.Serial.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(FwMaintenance_LoadStartV1._Code, FwMaintenance_LoadStartV1._Version)]
|
||||
public class FwMaintenance_LoadStartV1 : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 18;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x15;
|
||||
public const byte _Version = 0x00; // Use Subcommand field value
|
||||
|
||||
public FwMaintenance_LoadStartV1() : base(_Size)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public FwMaintenance_LoadStartV1(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public static FwMaintenance_LoadStartV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FwMaintenance_LoadStartV1>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte Subcommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public byte DeviceType { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
|
||||
public byte ProductType { get { return Buffer.Read<byte>((Offset + 2) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8); } }
|
||||
|
||||
public UInt16 ProductTypeVersion { get { return Buffer.Read<UInt16>((Offset + 3) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 16); } }
|
||||
|
||||
public UInt16 Flags { get { return Buffer.Read<UInt16>((Offset + 5) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 5) * 8 + 0, 16); } }
|
||||
|
||||
public byte BlockSize { get { return Buffer.Read<byte>((Offset + 7) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 7) * 8 + 0, 8); } }
|
||||
|
||||
public UInt16 ImageBlocks { get { return Buffer.Read<UInt16>((Offset + 8) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 8) * 8 + 0, 16); } }
|
||||
|
||||
public UInt32 ImageSize { get { return Buffer.Read<UInt32>((Offset + 10) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 10) * 8 + 0, 32); } }
|
||||
|
||||
public UInt32 ImageCrc { get { return Buffer.Read<UInt32>((Offset + 14) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 14) * 8 + 0, 32); } }
|
||||
}
|
||||
|
||||
[NA2WSerialProtocolCommand(FwMaintenance_LoadBlockV1._Code, FwMaintenance_LoadBlockV1._Version)]
|
||||
public class FwMaintenance_LoadBlockV1 : Envelope<IFrame>, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 5;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x15;
|
||||
public const byte _Version = 0x01; // Use Subcommand field value
|
||||
|
||||
public FwMaintenance_LoadBlockV1() : base(_Size, 0)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public static FwMaintenance_LoadBlockV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Envelope<IFrame>.Parse<FwMaintenance_LoadBlockV1>(buffer, offset, 0, 0, length);
|
||||
}
|
||||
|
||||
protected override UInt32 Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
UInt32 headerSize = PayloadOffset;
|
||||
PayloadLength = wholeMessageLength - headerSize;
|
||||
return headerSize;
|
||||
}
|
||||
protected override IFrame ParsePayload(byte[] buffer, UInt32 offset)
|
||||
{
|
||||
return Frame.Parse<Frame>(buffer, offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
if (typeof(T).IsAssignableFrom(Payload.GetType()))
|
||||
return (T)Payload;
|
||||
if (Payload is NA2WSerialFrame)
|
||||
return ((NA2WSerialFrame)Payload).Unwrap<T>();
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
PayloadLength = Payload.Length;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return header.Read<byte>(0 * 8 + 0, 4); } set { header.Write(value, 0 * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return header.Read<byte>(0 * 8 + 4, 4); } set { header.Write(value, 0 * 8 + 4, 4); } }
|
||||
|
||||
public byte Subcommand { get { return header.Read<byte>(0 * 8 + 0, 8); } set { header.Write(value, 0 * 8 + 0, 8); } }
|
||||
|
||||
public byte DeviceType { get { return header.Read<byte>(1 * 8 + 0, 8); } set { header.Write(value, 1 * 8 + 0, 8); } }
|
||||
|
||||
public byte ProductType { get { return header.Read<byte>(2 * 8 + 0, 8); } set { header.Write(value, 2 * 8 + 0, 8); } }
|
||||
|
||||
public byte BlockSize { get { return header.Read<byte>(3 * 8 + 0, 8); } set { header.Write(value, 3 * 8 + 0, 8); } }
|
||||
|
||||
public byte BlockCount { get { return header.Read<byte>(4 * 8 + 0, 8); } set { header.Write(value, 4 * 8 + 0, 8); } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadOffset { get { return _Size; } }
|
||||
}
|
||||
|
||||
[NA2WSerialProtocolCommand(FwMaintenance_CheckImageV1._Code, FwMaintenance_CheckImageV1._Version)]
|
||||
public class FwMaintenance_CheckImageV1 : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 9;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x15;
|
||||
public const byte _Version = 0x02; // Use Subcommand field value
|
||||
|
||||
public FwMaintenance_CheckImageV1() : base(_Size)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public FwMaintenance_CheckImageV1(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public static FwMaintenance_CheckImageV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FwMaintenance_CheckImageV1>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte Subcommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public byte DeviceType { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
|
||||
public byte ProductType { get { return Buffer.Read<byte>((Offset + 2) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8); } }
|
||||
|
||||
public UInt16 ImageBlocks { get { return Buffer.Read<UInt16>((Offset + 3) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 32); } }
|
||||
|
||||
public UInt32 ImageCrc { get { return Buffer.Read<UInt32>((Offset + 5) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 5) * 8 + 0, 32); } }
|
||||
}
|
||||
|
||||
public class FwMaintenance_SegmentDescriptor : Frame
|
||||
{
|
||||
public const byte _Size = 9;
|
||||
|
||||
public FwMaintenance_SegmentDescriptor(UInt32 startAddress, UInt16 blocks) : base(_Size)
|
||||
{
|
||||
StartAddress = startAddress;
|
||||
Blocks = blocks;
|
||||
}
|
||||
|
||||
public UInt32 StartAddress { get { return buffer.Read<UInt32>(0 * 8 + 0, 32); } set { buffer.Write(value, 0 * 8 + 0, 32); } }
|
||||
|
||||
public UInt16 Blocks { get { return buffer.Read<UInt16>(4 * 8 + 0, 32); } set { buffer.Write(value, 4 * 8 + 0, 32); } }
|
||||
}
|
||||
|
||||
[NA2WSerialProtocolCommand(FwMaintenance_LoadFlashV1._Code, FwMaintenance_LoadFlashV1._Version)]
|
||||
public class FwMaintenance_LoadFlashV1 : Envelope<IFrame>, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 10;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x15;
|
||||
public const byte _Version = 0x03; // Use Subcommand field value
|
||||
|
||||
public FwMaintenance_LoadFlashV1() : base(_Size, 0)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public static FwMaintenance_LoadFlashV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Envelope<IFrame>.Parse<FwMaintenance_LoadFlashV1>(buffer, offset, 0, 0, length);
|
||||
}
|
||||
|
||||
protected override UInt32 Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
UInt32 headerSize = PayloadOffset;
|
||||
PayloadLength = wholeMessageLength - headerSize;
|
||||
return headerSize;
|
||||
}
|
||||
protected override IFrame ParsePayload(byte[] buffer, UInt32 offset)
|
||||
{
|
||||
return FlexNetFrame.Parse(buffer, offset);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
if (typeof(T).IsAssignableFrom(Payload.GetType()))
|
||||
return (T)Payload;
|
||||
if (Payload is NA2WSerialFrame)
|
||||
return ((NA2WSerialFrame)Payload).Unwrap<T>();
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
PayloadLength = Payload.Length;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return header.Read<byte>(0 * 8 + 0, 4); } set { header.Write(value, 0 * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return header.Read<byte>(0 * 8 + 4, 4); } set { header.Write(value, 0 * 8 + 4, 4); } }
|
||||
|
||||
public byte Subcommand { get { return header.Read<byte>(0 * 8 + 0, 8); } set { header.Write(value, 0 * 8 + 0, 8); } }
|
||||
|
||||
public byte DeviceType { get { return header.Read<byte>(1 * 8 + 0, 8); } set { header.Write(value, 1 * 8 + 0, 8); } }
|
||||
|
||||
public byte ProductType { get { return header.Read<byte>(2 * 8 + 0, 8); } set { header.Write(value, 2 * 8 + 0, 8); } }
|
||||
|
||||
public UInt16 ImageBlocks { get { return header.Read<UInt16>(3 * 8 + 0, 32); } set { header.Write(value, 3 * 8 + 0, 32); } }
|
||||
|
||||
public UInt32 ImageCrc { get { return header.Read<UInt32>(5 * 8 + 0, 32); } set { header.Write(value, 5 * 8 + 0, 32); } }
|
||||
|
||||
public byte SegmentCount { get { return header.Read<byte>(9 * 8 + 0, 8); } set { header.Write(value, 9 * 8 + 0, 8); } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadOffset { get { return _Size; } }
|
||||
}
|
||||
|
||||
public class FwMaintenance_CancelV1 : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 3;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x15;
|
||||
public const byte _Version = 0x04; // Use Subcommand field value
|
||||
|
||||
public FwMaintenance_CancelV1() : base(_Size)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public FwMaintenance_CancelV1(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public static FwMaintenance_CancelV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FwMaintenance_CancelV1>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte Subcommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public byte DeviceType { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
|
||||
public byte ProductType { get { return Buffer.Read<byte>((Offset + 2) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8); } }
|
||||
}
|
||||
|
||||
public class FwMaintenance_ResetV1 : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 3;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x15;
|
||||
public const byte _Version = 0x05; // Use Subcommand field value
|
||||
|
||||
public FwMaintenance_ResetV1() : base(_Size)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public FwMaintenance_ResetV1(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
Subcommand = _Version;
|
||||
}
|
||||
|
||||
public static FwMaintenance_CancelV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<FwMaintenance_CancelV1>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte Subcommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
|
||||
public byte DeviceType { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
|
||||
public byte ProductType { get { return Buffer.Read<byte>((Offset + 2) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8); } }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// GlobalIPerlTags
|
||||
public enum GlobalIPerlTag : uint
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// Product Type.
|
||||
ProductType = 0x00,
|
||||
//
|
||||
// Summary:
|
||||
// Meter Type.
|
||||
MeterType = 0x01,
|
||||
//
|
||||
// Summary:
|
||||
// Product Type Version.
|
||||
ProductTypeVersion = 0x02,
|
||||
//
|
||||
// Summary:
|
||||
// Serial Number.
|
||||
SerialNumber = 0x03,
|
||||
//
|
||||
// Summary:
|
||||
// Device Id (TFXv2 Address).
|
||||
DeviceId = 0x04,
|
||||
//
|
||||
// Summary:
|
||||
// PCB/Variant ID.
|
||||
PcbVariantId = 0x06,
|
||||
//
|
||||
// Summary:
|
||||
// Manufacturing Note.
|
||||
ManufacturingNote = 0x08,
|
||||
//
|
||||
// Summary:
|
||||
// Processor ID.
|
||||
ProcessorId = 0x09,
|
||||
//
|
||||
// Summary:
|
||||
// Flash CRC.
|
||||
FlashCrc = 0x0a,
|
||||
//
|
||||
// Summary:
|
||||
// Capabilities.
|
||||
Capabilities = 0x0b,
|
||||
//
|
||||
// Summary:
|
||||
// NFC Tag ID.
|
||||
NfcTagId = 0x0c, //
|
||||
// Summary:
|
||||
// Serial Flash ID.
|
||||
SerialFlashId = 0x0d, //
|
||||
// Summary:
|
||||
// Transceiver ID.
|
||||
TransceiverId = 0x0e,
|
||||
// Summary:
|
||||
// Transceiver ID.
|
||||
MetrologyId = 0x0f,
|
||||
// Summary:
|
||||
// Transceiver ID.
|
||||
SecurityCoprocessorId = 0x10,
|
||||
//
|
||||
// Summary:
|
||||
// Relative Humidity Sensor ID
|
||||
RHumidId = 0x11,
|
||||
//
|
||||
// Summary:
|
||||
// System Time.
|
||||
SystemTime = 0x20,
|
||||
//
|
||||
// Summary:
|
||||
// Product Time.
|
||||
ProductTime = 0x21,
|
||||
//
|
||||
// Summary:
|
||||
// Temperature.
|
||||
Temperature = 0x22,
|
||||
//
|
||||
// Summary:
|
||||
// Temperature ADC.
|
||||
TemperatureAdc = 0x23,
|
||||
//
|
||||
// Summary:
|
||||
// Vbat.
|
||||
Vbat = 0x24,
|
||||
//
|
||||
// Summary:
|
||||
// Vbat ADC.
|
||||
VbatAdc = 0x25,
|
||||
//
|
||||
// Summary:
|
||||
// PCB/Variant ID ADC.
|
||||
PcbVariantIdAdc = 0x26,
|
||||
//
|
||||
// Summary:
|
||||
// Reset Information.
|
||||
ResetInfo = 0x28,
|
||||
//
|
||||
// Summary:
|
||||
// Vsys.
|
||||
Vsys = 0x29,
|
||||
//
|
||||
// Summary:
|
||||
// Vsys ADC.
|
||||
VsysAdc = 0x2A,
|
||||
// Summary:
|
||||
// PCB/Variant ID ADC.
|
||||
InitialPcbVariantIdAdc = 0x2B,
|
||||
//
|
||||
// Summary
|
||||
// Relative Humidity Reading
|
||||
RHumid = 0x2C,
|
||||
// Summary:
|
||||
// TCXO Correction.
|
||||
TcxoCorrection = 0x40,
|
||||
//
|
||||
// Summary:
|
||||
// RF Power Level.
|
||||
RfPowerLevel = 0x41,
|
||||
//
|
||||
// Summary:
|
||||
// Temperature Calibration.
|
||||
TemperatureCalibration = 0x42,
|
||||
//
|
||||
// Summary:
|
||||
// Vbat Calibration.
|
||||
VbatCalibration = 0x43,
|
||||
//
|
||||
// Summary:
|
||||
// Vsys Calibration.
|
||||
VsysCalibration = 0x44,
|
||||
//
|
||||
// Summary
|
||||
// Relative Humidity Offset Calibration
|
||||
RHumidCalOffset = 0x45,
|
||||
//
|
||||
// Summary:
|
||||
// Mode.
|
||||
Mode = 0x60,
|
||||
//
|
||||
// Summary:
|
||||
// Reading.
|
||||
Reading = 0x61,
|
||||
//
|
||||
// Summary:
|
||||
// Alarms.
|
||||
Alarms = 0x62,
|
||||
//
|
||||
// Summary:
|
||||
// Activity Credits
|
||||
ActivityCredits = 0x70,
|
||||
//
|
||||
// Summary:
|
||||
// Network Status
|
||||
NetworkStatus = 0x80,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(DeviceId._TagMap, (byte)DeviceId._Tag)]
|
||||
public class DeviceId : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.DeviceId;
|
||||
public const byte _ParameterLength = 4;
|
||||
|
||||
public DeviceId() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public DeviceId(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public DeviceId(UInt16 value) : this()
|
||||
{
|
||||
Id = value;
|
||||
}
|
||||
|
||||
public UInt32 Id { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 8 * 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8 * 4); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(HumidityCalibration._TagMap, (byte)HumidityCalibration._Tag)]
|
||||
public class HumidityCalibration : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.RHumidCalOffset;
|
||||
public const byte _ParameterLength = 1;
|
||||
|
||||
public HumidityCalibration() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public HumidityCalibration(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public HumidityCalibration(sbyte offset) : this()
|
||||
{
|
||||
CalOffset = offset;
|
||||
}
|
||||
|
||||
public sbyte CalOffset { get { return Buffer.Read<sbyte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(ManufacturingNote._TagMap, (byte)ManufacturingNote._Tag)]
|
||||
public class ManufacturingNote : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.ManufacturingNote;
|
||||
public const byte _ParameterLength = 64;
|
||||
|
||||
public ManufacturingNote() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public ManufacturingNote(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public ManufacturingNote(String note) : this()
|
||||
{
|
||||
NoteParsed = note;
|
||||
}
|
||||
public byte[] Note { get { return Buffer.Read<byte[]>((Offset + 2) * 8 + 0, 64 * 8); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 64 * 8); } }
|
||||
public string NoteParsed
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.Text.Encoding.ASCII.GetString(Note, 0, Array.IndexOf(Note, (byte)0x00));
|
||||
}
|
||||
set
|
||||
{
|
||||
var nv = new byte[Note.Length];
|
||||
var b = value.ToASCIIBytes();
|
||||
Array.Copy(b, nv, b.Length);
|
||||
Note = nv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(RfPowerLevel._TagMap, (byte)RfPowerLevel._Tag)]
|
||||
public class RfPowerLevel : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.RfPowerLevel;
|
||||
public const byte _ParameterLength = 1;
|
||||
|
||||
public RfPowerLevel() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public RfPowerLevel(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public RfPowerLevel(byte powerLevel) : this()
|
||||
{
|
||||
PowerLevel = powerLevel;
|
||||
}
|
||||
|
||||
public byte PowerLevel { get { return Buffer.Read<byte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(SerialNumber._TagMap, (byte)SerialNumber._Tag)]
|
||||
public class SerialNumber : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.SerialNumber;
|
||||
public const byte _ParameterLength = 8;
|
||||
|
||||
public SerialNumber() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public SerialNumber(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public SerialNumber(UInt64 value) : this()
|
||||
{
|
||||
SN = value;
|
||||
}
|
||||
|
||||
public UInt64 SN { get { return Buffer.Read<UInt64>((Offset + 2) * 8 + 0, 8*8); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8*8); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(TcxoCorrection._TagMap, (byte)TcxoCorrection._Tag)]
|
||||
public class TcxoCorrection : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.TcxoCorrection;
|
||||
public const byte _ParameterLength = 2;
|
||||
|
||||
public TcxoCorrection() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public TcxoCorrection(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public TcxoCorrection(Int16 value) : this()
|
||||
{
|
||||
Correction = value;
|
||||
}
|
||||
|
||||
public Int16 Correction { get { return Buffer.Read<Int16>((Offset + 2) * 8 + 0, 8 * 2); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(TemperatureCalibration._TagMap, (byte)TemperatureCalibration._Tag)]
|
||||
public class TemperatureCalibration : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.TemperatureCalibration;
|
||||
public const byte _ParameterLength = 1;
|
||||
|
||||
public TemperatureCalibration() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public TemperatureCalibration(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public TemperatureCalibration(sbyte offset) : this()
|
||||
{
|
||||
CalOffset = offset;
|
||||
}
|
||||
|
||||
public sbyte CalOffset { get { return Buffer.Read<sbyte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(VbatCalibration._TagMap, (byte)VbatCalibration._Tag)]
|
||||
public class VbatCalibration : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.VbatCalibration;
|
||||
public const byte _ParameterLength = 3;
|
||||
|
||||
public VbatCalibration() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public VbatCalibration(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public VbatCalibration(sbyte offset, UInt16 slope) : this()
|
||||
{
|
||||
CalOffset = offset;
|
||||
CalSlope = slope;
|
||||
}
|
||||
|
||||
public sbyte CalOffset { get { return Buffer.Read<sbyte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
|
||||
public UInt16 CalSlope { get { return Buffer.Read<UInt16>((Offset + 3) * 8 + 0, 8 * 2); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.GlobalIPerlTags
|
||||
{
|
||||
[NA2WParameter(VsysCalibration._TagMap, (byte)VsysCalibration._Tag)]
|
||||
public class VsysCalibration : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = TagMap.GlobalIPerl;
|
||||
public const GlobalIPerlTag _Tag = GlobalIPerlTag.VsysCalibration;
|
||||
public const byte _ParameterLength = 3;
|
||||
|
||||
public VsysCalibration() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public VsysCalibration(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public VsysCalibration(sbyte offset, UInt16 slope) : this()
|
||||
{
|
||||
CalOffset = offset;
|
||||
CalSlope = slope;
|
||||
}
|
||||
|
||||
public sbyte CalOffset { get { return Buffer.Read<sbyte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
|
||||
public UInt16 CalSlope { get { return Buffer.Read<UInt16>((Offset + 3) * 8 + 0, 8 * 2); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Sensus;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
public class IPerlS4
|
||||
{
|
||||
public const byte MeterType = 8;
|
||||
}
|
||||
|
||||
class IPerlS4Semi : Frame
|
||||
{
|
||||
public const int _Size = 79;
|
||||
|
||||
public IPerlS4Semi(byte[] buffer)
|
||||
{
|
||||
this.buffer = new byte[_Size];
|
||||
Array.Copy(buffer, this.buffer, (buffer.Length < _Size) ? buffer.Length : _Size);
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt32 Reading { get { return buffer.Read<UInt32>(0, 32, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte Alarms { get { return buffer.Read<byte>(4 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte PamStatus { get { return buffer.Read<byte>(5 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte PamRssi { get { return buffer.Read<byte>(6 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte MeterType { get { return buffer.Read<byte>(7 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 TransmissionInterval { get { return buffer.Read<UInt16>(8 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte LatInterval { get { return buffer.Read<byte>(10 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 CurrentFlow { get { return buffer.Read<UInt16>(11 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt32 BackwardVolume { get { return buffer.Read<UInt32>(13 * 8, 32, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte Units { get { return buffer.Read<byte>(17 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte MBusStatus { get { return buffer.Read<byte>(18 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 MBusInterval { get { return buffer.Read<UInt16>(19 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte AlarmActiveInfo { get { return buffer.Read<byte>(21 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte LeakDetectionParms { get { return buffer.Read<byte>(22 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte BrokenPipeDetectionParams { get { return buffer.Read<byte>(23 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 BatteryRemaining { get { return buffer.Read<UInt16>(24 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 BatteryEndDetected { get { return buffer.Read<UInt16>(26 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 TimeOfMaximumFlow { get { return buffer.Read<UInt16>(28 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 MaximumFlow { get { return buffer.Read<UInt16>(30 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 LowBatteryDetected { get { return buffer.Read<UInt16>(32 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 LeakStart { get { return buffer.Read<UInt16>(34 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 LeakEnd { get { return buffer.Read<UInt16>(36 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 MagneticTamperStart { get { return buffer.Read<UInt16>(38 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 MagneticTamperEnd { get { return buffer.Read<UInt16>(40 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 AirInServiceStart { get { return buffer.Read<UInt16>(42 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 AirInServiceEnd { get { return buffer.Read<UInt16>(44 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 BackFlowStart { get { return buffer.Read<UInt16>(46 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 BlackFlowEnd { get { return buffer.Read<UInt16>(48 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 BrokenPipeStart { get { return buffer.Read<UInt16>(50 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 BrokenPipeEnd { get { return buffer.Read<UInt16>(52 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 LoggingContent { get { return buffer.Read<UInt16>(54 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 LoggingInterval { get { return buffer.Read<UInt16>(56 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 FixedDateReadingContent { get { return buffer.Read<UInt16>(58 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte FixedDateReadingDayOfMonth { get { return buffer.Read<byte>(60 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt32 ActualDateAndTime { get { return buffer.Read<UInt32>(61 * 8, 32, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public byte HistoricalErrorLimit { get { return buffer.Read<byte>(65 * 8); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 TimeOfFixedDateReadingReset { get { return buffer.Read<UInt16>(75 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
[Browsable(true)]
|
||||
public UInt16 TimeOfLogReset { get { return buffer.Read<UInt16>(77 * 8, 16, ByteOrder.BigEndian); } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var flags = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy;
|
||||
System.Reflection.PropertyInfo[] infos = this.GetType().GetProperties(flags);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
string typeName = this.GetType().Name;
|
||||
sb.AppendLine(typeName);
|
||||
sb.AppendLine(string.Empty.PadRight(typeName.Length + 5, '='));
|
||||
|
||||
foreach (var info in infos)
|
||||
{
|
||||
if (info.GetCustomAttributes<BrowsableAttribute>().Contains(BrowsableAttribute.Yes))
|
||||
{
|
||||
object value = info.GetValue(this, null);
|
||||
sb.AppendFormat("{0}: {1}{2}", info.Name, value != null ? value : "null", Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// NA2WProductType
|
||||
public enum NA2WProductType : uint
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// Water.
|
||||
[Description("Water")]
|
||||
Water = 0u,
|
||||
//
|
||||
// Summary:
|
||||
// Gas.
|
||||
[Description("Gas")]
|
||||
Gas = 1u,
|
||||
//
|
||||
// Summary:
|
||||
// Gas Shutoff Valve.
|
||||
[Description("Gas Shutoff Valve")]
|
||||
GasShutoffValve = 2u,
|
||||
//
|
||||
// Summary:
|
||||
// MLC.
|
||||
[Description("MLC")]
|
||||
MLC = 3u,
|
||||
//
|
||||
// Summary:
|
||||
// Three Port Gas Corrector.
|
||||
[Description("Three Port Gas Corrector")]
|
||||
ThreePortGasCorrector = 4u,
|
||||
//
|
||||
// Summary:
|
||||
// Dual Port Pulse Gas.
|
||||
[Description("Dual Port Pulse Gas")]
|
||||
DualPortPulseGas = 5u,
|
||||
//
|
||||
// Summary:
|
||||
// Arqiva Thames Water [HAN].
|
||||
[Description("Arqiva Thames Water [HAN]")]
|
||||
ArqivaThamesWater_HAN = 6u,
|
||||
//
|
||||
// Summary:
|
||||
// Arqiva Thames Water [No HAN].
|
||||
[Description("Arqiva Thames Water [No HAN]")]
|
||||
ArqivaThamesWater_NoHAN = 7u,
|
||||
//
|
||||
// Summary:
|
||||
// Arqiva Liberty Gas.
|
||||
[Description("Arqiva Liberty Gas")]
|
||||
ArqivaLibertyGas = 8u,
|
||||
//
|
||||
// Summary:
|
||||
// Arqiva Thames Water [HAN/New loop].
|
||||
[Description("Arqiva Thames Water [HAN/New loop]")]
|
||||
ArqivaThamesWater_HANNewLoop = 9u,
|
||||
//
|
||||
// Summary:
|
||||
// Three Port Gas Rev 5.
|
||||
[Description("Three Port Gas Rev 5")]
|
||||
ThreePortGasRev5 = 10u,
|
||||
//
|
||||
// Summary:
|
||||
// Dual Port Gas Rev 5.
|
||||
[Description("Dual Port Gas Rev 5")]
|
||||
DualPortGasRev5 = 11u,
|
||||
//
|
||||
// Summary:
|
||||
// Electronic Register (2012).
|
||||
[Description("Electronic Register (2012)")]
|
||||
ElectronicRegister = 12u,
|
||||
//
|
||||
// Summary:
|
||||
// SLC Phase II Light Controller (U90952).
|
||||
[Description("SLC Phase II Light Controller (U90952)")]
|
||||
SLCPhaseIILightController = 13u,
|
||||
//
|
||||
// Summary:
|
||||
// SLC Phase II Radio (U90951).
|
||||
[Description("SLC Phase II Radio (U90951)")]
|
||||
SLCPhaseIIRadio = 14u,
|
||||
//
|
||||
// Summary:
|
||||
// 640 E-register.
|
||||
[Description("640 E-register")]
|
||||
_640ERegister = 0xFu,
|
||||
//
|
||||
// Summary:
|
||||
// ESAAP Water (1000123).
|
||||
[Description("ESAAP Water (1000123)")]
|
||||
ESAAPWater = 0x10u,
|
||||
//
|
||||
// Summary:
|
||||
// Smart Gateway.
|
||||
[Description("Smart Gateway")]
|
||||
SmartGateway = 17u,
|
||||
//
|
||||
// Summary:
|
||||
// SLC Phase III.
|
||||
[Description("SLC Phase III")]
|
||||
SLCPhaseIII = 18u,
|
||||
//
|
||||
// Summary:
|
||||
// Cathodic Protection Test Point.
|
||||
[Description("Cathodic Protection Test Point")]
|
||||
CathodicProtectionTestPoint = 19u,
|
||||
//
|
||||
// Summary:
|
||||
// iPERL2.
|
||||
[Description("iPERL2")]
|
||||
IPERL2 = 20u,
|
||||
//
|
||||
// Summary:
|
||||
// iPERL S4 TFx.
|
||||
[Description("iPERL S4 TFx")]
|
||||
IPERLS4TFx = 21u,
|
||||
//
|
||||
// Summary:
|
||||
// Pulse RF TFx.
|
||||
[Description("Pulse RF TFx")]
|
||||
PulseRFTFx = 22u,
|
||||
//
|
||||
// Summary:
|
||||
// Japan Demo.
|
||||
[Description("Japan Demo")]
|
||||
JapanDemo = 23u,
|
||||
//
|
||||
// Summary:
|
||||
// Australia Demo.
|
||||
[Description("Australia Demo")]
|
||||
AustraliaDemo = 24u,
|
||||
//
|
||||
// Summary:
|
||||
// Bullhorn FlexNet Radio Module.
|
||||
[Description("Bullhorn FlexNet Radio Module")]
|
||||
BullhornFlexNetRadioModule = 25u,
|
||||
//
|
||||
// Summary:
|
||||
// AutoGun Bluetooth.
|
||||
[Description("AutoGun Bluetooth")]
|
||||
AutoGunBluetooth = 26u,
|
||||
//
|
||||
// Summary:
|
||||
// ESAAP MP SmartPoint.
|
||||
[Description("ESAAP MP SmartPoint")]
|
||||
ESAAPMPSmartPoint = 27u,
|
||||
//
|
||||
// Summary:
|
||||
// Japan Field Trial.
|
||||
[Description("Japan Field Trial")]
|
||||
JapanFieldTrial = 28u,
|
||||
//
|
||||
// Summary:
|
||||
// Electronic Register +. XML serializes as "Electronic Register Plus".
|
||||
[Description("Electronic Register +")]
|
||||
[SerializedName("Electronic Register Plus")]
|
||||
ElectronicRegisterPlus = 29u,
|
||||
//
|
||||
// Summary:
|
||||
// PHIT2.
|
||||
[Description("PHIT2")]
|
||||
PHIT2 = 30u,
|
||||
//
|
||||
// Summary:
|
||||
// VantagePoint DALI.
|
||||
[Description("VantagePoint DALI")]
|
||||
VantagePointDALI = 0x1Fu,
|
||||
//
|
||||
// Summary:
|
||||
// SLC-SELC Meter.
|
||||
[Description("SLC-SELC Meter")]
|
||||
SLCSELCMeter = 0x20u,
|
||||
//
|
||||
// Summary:
|
||||
// SonixV2 Radio EP1.
|
||||
[Description("SonixV2 Radio EP1")]
|
||||
SonixV2RadioEP1 = 33u,
|
||||
//
|
||||
// Summary:
|
||||
// SonixV2 Meter.
|
||||
[Description("SonixV2 Meter")]
|
||||
SonixV2Meter = 34u,
|
||||
//
|
||||
// Summary:
|
||||
// Utility Pole Monitor.
|
||||
[Description("Utility Pole Monitor")]
|
||||
UtilityPoleMonitor = 35u,
|
||||
//
|
||||
// Summary:
|
||||
// FlexNet iPERL S4 Radio EP1.
|
||||
[Description("FlexNet iPERL S4 Radio EP1")]
|
||||
FlexNetIPERLS4RadioEP1 = 36u,
|
||||
//
|
||||
// Summary:
|
||||
// AutoGun Bluetooth Radio Module.
|
||||
[Description("AutoGun Bluetooth Radio Module")]
|
||||
AutoGunBluetoothRadioModule = 37u,
|
||||
//
|
||||
// Summary:
|
||||
// sim3l1xx 900MHz Development Board.
|
||||
[Description("sim3l1xx 900MHz Development Board")]
|
||||
Sim3l1xx900MHzDevelopmentBoard = 38u,
|
||||
//
|
||||
// Summary:
|
||||
// Chile Field Trial.
|
||||
[Description("Chile Field Trial")]
|
||||
ChileFieldTrial = 39u,
|
||||
//
|
||||
// Summary:
|
||||
// EFM32GG 900MHz Development Board.
|
||||
[Description("EFM32GG 900MHz Development Board")]
|
||||
EFM32GG900MHzDevelopmentBoard = 40u,
|
||||
//
|
||||
// Summary:
|
||||
// Japan Field Trial Gen 2.
|
||||
[Description("Japan Field Trial Gen 2")]
|
||||
JapanFieldTrialGen2 = 41u,
|
||||
//
|
||||
// Summary:
|
||||
// FlexNet iPERL S4 Radio.
|
||||
[Description("FlexNet iPERL S4 Radio")]
|
||||
FlexNetIPERLS4Radio = 42u,
|
||||
//
|
||||
// Summary:
|
||||
// SonixV2 Radio.
|
||||
[Description("SonixV2 Radio")]
|
||||
SonixV2Radio = 43u,
|
||||
//
|
||||
// Summary:
|
||||
// iPERL ASIC.
|
||||
[Description("iPERL ASIC")]
|
||||
IPERLASIC = 44u,
|
||||
//
|
||||
// Summary:
|
||||
// Cordonel SRF. XML serializes as "Cordonel SRF".
|
||||
[Description("Cordonel SRF")]
|
||||
[SerializedName("Cordonel SRF")]
|
||||
CordonelROW = 45u,
|
||||
//
|
||||
// Summary:
|
||||
// Omni+. XML serializes as "Omni eRegister Plus".
|
||||
[Description("Omni+")]
|
||||
[SerializedName("Omni eRegister Plus")]
|
||||
OmniERegisterPlus = 46u,
|
||||
//
|
||||
// Summary:
|
||||
// Cordonel North America.
|
||||
[Description("Cordonel North America")]
|
||||
CordonelNorthAmerica = 49u,
|
||||
//
|
||||
// Summary:
|
||||
// Water Pulse.
|
||||
[Description("Water Pulse")]
|
||||
WaterPulse = 50u,
|
||||
//
|
||||
// Summary:
|
||||
// Omni Optical Adapter.
|
||||
[Description("Omni Optical Adapter")]
|
||||
OmniOpticalAdapter = 51u,
|
||||
//
|
||||
// Summary:
|
||||
// Wireless (TFR) ESAAP iPERL ULFN.
|
||||
[Description("Wireless (TFR) ESAAP iPERL ULFN")]
|
||||
WirelessESAAPIPERLULFN = 52u,
|
||||
//
|
||||
// Summary:
|
||||
// SonixV2 Radio Phase II.
|
||||
[Description("SonixV2 Radio Phase II")]
|
||||
SonixV2RadioPhaseII = 53u,
|
||||
//
|
||||
// Summary:
|
||||
// SonixV2 Meter Phase II.
|
||||
[Description("SonixV2 Meter Phase II")]
|
||||
SonixV2MeterPhaseII = 54u,
|
||||
//
|
||||
// Summary:
|
||||
// CommandLink II.
|
||||
[Description("CommandLink II")]
|
||||
CommandLinkII = 55u,
|
||||
//
|
||||
// Summary:
|
||||
// ESAAP Agnostic SmartPoint.
|
||||
[Description("ESAAP Agnostic SmartPoint")]
|
||||
ESAAPAgnosticSmartPoint = 56u,
|
||||
//
|
||||
// Summary:
|
||||
// ESAAP Pulse Output Module.
|
||||
[Description("ESAAP Pulse Output Module")]
|
||||
ESAAPPulseOutputModule = 69u,
|
||||
//
|
||||
// Summary:
|
||||
// Global iPERL.
|
||||
[Description("Global iPERL")]
|
||||
GlobalIPerl = 74u
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(NfcCommand_InventoryRead._Code, NfcCommand_InventoryRead._Version)]
|
||||
public class NfcCommand_InventoryRead : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 1;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x26;
|
||||
public const byte _Version = 0x00; // Use Sub Command field value
|
||||
|
||||
public NfcCommand_InventoryRead() : base(_Size)
|
||||
{
|
||||
SubCommand = _Version;
|
||||
}
|
||||
|
||||
public NfcCommand_InventoryRead(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
SubCommand = _Version;
|
||||
}
|
||||
|
||||
public static NfcCommand_InventoryRead Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<NfcCommand_InventoryRead>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte SubCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(NfcCommand_NdefRead._Code, NfcCommand_NdefRead._Version)]
|
||||
public class NfcCommand_NdefRead : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 1;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x26;
|
||||
public const byte _Version = 0x01; // Use Sub Command field value
|
||||
|
||||
public NfcCommand_NdefRead() : base(_Size)
|
||||
{
|
||||
SubCommand = _Version;
|
||||
}
|
||||
|
||||
public NfcCommand_NdefRead(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
SubCommand = _Version;
|
||||
}
|
||||
|
||||
public static NfcCommand_NdefRead Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<NfcCommand_NdefRead>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte SubCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.SensusRF;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
public class PulseOutputModuleInstallation : Frame, IPAMCommand
|
||||
{
|
||||
const byte _PamCode = 0x97;
|
||||
const byte _Size = 17;
|
||||
const byte _Length = 15;
|
||||
|
||||
public PulseOutputModuleInstallation()
|
||||
: base(_Size)
|
||||
{
|
||||
ID = (CommandID)_PamCode;
|
||||
PayloadLength = _Length;
|
||||
}
|
||||
|
||||
public CommandID ID
|
||||
{
|
||||
get { return buffer.Read<CommandID>(0, 8); }
|
||||
private set { buffer.Write<CommandID>(value, 0, 8); }
|
||||
}
|
||||
|
||||
public byte PayloadLength
|
||||
{
|
||||
get { return buffer.Read<byte>(1 * 8, 8); }
|
||||
set { buffer.Write<byte>(value, 1 * 8, 8); }
|
||||
}
|
||||
|
||||
public UInt32 RegisterAddress
|
||||
{
|
||||
get { return buffer.Read<UInt32>(2 * 8, 32, ByteOrder.BigEndian); }
|
||||
set { buffer.Write<UInt32>(value, 2 * 8, 32, ByteOrder.BigEndian); }
|
||||
}
|
||||
|
||||
public UInt32 RegisterExtendedAddress
|
||||
{
|
||||
get { return buffer.Read<UInt32>(6 * 8, 32, ByteOrder.BigEndian); }
|
||||
set { buffer.Write<UInt32>(value, 6 * 8, 32, ByteOrder.BigEndian); }
|
||||
}
|
||||
|
||||
public UInt16 WMBusTxRate
|
||||
{
|
||||
get { return buffer.Read<UInt16>(10 * 8 + 0, 16, ByteOrder.BigEndian); }
|
||||
set { buffer.Write<UInt16>(value, 10 * 8 + 0, 16, ByteOrder.BigEndian); }
|
||||
}
|
||||
|
||||
public byte MeterReceiveOccurrence
|
||||
{
|
||||
get { return buffer.Read<byte>(12 * 8, 8); }
|
||||
set { buffer.Write<byte>(value, 12 * 8, 8); }
|
||||
}
|
||||
|
||||
public byte PulseWeight
|
||||
{
|
||||
get { return buffer.Read<byte>(13 * 8 + 0, 3); }
|
||||
set { buffer.Write<byte>(value, 13 * 8 + 0, 3); }
|
||||
}
|
||||
|
||||
public byte PulseWidth
|
||||
{
|
||||
get { return buffer.Read<byte>(13 * 8 + 3, 3); }
|
||||
set { buffer.Write<byte>(value, 13 * 8 + 3, 3); }
|
||||
}
|
||||
public byte PulseOutputMode
|
||||
{
|
||||
get { return buffer.Read<byte>(13 * 8 + 6, 2); }
|
||||
set { buffer.Write<byte>(value, 13 * 8 + 6, 2); }
|
||||
}
|
||||
|
||||
public byte PulseSpreading
|
||||
{
|
||||
get { return buffer.Read<byte>(14 * 8 + 0, 2); }
|
||||
set { buffer.Write<byte>(value, 14 * 8 + 0, 2); }
|
||||
}
|
||||
|
||||
public bool LockImmediately
|
||||
{
|
||||
get { return buffer.Read<bool>(14 * 8 + 2, 1); }
|
||||
set { buffer.Write<bool>(value, 14 * 8 + 2, 1); }
|
||||
}
|
||||
|
||||
public bool DelayPulses
|
||||
{
|
||||
get { return buffer.Read<bool>(14 * 8 + 3, 1); }
|
||||
set { buffer.Write<bool>(value, 14 * 8 + 3, 1); }
|
||||
}
|
||||
|
||||
public bool RegisterAddressChanged
|
||||
{
|
||||
get { return buffer.Read<bool>(15 * 8 + 0, 1); }
|
||||
set { buffer.Write<bool>(value, 15 * 8 + 0, 1); }
|
||||
}
|
||||
|
||||
public bool RegisterExtendedAddressChanged
|
||||
{
|
||||
get { return buffer.Read<bool>(15 * 8 + 1, 1); }
|
||||
set { buffer.Write<bool>(value, 15 * 8 + 1, 1); }
|
||||
}
|
||||
|
||||
public bool ReadingTxRateChanged
|
||||
{
|
||||
get { return buffer.Read<bool>(15 * 8 + 2, 1); }
|
||||
set { buffer.Write<bool>(value, 15 * 8 + 2, 1); }
|
||||
}
|
||||
|
||||
public bool ReadingRxRateChanged
|
||||
{
|
||||
get { return buffer.Read<bool>(15 * 8 + 3, 1); }
|
||||
set { buffer.Write<bool>(value, 15 * 8 + 3, 1); }
|
||||
}
|
||||
|
||||
public bool PulseWeightChanged
|
||||
{
|
||||
get { return buffer.Read<bool>(15 * 8 + 4, 1); }
|
||||
set { buffer.Write<bool>(value, 15 * 8 + 4, 1); }
|
||||
}
|
||||
|
||||
public bool PulseWidthChanged
|
||||
{
|
||||
get { return buffer.Read<bool>(15 * 8 + 5, 1); }
|
||||
set { buffer.Write<bool>(value, 15 * 8 + 5, 1); }
|
||||
}
|
||||
|
||||
public bool PulseOutputModeChanged
|
||||
{
|
||||
get { return buffer.Read<bool>(15 * 8 + 6, 1); }
|
||||
set { buffer.Write<bool>(value, 15 * 8 + 6, 1); }
|
||||
}
|
||||
|
||||
public bool PulseSpreadingChanged
|
||||
{
|
||||
get { return buffer.Read<bool>(15 * 8 + 7, 1); }
|
||||
set { buffer.Write<bool>(value, 15 * 8 + 7, 1); }
|
||||
}
|
||||
|
||||
} // end class
|
||||
} // end namespace
|
||||
@@ -0,0 +1,47 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.SensusRF;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
public class PulseOutputTest : Frame, IPAMCommand
|
||||
{
|
||||
const byte _PamCode = 0x22;
|
||||
const byte _Size = 4;
|
||||
|
||||
public PulseOutputTest()
|
||||
: base(_Size)
|
||||
{
|
||||
ID = (CommandID)_PamCode;
|
||||
}
|
||||
|
||||
public CommandID ID
|
||||
{
|
||||
get { return buffer.Read<CommandID>(0, 8); }
|
||||
private set { buffer.Write<CommandID>(value, 0, 8); }
|
||||
}
|
||||
|
||||
public byte PulseWidth
|
||||
{
|
||||
get { return buffer.Read<byte>(1 * 8 + 0, 3); }
|
||||
set { buffer.Write<byte>(value, 1 * 8 + 0, 3); }
|
||||
}
|
||||
|
||||
public byte PulseOutputMode
|
||||
{
|
||||
get { return buffer.Read<byte>(1 * 8 + 3, 2); }
|
||||
set { buffer.Write<byte>(value, 1 * 8 + 3, 2); }
|
||||
}
|
||||
|
||||
public byte ForwardPulses
|
||||
{
|
||||
get { return buffer.Read<byte>(2 * 8, 8); }
|
||||
set { buffer.Write<byte>(value, 2 * 8, 8); }
|
||||
}
|
||||
|
||||
public byte ReversePulses
|
||||
{
|
||||
get { return buffer.Read<byte>(3 * 8, 8); }
|
||||
set { buffer.Write<byte>(value, 3 * 8, 8); }
|
||||
}
|
||||
} // end class
|
||||
} // end namespace
|
||||
@@ -0,0 +1,182 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(RadioListen._Code, RadioListen._Version)]
|
||||
public class RadioListen : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 7;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x24;
|
||||
public const byte _Version = 0;
|
||||
|
||||
public RadioListen() : base(_Size) { }
|
||||
|
||||
public RadioListen(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { }
|
||||
|
||||
public static RadioListen Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<RadioListen>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
public byte PortId { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
public RadioReceiveModulationType RadioReceiveModulation { get { return Buffer.Read<RadioReceiveModulationType>((Offset + 2) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 4); } }
|
||||
public RadioReceiveDataRate DataRate { get { return Buffer.Read<RadioReceiveDataRate>((Offset + 2) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 4, 4); } }
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 3) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 32); } }
|
||||
}
|
||||
|
||||
[NA2WSerialProtocolCommand(RadioListenV1._Code, RadioListenV1._Version)]
|
||||
public class RadioListenV1 : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 8;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x24;
|
||||
public const byte _Version = 1;
|
||||
|
||||
public RadioListenV1() : base(_Size) { Version = _Version; }
|
||||
|
||||
public RadioListenV1(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { Version = _Version; }
|
||||
|
||||
public static RadioListenV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<RadioListenV1>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
public byte PortId { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
public RadioReceiveModulationType RadioReceiveModulation { get { return Buffer.Read<RadioReceiveModulationType>((Offset + 2) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 4); } }
|
||||
public RadioReceiveDataRate DataRate { get { return Buffer.Read<RadioReceiveDataRate>((Offset + 2) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 4, 4); } }
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 3) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 32); } }
|
||||
public byte Sensitivity { get { return Buffer.Read<byte>((Offset + 7) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 7) * 8 + 0, 4); } }
|
||||
}
|
||||
|
||||
[NA2WSerialProtocolCommand(RadioListenV2._Code, RadioListenV2._Version)]
|
||||
public class RadioListenV2 : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 14;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x24;
|
||||
public const byte _Version = 2;
|
||||
|
||||
public RadioListenV2() : base(_Size) { Version = _Version; }
|
||||
|
||||
public RadioListenV2(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { Version = _Version; }
|
||||
|
||||
public static RadioListenV2 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<RadioListenV2>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
public byte PortId { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
public RadioReceiveModulationType RadioReceiveModulation { get { return Buffer.Read<RadioReceiveModulationType>((Offset + 2) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 4); } }
|
||||
public RadioReceiveDataRate DataRate { get { return Buffer.Read<RadioReceiveDataRate>((Offset + 2) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 4, 4); } }
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 3) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 32); } }
|
||||
public byte Sensitivity { get { return Buffer.Read<byte>((Offset + 7) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 7) * 8 + 0, 4); } }
|
||||
public UInt16 TimeWindow { get { return Buffer.Read<UInt16>((Offset + 8) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 8) * 8 + 0, 16); } }
|
||||
public UInt32 AddressFilter { get { return Buffer.Read<UInt32>((Offset + 10) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 10) * 8 + 0, 32); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(RadioTransmitCommandV1._Code, RadioTransmitCommandV1._Version)]
|
||||
public class RadioTransmitCommandV1 : Envelope<IFrame>, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 10;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x20;
|
||||
public const byte _Version = 1;
|
||||
|
||||
public RadioTransmitCommandV1() : base(_Size, 0)
|
||||
{
|
||||
Version = _Version;
|
||||
}
|
||||
|
||||
public static RadioTransmitCommandV1 Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Envelope<IFrame>.Parse<RadioTransmitCommandV1>(buffer, offset, 0, 0, length);
|
||||
}
|
||||
|
||||
protected override UInt32 Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
UInt32 headerSize = PayloadOffset;
|
||||
PayloadLength = wholeMessageLength - headerSize;
|
||||
return headerSize;
|
||||
}
|
||||
|
||||
protected override IFrame ParsePayload(byte[] buffer, UInt32 offset)
|
||||
{
|
||||
return FlexNetFrame.Parse(buffer, offset);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
if (typeof(T).IsAssignableFrom(Payload.GetType()))
|
||||
return (T)Payload;
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public RadioTransmitCommandV1(IFrame frame) : base(_Size, 0)
|
||||
{
|
||||
Payload = frame;
|
||||
Version = _Version;
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
PayloadLength = Payload.Length;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return header.Read<byte>(0 * 8 + 0, 4); } set { header.Write(value, 0 * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return header.Read<byte>(0 * 8 + 4, 4); } set { header.Write(value, 0 * 8 + 4, 4); } }
|
||||
|
||||
public byte Port { get { return header.Read<byte>(1 * 8 + 0, 8); } set { header.Write(value, 1 * 8 + 0, 8); } }
|
||||
public RadioFrameType RadioFrameType { get { return header.Read<RadioFrameType>(2 * 8 + 0, 4); } set { header.Write(value, 2 * 8 + 0, 4); } }
|
||||
public byte Reserved1 { get { return header.Read<byte>(2 * 8 + 4, 4); } set { header.Write(value, 2 * 8 + 4, 4); } }
|
||||
public RadioTransmitModulation RadioTransmitModulation { get { return header.Read<RadioTransmitModulation>(3 * 8 + 0, 6); } set { header.Write(value, 3 * 8 + 0, 6); } }
|
||||
public byte Reserved2 { get { return header.Read<byte>(3 * 8 + 6, 2); } set { header.Write(value, 3 * 8 + 6, 2); } }
|
||||
public UInt32 Frequency { get { return header.Read<UInt32>(4 * 8 + 0, 32); } set { header.Write(value, 4 * 8 + 0, 32); } }
|
||||
public Int16 PowerLevel { get { return header.Read<Int16>(8 * 8 + 0, 16); } set { header.Write(value, 8 * 8 + 0, 16); } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadOffset { get { return _Size; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
public enum WakeUpType : uint
|
||||
{
|
||||
Broadcast = 0,
|
||||
Addressed = 1,
|
||||
}
|
||||
|
||||
[NA2WSerialProtocolCommand(RadioWakeUpTone._Code, RadioWakeUpTone._Version)]
|
||||
public class RadioWakeUpTone : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 15;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x22;
|
||||
public const byte _Version = 0;
|
||||
|
||||
public RadioWakeUpTone() : base(_Size)
|
||||
{
|
||||
Version = _Version;
|
||||
}
|
||||
|
||||
public static RadioWakeUpTone Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<RadioWakeUpTone>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte Port { get { return Buffer.Read<byte>((Offset + 1) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 8); } }
|
||||
public RadioFrameType RadioFrameType { get { return Buffer.Read<RadioFrameType>((Offset + 2) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 4); } }
|
||||
public WakeUpType WakeUpType { get { return Buffer.Read<WakeUpType>((Offset + 2) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 2) * 8 + 4, 4); } }
|
||||
public UInt32 Frequency { get { return Buffer.Read<UInt32>((Offset + 3) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 3) * 8 + 0, 32); } }
|
||||
public Int16 PowerLevel { get { return Buffer.Read<Int16>((Offset + 7) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 7) * 8 + 0, 16); } }
|
||||
public UInt32 Address { get { return Buffer.Read<UInt32>((Offset + 9) * 8 + 0, 32); } set { Buffer.Write(value, (Offset + 9) * 8 + 0, 32); } }
|
||||
public UInt16 Timeout { get { return Buffer.Read<UInt16>((Offset + 13) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 13) * 8 + 0, 16); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(ResetSoftware._Code, ResetSoftware._Version)]
|
||||
public class ResetSoftware : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 3;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0xF0;
|
||||
public const byte _Version = 0;
|
||||
|
||||
public ResetSoftware() : base(_Size) { }
|
||||
|
||||
public ResetSoftware(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset) { }
|
||||
|
||||
public static ResetSoftware Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<ResetSoftware>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
public UInt16 ResetDelay { get { return Buffer.Read<UInt16>((Offset + 1) * 8 + 0, 16); } set { Buffer.Write(value, (Offset + 1) * 8 + 0, 16, null, true); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// Sterling Metrology Tags
|
||||
public enum SterlingMetrologyTag : uint
|
||||
{
|
||||
FactoryId = 0x00,
|
||||
CustomerId = 0x01,
|
||||
CustomerText = 0x02,
|
||||
BuildInformation = 0x03,
|
||||
ManufactureDate = 0x04,
|
||||
CalibrationStatus = 0x05,
|
||||
MeterOptions = 0x06,
|
||||
FactorySeal = 0x07,
|
||||
|
||||
MeterSize = 0x10,
|
||||
ReadingUnits = 0x11,
|
||||
ReadingResolution = 0x12,
|
||||
ReadingDigits = 0x13,
|
||||
Reading = 0x14,
|
||||
|
||||
TestTotalizer = 0x15,
|
||||
|
||||
SystemTime = 0x20,
|
||||
MeterState = 0x21,
|
||||
Status = 0x22,
|
||||
OpticalDataMode = 0x23,
|
||||
DisplayTimeout = 0x24,
|
||||
|
||||
Temperature = 0x30,
|
||||
TemperatureAdc = 0x31,
|
||||
TemperatureCalibration = 0x32,
|
||||
Vbat = 0x33,
|
||||
VbatAdc = 0x34,
|
||||
VbatCalibration = 0x35,
|
||||
DisplaySwitchAdc = 0x36,
|
||||
|
||||
//
|
||||
// Summary:
|
||||
// Empty Pipe Parameters.
|
||||
EmptyPipeParameters = 0x80,
|
||||
InputRangeParameters = 0x81,
|
||||
LowFlowParameters = 0x82,
|
||||
ImpedanceDriveParameters = 0x83,
|
||||
MagneticFieldDriveParameters = 0x84,
|
||||
MagneticTamperParameters = 0x85,
|
||||
ReverseVolumeBufferParameters = 0x86,
|
||||
|
||||
CalibrationFactor = 0x88,
|
||||
ZeroFlowOffsetParameters = 0x89,
|
||||
|
||||
TargetFieldParameters = 0x8A,
|
||||
SpreadSpectrumParameters = 0x8B,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(BuildInformation._TagMap, (byte)BuildInformation._Tag)]
|
||||
public class BuildInformation : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.BuildInformation;
|
||||
private const byte BUILD_INFO_NUM_BYTES = (14);
|
||||
public const byte _ParameterLength = BUILD_INFO_NUM_BYTES;
|
||||
public BuildInformation() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public BuildInformation(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public string BuildInfo
|
||||
{
|
||||
get { return Buffer.Read<string>((Offset + 2) * 8 + 0, 8 * _ParameterLength); }
|
||||
set { Buffer.Write<string>(value, (Offset + 2) * 8 + 0, 8 * _ParameterLength); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(CalibrationFactor._TagMap, (byte)CalibrationFactor._Tag)]
|
||||
public class CalibrationFactor : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.CalibrationFactor;
|
||||
public const byte _ParameterLength = 2;
|
||||
public CalibrationFactor() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public CalibrationFactor(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public UInt16 Setting { get { return Buffer.Read<UInt16>((Offset + 2) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 2) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(CustomerId._TagMap, (byte)CustomerId._Tag)]
|
||||
public class CustomerId : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.CustomerId;
|
||||
private const byte CUSTOMER_ID_NUM_BYTES = (12);
|
||||
public const byte _ParameterLength = CUSTOMER_ID_NUM_BYTES;
|
||||
public CustomerId() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public CustomerId(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public string CustomerID
|
||||
{
|
||||
get { return Buffer.Read<string>((Offset + 2) * 8 + 0, 8 * _ParameterLength); }
|
||||
set { Buffer.Write<string>(value, (Offset + 2) * 8 + 0, 8 * _ParameterLength); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(DisplayTimeout._TagMap, (byte)DisplayTimeout._Tag)]
|
||||
public class DisplayTimeout : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.DisplayTimeout;
|
||||
public const byte _ParameterLength = 1;
|
||||
public DisplayTimeout() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public DisplayTimeout(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public Byte Timeout
|
||||
{
|
||||
get { return Buffer.Read<Byte>((Offset + 2) * 8 + 0, 8 * _ParameterLength); }
|
||||
set { Buffer.Write<Byte>(value, (Offset + 2) * 8 + 0, 8 * _ParameterLength); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(EmptyPipeParameters._TagMap, (byte)EmptyPipeParameters._Tag)]
|
||||
public class EmptyPipeParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.EmptyPipeParameters;
|
||||
public const byte _ParameterLength = 4;
|
||||
|
||||
public EmptyPipeParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public EmptyPipeParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public UInt16 ImpedanceThreshold { get { return Buffer.Read<UInt16>((Offset + 2) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 2) * 8 + 0, 8 * 2); } }
|
||||
|
||||
public Byte EmptyTimeThreshold { get { return Buffer.Read<Byte>((Offset + 4) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 4) * 8 + 0, 8 * 1); } }
|
||||
|
||||
public Byte HydrationDuration_hr { get { return Buffer.Read<Byte>((Offset + 5) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 5) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(FactoryId._TagMap, (byte)FactoryId._Tag)]
|
||||
public class FactoryId : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.FactoryId;
|
||||
private const byte FACTORY_ID_NUM_BYTES = (12);
|
||||
public const byte _ParameterLength = FACTORY_ID_NUM_BYTES;
|
||||
public FactoryId() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public FactoryId(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public string FactoryID
|
||||
{
|
||||
get { return Buffer.Read<string>((Offset + 2) * 8 + 0, 8 * _ParameterLength); }
|
||||
set { Buffer.Write<string>(value, (Offset + 2) * 8 + 0, 8 * _ParameterLength); }
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(LowFlowParameters._TagMap, (byte)ImpedanceDriveParameters._Tag)]
|
||||
public class ImpedanceDriveParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.ImpedanceDriveParameters;
|
||||
public const byte _ParameterLength = 1;
|
||||
public ImpedanceDriveParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public ImpedanceDriveParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public Byte DriveStrength { get { return Buffer.Read<Byte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(InputRangeParameters._TagMap, (byte)InputRangeParameters._Tag)]
|
||||
public class InputRangeParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.InputRangeParameters;
|
||||
public const byte _ParameterLength = 25;
|
||||
public InputRangeParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public InputRangeParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public UInt32 AdcRailingHighThreshold { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 8 * 4); } set { Buffer.Write<UInt32>(value, (Offset + 2) * 8 + 0, 8 * 4); } }
|
||||
public UInt32 AdcRailingLowThreshold { get { return Buffer.Read<UInt32>((Offset + 6) * 8 + 0, 8 * 4); } set { Buffer.Write<UInt32>(value, (Offset + 6) * 8 + 0, 8 * 4); } }
|
||||
public UInt32 MaxAdcThreshold { get { return Buffer.Read<UInt32>((Offset + 10) * 8 + 0, 8 * 4); } set { Buffer.Write<UInt32>(value, (Offset + 10) * 8 + 0, 8 * 4); } }
|
||||
public UInt16 MaxElectrodeDelta { get { return Buffer.Read<UInt16>((Offset + 14) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 14) * 8 + 0, 8 * 2); } }
|
||||
public Byte EmfAlarmHoldoffHours { get { return Buffer.Read<Byte>((Offset + 16) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 16) * 8 + 0, 8 * 1); } }
|
||||
public UInt16 AdcNoiseThreshold { get { return Buffer.Read<UInt16>((Offset + 17) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 17) * 8 + 0, 8 * 2); } }
|
||||
public UInt32 RawImpedanceClamp { get { return Buffer.Read<UInt32>((Offset + 19) * 8 + 0, 8 * 4); } set { Buffer.Write<UInt32>(value, (Offset + 19) * 8 + 0, 8 * 4); } }
|
||||
public UInt16 MaxFlowRate { get { return Buffer.Read<UInt16>((Offset + 23) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 23) * 8 + 0, 8 * 2); } }
|
||||
public Byte MaxFlowRateAlarmCount { get { return Buffer.Read<Byte>((Offset + 25) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 25) * 8 + 0, 8 * 1); } }
|
||||
public Byte FlowRateStdDevInvSlope { get { return Buffer.Read<Byte>((Offset + 26) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 26) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(LowFlowParameters._TagMap, (byte)LowFlowParameters._Tag)]
|
||||
public class LowFlowParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.LowFlowParameters;
|
||||
public const byte _ParameterLength = 9;
|
||||
public LowFlowParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public LowFlowParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public UInt16 EntryRate { get { return Buffer.Read<UInt16>((Offset + 2) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 2) * 8 + 0, 8 * 2); } }
|
||||
public UInt16 EntryTime { get { return Buffer.Read<UInt16>((Offset + 4) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 4) * 8 + 0, 8 * 2); } }
|
||||
public UInt16 ExitRate { get { return Buffer.Read<UInt16>((Offset + 6) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 6) * 8 + 0, 8 * 2); } }
|
||||
public UInt16 ExitTime { get { return Buffer.Read<UInt16>((Offset + 8) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 8) * 8 + 0, 8 * 2); } }
|
||||
public Byte LowPowerDelay_min { get { return Buffer.Read<Byte>((Offset + 10) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 10) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(MagneticFieldDriveParameters._TagMap, (byte)MagneticFieldDriveParameters._Tag)]
|
||||
public class MagneticFieldDriveParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.MagneticFieldDriveParameters;
|
||||
public const byte _ParameterLength = 13;
|
||||
public MagneticFieldDriveParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public MagneticFieldDriveParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public Byte DriveTime { get { return Buffer.Read<Byte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
public Int32 FieldFitA0 { get { return Buffer.Read<Int32>((Offset + 3) * 8 + 0, 8 * 4); } set { Buffer.Write<Int32>(value, (Offset + 3) * 8 + 0, 8 * 4); } }
|
||||
public Int32 FieldFitA1 { get { return Buffer.Read<Int32>((Offset + 7) * 8 + 0, 8 * 4); } set { Buffer.Write<Int32>(value, (Offset + 7) * 8 + 0, 8 * 4); } }
|
||||
public UInt16 FieldDriveStepMagnitude { get { return Buffer.Read<UInt16>((Offset + 11) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 11) * 8 + 0, 8 * 2); } }
|
||||
public UInt16 FieldControlHysteresis_mG { get { return Buffer.Read<UInt16>((Offset + 13) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 13) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(MagneticTamperParameters._TagMap, (byte)MagneticTamperParameters._Tag)]
|
||||
public class MagneticTamperParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.MagneticTamperParameters;
|
||||
public const byte _ParameterLength = 5;
|
||||
|
||||
public MagneticTamperParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public MagneticTamperParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public Byte MaxPercentError { get { return Buffer.Read<Byte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write<UInt16>(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
|
||||
public Byte DetectionCounts { get { return Buffer.Read<Byte>((Offset + 3) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 3) * 8 + 0, 8 * 1); } }
|
||||
|
||||
public Byte PidSettlingTime_s { get { return Buffer.Read<Byte>((Offset + 4) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 4) * 8 + 0, 8 * 1); } }
|
||||
|
||||
public Byte DriveLow { get { return Buffer.Read<Byte>((Offset + 5) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 5) * 8 + 0, 8 * 1); } }
|
||||
|
||||
public Byte DriveHigh { get { return Buffer.Read<Byte>((Offset + 6) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 6) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(ManufactureDate._TagMap, (byte)ManufactureDate._Tag)]
|
||||
public class ManufactureDate : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.ManufactureDate;
|
||||
public const byte _ParameterLength = 4;
|
||||
public ManufactureDate() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public ManufactureDate(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public UInt32 Date { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 8 * 4); } set { Buffer.Write<UInt32>(value, (Offset + 2) * 8 + 0, 8 * 4); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(MeterSize._TagMap, (byte)MeterSize._Tag)]
|
||||
public class MeterSize : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.MeterSize;
|
||||
public const byte _ParameterLength = 1;
|
||||
public MeterSize() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public MeterSize(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public Byte Size { get { return Buffer.Read<Byte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(MeterState._TagMap, (byte)MeterState._Tag)]
|
||||
public class MeterState : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.MeterState;
|
||||
public const byte _ParameterLength = 1;
|
||||
public MeterState() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public MeterState(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public Byte Mode { get { return Buffer.Read<Byte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(OpticalDataMode._TagMap, (byte)OpticalDataMode._Tag)]
|
||||
public class OpticalDataMode : NA2WParameter
|
||||
{
|
||||
public const byte Enable = 0xC0; // bits 6-7 set enables optical data
|
||||
public const byte Disable = 0x00; // bits 6-7 reset disables optical data
|
||||
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.OpticalDataMode;
|
||||
public const byte _ParameterLength = 1;
|
||||
|
||||
public OpticalDataMode() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
|
||||
public OpticalDataMode(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public OpticalDataMode(byte value) : this()
|
||||
{
|
||||
Mode = value;
|
||||
}
|
||||
|
||||
public byte Mode { get { return Buffer.Read<byte>((Offset + 2) * 8 + 0, 8 * 1); } set { Buffer.Write(value, (Offset + 2) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(ReverseVolumeBufferParameters._TagMap, (byte)ReverseVolumeBufferParameters._Tag)]
|
||||
public class ReverseVolumeBufferParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.ReverseVolumeBufferParameters;
|
||||
public const byte _ParameterLength = 6;
|
||||
public ReverseVolumeBufferParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public ReverseVolumeBufferParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public UInt32 Threshold_qml { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 8 * 4); } set { Buffer.Write<UInt32>(value, (Offset + 2) * 8 + 0, 8 * 4); } }
|
||||
public UInt16 Leak_qml_s { get { return Buffer.Read<UInt16>((Offset + 6) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 6) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(SpreadSpectrumParameters._TagMap, (byte)SpreadSpectrumParameters._Tag)]
|
||||
public class SpreadSpectrumParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.SpreadSpectrumParameters;
|
||||
public const byte _ParameterLength = 14;
|
||||
public SpreadSpectrumParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public SpreadSpectrumParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public Boolean DisableSpreadSpectrum { get { return Buffer.Read<Boolean>((Offset + 2) * 8 + 0, 1); } set { Buffer.Write<Boolean>(value, (Offset + 2) * 8 + 0, 1); } }
|
||||
public Boolean AlwaysUseFullRateBags { get { return Buffer.Read<Boolean>((Offset + 2) * 8 + 1, 1); } set { Buffer.Write<Boolean>(value, (Offset + 2) * 8 + 1, 1); } }
|
||||
public Byte PowerUp { get { return Buffer.Read<Byte>((Offset + 3) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 3) * 8 + 0, 8 * 1); } }
|
||||
public Byte HighNoise { get { return Buffer.Read<Byte>((Offset + 4) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 4) * 8 + 0, 8 * 1); } }
|
||||
public Byte EmptyPipe { get { return Buffer.Read<Byte>((Offset + 5) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 5) * 8 + 0, 8 * 1); } }
|
||||
public Byte BadAdc { get { return Buffer.Read<Byte>((Offset + 6) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 6) * 8 + 0, 8 * 1); } }
|
||||
public UInt16 InitLearningCompleteCount { get { return Buffer.Read<UInt16>((Offset + 7) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 7) * 8 + 0, 8 * 2); } }
|
||||
public UInt16 MinOffsetLearningSampleCount { get { return Buffer.Read<UInt16>((Offset + 9) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 9) * 8 + 0, 8 * 2); } }
|
||||
public Byte AdcShiftUpdateInterval { get { return Buffer.Read<Byte>((Offset + 11) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 11) * 8 + 0, 8 * 1); } }
|
||||
public Byte MaxPreviousAdcAge { get { return Buffer.Read<Byte>((Offset + 12) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 12) * 8 + 0, 8 * 1); } }
|
||||
public UInt16 AdcOffsetLearningGuard { get { return Buffer.Read<UInt16>((Offset + 13) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 13) * 8 + 0, 8 * 2); } }
|
||||
public Byte DisplacementCorrectionCount { get { return Buffer.Read<Byte>((Offset + 15) * 8 + 0, 8 * 1); } set { Buffer.Write<Byte>(value, (Offset + 15) * 8 + 0, 8 * 1); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(TargetFieldParameters._TagMap, (byte)TargetFieldParameters._Tag)]
|
||||
public class TargetFieldParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.TargetFieldParameters;
|
||||
public const byte _ParameterLength = 6;
|
||||
public TargetFieldParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public TargetFieldParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public UInt16 NormalPowerTargetField { get { return Buffer.Read<UInt16>((Offset + 2) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 2) * 8 + 0, 8 * 2); } }
|
||||
public UInt16 LowPowerTargetField { get { return Buffer.Read<UInt16>((Offset + 4) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 4) * 8 + 0, 8 * 2); } }
|
||||
public UInt16 HighPowerTargetField { get { return Buffer.Read<UInt16>((Offset + 6) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 6) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(TemperatureCalibration._TagMap, (byte)TemperatureCalibration._Tag)]
|
||||
public class TemperatureCalibration : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.TemperatureCalibration;
|
||||
public const byte _ParameterLength = 2;
|
||||
public TemperatureCalibration() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public TemperatureCalibration(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public Int16 TemperatureCal { get { return Buffer.Read<Int16>((Offset + 2) * 8 + 0, 8 * 2); } set { Buffer.Write<Int16>(value, (Offset + 2) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(TestTotalizer._TagMap, (byte)TestTotalizer._Tag)]
|
||||
public class TestTotalizer : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.TestTotalizer;
|
||||
public const byte _ParameterLength = 4;
|
||||
public TestTotalizer() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public TestTotalizer(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
|
||||
public UInt32 Value { get { return Buffer.Read<UInt32>((Offset + 2) * 8 + 0, 8 * 4); } set { Buffer.Write<UInt32>(value, (Offset + 2) * 8 + 0, 8 * 4); } }
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging.SterlingMetrologyTags
|
||||
{
|
||||
[NA2WParameter(ZeroFlowOffsetParameters._TagMap, (byte)ZeroFlowOffsetParameters._Tag)]
|
||||
public class ZeroFlowOffsetParameters : NA2WParameter
|
||||
{
|
||||
public const TagMap _TagMap = (TagMap)5; // SterlingMetrology
|
||||
public const SterlingMetrologyTag _Tag = SterlingMetrologyTag.ZeroFlowOffsetParameters;
|
||||
public const byte _ParameterLength = 4;
|
||||
public ZeroFlowOffsetParameters() : base(_ParmHeaderSize + _ParameterLength)
|
||||
{
|
||||
TagMap = _TagMap;
|
||||
Tag = (byte)_Tag;
|
||||
ParameterLength = _ParameterLength;
|
||||
}
|
||||
public ZeroFlowOffsetParameters(Func<byte[]> buffer, Func<UInt32> offset) : base(_TagMap, buffer, offset)
|
||||
{
|
||||
}
|
||||
public UInt16 ZeroFlowOffset { get { return Buffer.Read<UInt16>((Offset + 2) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 2) * 8 + 0, 8 * 2); } }
|
||||
public UInt16 ZeroFlowOffsetThreshold { get { return Buffer.Read<UInt16>((Offset + 4) * 8 + 0, 8 * 2); } set { Buffer.Write<UInt16>(value, (Offset + 4) * 8 + 0, 8 * 2); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.FieldLogicStaging
|
||||
{
|
||||
[NA2WSerialProtocolCommand(TouchReadTransmit._Code, TouchReadTransmit._Version)]
|
||||
public class TouchReadTransmit : Envelope<IFrame>, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 2;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x23;
|
||||
public const byte _Version = 0;
|
||||
|
||||
public TouchReadTransmit() : base(_Size, 0)
|
||||
{
|
||||
Version = _Version;
|
||||
}
|
||||
|
||||
public static TouchReadTransmit Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Envelope<IFrame>.Parse<TouchReadTransmit>(buffer, offset, 0, 0, length);
|
||||
}
|
||||
|
||||
protected override UInt32 Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
UInt32 headerSize = PayloadOffset;
|
||||
PayloadLength = wholeMessageLength - headerSize;
|
||||
return headerSize;
|
||||
}
|
||||
|
||||
protected override IFrame ParsePayload(byte[] buffer, UInt32 offset)
|
||||
{
|
||||
return FlexNetFrame.Parse(buffer, offset);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
if (typeof(T).IsAssignableFrom(Payload.GetType()))
|
||||
return (T)Payload;
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public TouchReadTransmit(IFrame frame) : base(_Size, 0)
|
||||
{
|
||||
Payload = frame;
|
||||
Version = _Version;
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
PayloadLength = (null != Payload) ? Payload.Length : 0;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return header.Read<byte>(0 * 8 + 0, 4); } set { header.Write(value, 0 * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return header.Read<byte>(0 * 8 + 4, 4); } set { header.Write(value, 0 * 8 + 4, 4); } }
|
||||
|
||||
public byte Port { get { return header.Read<byte>(1 * 8 + 0, 8); } set { header.Write(value, 1 * 8 + 0, 8); } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadOffset { get { return _Size; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,922 @@
|
||||
using Sensus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Packaging;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace GlobalIPerlUtility
|
||||
{
|
||||
public class GlobalIPerlRma
|
||||
{
|
||||
static readonly string[] StateLabel = { "Idle", "Search", "Locked", "Undefined" };
|
||||
|
||||
byte[] data;
|
||||
public GlobalIPerlRma(byte[] data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public byte MapRev => data.Read<byte>(0u, 8u);
|
||||
|
||||
public byte StorageSize => data.Read<byte>((1 * 8), 8u);
|
||||
|
||||
public ushort Spare => data.Read<ushort>((2 * 8), 16u);
|
||||
|
||||
public UInt32 Time => data.Read<UInt32>((4 * 8), 32u);
|
||||
|
||||
public UInt16 Mode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 8)
|
||||
{
|
||||
return data.Read<UInt16>((8 * 8), 16u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte State
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((data.Length > 8))
|
||||
{
|
||||
return data.Read<byte>((8 * 8 + 0), 2u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool LockImmediately
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 8)
|
||||
{
|
||||
return data.Read<bool>((8 * 8 + 2), 1u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool DelayPulses
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 8)
|
||||
{
|
||||
return data.Read<bool>((8 * 8 + 3), 1u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool LogCorrupted
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 8)
|
||||
{
|
||||
return data.Read<bool>((8 * 8 + 4), 1u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte AccessLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 8)
|
||||
{
|
||||
return data.Read<byte>((8 * 8 + 5), 2u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt16 NumberResets
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 11)
|
||||
{
|
||||
return data.Read<UInt16>((10 * 8), 16u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt16 NumberWdResets
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 13)
|
||||
{
|
||||
return data.Read<UInt16>((12 * 8), 16u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt16 MinimumVoltage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 15)
|
||||
{
|
||||
return data.Read<UInt16>((14 * 8), 16u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt16 LastResetVoltage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 15)
|
||||
{
|
||||
return data.Read<UInt16>((16 * 8), 16u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SByte MinimumTemperature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 18)
|
||||
{
|
||||
return data.Read<SByte>((18 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (SByte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SByte MaximumTemperature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 19)
|
||||
{
|
||||
return data.Read<SByte>((19 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (SByte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 Alarms
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 23)
|
||||
{
|
||||
return data.Read<UInt32>((20 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 RegisterAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 27)
|
||||
{
|
||||
return data.Read<UInt32>((24 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 ExtendedAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 31)
|
||||
{
|
||||
return data.Read<UInt32>((28 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt16 ManufacturerId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 31)
|
||||
{
|
||||
return data.Read<UInt16>((28 * 8 + 0), 16u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt16)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte Generation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 31)
|
||||
{
|
||||
return data.Read<byte>((28 * 8 + 16), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte Medium
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 31)
|
||||
{
|
||||
return data.Read<byte>((28 * 8 + 24), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 TimeSinceBirth
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 35)
|
||||
{
|
||||
return data.Read<UInt32>((32 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 SleepTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 39)
|
||||
{
|
||||
return data.Read<UInt32>((36 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 AwakeTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 43)
|
||||
{
|
||||
return data.Read<UInt32>((40 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 TotalPower
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 47)
|
||||
{
|
||||
return data.Read<UInt32>((44 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 LoadResetRegister
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 51)
|
||||
{
|
||||
return data.Read<UInt32>((48 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte PowerOnResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 52)
|
||||
{
|
||||
return data.Read<byte>((52 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte AnalogBrownOutResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 53)
|
||||
{
|
||||
return data.Read<byte>((53 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte DigitalBrownOutReetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 54)
|
||||
{
|
||||
return data.Read<byte>((54 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte DecoupleBrownOutResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 55)
|
||||
{
|
||||
return data.Read<byte>((55 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte PinResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 56)
|
||||
{
|
||||
return data.Read<byte>((56 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte LockupResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 57)
|
||||
{
|
||||
return data.Read<byte>((57 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte WatchdogTimerResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 58)
|
||||
{
|
||||
return data.Read<byte>((58 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte IoVddBrownOutResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 59)
|
||||
{
|
||||
return data.Read<byte>((59 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte EM4ResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 60)
|
||||
{
|
||||
return data.Read<byte>((60 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte Watchdog1ResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 61)
|
||||
{
|
||||
return data.Read<byte>((61 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte DigitalBrownOutLEResetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 62)
|
||||
{
|
||||
return data.Read<byte>((62 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte ExceptionCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 63)
|
||||
{
|
||||
return data.Read<byte>((63 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ExceptionData
|
||||
{
|
||||
get
|
||||
{
|
||||
byte[] temp = new byte[56];
|
||||
if (data.Length > 120)
|
||||
{
|
||||
Buffer.BlockCopy(data, 64, temp, 0, 56);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 SensusRfWakeToneDetectedCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 123)
|
||||
{
|
||||
return data.Read<UInt32>((120 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 SensusRfTxOnTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 127)
|
||||
{
|
||||
return data.Read<UInt32>((124 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 SensusRfRxOnTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 131)
|
||||
{
|
||||
return data.Read<UInt32>((128 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 WMBusRxOnTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 135)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((132 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 WMBusMeterReadingCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 139)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((136 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 NfcInterruptCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 143)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((140 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 NfcPowerTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 147)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((144 * 8), 32u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 NfcMailboxIncomingCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 151)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((148 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 NfcMailboxOutgoingCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 155)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((152 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte SpNewLoadStartCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 156)
|
||||
{
|
||||
return data.Read<byte>((156 * 8), 8u);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte SpFwUpdateCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 157)
|
||||
{
|
||||
return data.Read<byte>((157 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 ReceivedRadioPacketCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 163)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((160 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 ReceivedNfcPacketCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 167)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((164 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 LockLostCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 171)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((168 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt16 ActivityCreditsExhausted
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 173)
|
||||
{
|
||||
return (UInt16)data.Read<UInt16>((172 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt16)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt16 AuthorizationCreditsExhausted
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 175)
|
||||
{
|
||||
return (UInt16)data.Read<UInt16>((174 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt16)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 IdleStateTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 179)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((176 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 SearchStateTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 183)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((180 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 LockedStateTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data.Length > 187)
|
||||
{
|
||||
return (UInt32)data.Read<UInt32>((184 * 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (UInt32)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder("RMA Data:\n");
|
||||
sb.AppendLine(data.ToHexString());
|
||||
sb.AppendLine($"RMA Map Revision: {MapRev}");
|
||||
sb.AppendLine($"RMA Storage Size: {StorageSize}");
|
||||
sb.AppendLine($"Time: {Time}");
|
||||
if (data.Length > 8)
|
||||
{
|
||||
sb.AppendLine($"Mode: {Mode.ToString("X4")}");
|
||||
sb.AppendLine($" State: {StateLabel[State]} ({State})");
|
||||
sb.AppendLine($" LockImmediately: {LockImmediately}");
|
||||
sb.AppendLine($" DelayPulses: {DelayPulses}");
|
||||
sb.AppendLine($" LogCorrupted: {LogCorrupted}");
|
||||
sb.AppendLine($" AccessLevel: {AccessLevel}");
|
||||
sb.AppendLine($"Number of Reset: {NumberResets}");
|
||||
sb.AppendLine($"Number of WD Resets: {NumberWdResets}");
|
||||
sb.AppendLine($"Minimum Voltage: {MinimumVoltage}");
|
||||
sb.AppendLine($"Last Reset Voltage: {LastResetVoltage}");
|
||||
sb.AppendLine($"Minimum Temperature: {MinimumTemperature}");
|
||||
sb.AppendLine($"Maximum Temperature: {MaximumTemperature}");
|
||||
sb.AppendLine($"Alarms: {Alarms} ({Alarms.ToString("X8")})");
|
||||
sb.AppendLine($"Register Address: {RegisterAddress} ({RegisterAddress.ToString("X8")})");
|
||||
sb.AppendLine($"Extended Address: {ExtendedAddress.ToString("X8")}");
|
||||
sb.AppendLine($" Manufacturer Id: {ManufacturerId} ({ManufacturerId.ToString("X4")})");
|
||||
sb.AppendLine($" Generation: {Generation} ({Generation.ToString("X2")}");
|
||||
sb.AppendLine($" Medium: {Medium} ({Medium.ToString("X2")}");
|
||||
sb.AppendLine($"Time Since Birth: {TimeSinceBirth}");
|
||||
sb.AppendLine($"Sleep Time: {SleepTime}");
|
||||
sb.AppendLine($"Awake Time: {AwakeTime}");
|
||||
sb.AppendLine($"Total Power: {TotalPower}");
|
||||
sb.AppendLine($"Load Reset Register: {LoadResetRegister} ({LoadResetRegister.ToString("X8")})");
|
||||
sb.AppendLine($"Power On Reset Count: {PowerOnResetCount}");
|
||||
sb.AppendLine($"Analog Brown Out Reset Count: {AnalogBrownOutResetCount}");
|
||||
sb.AppendLine($"Digital Brown Out Reset Count: {DigitalBrownOutReetCount}");
|
||||
sb.AppendLine($"Decouple Brown Out Reset Count: {DecoupleBrownOutResetCount}");
|
||||
sb.AppendLine($"Pin Reset Count: {PinResetCount}");
|
||||
sb.AppendLine($"Lockup Reset Count: {LockupResetCount}");
|
||||
sb.AppendLine($"Watchdog Timer Reset Count: {WatchdogTimerResetCount}");
|
||||
sb.AppendLine($"IOVDD Brown Out Reset Count: {IoVddBrownOutResetCount}");
|
||||
sb.AppendLine($"EM4 Reset Count: {EM4ResetCount}");
|
||||
sb.AppendLine($"Watchdog 1 Reset Count: {Watchdog1ResetCount}");
|
||||
sb.AppendLine($"Digital Brown Out LE Reset Count: {DigitalBrownOutLEResetCount}");
|
||||
sb.AppendLine($"Exception Count: {ExceptionCount}");
|
||||
sb.AppendLine($"Exception Data: {ExceptionData.ToHexString()}");
|
||||
sb.AppendLine($"SensusRF Wake Tone Detected Count: {SensusRfWakeToneDetectedCount}");
|
||||
sb.AppendLine($"SensusRF TX On Time: {SensusRfTxOnTime}");
|
||||
sb.AppendLine($"SensusRF RX On Time: {SensusRfRxOnTime}");
|
||||
sb.AppendLine($"wM-Bus RX On Time: {WMBusRxOnTime}");
|
||||
sb.AppendLine($"wM-Bus Meter Reading Count: {WMBusMeterReadingCount}");
|
||||
sb.AppendLine($"NFC Interrupt Count: {NfcInterruptCount}");
|
||||
sb.AppendLine($"NFC Power Time: {NfcPowerTime}");
|
||||
sb.AppendLine($"NFC Mailbox Incoming Count: {NfcMailboxIncomingCount}");
|
||||
sb.AppendLine($"NFC Mailbox Outgoing Count: {NfcMailboxOutgoingCount}");
|
||||
sb.AppendLine($"SP New Load Start Count: {SpNewLoadStartCount}");
|
||||
sb.AppendLine($"SP FW Update Count: {SpFwUpdateCount}");
|
||||
sb.AppendLine($"Received Radio Packet Count: {ReceivedRadioPacketCount}");
|
||||
sb.AppendLine($"Received NFC Packet Count: {ReceivedNfcPacketCount}");
|
||||
sb.AppendLine($"Lock Lost Count: {LockLostCount}");
|
||||
sb.AppendLine($"Activity Credits Exhausted: {ActivityCreditsExhausted}");
|
||||
sb.AppendLine($"Authorization Credits Exhausted: {AuthorizationCreditsExhausted}");
|
||||
sb.AppendLine($"Idle State Time: {IdleStateTime}");
|
||||
sb.AppendLine($"Search State Time: {SearchStateTime}");
|
||||
sb.AppendLine($"Lock State Time: {LockedStateTime}");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
} // end class
|
||||
} // end namespace
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,572 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.CommunicationDevices;
|
||||
using Sensus.Protocols.FlexNet.Serial;
|
||||
using Sensus.Protocols.FlexNet.Serial.FNv2;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
using Serial = Sensus.Protocols.FlexNet.Serial;
|
||||
using Sensus.Protocols;
|
||||
using Sensus.Protocols.FlexNet.FNv2.NA2WParameters;
|
||||
using System.ComponentModel;
|
||||
using Sensus.Protocols.FlexNet.Transactions;
|
||||
using Sensus.Protocols.SensusRF;
|
||||
using System.Windows.Markup;
|
||||
using NA2WNFC;
|
||||
using NfcC7_DLL.NfcHanler;
|
||||
using NfcC7_DLL.NfcHanler.Protocols;
|
||||
using NfcC7_DLL.NfcHanler.Utils;
|
||||
using Log = NfcC7_DLL.NfcHanler.Utils.Log;
|
||||
|
||||
namespace GlobalIPerlUtility
|
||||
{
|
||||
class MeterTestHatLink : ISerialConnection, IDisposable
|
||||
{
|
||||
private SerialManager serialManager = null;
|
||||
private UInt16 sessionId = 0;
|
||||
|
||||
public MeterTestHatLink(string comPortString)
|
||||
{
|
||||
serialManager = new SerialManager(comPortString);
|
||||
}
|
||||
|
||||
public bool IsConnected { get { return (serialManager != null ? serialManager.FactoryUart.IsConnected : false); } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposing)
|
||||
{
|
||||
// eventThread.Abort();
|
||||
}
|
||||
}
|
||||
private BackgroundWorker openBackgroundWorker;
|
||||
|
||||
private void OpenDoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
bool isOpen = false;
|
||||
|
||||
// windowViewModel.IsBusy = true;
|
||||
|
||||
Log.Write("Opening connection on " + serialManager.ComPortString + "." + System.Environment.NewLine);
|
||||
|
||||
try
|
||||
{
|
||||
serialManager.Open();
|
||||
|
||||
if (serialManager.FactoryUart.IsConnected)
|
||||
{
|
||||
serialManager.FactoryUart.MessageReceived += MessageReceived;
|
||||
|
||||
CommDeviceSessionOpen commDeviceSessionOpen = new CommDeviceSessionOpen();
|
||||
commDeviceSessionOpen.HostParsed = "GlobalIPerlUtility";
|
||||
NA2WSerialFrame response = SendNa2wSerialToHat(commDeviceSessionOpen, true);
|
||||
|
||||
isOpen = (response != null);
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
serialManager.Close();
|
||||
serialManager = null;
|
||||
|
||||
Log.Write("MTH session open failed. Is device MTH?" + System.Environment.NewLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
String version = "Unknown version ";
|
||||
|
||||
NetworkResponse networkResponse = (NetworkResponse)response.Payload;
|
||||
|
||||
if (networkResponse.Payload is Sensus.Protocols.FlexNet.FNv2.CommDeviceSessionBegin)
|
||||
{
|
||||
var sessionBegin = (Sensus.Protocols.FlexNet.FNv2.CommDeviceSessionBegin)networkResponse.Payload;
|
||||
|
||||
version = String.Format("{0}{1}.{2}.{3}", (sessionBegin.ProductVersionBeta ? "B" : "R"), sessionBegin.ProductVersionMajor, sessionBegin.ProductVersionMinor, sessionBegin.ProductVersionPatch);
|
||||
sessionId = sessionBegin.SessionID;
|
||||
}
|
||||
else if (networkResponse.Payload is Sensus.Protocols.FlexNet.FNv2.CommDeviceSessionBeginV1)
|
||||
{
|
||||
var sessionBegin = (Sensus.Protocols.FlexNet.FNv2.CommDeviceSessionBeginV1)networkResponse.Payload;
|
||||
|
||||
version = String.Format("{0}{1}.{2}.{3}", (sessionBegin.ProductVersionBeta ? "B" : "R"), sessionBegin.ProductVersionMajor, sessionBegin.ProductVersionMinor, sessionBegin.ProductVersionPatch);
|
||||
sessionId = sessionBegin.SessionID;
|
||||
}
|
||||
|
||||
Log.Write("MTH session opened: " + version + " supporting NFC" + "." + System.Environment.NewLine);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Write("Serial port open failed. Check device." + System.Environment.NewLine);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
isOpen = false;
|
||||
serialManager = null;
|
||||
|
||||
Log.Write("Serial port open failed (" + ex.ToString() + ")." + System.Environment.NewLine);
|
||||
}
|
||||
|
||||
e.Result = isOpen;
|
||||
|
||||
if (isOpen)
|
||||
{
|
||||
serialManager.FactoryUart.MessageReceived += SerialMessageReceived;
|
||||
}
|
||||
|
||||
if (isOpen)
|
||||
{
|
||||
NfcCommand("Inventory");
|
||||
// windowViewModel.IsBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void NfcCommand(String type)
|
||||
{
|
||||
if (type.Equals("Inventory"))
|
||||
{
|
||||
NfcCommand_InventoryRead nfcCommand = new NfcCommand_InventoryRead();
|
||||
SendNa2wSerialToHat(nfcCommand, false);
|
||||
}
|
||||
else if (type.Equals("NDEF Read"))
|
||||
{
|
||||
NfcCommand_NdefRead nfcCommand = new NfcCommand_NdefRead();
|
||||
SendNa2wSerialToHat(nfcCommand, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
// windowViewModel.IsOpen = (bool)e.Result;
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
// openBackgroundWorker = new BackgroundWorker();
|
||||
// openBackgroundWorker.DoWork += new DoWorkEventHandler(OpenDoWork);
|
||||
// openBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OpenRunWorkerCompleted);
|
||||
|
||||
// openBackgroundWorker.RunWorkerAsync();
|
||||
OpenDoWork(this, new DoWorkEventArgs(this));
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
CommDeviceSessionClose commDeviceSessionClose = new CommDeviceSessionClose();
|
||||
commDeviceSessionClose.SessionID = sessionId;
|
||||
SendNa2wSerialToHat(commDeviceSessionClose, false);
|
||||
|
||||
serialManager.Close();
|
||||
serialManager = null;
|
||||
|
||||
Log.Write("MTH session closed." + System.Environment.NewLine);
|
||||
}
|
||||
|
||||
public event EventHandler<ReceptionEventArgs<ISerialMessageFrame>> MessageReceived;
|
||||
|
||||
public event EventHandler<EventArgs> Disconnected;
|
||||
|
||||
public ClassicSerialMessageFrame SendFlexNetSerial(ISerialCommandFrame cmd, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private byte transactionId = 0;
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerialToHat(ISerialCommand cmd, bool responseExpected)
|
||||
{
|
||||
NA2WSerialFrame cmdFrame = new NA2WSerialFrame(cmd);
|
||||
INetworkLayer networkLayer = cmdFrame.Unwrap<INetworkLayer>();
|
||||
networkLayer.PWNs.Set(new TransactionPWN() { TransactionID = transactionId++ });
|
||||
cmdFrame.Bake();
|
||||
|
||||
// LogOutgoing(cmdFrame);
|
||||
|
||||
return serialManager.SendNa2wSerial(cmdFrame, responseExpected);
|
||||
}
|
||||
|
||||
// State to track expected response when routing through NFC
|
||||
private bool lookingForCommandCode = false;
|
||||
private byte expectedResponseCommandCode = 0;
|
||||
private NA2WSerialFrame foundResponse = null;
|
||||
private AutoResetEvent autoResetEvent = null;
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerialToNfc(ISerialCommandFrame cmdFrame, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
// Harden command frame
|
||||
cmdFrame.Bake();
|
||||
|
||||
// Place serial frame in Serial Transmit command
|
||||
SerialTransmitCommandV1 serialTransmitCommandV1 = new SerialTransmitCommandV1();
|
||||
serialTransmitCommandV1.Payload = new Frame(cmdFrame.ToBytes());
|
||||
serialTransmitCommandV1.PortId = 0x02; // NFC port
|
||||
serialTransmitCommandV1.Bake();
|
||||
|
||||
// Place Serial Transmit command in serial frame. Set transaction id
|
||||
NA2WSerialFrame serialTransmitCmdFrame = new NA2WSerialFrame(serialTransmitCommandV1);
|
||||
INetworkLayer networkLayer = serialTransmitCmdFrame.Unwrap<INetworkLayer>();
|
||||
networkLayer.PWNs.Set(new TransactionPWN() { TransactionID = transactionId++ });
|
||||
serialTransmitCmdFrame.Bake();
|
||||
|
||||
// Setup response tracking which is done in SerialMessageReceived
|
||||
NA2WSerialFrame responseFrame = null;
|
||||
if (responseExpected)
|
||||
{
|
||||
lookingForCommandCode = false;
|
||||
autoResetEvent = new AutoResetEvent(false);
|
||||
}
|
||||
|
||||
// Serial Transmit command should have response (Command Ack) which is thrown away. Caller
|
||||
// doesn't care about messaging to hat.
|
||||
serialManager.SendNa2wSerial(serialTransmitCmdFrame, CommandAckResponse._Code);
|
||||
|
||||
// Wait for response
|
||||
if (null != autoResetEvent)
|
||||
{
|
||||
// Utility.Log.Write("Waiting" + System.Environment.NewLine);
|
||||
|
||||
if (autoResetEvent.WaitOne(TimeSpan.FromMilliseconds(timeoutMs)))
|
||||
{
|
||||
// Utility.Log.Write("Event" + System.Environment.NewLine);
|
||||
responseFrame = foundResponse;
|
||||
}
|
||||
autoResetEvent = null;
|
||||
foundResponse = null;
|
||||
}
|
||||
|
||||
return responseFrame;
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerialToNfc(ISerialCommandFrame cmdFrame, bool responseExpected)
|
||||
{
|
||||
return SendNa2wSerialToNfc(cmdFrame, responseExpected, 8000);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerialToNfc(ISerialCommand cmd, bool responseExpected)
|
||||
{
|
||||
// Make serial frame from command
|
||||
NA2WSerialFrame cmdFrame = new NA2WSerialFrame(cmd);
|
||||
|
||||
return SendNa2wSerialToNfc(cmdFrame, responseExpected);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommand cmd, bool responseExpected)
|
||||
{
|
||||
// Route command through Hat's NFC
|
||||
return SendNa2wSerialToNfc(cmd, responseExpected);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected)
|
||||
{
|
||||
// Route command through Hat's NFC
|
||||
return SendNa2wSerialToNfc(cmdFrame, responseExpected);
|
||||
}
|
||||
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerialToNfc(ISerialCommandFrame cmdFrame, byte responseCommandCode)
|
||||
{
|
||||
// Harden command frame
|
||||
cmdFrame.Bake();
|
||||
|
||||
// Place serial frame in Serial Transmit command
|
||||
SerialTransmitCommandV1 serialTransmitCommandV1 = new SerialTransmitCommandV1();
|
||||
serialTransmitCommandV1.Payload = new Frame(cmdFrame.ToBytes());
|
||||
serialTransmitCommandV1.PortId = 0x02; // NFC port
|
||||
serialTransmitCommandV1.Bake();
|
||||
|
||||
// Place Serial Transmit command in serial frame. Set transaction id
|
||||
NA2WSerialFrame serialTransmitCmdFrame = new NA2WSerialFrame(serialTransmitCommandV1);
|
||||
INetworkLayer networkLayer = serialTransmitCmdFrame.Unwrap<INetworkLayer>();
|
||||
networkLayer.PWNs.Set(new TransactionPWN() { TransactionID = transactionId++ });
|
||||
serialTransmitCommandV1.Bake();
|
||||
|
||||
return serialManager.SendNa2wSerial(serialTransmitCmdFrame, responseCommandCode);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerialToNfc(ISerialCommand cmd, byte responseCommandCode)
|
||||
{
|
||||
// Make serial frame from command
|
||||
NA2WSerialFrame cmdFrame = new NA2WSerialFrame(cmd);
|
||||
|
||||
return SendNa2wSerialToNfc(cmdFrame, responseCommandCode);
|
||||
}
|
||||
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommand cmd, byte responseCommandCode)
|
||||
{
|
||||
// Route command through Hat's NFC
|
||||
return SendNa2wSerialToNfc(cmd, responseCommandCode);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
// Ignore time out. Polling built into reader.
|
||||
return SendNa2wSerialToNfc(cmdFrame, responseExpected, timeoutMs);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, byte responseCommandCode)
|
||||
{
|
||||
// Route command through Hat's NFC
|
||||
return SendNa2wSerialToNfc(cmdFrame, responseCommandCode);
|
||||
}
|
||||
|
||||
|
||||
void SerialMessageReceived(object sender, ReceptionEventArgs<ISerialMessageFrame> args)
|
||||
{
|
||||
ISerialMessageFrame message = args.Frame;
|
||||
bool pushMessageUp = false;
|
||||
|
||||
// LogIncoming(message);
|
||||
|
||||
if (message.Payload is UnknownResponse)
|
||||
{
|
||||
UnknownResponse unknownResponse = message.Unwrap<UnknownResponse>();
|
||||
|
||||
// Serial Receive - extract and push up frame in payload
|
||||
byte[] newFrame = unknownResponse.ToBytes();
|
||||
try
|
||||
{
|
||||
NA2WSerialFrame na2wSerialFrame = NA2WSerialFrame.Parse(newFrame, 10, (uint)newFrame.Length - 10);
|
||||
args.Frame = na2wSerialFrame;
|
||||
message = na2wSerialFrame;
|
||||
|
||||
// If waiting for response, trigger found if content is expected
|
||||
if (null != autoResetEvent)
|
||||
{
|
||||
// Utility.Log.Write("Response Found: " + System.Environment.NewLine);
|
||||
foundResponse = na2wSerialFrame;
|
||||
autoResetEvent.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
pushMessageUp = true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
if (message.Payload is UnknownMessage)
|
||||
{
|
||||
UnknownMessage unknownMessage = message.Unwrap<UnknownMessage>();
|
||||
|
||||
// Serial Receive - extract and push up frame in payload
|
||||
byte[] newFrame = unknownMessage.ToBytes();
|
||||
try
|
||||
{
|
||||
NA2WSerialFrame na2wSerialFrame = NA2WSerialFrame.Parse(newFrame, 10, (uint)newFrame.Length - 10);
|
||||
args.Frame = na2wSerialFrame;
|
||||
message = na2wSerialFrame;
|
||||
|
||||
// If waiting for response, trigger found if content is expected
|
||||
if (null != autoResetEvent)
|
||||
{
|
||||
// Utility.Log.Write("Message Found" + System.Environment.NewLine);
|
||||
foundResponse = na2wSerialFrame;
|
||||
autoResetEvent.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
pushMessageUp = true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
else if (message.Payload is CommandAckResponse)
|
||||
{
|
||||
// Throw away. Hat ACKing a command. For example, Serial Transmit command will ack.
|
||||
CommandAckResponse commandAckResponse = (CommandAckResponse)message.Payload;
|
||||
// Utility.Log.Write(String.Format("Command to Hat returned ack: {0}\n", commandAckResponse.AckCommandCode));
|
||||
}
|
||||
else if (message.Payload is CommandErrorResponse)
|
||||
{
|
||||
// Throw away. Hat ACKing a command. For example, Serial Transmit command will ack.
|
||||
CommandErrorResponse commandErrorResponse = (CommandErrorResponse)message.Payload;
|
||||
Log.Write(String.Format("Command to Hat returned error: {0} {1}\n", commandErrorResponse.ErrorCommandCode, commandErrorResponse.ErrorCode));
|
||||
}
|
||||
else if (message.Payload is CommDeviceSessionBegin)
|
||||
{
|
||||
CommDeviceSessionBegin commDeviceSessionBegin = (CommDeviceSessionBegin)message.Payload;
|
||||
sessionId = commDeviceSessionBegin.SessionID;
|
||||
}
|
||||
else if (message.Payload is CommDeviceSessionBeginV1)
|
||||
{
|
||||
CommDeviceSessionBeginV1 commDeviceSessionBegin = (CommDeviceSessionBeginV1)message.Payload;
|
||||
sessionId = commDeviceSessionBegin.SessionID;
|
||||
}
|
||||
else if (message.Payload is SerialEventNotification)
|
||||
{
|
||||
SerialEventNotification serialEventNotification = (SerialEventNotification)message.Payload;
|
||||
if (serialEventNotification.EventMap == 0x00) // CmdLinkII
|
||||
{
|
||||
Frame notification = (Frame)(serialEventNotification.Payload);
|
||||
byte[] notificationBytes = notification.ToBytes();
|
||||
|
||||
SByte idNum = notificationBytes.Read<SByte>((0 * 8) + 0, 8);
|
||||
// UInt64 timeStamp = notificationBytes.Read<UInt64>((1 * 8) + 0, 64);
|
||||
// UInt16 numDataBytes = notificationBytes.Read<UInt16>((9 * 8) + 0, 16);
|
||||
// UInt16 eventDataLength = (UInt16)((numDataBytes <= notificationBytes.Length - 11) ? numDataBytes : (notificationBytes.Length - 11));
|
||||
// byte[] eventData = new byte[eventDataLength];
|
||||
// Array.Copy(notificationBytes, 11, eventData, 0, eventDataLength);
|
||||
|
||||
if (idNum == 5) // ButtonClick
|
||||
{
|
||||
NfcCommand_InventoryRead nfcCommand = new NfcCommand_InventoryRead();
|
||||
SendNa2wSerial(nfcCommand, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (message.Payload is NfcCommandResponse)
|
||||
{
|
||||
NfcCommandResponse commandResponse = (NfcCommandResponse)message.Payload;
|
||||
|
||||
String dataString = "";
|
||||
bool readNDef = false;
|
||||
|
||||
if (0x00 == commandResponse.SubCommand)
|
||||
{
|
||||
// dataString = "Inventory -> Status = " + String.Format("{0:X2}", commandResponse.Status) + System.Environment.NewLine;
|
||||
readNDef = (0x00 == commandResponse.SubCommand);
|
||||
}
|
||||
else if (0x01 == commandResponse.SubCommand)
|
||||
{
|
||||
// dataString = "NDEF Read -> Status = " + String.Format("{0:X2}", commandResponse.Status) + System.Environment.NewLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataString = "Unknown -> Status = " + String.Format("{0:X2}", commandResponse.Status) + System.Environment.NewLine;
|
||||
}
|
||||
|
||||
byte[] data = commandResponse.AdditionalData;
|
||||
if ((data != null) && (data.Length > 0))
|
||||
{
|
||||
int numberOfBytes = data.Length;
|
||||
uint index = 0;
|
||||
|
||||
while (numberOfBytes > 16)
|
||||
{
|
||||
byte[] lineData = data.Read<byte[]>(index * 8, 16 * 8);
|
||||
|
||||
// dataString += lineData.ToHexString() + System.Environment.NewLine;
|
||||
|
||||
index += 16;
|
||||
numberOfBytes -= 16;
|
||||
}
|
||||
|
||||
if (numberOfBytes > 0)
|
||||
{
|
||||
byte[] lineData = data.Read<byte[]>(index * 8, (uint)(8 * numberOfBytes));
|
||||
|
||||
// dataString += lineData.ToHexString();
|
||||
}
|
||||
|
||||
if (0x00 == commandResponse.SubCommand)
|
||||
{
|
||||
// dataString += System.Environment.NewLine + System.Environment.NewLine + "----" + System.Environment.NewLine;
|
||||
// AdditionData[0] is tag ID
|
||||
// AdditionData[1 - 8] is UUID
|
||||
// AdditionalData[9 - 28] is UUID String
|
||||
tagId = System.Text.Encoding.ASCII.GetString(commandResponse.AdditionalData, 9, 20).TrimEnd('\0', '\n') ;
|
||||
}
|
||||
else if (0x01 == commandResponse.SubCommand)
|
||||
{
|
||||
// dataString += System.Environment.NewLine + System.Environment.NewLine + "----" + System.Environment.NewLine;
|
||||
// dataString += System.Text.Encoding.ASCII.GetString(commandResponse.AdditionalData, 0, commandResponse.AdditionalData.Length);
|
||||
|
||||
ndefData = commandResponse.AdditionalData;
|
||||
NdefMessage ndefMessage = new NdefMessage(ndefData);
|
||||
foreach (NdefRecord record in ndefMessage.recordList)
|
||||
{
|
||||
if (record.RecordType == NdefRecord.SensusNdefRecordType.ProductDetailsRecord)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProductDetailsRecord pdRecord = new ProductDetailsRecord(record.Payload.GetRawData());
|
||||
nfcTargetDetails = new NfcTargetDetails()
|
||||
{
|
||||
TagId = tagId,
|
||||
DeviceId = System.Text.Encoding.ASCII.GetString(pdRecord.ID1.ToArray()).Split(':')[1].Trim(),
|
||||
ProductType = System.Text.Encoding.ASCII.GetString(pdRecord.ProductType.ToArray()).Split(':')[1].Trim(),
|
||||
ProductVersion = System.Text.Encoding.ASCII.GetString(pdRecord.ProductTypeVersion.ToArray()).Split(':')[1].Trim(),
|
||||
};
|
||||
NfcTagDetected = true; // This uses nfcTargetDetails.
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log.Write(dataString);
|
||||
|
||||
if (readNDef)
|
||||
{
|
||||
NfcCommand_NdefRead nfcCommand = new NfcCommand_NdefRead();
|
||||
SendNa2wSerialToHat(nfcCommand, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pushMessageUp = true;
|
||||
}
|
||||
|
||||
if (pushMessageUp)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.MessageReceived.Raise(this, args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Write(String.Format("MessageReceived event handler threw: {0}", ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool nfcTagDetected;
|
||||
private byte[] rmaData;
|
||||
private byte[] ndefData;
|
||||
private string tagId = "";
|
||||
private NfcTargetDetails nfcTargetDetails;
|
||||
|
||||
public bool NfcTagDetected
|
||||
{
|
||||
get
|
||||
{
|
||||
return nfcTagDetected;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != nfcTagDetected)
|
||||
{
|
||||
nfcTagDetected = value;
|
||||
OnTagEvent(new TagEventArgs() { Present = value });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<TagEventArgs> TagEvent;
|
||||
|
||||
public byte[] NDEF { get { return ndefData; } }
|
||||
|
||||
public byte[] RMA { get { return rmaData; } }
|
||||
|
||||
public NfcTargetDetails NfcTargetDetails { get { return nfcTargetDetails; } }
|
||||
|
||||
protected virtual void OnTagEvent(TagEventArgs e)
|
||||
{
|
||||
EventHandler<TagEventArgs> handler = TagEvent;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler
|
||||
{
|
||||
public delegate void DelNfcMessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public delegate void DelNfc_ST25DV_MessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public delegate void DelNfc_CR95HF_MessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public delegate void DelNfc_MCI_MessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public delegate void DelNfc_NFCHeadConfig_MessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public class NfcMessageEventArgs
|
||||
{
|
||||
public string Message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,584 @@
|
||||
using NA2WNFC;
|
||||
using NfcC7_DLL.NfcHanler.Utils;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet.Serial;
|
||||
using Sensus.Protocols.FlexNet.Serial.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler
|
||||
{
|
||||
class NfcReader : ISerialConnection, IDisposable
|
||||
{
|
||||
public static string[] AvailableReaders { get { return NFCReader.GetAvailableReaders().ToArray(); } }
|
||||
private NFCReader Reader;
|
||||
private Thread InventoryThread;
|
||||
private bool nfcTagDetected;
|
||||
private byte[] rmaData;
|
||||
private byte[] ndefData;
|
||||
private NfcTargetDetails nfcTargetDetails;
|
||||
|
||||
public static string TimeFormatString = "yyyy-MM-dd HH:mm:ss.fffzz";
|
||||
|
||||
public int KeepAlive_S { set { if (value > delayResponseCountdown) { delayResponseCountdown = value; } } }
|
||||
|
||||
public bool NfcTagDetected
|
||||
{
|
||||
get
|
||||
{
|
||||
return nfcTagDetected;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != nfcTagDetected)
|
||||
{
|
||||
nfcTagDetected = value;
|
||||
OnTagEvent(new TagEventArgs() { Present = value });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<TagEventArgs> TagEvent;
|
||||
|
||||
public byte[] NDEF { get { return ndefData; } }
|
||||
|
||||
public byte[] RMA { get { return rmaData; } }
|
||||
|
||||
public NfcTargetDetails NfcTargetDetails { get { return nfcTargetDetails; } }
|
||||
|
||||
protected virtual void OnTagEvent(TagEventArgs e)
|
||||
{
|
||||
EventHandler<TagEventArgs> handler = TagEvent;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public NfcReader(string name)
|
||||
{
|
||||
Reader = new NFCReader(name, 64, 128);
|
||||
InitializeListener();
|
||||
rmaData = new byte[0];
|
||||
ndefData = new byte[0];
|
||||
nfcTargetDetails = new NfcTargetDetails() { DeviceId = "", ProductType = "", ProductVersion = "" };
|
||||
}
|
||||
|
||||
protected void InitializeListener()
|
||||
{
|
||||
receiveQueue = new BlockingQueue<ReceptionEventArgs<ISerialMessageFrame>>();
|
||||
|
||||
eventThread = ThreadHelpers.MakeThread("NFC RX", MessageReceivedLoop);
|
||||
eventThread.IsBackground = true;
|
||||
eventThread.Start();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Close();
|
||||
|
||||
Reader.ReleaseReader();
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
Reader.ConnectReader();
|
||||
|
||||
if (IsConnected)
|
||||
{
|
||||
lastActivity = DateTime.MinValue;
|
||||
|
||||
InventoryThread = ThreadHelpers.MakeThread("NFC Inventory", Inventory);
|
||||
InventoryThread.IsBackground = true;
|
||||
InventoryThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
nfcTargetDetails = new NfcTargetDetails() { DeviceId = "", ProductType = "", ProductVersion = "" };
|
||||
|
||||
if (IsConnected)
|
||||
{
|
||||
if (InventoryThread != null)
|
||||
{
|
||||
InventoryThread.Abort();
|
||||
}
|
||||
|
||||
if (sendThread != null)
|
||||
{
|
||||
sendThread.Abort();
|
||||
sendThread = null;
|
||||
}
|
||||
|
||||
if (eventThread != null)
|
||||
{
|
||||
eventThread.Abort();
|
||||
eventThread = null;
|
||||
}
|
||||
|
||||
NfcTagDetected = false;
|
||||
|
||||
try
|
||||
{
|
||||
Reader.DisconnectReader();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
Reader.ReleaseReader();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return Reader.IsConnected(); }
|
||||
}
|
||||
|
||||
object objectLock = new Object();
|
||||
|
||||
public event EventHandler<ReceptionEventArgs<ISerialMessageFrame>> MessageReceived;
|
||||
|
||||
public event EventHandler<EventArgs> Disconnected;
|
||||
|
||||
public ClassicSerialMessageFrame SendFlexNetSerial(ISerialCommandFrame cmd, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
ClassicSerialMessageFrame response = null;
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected)
|
||||
{
|
||||
NA2WSerialFrame rxFrame = null;
|
||||
|
||||
if (String.IsNullOrEmpty(Reader.TagSerialNumber))
|
||||
{
|
||||
if (Reader.IsConnected())
|
||||
{
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
// If no tag is found this is throwing system exception. Possiblity because
|
||||
// in UI thread.
|
||||
try
|
||||
{
|
||||
Reader.Inventory();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(Reader.TagSerialNumber))
|
||||
{
|
||||
byte[] response = null;
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
if (responseExpected)
|
||||
{
|
||||
response = Reader.SendMailboxMessage(cmdFrame.ToBytes(), TimeSpan.FromSeconds(6));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Even though response not expected, sniff for 1 second
|
||||
response = Reader.SendMailboxMessage(cmdFrame.ToBytes(), TimeSpan.FromSeconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
lastActivity = DateTime.Now;
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
rxFrame = NA2WSerialFrame.Parse(response);
|
||||
ReceptionEventArgs<ISerialMessageFrame> eventFrame = new ReceptionEventArgs<ISerialMessageFrame>() { Frame = rxFrame };
|
||||
MessageReceived(this, eventFrame);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Utility.Log.Write(response.ToHexString());
|
||||
}
|
||||
|
||||
// Response. Could be more. Extend polling for 2 seconds. Trigger read.
|
||||
KeepAlive_S = 2;
|
||||
InventoryThread.Interrupt();
|
||||
}
|
||||
else
|
||||
{
|
||||
// No response, poll for commulative 10 seconds
|
||||
KeepAlive_S = (responseExpected ? 4 : 9);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Utility.Log.Write("No tag found." + System.Environment.NewLine);
|
||||
}
|
||||
|
||||
return rxFrame;
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
NA2WSerialFrame rxFrame = null;
|
||||
|
||||
if (String.IsNullOrEmpty(Reader.TagSerialNumber))
|
||||
{
|
||||
if (Reader.IsConnected())
|
||||
{
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
// If no tag is found this is throwing system exception. Possiblity because
|
||||
// in UI thread.
|
||||
try
|
||||
{
|
||||
Reader.Inventory();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(Reader.TagSerialNumber))
|
||||
{
|
||||
byte[] response = null;
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
if (responseExpected)
|
||||
{
|
||||
response = Reader.SendMailboxMessage(cmdFrame.ToBytes(), TimeSpan.FromMilliseconds(timeoutMs));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Even though response not expected, sniff for 1 second
|
||||
response = Reader.SendMailboxMessage(cmdFrame.ToBytes(), TimeSpan.FromSeconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
lastActivity = DateTime.Now;
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
rxFrame = NA2WSerialFrame.Parse(response);
|
||||
ReceptionEventArgs<ISerialMessageFrame> eventFrame = new ReceptionEventArgs<ISerialMessageFrame>() { Frame = rxFrame };
|
||||
MessageReceived(this, eventFrame);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Utility.Log.Write(response.ToHexString());
|
||||
}
|
||||
|
||||
// Response. Could be more. Extend polling for 2 seconds. Trigger read.
|
||||
KeepAlive_S = 2;
|
||||
InventoryThread.Interrupt();
|
||||
}
|
||||
else
|
||||
{
|
||||
// No response, poll for commulative 10 seconds
|
||||
KeepAlive_S = (responseExpected ? 4 : 9);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Utility.Log.Write("No tag found." + System.Environment.NewLine);
|
||||
}
|
||||
|
||||
return rxFrame;
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, byte responseCommmandCode)
|
||||
{
|
||||
NA2WSerialFrame rxFrame = null;
|
||||
|
||||
if (String.IsNullOrEmpty(Reader.TagSerialNumber))
|
||||
{
|
||||
if (Reader.IsConnected())
|
||||
{
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
// If no tag is found this is throwing system exception. Possiblity because
|
||||
// in UI thread.
|
||||
try
|
||||
{
|
||||
Reader.Inventory();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(Reader.TagSerialNumber))
|
||||
{
|
||||
byte[] response = null;
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
response = Reader.SendMailboxMessage(cmdFrame.ToBytes(), TimeSpan.FromSeconds(6));
|
||||
}
|
||||
|
||||
lastActivity = DateTime.Now;
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
rxFrame = NA2WSerialFrame.Parse(response);
|
||||
if (rxFrame.CommandCode != responseCommmandCode)
|
||||
{
|
||||
ReceptionEventArgs<ISerialMessageFrame> eventFrame = new ReceptionEventArgs<ISerialMessageFrame>() { Frame = rxFrame };
|
||||
MessageReceived(this, eventFrame);
|
||||
rxFrame = null;
|
||||
|
||||
// Response. Could be more. Extend polling for 2 seconds. And read again
|
||||
KeepAlive_S = 2;
|
||||
InventoryThread.Interrupt();
|
||||
}
|
||||
else
|
||||
{
|
||||
// No response, poll for commulative 10 seconds
|
||||
KeepAlive_S = 4;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Utility.Log.Write("No tag found." + System.Environment.NewLine);
|
||||
}
|
||||
|
||||
return rxFrame;
|
||||
}
|
||||
|
||||
|
||||
public void SerialMessageFound(object sender, ReceptionEventArgs<ISerialMessageFrame> e)
|
||||
{
|
||||
receiveQueue.Enqueue(e);
|
||||
}
|
||||
|
||||
public List<NdefRecord> GetNdefRecords()
|
||||
{
|
||||
List<NdefRecord> records = new List<NdefRecord>();
|
||||
if (Reader != null && Reader.IsConnected())
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
records = Reader.Read_Ndef_Records();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log.Write($"{ex.Message}\n{ex.StackTrace}\n");
|
||||
}
|
||||
}
|
||||
return records;
|
||||
}
|
||||
public byte[] Get_Ndef_Data()
|
||||
{
|
||||
if (Reader != null && Reader.IsConnected())
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
ndefData = Reader.Read_Ndef_RawData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log.Write($"{ex.Message}\n{ex.StackTrace}\n");
|
||||
}
|
||||
}
|
||||
return ndefData;
|
||||
}
|
||||
|
||||
public byte[] Get_RMA_Data()
|
||||
{
|
||||
if (Reader != null && Reader.IsConnected())
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
rmaData = Reader.Read_RMA_RawData(false, string.Empty);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utility.Log.Write($"{ex.Message}\n{ex.StackTrace}\n");
|
||||
}
|
||||
}
|
||||
return rmaData;
|
||||
}
|
||||
|
||||
private void MessageReceivedLoop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
ReceptionEventArgs<ISerialMessageFrame> m = receiveQueue.Dequeue();
|
||||
|
||||
try
|
||||
{
|
||||
MessageReceived.Raise(this, m);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utility.Log.Write(String.Format("FrameReceived event handler threw: {0}", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Inventory()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (delayResponseCountdown <= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Reader.IsConnected())
|
||||
{
|
||||
if ((DateTime.Now - lastActivity).TotalSeconds > 4) // Timestamp based check
|
||||
{
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
Reader.Inventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
|
||||
if (String.IsNullOrEmpty(Reader.TagSerialNumber) &&
|
||||
NfcTagDetected == true)
|
||||
{
|
||||
Utility.Log.Write(DateTime.Now.ToString(TimeFormatString) + " : " + "Disconnected from tag.\n");
|
||||
nfcTargetDetails = new NfcTargetDetails() { DeviceId = "", ProductType = "", ProductVersion = "" };
|
||||
NfcTagDetected = false; // This uses nfcTargetDetails.
|
||||
tagSerialNumber = "";
|
||||
}
|
||||
else if (!String.IsNullOrEmpty(Reader.TagSerialNumber) &&
|
||||
!tagSerialNumber.Equals(Reader.TagSerialNumber))
|
||||
{
|
||||
// Transitioning from disconnected to connected or tag serial number has changed
|
||||
tagSerialNumber = Reader.TagSerialNumber;
|
||||
|
||||
// Read NDEF record to logging.
|
||||
String productType = "";
|
||||
String productVersion = "";
|
||||
String sfID = "";
|
||||
try
|
||||
{
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
productType = Reader.Read_Ndef_Product_Type();
|
||||
productType = (!String.IsNullOrEmpty(productType) ? productType.Trim() : "No PT NDEF message");
|
||||
productVersion = Reader.Read_Ndef_Product_Type_Version();
|
||||
productVersion = (!String.IsNullOrEmpty(productVersion) ? (" " + productVersion.Trim()) : "");
|
||||
sfID = Reader.Read_Ndef_ID1();
|
||||
sfID = (!String.IsNullOrEmpty(sfID) ? (" " + sfID.Trim()) : "");
|
||||
ndefData = Reader.Read_Ndef_RawData();
|
||||
rmaData = Reader.Read_RMA_RawData(false, string.Empty);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
Utility.Log.Write(DateTime.Now.ToString(TimeFormatString) + " : " + String.Format("Connected to NFC tag, {0} ({1}{2}{3}).\n", Reader.TagSerialNumber, productType, productVersion, sfID));
|
||||
try
|
||||
{
|
||||
nfcTargetDetails = new NfcTargetDetails()
|
||||
{
|
||||
DeviceId = sfID.Split(':')[1],
|
||||
ProductType = productType.Split(':')[1],
|
||||
ProductVersion = productVersion.Split(':')[1]
|
||||
};
|
||||
NfcTagDetected = true; // This uses nfcTargetDetails.
|
||||
}
|
||||
catch { }
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Thread.Sleep(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Reader.IsConnected())
|
||||
{
|
||||
delayResponseCountdown--;
|
||||
|
||||
byte[] response = null;
|
||||
lock (transactionInProgress)
|
||||
{
|
||||
response = Reader.ReadMailboxMessage(TimeSpan.FromSeconds(0)); ;
|
||||
}
|
||||
|
||||
lastActivity = DateTime.Now;
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
NA2WSerialFrame rxFrame = NA2WSerialFrame.Parse(response);
|
||||
ReceptionEventArgs<ISerialMessageFrame> eventFrame = new ReceptionEventArgs<ISerialMessageFrame>() { Frame = rxFrame };
|
||||
SerialMessageFound(this, eventFrame);
|
||||
}
|
||||
catch { }
|
||||
|
||||
// Response. Could be more. Extend polling for 2 seconds.
|
||||
KeepAlive_S = 2; ;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DateTime lastActivity;
|
||||
private Thread sendThread;
|
||||
private Thread eventThread;
|
||||
private BlockingQueue<ReceptionEventArgs<ISerialMessageFrame>> receiveQueue;
|
||||
private object transactionInProgress = new object();
|
||||
private int delayResponseCountdown = 0;
|
||||
private String tagSerialNumber = "";
|
||||
}
|
||||
|
||||
public class TagEventArgs : EventArgs
|
||||
{
|
||||
public bool Present { get; set; }
|
||||
}
|
||||
|
||||
public class NfcTargetDetails
|
||||
{
|
||||
public string TagId { get; set; }
|
||||
public string ProductType { get; set; }
|
||||
public string ProductVersion { get; set; }
|
||||
public string DeviceId { get; set; }
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,848 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>NA2WNFC</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="M:NA2WNFC.NativeMethods.SCardEstablishContext(System.Int32,System.Int32,System.Int32,System.Int32@)">
|
||||
The SCardEstablishContext function instantiates a context for the application
|
||||
within the PC/SC Resource Manager. This must be the first function called in a
|
||||
PC/SC application.
|
||||
|
||||
Parameters: dwScope - Scope of communication context. Can be either SCARD_SCOPE_USER
|
||||
or SCARD_SCOPE_SYSTEM.
|
||||
pvReserved1(in) - System Reserved and Must be NULL.
|
||||
pvReserved2(in) - System Reserved and Must be NULL.
|
||||
PhContext(out) - Handle to the PC/SC resource manager(established communication context).
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NativeMethods.SCardReleaseContext(System.Int32)">
|
||||
The SCardReleaseContext function destroys the application context within the
|
||||
PC/SC Resource Manager. This must be the last function called in a PC/SC
|
||||
application.
|
||||
|
||||
Parameters: hContext(in) - Handle that identifies the Communication context returned from
|
||||
SCardEstablishContext/ Handle to be released.
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NativeMethods.SCardListReaders(System.Int32,System.Byte[],System.Byte[],System.Int32@)">
|
||||
The ScardListReaders functions returns a list of currently available readers on
|
||||
the system, optionally filtered by a set of named reader groups. Application must parse the buffer
|
||||
storing names of readers to retrieve the name of individual reader. mszReaders is a pointer
|
||||
to a character string that is allocated by the application. If the application sends szReaders
|
||||
as NULL then this function returns the size of the buffer needed to allocate in pcchReaders.
|
||||
If value pointed by pcchReaders is specified as SCARD_AUTOALLOCATE, then mszReaders is casted
|
||||
as a pointer to a pointer, and receives the address of a block of memory containing the
|
||||
character string, allocated by the PC/SC API. This block of memory must be deallocated by the
|
||||
calling application with SCardFreeMemory. On success, mszReaders is a multi-string and separated
|
||||
by a null character ('\0') and ended by a double null character (e.g. "Reader A\0Reader B\0\0").
|
||||
|
||||
Parameters: hContext(in) - Connection context to the PC/SC Resource Manager/ Handle that identifies the
|
||||
communication context for the query (returned from a previous call to SCardEstablish
|
||||
Context).
|
||||
mszGroups(in) - List of groups to list readers/ Name of reader groups defined in the system. Use NULL here.
|
||||
MszReaders(out) - Multi-string buffer with list of readers. Reader names are separated by NULL characters.
|
||||
pcchReaders(in) - Max. length of mszReaders
|
||||
(out) - Actual Length of the multi-string buffer in characters including NULL.
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NativeMethods.SCardConnect(System.Int32,System.String,System.Int32,System.Int32,System.Int32@,System.Int32@)">
|
||||
The SCardConnect function establishes a connection between the calling application and a specific
|
||||
reader.
|
||||
|
||||
Parameters: hContext(in) - Connection context to the PC/SC Resource Manager/ Handle that identifies
|
||||
the communication context returned from a previous call to SCardEstablish
|
||||
Context.
|
||||
szReader(in) - The name of the reader
|
||||
dwShareMode(in) - Exclusive or shared connection
|
||||
dwPreferredProtocols(in) - Bit-mask specifying the list of acceptable card protocols
|
||||
phCard(out) - Handle to the reader/ Handle that identifies the connection to the specified
|
||||
reader
|
||||
pdwActiveProtocol(in) - The smart card protocol to be used in the subsequent communication
|
||||
(out) - Actual protocol selected by the reader
|
||||
</member>
|
||||
<member name="T:NA2WNFC.INdefRecordPayload">
|
||||
<summary>
|
||||
Interface for all type of NFC record payload
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.INdefRecordPayload.ToString">
|
||||
<summary>
|
||||
Get Payload as String
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.INdefRecordPayload.GetRawData">
|
||||
<summary>
|
||||
Get Payload as Raw Data
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.INdefRecordPayload.Text_Record_Status_Byte">
|
||||
<summary>
|
||||
Length of Language Code if the Record is a Text Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.INdefRecordPayload.Language_Code">
|
||||
<summary>
|
||||
Language Code if the Record is a Text Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:NA2WNFC.NdefMessage">
|
||||
<summary>
|
||||
Class for NDEF Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:NA2WNFC.NdefMessage.rawData">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:NA2WNFC.NdefMessage.recordList">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NdefMessage.#ctor(System.Byte[])">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="rawData"></param>
|
||||
</member>
|
||||
<member name="T:NA2WNFC.NdefRecord">
|
||||
<summary>
|
||||
Class for NDEF Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NdefRecord.Payload">
|
||||
<summary>
|
||||
Actual Payload of NDEF Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NdefRecord.Is_Text_Record">
|
||||
<summary>
|
||||
Indicates if the NDEF Record is a Text Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NdefRecord.RecordSize">
|
||||
<summary>
|
||||
Size of NDEF Record in number of Bytes
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:NA2WNFC.NdefRecord.SensusNdefRecordType">
|
||||
<summary>
|
||||
All avaliable types of NDEF Record in Sensus NA2W products
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:NA2WNFC.NdefRecord.SensusNdefRecordType.ProductDetailsRecord">
|
||||
<summary>
|
||||
NA2W Product Details Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:NA2WNFC.NdefRecord.SensusNdefRecordType.CRCRecord">
|
||||
<summary>
|
||||
NA2W CRC Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:NA2WNFC.NdefRecord.SensusNdefRecordType.MeterReadRecord">
|
||||
<summary>
|
||||
NA2W Meter Read Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:NA2WNFC.NdefRecord.RecordType">
|
||||
<summary>
|
||||
Type of Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NdefRecord.Parse(System.Byte[],System.Int32)">
|
||||
<summary>
|
||||
Parse a standard NDEF record from raw data
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NdefRecordText.Text_Record_Status_Byte">
|
||||
<summary>
|
||||
Length of Language Code if the Record is a Text Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NdefRecordText.Language_Code">
|
||||
<summary>
|
||||
Language Code if the Record is a Text Record
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:NA2WNFC.NFCReader">
|
||||
<summary>
|
||||
NFC Reader class to use HID Omnikey reader
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NFCReader.AvailableReaders">
|
||||
<summary>
|
||||
List of Available Readers
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NFCReader.TagSerialNumber">
|
||||
<summary>
|
||||
Serial number of the NFC Tag
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NFCReader.ReaderName">
|
||||
<summary>
|
||||
Currently Selected Reader
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.NFCReader.EnableLogging">
|
||||
<summary>
|
||||
Enable or Disable failure logging
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.#ctor(System.String,System.Byte,System.Byte)">
|
||||
<summary>
|
||||
Create a new instance of NFC Reader type
|
||||
</summary>
|
||||
<param name="readername">Full Readername as string e.g. "HID Global OMNIKEY 5022 Smart Card Reader 0"</param>
|
||||
<param name="RMA_Start_Block">Starting Block Address of RMA data, 0 if there is no RMA data</param>
|
||||
<param name="RMA_Last_Block">Last Block Address of RMA data, 0 if there is no RMA data</param>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.GetAvailableReaders">
|
||||
<summary>
|
||||
Get the list of Available Readers
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>The list of available readers, empty list otherwise </returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.ConnectReaderDoInventory">
|
||||
<summary>
|
||||
Connect to the NFC Reader and do an Inventory. This function must be called first before using any other function
|
||||
from this library. This function will automatically select the first tag.
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>0 if the Connection was successful, -1 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.ConnectReader">
|
||||
<summary>
|
||||
Connect to the the NFC Reader. This function must be called first before using any other function
|
||||
from this library. Call Inventory() after this function.
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>0 if the Connection was successful, -1 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Inventory">
|
||||
<summary>
|
||||
Connect to the the NFC Reader. This function must be called first before using any other function
|
||||
from this library
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>0 if the Connection was successful, -1 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.DisconnectReader">
|
||||
<summary>
|
||||
Disconnect the NFC Reader.
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>0 if the Disconnection was successful, -1 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.ReleaseReader">
|
||||
<summary>
|
||||
Release the NFC Reader. This function must be the last function to call
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>0 if the release was successful, -1 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.IsConnected">
|
||||
<summary>
|
||||
Check whether the NFC reader is succesfully connected
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>True if it is connected, false otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_RawData">
|
||||
<summary>
|
||||
Read the whole NDEF message from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>byte array if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_Records">
|
||||
<summary>
|
||||
Read all the NDEF records from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>List of NdefRecords if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Product_Details_Record">
|
||||
<summary>
|
||||
Read the Product Details Record from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Product Details Record if reading was successfull, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Meter_Read_Record">
|
||||
<summary>
|
||||
Read the Meter Read Record from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Meter Read Record if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_Product_Details_Identifier">
|
||||
<summary>
|
||||
Read the Product Details Identifier from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Product Details Identifier string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_Product_Type">
|
||||
<summary>
|
||||
Read the Product Type from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Product Type string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_Product_Type_Version">
|
||||
<summary>
|
||||
Read the Product Type Version from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Product Type Version string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_ID1">
|
||||
<summary>
|
||||
Read ID1 from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>ID1 string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_ID2">
|
||||
<summary>
|
||||
Read ID2 from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>ID2 string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_ID3">
|
||||
<summary>
|
||||
Read ID3 from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>ID3 string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_ID4">
|
||||
<summary>
|
||||
Read ID4 from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>ID4 string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_BoardID">
|
||||
<summary>
|
||||
Read Board ID from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Board ID string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_VariantID">
|
||||
<summary>
|
||||
Read Variant ID from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Variant ID string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_Meter_Read_Identifier">
|
||||
<summary>
|
||||
Read Meter Read Identifier from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Meter Read Identifier string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_Meter_Volume">
|
||||
<summary>
|
||||
Read Meter Volume from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Meter Volume string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_Meter_Unit">
|
||||
<summary>
|
||||
Read Meter Unit from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Meter Unit string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_Meter_DateTime">
|
||||
<summary>
|
||||
Read Meter DateTime from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Meter DateTime string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Ndef_ChecksumString">
|
||||
<summary>
|
||||
Read Checksum string from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Checksum string if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_Parse_Ndef_Checksum">
|
||||
<summary>
|
||||
Read and Parse Checksum Value from the tag
|
||||
</summary>
|
||||
<param></param>
|
||||
<returns>Checksum value if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_RawData(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read RMA Raw Data from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Byte array of Raw Data if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_MapRev(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read RMA Map Revision from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>RMA Map Revision if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_StorageSize(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read RMA Storage Size from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>RMA Storage Size if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_Spare(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read RMA Spare Bytes from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>RMA Spare Bytes if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_NumOfResets(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Number of Resets from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Number of Resets if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_NumOfWDResets(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Number of WatchDog Resets from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Number of WatchDog Resets if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_ResetReasons(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Reset Reasons from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>List of Reset Reasons if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_ResetTime(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Reset Time from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>List of Reset Time if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_UpdateTime(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read RMA Update Time from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>RMA Update Time if reading was successful, 0 otherwise.</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_SecondsBatActive(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Number of Battery Active Seconds from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Number of Battery Active Seconds if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_SecondsInstallation(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Number of Seconds Since Installation from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Number of Seconds Since Installation if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_VolumeReading(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Volume Reading from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Volume Reading if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_LifeTimeTotalizer(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Life Time Totalizer from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Life Time Totalizer if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_SecondsTestTotalizerActive(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Test Totalizer Active Seconds from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Test Totalizer Active Seconds if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_PreDefAlarmInfo(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read PreDefined Alarms Info from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>PreDefined Alarms Info if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_PreDefAlarmInfo_Raw(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read PreDefined Alarm Info from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>PreDefined Alarm Info if reading was successful, 0 otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_UserDefAlarmInfo(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read User Defined Alarms Info from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>User Defined Alarms Info if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_UserDefAlarmInfo_Raw(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read User Defined Alarm Info from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>User Defined Alarm Info if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_AdapterFactoryID(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Adapter Factory ID from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Adapter Factory ID if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_AdapterFactoryID_Raw(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Adapter Factory ID from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Adapter Factory ID if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_AdapterFWVersion(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Adapter Firmware Version from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Adapter Firmware Version if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.Read_RMA_AdapterFWVersion_Raw(System.Boolean,System.String)">
|
||||
<summary>
|
||||
Read Adapter Firmware Version from the tag
|
||||
</summary>
|
||||
<param name="passwordprotected">True if RMA is password protected, False otherwise</param>
|
||||
<param name="password">RMA area password as a Hex string without "0x" and spaces,if RMA is password protected and RMA password is different
|
||||
from defaul password. If RMA is not password protected or RMA password is a default password, use empty string as a parameter</param>
|
||||
<returns>Adapter Firmware Version if reading was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.SendMailboxMessage(System.Byte[],System.TimeSpan)">
|
||||
<summary>
|
||||
Send Receive Mailbox Message
|
||||
</summary>
|
||||
<param name="message">Message array</param>
|
||||
<param name="timeout">Timeout for Response from the tag</param>
|
||||
<returns>Received Message if transaction was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.SendMailbox_FlexNet_Serial_Ping(System.TimeSpan)">
|
||||
<summary>
|
||||
Send FlexNet Serial Ping through Mailbox
|
||||
</summary>
|
||||
<param name="timeout">Timeout for Response from the tag</param>
|
||||
<returns>"1B019C01006215" if transaction was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.NFCReader.ReadMailboxMessage(System.TimeSpan)">
|
||||
<summary>
|
||||
Receive Mailbox Message
|
||||
</summary>
|
||||
<param name="timeout">Timeout for Response from the tag</param>
|
||||
<returns>Received Message if transaction was successful, null otherwise</returns>
|
||||
</member>
|
||||
<member name="T:NA2WNFC.Properties.Resources">
|
||||
<summary>
|
||||
A strongly-typed resource class, for looking up localized strings, etc.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.Properties.Resources.ResourceManager">
|
||||
<summary>
|
||||
Returns the cached ResourceManager instance used by this class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.Properties.Resources.Culture">
|
||||
<summary>
|
||||
Overrides the current thread's CurrentUICulture property for all
|
||||
resource lookups using this strongly typed resource class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:NA2WNFC.RMAPreDefinedAlarms">
|
||||
<summary>
|
||||
Class for PreDefined Alarms
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.RMAPreDefinedAlarms.#ctor(System.UInt64)">
|
||||
<summary>
|
||||
Create a new instance of RMA PreDefined Alarms
|
||||
</summary>
|
||||
<param name="info">8 bytes Raw data of PreDefined Alarms from RMA</param>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_UpgradeMode">
|
||||
<summary>
|
||||
Get the last known state of Upgrade Mode Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_SevereHardwareFailure">
|
||||
<summary>
|
||||
Get the last known state of Severe Hardware Failure Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_NVMemoryError">
|
||||
<summary>
|
||||
Get the last known state of NV Memory Error Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_DeadBattery">
|
||||
<summary>
|
||||
Get the last known state of Dead Battery Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_EmptyPipe">
|
||||
<summary>
|
||||
Get the last known state of Empty Pipe Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_MagneticTamper">
|
||||
<summary>
|
||||
Get the last known state of Magnetic Tamper Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_MeterDisconnectTamper">
|
||||
<summary>
|
||||
Get the last known state of Meter Disconnect Tamper Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_NearEndOfLife">
|
||||
<summary>
|
||||
Get the last known state of Near End Of Life Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_BeyondEndOfLife">
|
||||
<summary>
|
||||
Get the last known state of Beyond End Of Life Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_MetrologyCommError">
|
||||
<summary>
|
||||
Get the last known state of Metrology Comm Error Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_CriticalHardwareWarning">
|
||||
<summary>
|
||||
Get the last known state of Critical Hardware Warning Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_Reboot">
|
||||
<summary>
|
||||
Get the last known state of Reboot Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_EMFRange">
|
||||
<summary>
|
||||
Get the last known state of EMF Range Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_LowField">
|
||||
<summary>
|
||||
Get the last known state of Low Field Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_HighCurrent">
|
||||
<summary>
|
||||
Get the last known state of High Current Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_LowPrimaryBattery">
|
||||
<summary>
|
||||
Get the last known state of Low Primary Battery Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_LowSecondaryBattery">
|
||||
<summary>
|
||||
Get the last known state of Low Secondary Battery Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_GlideSlope">
|
||||
<summary>
|
||||
Get the last known state of Glide Slope Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_HighTemperature">
|
||||
<summary>
|
||||
Get the last known state of High Temperature Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_ConfigError">
|
||||
<summary>
|
||||
Get the last known state of Config Error Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_ActuatorFailure">
|
||||
<summary>
|
||||
Get the last known state of Actuator Failure Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAPreDefinedAlarms.PreDef_Alarm_HumiditySensorRead">
|
||||
<summary>
|
||||
Get the last known state of Humidity Sensor Read Alarm
|
||||
</summary>
|
||||
<returns>Alarm State Vector Entry</returns>
|
||||
</member>
|
||||
<member name="T:NA2WNFC.RMAUserDefinedAlarms">
|
||||
<summary>
|
||||
Class for User Defined Alarms
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NA2WNFC.RMAUserDefinedAlarms.#ctor(System.Collections.Generic.IEnumerable{System.Byte})">
|
||||
<summary>
|
||||
Create a new instance of RMA User Defined Alarms
|
||||
</summary>
|
||||
<param name="info">10 bytes Raw data of User Defined Alarms from RMA</param>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_0_Defintion">
|
||||
<summary>
|
||||
Get the defintion(type) of User Defined Alarm in Slot 0
|
||||
</summary>
|
||||
<returns>Enumeration value representing the type of alarm</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_1_Defintion">
|
||||
<summary>
|
||||
Get the defintion(type) of User Defined Alarm in Slot 1
|
||||
</summary>
|
||||
<returns>Enumeration value representing the type of alarm</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_2_Defintion">
|
||||
<summary>
|
||||
Get the defintion(type) of User Defined Alarm in Slot 2
|
||||
</summary>
|
||||
<returns>Enumeration value representing the type of alarm</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_3_Defintion">
|
||||
<summary>
|
||||
Get the defintion(type) of User Defined Alarm in Slot 3
|
||||
</summary>
|
||||
<returns>Enumeration value representing the type of alarm</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_0_State">
|
||||
<summary>
|
||||
Get the last known state of User Defined Alarm in Slot 0
|
||||
</summary>
|
||||
<returns>true if the alarm condition is present, false otherwise</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_1_State">
|
||||
<summary>
|
||||
Get the last known state of User Defined Alarm in Slot 1
|
||||
</summary>
|
||||
<returns>true if the alarm condition is present, false otherwise</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_2_State">
|
||||
<summary>
|
||||
Get the last known state of User Defined Alarm in Slot 2
|
||||
</summary>
|
||||
<returns>true if the alarm condition is present, false otherwise</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_3_State">
|
||||
<summary>
|
||||
Get the last known state of User Defined Alarm in Slot 3
|
||||
</summary>
|
||||
<returns>true if the alarm condition is present, false otherwise</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_0_ID">
|
||||
<summary>
|
||||
Get the ID of User Defined Alarm in Slot 0
|
||||
</summary>
|
||||
<returns>ID Value representing the alarm</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_1_ID">
|
||||
<summary>
|
||||
Get the ID of User Defined Alarm in Slot 1
|
||||
</summary>
|
||||
<returns>ID Value representing the alarm</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_2_ID">
|
||||
<summary>
|
||||
Get the ID of User Defined Alarm in Slot 2
|
||||
</summary>
|
||||
<returns>ID Value representing the alarm</returns>
|
||||
</member>
|
||||
<member name="P:NA2WNFC.RMAUserDefinedAlarms.User_Defined_Alarm_Slot_3_ID">
|
||||
<summary>
|
||||
Get the ID of User Defined Alarm in Slot 3
|
||||
</summary>
|
||||
<returns>ID Value representing the alarm</returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,69 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Protocols
|
||||
{
|
||||
[NA2WSerialProtocolCommand(NfcCommand_InventoryRead._Code, NfcCommand_InventoryRead._Version)]
|
||||
public class NfcCommand_InventoryRead : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 1;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x26;
|
||||
public const byte _Version = 0x00; // Use Sub Command field value
|
||||
|
||||
public NfcCommand_InventoryRead() : base(_Size)
|
||||
{
|
||||
SubCommand = _Version;
|
||||
}
|
||||
|
||||
public NfcCommand_InventoryRead(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
SubCommand = _Version;
|
||||
}
|
||||
|
||||
public static NfcCommand_InventoryRead Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<NfcCommand_InventoryRead>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte SubCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.ComponentModel;
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet;
|
||||
using Sensus.Protocols.FlexNet.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Protocols
|
||||
{
|
||||
[NA2WSerialProtocolCommand(NfcCommand_NdefRead._Code, NfcCommand_NdefRead._Version)]
|
||||
public class NfcCommand_NdefRead : BackedHeaders, INA2WSerialProtocolCommand
|
||||
{
|
||||
public const byte _Size = 1;
|
||||
public const DataLinkFrameType _FrameType = DataLinkFrameType.Command;
|
||||
public const byte _Code = 0x26;
|
||||
public const byte _Version = 0x01; // Use Sub Command field value
|
||||
|
||||
public NfcCommand_NdefRead() : base(_Size)
|
||||
{
|
||||
SubCommand = _Version;
|
||||
}
|
||||
|
||||
public NfcCommand_NdefRead(Func<byte[]> buffer, Func<UInt32> offset) : base(buffer, offset)
|
||||
{
|
||||
SubCommand = _Version;
|
||||
}
|
||||
|
||||
public static NfcCommand_NdefRead Parse(byte[] buffer, UInt32 offset, UInt32 length)
|
||||
{
|
||||
return Parse<NfcCommand_NdefRead>(buffer, offset, length);
|
||||
}
|
||||
|
||||
protected override void Initialize(UInt32 wholeMessageLength)
|
||||
{
|
||||
base.Initialize(wholeMessageLength);
|
||||
}
|
||||
|
||||
public override void Bake()
|
||||
{
|
||||
base.Bake();
|
||||
}
|
||||
|
||||
IFrame IFrame.Clone()
|
||||
{
|
||||
return Parse(Buffer, Offset, _Size);
|
||||
}
|
||||
|
||||
public T Unwrap<T>()
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override uint Size { get { return _Size; } set { } }
|
||||
|
||||
[Browsable(false)]
|
||||
public DataLinkFrameType FrameType { get { return _FrameType; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public byte CommandCode { get { return _Code; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public UInt32 PayloadLength { get; private set; }
|
||||
|
||||
public byte Version { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 4); } }
|
||||
public byte Reserved0 { get { return Buffer.Read<byte>((Offset + 0) * 8 + 4, 4); } set { Buffer.Write(value, (Offset + 0) * 8 + 4, 4); } }
|
||||
|
||||
public byte SubCommand { get { return Buffer.Read<byte>((Offset + 0) * 8 + 0, 8); } set { Buffer.Write(value, (Offset + 0) * 8 + 0, 8); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
using System.IO.Ports;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler
|
||||
{
|
||||
public class SERIAL_Driver
|
||||
{
|
||||
public string ErrorMessage { get; private set; }
|
||||
public Collection<byte> SerialPortReadBuffer = new Collection<byte>();
|
||||
private SerialPort _serialPort;
|
||||
|
||||
private List<byte[]> _binMessages = new List<byte[]>();
|
||||
private bool _isReading;
|
||||
private Parity Parity { get; set; }
|
||||
private StopBits StopBits { get; set; }
|
||||
|
||||
public SERIAL_Driver()
|
||||
{
|
||||
_serialPort = new SerialPort();
|
||||
}
|
||||
|
||||
public bool OpenConnection(string comPort, int baudrate, int dataBits, Parity parity, StopBits stopbits, int readTimeout=1000, int writeTimeout = 1000)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if ((_serialPort != null) && (_serialPort.IsOpen))
|
||||
{
|
||||
_serialPort.DataReceived -= DataReceivedHandler;
|
||||
_serialPort.Close();
|
||||
_serialPort.Dispose();
|
||||
_serialPort = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
ErrorMessage = "";
|
||||
//_serialPort = new SerialPort(comPort, 57600, Parity.None, 8, StopBits.Two);
|
||||
_serialPort = new SerialPort(comPort, baudrate, parity, dataBits, stopbits);
|
||||
_serialPort.ReadTimeout = readTimeout;
|
||||
_serialPort.WriteTimeout = writeTimeout;
|
||||
_serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
|
||||
_serialPort.Open();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Open failed {0}.{1}", comPort, ex.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_serialPort.IsOpen)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Can't Open {0}.", comPort);
|
||||
return false;
|
||||
}
|
||||
}//End Lock
|
||||
return true;
|
||||
}
|
||||
public bool SendMessage(byte[] sendDataBytes, int length, int readTimeout = 1000, int writeTimeout=1000)
|
||||
{
|
||||
if (!isOpen()) return false;
|
||||
if (sendDataBytes.Length == 0) return true; // nothing to send - no error
|
||||
try
|
||||
{
|
||||
PrepareReading(); //clear read buffer etc.
|
||||
_serialPort.WriteTimeout = writeTimeout;
|
||||
_serialPort.ReadTimeout = readTimeout;
|
||||
_serialPort.Write(sendDataBytes, 0, length);
|
||||
_isReading = true;
|
||||
Thread.Sleep(100);
|
||||
var stopWatch = Stopwatch.StartNew(); //start stop watch for data recevie timeout
|
||||
while (_isReading) //wait until reading finishes or timeout occur
|
||||
{
|
||||
if (stopWatch.ElapsedMilliseconds > readTimeout)
|
||||
{
|
||||
stopWatch.Stop();
|
||||
ErrorMessage = "COM error: Receive timeout";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Transmit timeout {0}.{1}", _serialPort.PortName, ex.Message);
|
||||
return false; // Exception in send function
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void PrepareReading()
|
||||
{
|
||||
_serialPort.DiscardInBuffer();
|
||||
if(_binMessages != null) _binMessages.Clear();
|
||||
_isReading = true;
|
||||
}
|
||||
public byte[] GetRawData()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _binMessages[0].ToArray();
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
byte[] err = { 0xFF };
|
||||
return err;
|
||||
}
|
||||
}
|
||||
private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
|
||||
{
|
||||
if (!_serialPort.IsOpen) return;
|
||||
lock (this)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
SerialPortReadBuffer = new Collection<byte>();
|
||||
while (_serialPort.BytesToRead > 0)
|
||||
{
|
||||
SerialPortReadBuffer.Add((byte)_serialPort.ReadByte());
|
||||
}
|
||||
|
||||
_binMessages.Add(SerialPortReadBuffer.ToArray());
|
||||
_isReading = false;
|
||||
}
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
if (isOpen())
|
||||
{
|
||||
_serialPort.Close();
|
||||
}
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (_serialPort != null)
|
||||
{
|
||||
_serialPort.Dispose();
|
||||
}
|
||||
}
|
||||
public bool isOpen()
|
||||
{
|
||||
if(_serialPort != null)
|
||||
return _serialPort.IsOpen;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GlobalIPerlUtility
|
||||
{
|
||||
public class SensusRFKey
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public byte[] Key;
|
||||
|
||||
|
||||
public static bool CheckKey(string keyStr)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
string[] check = keyStr.Split(' ');
|
||||
if(check.Length != 16)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < check.Length; i++)
|
||||
{
|
||||
byte testResult;
|
||||
if (!(byte.TryParse(check[i], System.Globalization.NumberStyles.HexNumber, null, out testResult))) //Check each bit.
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (testResult > 0xFF)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
bool ParseKey(string keyStr)
|
||||
{
|
||||
bool result = true;
|
||||
string[] check = keyStr.Split(' ');
|
||||
byte[] key = new byte[check.Length];
|
||||
//Check the length
|
||||
if(key.Length != 16)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < check.Length; i++) //Attempt to parse the key and shove it into a byte array
|
||||
{
|
||||
byte testResult;
|
||||
if (!(byte.TryParse(check[i], System.Globalization.NumberStyles.HexNumber, null, out testResult))) //Check each bit.
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
if (testResult > 0xFF)
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
key[i] = testResult;
|
||||
}
|
||||
|
||||
|
||||
if (result) //If we didn't fail, load it into the actual Key.
|
||||
{
|
||||
Key = key;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public SensusRFKey(string name, byte[] key)
|
||||
{
|
||||
Name = name;
|
||||
Key = key;
|
||||
|
||||
}
|
||||
|
||||
public SensusRFKey(string name, string keyStr)
|
||||
{
|
||||
Name = name;
|
||||
if (!ParseKey(keyStr))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Bad Key");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SensusRFKeyManager
|
||||
{
|
||||
public List<SensusRFKey> KeyList;
|
||||
|
||||
public bool AddKey(string name, string keyStr)
|
||||
{
|
||||
bool result = true;
|
||||
foreach(SensusRFKey key in KeyList)
|
||||
{
|
||||
if(key.Name == name)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
try
|
||||
{
|
||||
KeyList.Add(new SensusRFKey(name, keyStr));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool AddKey(string name, byte[] newKey)
|
||||
{
|
||||
bool result = true;
|
||||
foreach (SensusRFKey key in KeyList)
|
||||
{
|
||||
if (key.Name == name)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(result)
|
||||
{
|
||||
try
|
||||
{
|
||||
KeyList.Add(new SensusRFKey(name, newKey));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<string> GetNameList()
|
||||
{
|
||||
List<string> nameList = new List<string>();
|
||||
foreach(SensusRFKey key in KeyList)
|
||||
{
|
||||
nameList.Add(key.Name);
|
||||
}
|
||||
|
||||
return nameList;
|
||||
}
|
||||
|
||||
public byte[] GetKey(string name)
|
||||
{
|
||||
foreach(SensusRFKey key in KeyList)
|
||||
{
|
||||
if(key.Name == name)
|
||||
{
|
||||
return key.Key;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public SensusRFKeyManager()
|
||||
{
|
||||
KeyList = new List<SensusRFKey>();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FactoryKey
|
||||
{
|
||||
public static byte[] Value { get { return new byte[] { 0x90, 0xbe, 0x46, 0xa2, 0xc7, 0xb3, 0x09, 0x02, 0x28, 0xcf, 0x74, 0x96, 0x61, 0x10, 0xd8, 0xf2 }; } }
|
||||
}
|
||||
|
||||
class DefaultKey
|
||||
{
|
||||
public static byte[] Value { get { return new byte[] { 0xE6, 0xC8, 0x88, 0x00, 0xDE, 0xB8, 0x68, 0xC0, 0xD6, 0xA8, 0x48, 0x80, 0xCE, 0x98, 0x28, 0x40 }; } }
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.Poseidon.NfcHandler
|
||||
namespace NfcC7_DLL.NfcHanler
|
||||
{
|
||||
public static class Tools
|
||||
{
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace NfcC7_DLL.NfcHanler;
|
||||
|
||||
public class Utility
|
||||
{
|
||||
public class Logger
|
||||
{
|
||||
public void Write(string msg)
|
||||
{
|
||||
Console.WriteLine(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static Logger Log = new Logger();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class BoolInverter : IValueConverter
|
||||
{
|
||||
#region IValueConverter Members
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return !(bool)value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
[ValueConversion(typeof(bool), typeof(Visibility))]
|
||||
public class BoolToVisibility : IValueConverter
|
||||
{
|
||||
public Visibility TrueValue { get; set; }
|
||||
public Visibility FalseValue { get; set; }
|
||||
|
||||
public BoolToVisibility()
|
||||
{
|
||||
// set defaults
|
||||
TrueValue = Visibility.Visible;
|
||||
FalseValue = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
#region IValueConverter Members
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (!(value is bool))
|
||||
return null;
|
||||
return (bool)value ? TrueValue : FalseValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (Equals(value, TrueValue))
|
||||
return true;
|
||||
if (Equals(value, FalseValue))
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
using Sensus.Protocols.FlexNet;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class ChannelizedFlexNetId : IEquatable<ChannelizedFlexNetId> // TODO: maybe refactor this to include NA2W in the name
|
||||
{
|
||||
public static char SeparationChar = ':';
|
||||
public FlexNetID ID;
|
||||
public UInt32 Channel; // defaults to primary channel, which also can mean not used
|
||||
|
||||
public ChannelizedFlexNetId()
|
||||
: this(0, 0)
|
||||
{ }
|
||||
|
||||
public ChannelizedFlexNetId(UInt32 id)
|
||||
: this(id, 0)
|
||||
{ }
|
||||
|
||||
public ChannelizedFlexNetId(UInt32 id, UInt32 channel)
|
||||
{
|
||||
ID = (FlexNetID)id;
|
||||
Channel = channel;
|
||||
}
|
||||
|
||||
public ChannelizedFlexNetId(ChannelizedFlexNetId other)
|
||||
{
|
||||
ID = other.ID;
|
||||
Channel = other.Channel;
|
||||
}
|
||||
|
||||
public ChannelizedFlexNetId(string GUIstring)
|
||||
{
|
||||
string[] parts = GUIstring.Split(SeparationChar);
|
||||
UInt32 temp;
|
||||
bool parsedCorrectly = true;
|
||||
|
||||
// get FNID
|
||||
if (parts.Length >= 1)
|
||||
{
|
||||
if (Conversion.TryParseHexOrDecString(parts[0], out temp))
|
||||
{
|
||||
ID = (FlexNetID)temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
ID = 0;
|
||||
parsedCorrectly = false;
|
||||
}
|
||||
}
|
||||
|
||||
// get Channel
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
if (!Conversion.TryParseHexOrDecString(parts[1], out Channel))
|
||||
{
|
||||
Channel = 0;
|
||||
parsedCorrectly = false;
|
||||
}
|
||||
}
|
||||
|
||||
// throw exception here to keep ID or Channel, as one or both may be correct
|
||||
if (!parsedCorrectly)
|
||||
{
|
||||
throw new Exception("FNID and/or Channel is not hex or decimal string");
|
||||
}
|
||||
else if (!IsValid())
|
||||
{
|
||||
throw new Exception("FNID and/or Channel are/is not valid");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsValid(UInt32 id, UInt32 channel)
|
||||
{
|
||||
// only have 2^3=8 channels, but allow a little higher for testing
|
||||
// on firmware such that it will reject invalid channels
|
||||
return FlexNetID.IsValidDirect(id) && (channel < 16);
|
||||
}
|
||||
|
||||
public bool IsValid()
|
||||
{
|
||||
return ChannelizedFlexNetId.IsValid(ID, Channel);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string retStr = ID.ToString();
|
||||
if (Channel > 0)
|
||||
{
|
||||
retStr += (SeparationChar.ToString() + Channel.ToString());
|
||||
}
|
||||
return retStr;
|
||||
}
|
||||
|
||||
public bool Equals(ChannelizedFlexNetId other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((ID.ToString() == other.ID.ToString()) // need ToString(), else override Equals in class FlexNetID
|
||||
&& (Channel == other.Channel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse a string containing a FlexNet ID or a group address
|
||||
/// </summary>
|
||||
/// <param name="userText">The string containing the FlexNet ID in hex or decimal, or
|
||||
/// a group address in IPv4 octet notation. Can also contain FNID:Channel.</param>
|
||||
/// <param name="newFNID"></param>
|
||||
/// <returns>true if userText can successfully be parsed, false otherwise</returns>
|
||||
internal static bool TryParseFlexNetID(string userText, out ChannelizedFlexNetId newFNID)
|
||||
{
|
||||
UInt32 temp = 0;
|
||||
newFNID = new ChannelizedFlexNetId();
|
||||
try
|
||||
{
|
||||
if (userText.Contains('.'))
|
||||
{
|
||||
// user might be using group addressing in IPv4 format
|
||||
string[] octets = userText.Split('.');
|
||||
|
||||
if (octets.Length == 4)
|
||||
{
|
||||
// user *IS* using group addressing in IPv4 format
|
||||
foreach (var oct_str in octets)
|
||||
{
|
||||
byte oct_byte = byte.Parse(oct_str);
|
||||
temp = (UInt32)((temp << 8) | oct_byte);
|
||||
}
|
||||
newFNID.ID = temp;
|
||||
return true; // we got through all 4 octets w/o failing
|
||||
}
|
||||
// channel zero in newFNID
|
||||
}
|
||||
else if (userText.Contains(ChannelizedFlexNetId.SeparationChar))
|
||||
{
|
||||
try
|
||||
{
|
||||
newFNID = new ChannelizedFlexNetId(userText);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Conversion.TryParseHexOrDecString(userText, out temp))
|
||||
{
|
||||
newFNID.ID = temp; // channel is zero in newFNID
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// any kind of exception means user screwed up
|
||||
// continue to return false
|
||||
}
|
||||
|
||||
// none of the above worked out
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class Conversion
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to parse a string as a uint. If the string starts with "0x",
|
||||
/// it is assumed to be hex, otherwise, it is decimal.
|
||||
/// </summary>
|
||||
/// <param name="s">the string to parse</param>
|
||||
/// <param name="value">the value represented by s, if successfully parsed</param>
|
||||
/// <returns>true if the conversion was successful. False if s doesn't contain
|
||||
/// a valid integer.</returns>
|
||||
|
||||
public static bool TryParseHexOrDecString(string s, out Byte value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((s.Length > 2) && (s[0] == '0') && (s[1] == 'x'))
|
||||
{
|
||||
value = Convert.ToByte(s, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Byte.Parse(s);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
value = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static bool TryParseHexOrDecString(string s, out SByte value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((s.Length > 2) && (s[0] == '0') && (s[1] == 'x'))
|
||||
{
|
||||
value = Convert.ToSByte(s, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = SByte.Parse(s);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
value = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryParseHexOrDecString(string s, out Int16 value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((s.Length > 2) && (s[0] == '0') && (s[1] == 'x'))
|
||||
{
|
||||
value = Convert.ToInt16(s, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Int16.Parse(s);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
value = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryParseHexOrDecString(string s, out UInt16 value)
|
||||
{
|
||||
value = 0;
|
||||
try
|
||||
{
|
||||
if ((s.Length > 2) && (s[0] == '0') && (s[1] == 'x'))
|
||||
{
|
||||
s = s.Substring(2);
|
||||
value = Convert.ToUInt16(s, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Convert.ToUInt16(s);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool TryParseHexOrDecString(string s, out UInt32 value)
|
||||
{
|
||||
value = 0;
|
||||
try
|
||||
{
|
||||
if ((s.Length > 2) && (s[0] == '0') && (s[1] == 'x'))
|
||||
{
|
||||
s = s.Substring(2);
|
||||
value = Convert.ToUInt32(s, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Convert.ToUInt32(s);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryParseHexOrDecString(string s, out Int32 value)
|
||||
{
|
||||
value = 0;
|
||||
try
|
||||
{
|
||||
if ((s.Length > 2) && (s[0] == '0') && (s[1] == 'x'))
|
||||
{
|
||||
s = s.Substring(2);
|
||||
value = Convert.ToInt32(s, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Convert.ToInt32(s);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryParseHexOrDecString(string s, out UInt64 value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((s.Length > 2) && (s[0] == '0') && (s[1] == 'x'))
|
||||
{
|
||||
value = Convert.ToUInt64(s, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = UInt64.Parse(s);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
value = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a hex string to an array of bytes.
|
||||
/// </summary>
|
||||
/// <param name="hexString">A hexadecimal string. Must have an even number of nybbles (ie, no lone nybbles).
|
||||
/// Valid separators between bytes are ':', ',', '.', ' ', '\t', and '-'.
|
||||
/// </param>
|
||||
/// <returns>hexString converted to bytes. If hexString contains invalid characters or an odd number of nybbles, null is returned.</returns>
|
||||
public static byte[] HexStringToBytes(string hexString)
|
||||
{
|
||||
hexString = hexString.Replace("0x", "");
|
||||
hexString = hexString.Replace('\t', ' ');
|
||||
hexString = hexString.Replace(':', ' ');
|
||||
hexString = hexString.Replace('.', ' ');
|
||||
hexString = hexString.Replace('-', ' ');
|
||||
hexString = hexString.Replace(',', ' ');
|
||||
hexString = hexString.Replace(" ", "");
|
||||
|
||||
// string length cannot be ODD!
|
||||
if ((hexString.Length & 0x01) != 0) return null;
|
||||
|
||||
byte[] byteVals = new byte[hexString.Length / 2];
|
||||
|
||||
// parse the string one character at a time, going nybble by nybble
|
||||
for (int i = 0; i < byteVals.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
string byteStr = hexString.Substring(i * 2, 2);
|
||||
|
||||
byteVals[i] = (byte)int.Parse(byteStr, System.Globalization.NumberStyles.HexNumber);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
// the parsing failed, so skip this character in theChars
|
||||
}
|
||||
}
|
||||
|
||||
return byteVals;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
/*********************************************************************************************************
|
||||
**********************************************************************************************************
|
||||
ESDsaP256 Sign/Verify Parameter Classes:
|
||||
|
||||
********************************************************************************************************/
|
||||
public class ECDsaKeyPair
|
||||
{
|
||||
public byte[] priKey; // 32-byte private key (used for signing)
|
||||
public byte[] pubKey; // 64-byte public key (used for signature verification)
|
||||
public Boolean valid; // Flag to indicate that this object contains a valid key pair
|
||||
|
||||
// Constructor
|
||||
public ECDsaKeyPair()
|
||||
{
|
||||
this.priKey = new byte[32];
|
||||
this.pubKey = new byte[64];
|
||||
this.valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
public class ECDsaSignParams
|
||||
{
|
||||
public ECDsaKeyPair keyPair; // ECDsaKeyPair object containing a valid key pair
|
||||
public byte[] buffer; // buffer containing a packet to be signed (MAC header | MAC data)
|
||||
public int data_idx; // start index of the data to be signed
|
||||
public int data_len; // Length of the data to be signed
|
||||
public byte[] signature; // 64-byte buffer where signature will be returned
|
||||
}
|
||||
|
||||
public class ECDsaVerifyParams
|
||||
{
|
||||
public byte[] pubKey; // 64-byte public key (used for signature verification)
|
||||
public byte[] buffer; // buffer containing a packet to be verified (MAC header | MAC data | Signature)
|
||||
public int data_idx; // start index of the data to be verified
|
||||
public int data_len; // Length of the data to be verified
|
||||
public byte[] signature; // 64-byte buffer containing the signature to be verified
|
||||
}
|
||||
|
||||
public class ECDHExchangeParams
|
||||
{
|
||||
public UInt32 endpoint_id; // 32-bit FlexNet ID
|
||||
public byte[] pubKey_e; // 64-byte edpoint public key
|
||||
public byte[] pubKey_r; // 64-byte RNI public key
|
||||
public byte[] empKey; // 64-byte emphemeral key
|
||||
public byte[] symKey; // 32-byte derived symmetric key
|
||||
}
|
||||
|
||||
public static class FNv2_ECDsaP256_wSHA256
|
||||
{
|
||||
public static String VERSION = "160421-1.4";
|
||||
|
||||
public static byte _PRI_KEY_SIZE = 32;
|
||||
public static byte _PUB_KEY_SIZE = 64;
|
||||
public static byte _ECC_SIG_SIZE = 64;
|
||||
public static byte _KEY_BLOB_HDR = 8;
|
||||
|
||||
// Version 1.0 - Released 03.06.2016 - Stephen Schamber - Sensus USA Inc
|
||||
// Initial release to support ESCDaP256 w/ SHA-256 Ellipic Curve Cryptopgraphy Sign/Verify
|
||||
// Supports ECDsa signature generation and verification
|
||||
// Inludes method to parse/verify an ECDsa .ker.der file and extract the pub/pri key pair
|
||||
|
||||
// Version 1.1 - Released 04.01.2016 - Stephen Schamber - Sensus USA Inc
|
||||
// Added ECDHExchange method to suport EC-DH key derivations
|
||||
|
||||
// Version 1.2 - Released 04.03.2016 - Stephen Schamber - Sensus USA Inc
|
||||
// Use formatting function to generate symmetric key per FlexNet Asymmetric Encryption Spec
|
||||
|
||||
// Version 1.3 - Released 04.15.2016 - Stephen Schamber - Sensus USA Inc
|
||||
// Extended the lengths in ECCVerify and ECCSign classes to int's
|
||||
|
||||
// Version 1.4 - Released 04.21.2016 - Stephen Schamber - Sensus USA Inc
|
||||
// Changed .key file input format to PKCS8 to match Java generated keys/certs
|
||||
|
||||
// ERRORS......................................
|
||||
public static byte ERR_NO_ERROR = 0x00;
|
||||
public static byte ERR_INV_KEY_PAIR = 0x01;
|
||||
public static byte ERR_INV_PUB_KEY = 0x02;
|
||||
public static byte ERR_INV_SIG_LEN = 0x04;
|
||||
public static byte ERR_FAIL_SIG_VERIFY = 0x10;
|
||||
public static byte ERR_INV_DER_FILE = 0x20;
|
||||
public static byte ERR_INV_DER_PARSE = 0x40;
|
||||
|
||||
/*********************************************************************************************************
|
||||
**********************************************************************************************************
|
||||
Name: ECDsaSign
|
||||
|
||||
Purpose: This method creates a 64-byte ESDsaP256 w/ SHA-256 digital signature on the data to be signed
|
||||
|
||||
PARAMETERS: ECDsaSignParams
|
||||
(The signature will be returned in the ECDsaSignParams object)
|
||||
|
||||
RETURNS: 0 if sign is successful
|
||||
> 0 if error checks on input parameters fail
|
||||
|
||||
********************************************************************************************************/
|
||||
public static byte ECDsaSign(ECDsaSignParams ecdsa_s_p)
|
||||
{
|
||||
// Error Checks
|
||||
byte error = ERR_NO_ERROR;
|
||||
if (!ecdsa_s_p.keyPair.valid)
|
||||
error |= ERR_INV_KEY_PAIR;
|
||||
if (ecdsa_s_p.signature.Length != _ECC_SIG_SIZE)
|
||||
error |= ERR_INV_SIG_LEN;
|
||||
|
||||
// Return if error
|
||||
if (error > ERR_NO_ERROR) return error;
|
||||
|
||||
// Create the privKeyBlob from the key pair
|
||||
byte[] privKeyBlob = new byte[_KEY_BLOB_HDR + _PRI_KEY_SIZE + _PUB_KEY_SIZE];
|
||||
|
||||
// Apend the Microsoft Key Storage Provider (MKSP) header for an EccPrivateBlob
|
||||
privKeyBlob[0] = (byte)'E';
|
||||
privKeyBlob[1] = (byte)'C';
|
||||
privKeyBlob[2] = (byte)'S';
|
||||
privKeyBlob[3] = (byte)'2';
|
||||
privKeyBlob[4] = (byte)' ';
|
||||
privKeyBlob[5] = 0x00;
|
||||
privKeyBlob[6] = 0x00;
|
||||
privKeyBlob[7] = 0x00;
|
||||
|
||||
// Copy public key after header
|
||||
Array.Copy(ecdsa_s_p.keyPair.pubKey, 0, privKeyBlob, _KEY_BLOB_HDR, ecdsa_s_p.keyPair.pubKey.Length);
|
||||
|
||||
// Copy private key after public key
|
||||
Array.Copy(ecdsa_s_p.keyPair.priKey, 0, privKeyBlob, _KEY_BLOB_HDR + _PUB_KEY_SIZE, ecdsa_s_p.keyPair.priKey.Length);
|
||||
|
||||
// Create a CngKey Object and import the priKeyBlob
|
||||
CngKey ECDsakeyPair = CngKey.Import(privKeyBlob, CngKeyBlobFormat.EccPrivateBlob);
|
||||
|
||||
// Create the ECDsaCng object use the CngKey comtaining the key pair
|
||||
using (ECDsaCng dsa = new ECDsaCng(ECDsakeyPair))
|
||||
{
|
||||
// ECDsaP256 with SHA256
|
||||
dsa.HashAlgorithm = CngAlgorithm.Sha256;
|
||||
// Generate Signature
|
||||
ecdsa_s_p.signature = dsa.SignData(ecdsa_s_p.buffer, ecdsa_s_p.data_idx, ecdsa_s_p.data_len);
|
||||
}
|
||||
return ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
**********************************************************************************************************
|
||||
Name: ECDsaVerify
|
||||
|
||||
Purpose: This method verifies a 64-byte ESDsaP256 w/ SHA-256 digital signature on signed data
|
||||
|
||||
PARAMETERS: ECDSaVerifyParams
|
||||
|
||||
RETURNS: 0 if verify is successful
|
||||
> 0 if error checks on input parameters fail, or signature does not verify
|
||||
|
||||
********************************************************************************************************/
|
||||
public static byte ECDsaVerify(ECDsaVerifyParams ecdsa_v_p)
|
||||
{
|
||||
byte error = ERR_NO_ERROR;
|
||||
if (ecdsa_v_p.pubKey.Length != _PUB_KEY_SIZE)
|
||||
error |= ERR_INV_PUB_KEY;
|
||||
if (ecdsa_v_p.signature.Length != _ECC_SIG_SIZE)
|
||||
error |= ERR_INV_SIG_LEN;
|
||||
|
||||
// Return if error
|
||||
if (error > ERR_NO_ERROR) return error;
|
||||
|
||||
// Create the pubKeyBlob from the public key
|
||||
byte[] pubKeyBlob = new byte[_KEY_BLOB_HDR + _PUB_KEY_SIZE];
|
||||
|
||||
// Apend the Microsoft Key Storage Provider (MKSP) header for an EccPublicBlob
|
||||
pubKeyBlob[0] = (byte)'E';
|
||||
pubKeyBlob[1] = (byte)'C';
|
||||
pubKeyBlob[2] = (byte)'S';
|
||||
pubKeyBlob[3] = (byte)'1';
|
||||
pubKeyBlob[4] = (byte)' ';
|
||||
pubKeyBlob[5] = 0x00;
|
||||
pubKeyBlob[6] = 0x00;
|
||||
pubKeyBlob[7] = 0x00;
|
||||
|
||||
// Copy public key after header
|
||||
Array.Copy(ecdsa_v_p.pubKey, 0, pubKeyBlob, _KEY_BLOB_HDR, ecdsa_v_p.pubKey.Length);
|
||||
|
||||
// Create the ECDsaCng object and import a CngKey comtaining the public key
|
||||
using (ECDsaCng dsa = new ECDsaCng(CngKey.Import(pubKeyBlob, CngKeyBlobFormat.EccPublicBlob)))
|
||||
{
|
||||
// ECDsaP256 with SHA256
|
||||
dsa.HashAlgorithm = CngAlgorithm.Sha256;
|
||||
// Verify Signature
|
||||
return ((dsa.VerifyData(ecdsa_v_p.buffer, ecdsa_v_p.data_idx, ecdsa_v_p.data_len, ecdsa_v_p.signature)) ? ERR_NO_ERROR : ERR_FAIL_SIG_VERIFY);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
**********************************************************************************************************
|
||||
Name: ECDHExchange
|
||||
|
||||
Purpose: This method uses an endpoint public key and a generated key pair to derive a new symmetric key
|
||||
|
||||
PARAMETERS: ECDHExchangeParams
|
||||
|
||||
RETURNS: 0 if verify is successful
|
||||
> 0 if error checks on input parameters fail, or signature does not verify
|
||||
|
||||
********************************************************************************************************/
|
||||
public static byte ECDHExchange(ECDHExchangeParams ecdh_p)
|
||||
{
|
||||
byte error = ERR_NO_ERROR;
|
||||
if (ecdh_p.pubKey_e.Length != _PUB_KEY_SIZE)
|
||||
error |= ERR_INV_PUB_KEY;
|
||||
if (ecdh_p.pubKey_r.Length != _PUB_KEY_SIZE)
|
||||
error |= ERR_INV_PUB_KEY;
|
||||
|
||||
// Return if error
|
||||
if (error > ERR_NO_ERROR) return error;
|
||||
|
||||
// Create the pubKeyBlob from the public key
|
||||
byte[] pubKeyBlob = new byte[_KEY_BLOB_HDR + _PUB_KEY_SIZE];
|
||||
|
||||
// Apend the Microsoft Key Storage Provider (MKSP) header for an EccPublicBlob
|
||||
pubKeyBlob[0] = (byte)'E';
|
||||
pubKeyBlob[1] = (byte)'C';
|
||||
pubKeyBlob[2] = (byte)'K';
|
||||
pubKeyBlob[3] = (byte)'1';
|
||||
pubKeyBlob[4] = (byte)' ';
|
||||
pubKeyBlob[5] = 0x00;
|
||||
pubKeyBlob[6] = 0x00;
|
||||
pubKeyBlob[7] = 0x00;
|
||||
|
||||
// Copy the endpoint public key after header
|
||||
Array.Copy(ecdh_p.pubKey_e, 0, pubKeyBlob, _KEY_BLOB_HDR, ecdh_p.pubKey_e.Length);
|
||||
|
||||
// Generate a random key pair to be used for the exchange
|
||||
// ECC P256 Key Size
|
||||
using (ECDiffieHellmanCng myEcdh = new ECDiffieHellmanCng(256))
|
||||
{
|
||||
// Ephemeral Key
|
||||
// Remove ECK blob header and only return the ephemeral public key
|
||||
Array.Copy(myEcdh.PublicKey.ToByteArray(), 8, ecdh_p.empKey, 0, myEcdh.PublicKey.ToByteArray().Length - 8);
|
||||
|
||||
// Derived Symmetric Key
|
||||
myEcdh.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
|
||||
myEcdh.HashAlgorithm = CngAlgorithm.Sha256;
|
||||
|
||||
// From the FlexNet Asymmetric Encryption Specification:
|
||||
// KEP = SHA256( ‘b’32 0x00000001 (MSB First) || ‘b’256 Z || ‘b’64 RNI PubKey || ‘b’32 0x00000000 (MSB First) || ‘b’32 Meter FlexID (LSB First) || ‘b’24 0x000001 (MSB First))
|
||||
myEcdh.SecretPrepend = new byte[] { 0x00, 0x00, 0x00, 0x01 };
|
||||
byte[] append = new byte[19];
|
||||
Array.Copy(ecdh_p.pubKey_r, 24, append, 0, 8);
|
||||
Array.Copy(new byte[] { 0x00, 0x00, 0x00, 0x00 }, 0, append, 8, 4);
|
||||
append[12] = (byte)(ecdh_p.endpoint_id);
|
||||
append[13] = (byte)(ecdh_p.endpoint_id >> 8);
|
||||
append[14] = (byte)(ecdh_p.endpoint_id >> 16);
|
||||
append[15] = (byte)(ecdh_p.endpoint_id >> 24);
|
||||
Array.Copy(new byte[] { 0x00, 0x00, 0x01 }, 0, append, 16, 3);
|
||||
myEcdh.SecretAppend = append;
|
||||
ecdh_p.symKey = myEcdh.DeriveKeyMaterial(CngKey.Import(pubKeyBlob, CngKeyBlobFormat.EccPublicBlob));
|
||||
}
|
||||
return ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
**********************************************************************************************************
|
||||
Name: DERFileParseForKeys
|
||||
|
||||
Purpose: This method parses an ASN.1 binary key.der file, verifies format and extracts the key pair
|
||||
This detects if the .key.der file is openssl format or PKCS8 format
|
||||
|
||||
PARAMETERS: DERFileName - a string containing the filename (full path) to key.der file
|
||||
ECDsaKeyPair keyPair - the object where the extracted key pair will be returned
|
||||
|
||||
RETURNS: 0 if file format is correct and a valid key pair has been extracted
|
||||
> 0 if file format is invalid or not the correct type and a key pair has not been extracted
|
||||
|
||||
********************************************************************************************************/
|
||||
public static byte DERFileParseForKeys(String DERFileName, ECDsaKeyPair keyPair)
|
||||
{
|
||||
// Set the keyPair.valid to false
|
||||
keyPair.valid = false;
|
||||
|
||||
// Check if the file exists
|
||||
if (!File.Exists(DERFileName))
|
||||
return ERR_INV_DER_FILE;
|
||||
|
||||
// Check if the file is ".key.der"
|
||||
if (!DERFileName.Contains(".key.der"))
|
||||
return ERR_INV_DER_FILE;
|
||||
|
||||
// Read all of the bytes from the file
|
||||
byte[] rawDER = File.ReadAllBytes(DERFileName);
|
||||
|
||||
int derIdx = 0;
|
||||
int oidIdx = 0;
|
||||
int priKeyIdx = 0;
|
||||
int pubKeyIdx = 0;
|
||||
// Check for ASN.1 Start Sequence
|
||||
if (rawDER[derIdx++] == 0x30)
|
||||
{
|
||||
// Openssl generated .key.der file?
|
||||
if (rawDER[derIdx] == 0x77)
|
||||
{
|
||||
derIdx++;
|
||||
priKeyIdx = 5;
|
||||
oidIdx = priKeyIdx + 36;
|
||||
pubKeyIdx = priKeyIdx + 48;
|
||||
}
|
||||
// PKCS8 file?
|
||||
else if (rawDER[derIdx++] == 0x81 && rawDER[derIdx++] == 0x93)
|
||||
{
|
||||
priKeyIdx = 34;
|
||||
oidIdx = priKeyIdx + 36;
|
||||
pubKeyIdx = priKeyIdx + 48;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERR_INV_DER_PARSE;
|
||||
}
|
||||
}
|
||||
|
||||
derIdx = priKeyIdx;
|
||||
// Check for ASN.1 octect string and correct private key length
|
||||
if (rawDER[derIdx++] == 0x04 && rawDER[derIdx++] == _PRI_KEY_SIZE)
|
||||
{
|
||||
// Grab the private key and copy into keyPair.priKey
|
||||
for (int i = 0; i < _PRI_KEY_SIZE; i++)
|
||||
keyPair.priKey[i] = rawDER[derIdx++];
|
||||
}
|
||||
else
|
||||
return ERR_INV_DER_PARSE;
|
||||
|
||||
byte[] prime256v1OID = { 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07 };
|
||||
// Check for ASN.1 OID Type (0x06) and valid encoded OID Len (0x08)
|
||||
if (rawDER[derIdx++] == 0x06 && rawDER[derIdx++] == 0x08)
|
||||
{
|
||||
// Check for corrected ASN.1 encoded OID for "prime256v1" (1.2.840.10045.3.1.7)
|
||||
for (int i = 0; i < prime256v1OID.Length; i++)
|
||||
{
|
||||
if (rawDER[derIdx++] != prime256v1OID[i])
|
||||
return ERR_INV_DER_PARSE;
|
||||
}
|
||||
}
|
||||
|
||||
derIdx = pubKeyIdx;
|
||||
// Check for ASN.1 bit string, correct public key length, zero pad-bits and non-compressed key field
|
||||
if (rawDER[derIdx++] == 0x03 && rawDER[derIdx++] == 2 + _PUB_KEY_SIZE && rawDER[derIdx++] == 0 && rawDER[derIdx++] == 0x04)
|
||||
{
|
||||
// Grab the public key and copy into keyPair.pubKey
|
||||
for (int i = 0; i < _PUB_KEY_SIZE; i++)
|
||||
keyPair.pubKey[i] = rawDER[derIdx++];
|
||||
}
|
||||
else
|
||||
return ERR_INV_DER_PARSE;
|
||||
|
||||
// Set the keyPair.valid to true
|
||||
keyPair.valid = true;
|
||||
|
||||
return ERR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
using Sensus;
|
||||
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public enum SegmentType { Standard = 0, Extended = 1 }
|
||||
|
||||
public class FirmwareVersion : IComparable<FirmwareVersion>, IComparable
|
||||
{
|
||||
public FirmwareVersion() { }
|
||||
|
||||
public FirmwareVersion(Byte major, Byte minor)
|
||||
{
|
||||
if (major > 0x0f || minor > 0x0f)
|
||||
throw new ArgumentException("Invalid firmware version");
|
||||
|
||||
Major = major;
|
||||
Minor = minor;
|
||||
}
|
||||
|
||||
public Byte Major { get; protected set; }
|
||||
public Byte Minor { get; protected set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is FirmwareVersion))
|
||||
return false;
|
||||
|
||||
if ((object)this == obj) return true;
|
||||
FirmwareVersion other = (FirmwareVersion)obj;
|
||||
return other.GetHashCode() == this.GetHashCode();
|
||||
}
|
||||
|
||||
public virtual ushort ToShort()
|
||||
{
|
||||
return (ushort)(((Major & 0x0F) << 12) | ((Minor & 0x0F) << 8));
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (Major << 4) | Minor;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0:X}.{1:X} (hex)", Major, Minor);
|
||||
}
|
||||
|
||||
public virtual string ToShortString()
|
||||
{
|
||||
return String.Format("{0:X}.{1:X}", Major, Minor);
|
||||
}
|
||||
|
||||
#region IComparable<FirmwareVersion> Members
|
||||
|
||||
public int CompareTo(FirmwareVersion other)
|
||||
{
|
||||
if (this.Equals(other)) return 0; // all fields are same
|
||||
return this.GetHashCode() - other.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IComparable Members
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (obj.GetType() == this.GetType()) return CompareTo((FirmwareVersion)obj);
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static bool operator <(FirmwareVersion a, FirmwareVersion b) { return (a.CompareTo(b) < 0); }
|
||||
public static bool operator >(FirmwareVersion a, FirmwareVersion b) { return (a.CompareTo(b) > 0); }
|
||||
public static bool operator <=(FirmwareVersion a, FirmwareVersion b) { return (a < b) || (a.Equals(b)); }
|
||||
public static bool operator >=(FirmwareVersion a, FirmwareVersion b) { return (a > b) || (a.Equals(b)); }
|
||||
}
|
||||
|
||||
public class FlexNetFirmwareVersion : FirmwareVersion
|
||||
{
|
||||
public FlexNetFirmwareVersion() { }
|
||||
|
||||
public FlexNetFirmwareVersion(Byte major, Byte minor, Boolean beta)
|
||||
: base(major, minor)
|
||||
{
|
||||
if (major > 0x07)
|
||||
throw new ArgumentException("Invalid Firmware Version");
|
||||
|
||||
IsBeta = beta;
|
||||
}
|
||||
|
||||
public Boolean IsBeta { get; protected set; }
|
||||
|
||||
public override ushort ToShort()
|
||||
{
|
||||
if (!IsBeta)
|
||||
return base.ToShort();
|
||||
else
|
||||
return (ushort)(base.ToShort() | 0x8000);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode() | ((IsBeta ? 0 : 1) << 7);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0:X}.{1:X}{2} (hex)", Major, Minor, ((IsBeta) ? " beta" : String.Empty));
|
||||
}
|
||||
|
||||
public override string ToShortString()
|
||||
{
|
||||
return String.Format("{2}{0:X}.{1:X}", Major, Minor, ((IsBeta) ? "b" : String.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
public class NA2WFirmwareVersion : FlexNetFirmwareVersion
|
||||
{
|
||||
public NA2WFirmwareVersion() { }
|
||||
|
||||
public NA2WFirmwareVersion(Byte major, Byte minor, Byte patch, Boolean beta)
|
||||
: base(major, minor, beta)
|
||||
{
|
||||
Patch = patch;
|
||||
}
|
||||
|
||||
public static NA2WFirmwareVersion FromUInt16(UInt16 version)
|
||||
{
|
||||
return new NA2WFirmwareVersion(
|
||||
(byte)((version >> 12) & 7),
|
||||
(byte)((version & 0x0f00) >> 8),
|
||||
(byte)(version & 0xff),
|
||||
(version >> 15) == 1);
|
||||
}
|
||||
|
||||
public override ushort ToShort()
|
||||
{
|
||||
return (ushort)(base.ToShort() | (Patch & 0xFF));
|
||||
}
|
||||
|
||||
public static NA2WFirmwareVersion Parse(String s)
|
||||
{
|
||||
Boolean beta = false;
|
||||
Byte major, minor, patch;
|
||||
|
||||
if (s[0] == 'B')
|
||||
{
|
||||
beta = true;
|
||||
s = s.Substring(1);
|
||||
}
|
||||
else if (s[0] == 'R')
|
||||
{
|
||||
s = s.Substring(1);
|
||||
}
|
||||
|
||||
var versions = s.Split('.');
|
||||
|
||||
if (versions.Count() != 3)
|
||||
throw new FormatException("Not a recognized NA2W firmware version format");
|
||||
|
||||
major = Byte.Parse(versions[0], System.Globalization.NumberStyles.HexNumber);
|
||||
minor = Byte.Parse(versions[1], System.Globalization.NumberStyles.HexNumber);
|
||||
patch = Byte.Parse(versions[2], System.Globalization.NumberStyles.HexNumber);
|
||||
|
||||
return new NA2WFirmwareVersion(major, minor, patch, beta);
|
||||
}
|
||||
|
||||
public Byte Patch { get; protected set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (((((Major << 4) | Minor) << 8) | Patch) << 1) | (IsBeta ? 0 : 1);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0:X}.{1:X}.{2:X2}{3} (hex)", Major, Minor, Patch, ((IsBeta) ? " beta" : String.Empty));
|
||||
}
|
||||
|
||||
public override string ToShortString()
|
||||
{
|
||||
return String.Format("{3}{0:X}.{1:X}.{2:X2}", Major, Minor, Patch, ((IsBeta) ? "b" : String.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
public class SegmentDescriptor
|
||||
{
|
||||
public static SegmentDescriptor FromReader(BinaryReader reader, SegmentType type)
|
||||
{
|
||||
return new SegmentDescriptor(reader, type);
|
||||
}
|
||||
|
||||
public SegmentType Type { get; set; }
|
||||
public UInt32 Address { get; set; }
|
||||
public UInt16 BlockCount { get; set; }
|
||||
|
||||
public SegmentDescriptor()
|
||||
{
|
||||
}
|
||||
|
||||
protected SegmentDescriptor(BinaryReader reader, SegmentType type)
|
||||
{
|
||||
Type = type;
|
||||
switch (type)
|
||||
{
|
||||
case SegmentType.Extended:
|
||||
Address = (UInt32)(reader.ReadByte() | (reader.ReadByte() << 8) | (reader.ReadByte() << 16));
|
||||
break;
|
||||
case SegmentType.Standard:
|
||||
Address = (UInt32)(reader.ReadByte() | (reader.ReadByte() << 8));
|
||||
break;
|
||||
default:
|
||||
throw new InvalidDataException("Unrecognized segment type");
|
||||
}
|
||||
BlockCount = (UInt16)(reader.ReadByte() | (reader.ReadByte() << 8));
|
||||
}
|
||||
}
|
||||
|
||||
public class FirmwareBlock : ReadOnlyCollection<byte>
|
||||
{
|
||||
public static FirmwareBlock FromReader(BinaryReader reader)
|
||||
{
|
||||
return new FirmwareBlock(reader);
|
||||
}
|
||||
|
||||
public FirmwareBlock(UInt16 id, byte[] data, int offset)
|
||||
: base(new byte[19])
|
||||
{
|
||||
ID = id;
|
||||
Array.Copy(data, offset, (byte[])Items, 0, Math.Min(19, data.Length - offset));
|
||||
}
|
||||
|
||||
public UInt16 ID { get; set; }
|
||||
|
||||
protected FirmwareBlock(BinaryReader reader)
|
||||
: base(new byte[19])
|
||||
{
|
||||
ID = (UInt16)(reader.ReadByte() | (reader.ReadByte() << 8));
|
||||
Array.Copy(reader.ReadBytes(19), (byte[])Items, 19);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contents of a Sensus .upg file.
|
||||
/// </summary>
|
||||
public class FirmwareImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a FirmwareImage given the path to a .upg file.
|
||||
/// Non-NA2W UPG files must be named with the version number appended
|
||||
/// to the end of the file name after a _. For example: iConA_B1.2.3.4.upg
|
||||
/// NA2W-format UPG files have the firmware version embedded inside the file
|
||||
/// after the device type.
|
||||
/// </summary>
|
||||
/// <param name="path">path to the .upg file.</param>
|
||||
/// <returns></returns>
|
||||
public FirmwareImage(string upgPath)
|
||||
{
|
||||
switch (Path.GetExtension(upgPath).ToLower())
|
||||
{
|
||||
case ".upg":
|
||||
Filename = Path.GetFileName(upgPath);
|
||||
try
|
||||
{
|
||||
ProcessUPG(upgPath, SegmentType.Extended);
|
||||
}
|
||||
catch
|
||||
{
|
||||
ProcessUPG(upgPath, SegmentType.Standard);
|
||||
}
|
||||
break;
|
||||
|
||||
case ".gft":
|
||||
Filename = Path.GetFileName(upgPath);
|
||||
ProcessGft(upgPath);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException("invalid file extension for firmware file");
|
||||
}
|
||||
}
|
||||
|
||||
public string Filename { get; private set; }
|
||||
public byte DeviceType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Version of the firmware that will be installed if instance is loaded onto a device.
|
||||
/// This property does not indicate file format version of the .upg file.
|
||||
/// </summary>
|
||||
public FirmwareVersion Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compatibility byte from UPG file -- in NA2W devices, this is
|
||||
/// also known as the "Product type."
|
||||
/// </summary>
|
||||
public byte Compatibility { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of 19-byte blocks in the image
|
||||
/// </summary>
|
||||
public UInt16 BlockCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Size of the firmware image in bytes.
|
||||
/// </summary>
|
||||
public UInt32 ImageSize { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of segments in the image.
|
||||
/// </summary>
|
||||
public byte SegmentCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// CRC32 of the data in all of the blocks
|
||||
/// </summary>
|
||||
public UInt32 CRC { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Description of all the segments in the firmware image.
|
||||
/// </summary>
|
||||
public IList<SegmentDescriptor> Segments { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The new firmware image in 19-byte blocks.
|
||||
/// </summary>
|
||||
[Serialize(false)]
|
||||
public IList<FirmwareBlock> Blocks { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data from the firmware image as an array.
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return Blocks.SelectMany(b => b.ToList()).ToArray();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
ushort id = 0;
|
||||
Blocks.Clear();
|
||||
for (int offset = 0; offset < value.Length; offset += 19)
|
||||
Blocks.Add(new FirmwareBlock(id++, value, offset));
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] GetSegmentDescriptorBlock()
|
||||
{
|
||||
byte[] result = new byte[19];
|
||||
|
||||
int addrSize = Segments.First().Type == SegmentType.Extended ? 3 : 2;
|
||||
int segmentSize = addrSize + 2;
|
||||
|
||||
for (int i = 0; i < Segments.Count; i++)
|
||||
{
|
||||
result.Write(Segments[i].Address, (uint)(((i * segmentSize) + 0) * 8), (uint)(addrSize * 8), ByteOrder.LittleEndian);
|
||||
result.Write(Segments[i].BlockCount, (uint)(((i * segmentSize) + addrSize) * 8), 16, ByteOrder.LittleEndian);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public UInt32 GetCRCWithSegmentDescriptorBlock()
|
||||
{
|
||||
return ~CRC32.Calculate(~CRC, GetSegmentDescriptorBlock());
|
||||
}
|
||||
|
||||
private void ProcessUPG(string path, SegmentType segmentType)
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)))
|
||||
{
|
||||
Segments = new List<SegmentDescriptor>();
|
||||
Blocks = new List<FirmwareBlock>();
|
||||
|
||||
DeviceType = reader.ReadByte();
|
||||
|
||||
Version = NA2WFirmwareVersion.FromUInt16((UInt16)((reader.ReadByte() << 8) | reader.ReadByte()));
|
||||
Compatibility = reader.ReadByte();
|
||||
|
||||
BlockCount = (UInt16)(reader.ReadByte() | (reader.ReadByte() << 8));
|
||||
SegmentCount = reader.ReadByte();
|
||||
|
||||
for (int i = 0; i < SegmentCount; i++)
|
||||
Segments.Add(SegmentDescriptor.FromReader(reader, segmentType));
|
||||
|
||||
CRC = (UInt32)(reader.ReadByte() | (reader.ReadByte() << 8) | (reader.ReadByte() << 16) | (reader.ReadByte() << 24));
|
||||
ImageSize = (UInt32)(reader.ReadByte() | (reader.ReadByte() << 8) | (reader.ReadByte() << 16) | (reader.ReadByte() << 24));
|
||||
|
||||
if (ImageSize == 0)
|
||||
ImageSize = (uint)(BlockCount * 19);
|
||||
|
||||
uint minimumBlocks = ImageSize / 19;
|
||||
uint maximumBlocks = minimumBlocks + 1; // file is zero-padded to nearest block boundary
|
||||
|
||||
if (!(minimumBlocks <= BlockCount && BlockCount <= maximumBlocks))
|
||||
throw new InvalidDataException();
|
||||
|
||||
for (int i = 0; i < BlockCount; i++)
|
||||
Blocks.Add(FirmwareBlock.FromReader(reader));
|
||||
|
||||
UInt32 calculatedCRC = ~Blocks.Aggregate(CRC32.Seed, CRC32.Calculate);
|
||||
if (CRC != calculatedCRC)
|
||||
throw new InvalidDataException(String.Format("Invalid CRC. Calculated CRC = {0}, file CRC = {1}", calculatedCRC, CRC));
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessGft(string path)
|
||||
{
|
||||
Gft.parseGFTfile(path);
|
||||
|
||||
if (
|
||||
(!Gft.transfChunk.getTransferType().Equals("FWDL"))
|
||||
|| (Gft.parsedGFTfile.isElectric)
|
||||
)
|
||||
{
|
||||
throw new InvalidDataException("GFT not NA2W FWDL.");
|
||||
}
|
||||
|
||||
Log.Write("GFT Verification (" + Filename + ")\n");
|
||||
Log.Write(" Inner signature status: " + Gft.parsedGFTfile.BlockSignatureStatus + "\n");
|
||||
Log.Write(" File SHA-256 status: " + Gft.parsedGFTfile.FileSHA256Status + "\n");
|
||||
Log.Write(" File signature status: " + Gft.parsedGFTfile.FileSignatureStatus + "\n");
|
||||
|
||||
// Populate Firmware Image fields
|
||||
DeviceType = Gft.transfChunk.devType;
|
||||
Compatibility = Gft.na2wfwChunk.compatibilityId;
|
||||
CRC = Gft.na2wfwChunk.crc32;
|
||||
|
||||
// NA2W Chunk fileBytes and controlBytes should be multiple of 19 bytes.
|
||||
// NA2W Chunk verificationBytes is not a multiple of 19 bytes. Need to apply a ceiling logic.
|
||||
uint fileBlocks = Gft.na2wfwChunk.fileBytes / 19;
|
||||
uint controlBlocks = Gft.na2wfwChunk.controlBytes / 19;
|
||||
uint verificationBlocks = (uint)Math.Ceiling(((decimal)Gft.na2wfwChunk.verificationBytes / 19));
|
||||
BlockCount = (ushort)(fileBlocks + controlBlocks + verificationBlocks);
|
||||
uint imageSizeBytes = (uint)(BlockCount * 19);
|
||||
ImageSize = imageSizeBytes;
|
||||
Version = NA2WFirmwareVersion.FromUInt16(Gft.na2wfwChunk.fwVersion);
|
||||
|
||||
// GFT format is identified with signal NULL descriptor. Segment address is
|
||||
// load block number of start of control block
|
||||
SegmentCount = 1;
|
||||
Segments = new List<SegmentDescriptor>();
|
||||
Segments.Add(
|
||||
new SegmentDescriptor()
|
||||
{
|
||||
Type = SegmentType.Extended,
|
||||
Address = fileBlocks,
|
||||
BlockCount = 0
|
||||
}
|
||||
);
|
||||
|
||||
// Build load blocks
|
||||
Blocks = new List<FirmwareBlock>();
|
||||
for (ushort i = 0; i < BlockCount; i++)
|
||||
{
|
||||
Blocks.Add(new FirmwareBlock(i, Gft.blockData, i * 19));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,679 @@
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class Gft
|
||||
{
|
||||
// Key pair used to sign/verify FW and .gft files
|
||||
public static ECDsaKeyPair FWKeyPair = new ECDsaKeyPair();
|
||||
public static ECDsaVerifyParams ecdsa_v_p = new ECDsaVerifyParams();
|
||||
public static ECDsaSignParams ecdsa_s_p = new ECDsaSignParams();
|
||||
|
||||
public const String _HEADER = "\0GFT";
|
||||
public const int _HEADER_LEN = 4;
|
||||
public const int _TAG_LEN = 6;
|
||||
public const int _MAX_CHUNKS = 8;
|
||||
|
||||
public class chunk
|
||||
{
|
||||
public String tag;
|
||||
public int len;
|
||||
public long dataOffset;
|
||||
}
|
||||
|
||||
public static class parsedGFTfile
|
||||
{
|
||||
public static int version;
|
||||
public static int numChunks;
|
||||
public static chunk[] _chunk = new chunk[_MAX_CHUNKS];
|
||||
public static String FileSHA256Status;
|
||||
public static String FileSignatureStatus;
|
||||
public static String BlockSignatureStatus;
|
||||
public static bool isElectric = false;
|
||||
}
|
||||
|
||||
public static String parseGFTfile(String filename)
|
||||
{
|
||||
parsedGFTfile.numChunks = 0;
|
||||
try
|
||||
{
|
||||
using (BinaryReader bRdr = new BinaryReader(new FileStream(filename, FileMode.Open)))
|
||||
{
|
||||
// Check for GFT header
|
||||
if (!Encoding.ASCII.GetString(bRdr.ReadBytes(_HEADER_LEN), 0, _HEADER_LEN).Equals(_HEADER))
|
||||
{
|
||||
return "GFT File Header Invalid";
|
||||
}
|
||||
|
||||
// Grab the version
|
||||
parsedGFTfile.version = bRdr.ReadByte();
|
||||
|
||||
// Grab chunks until end of file is reached
|
||||
while ((bRdr.BaseStream.Position != bRdr.BaseStream.Length) && (parsedGFTfile.numChunks < _MAX_CHUNKS))
|
||||
{
|
||||
parsedGFTfile._chunk[parsedGFTfile.numChunks] = new chunk();
|
||||
parsedGFTfile._chunk[parsedGFTfile.numChunks].tag = Encoding.ASCII.GetString(bRdr.ReadBytes(_TAG_LEN), 0, _TAG_LEN);
|
||||
parsedGFTfile._chunk[parsedGFTfile.numChunks].len = bRdr.ReadInt32();
|
||||
parsedGFTfile._chunk[parsedGFTfile.numChunks].dataOffset = bRdr.BaseStream.Position;
|
||||
bRdr.BaseStream.Position += parsedGFTfile._chunk[parsedGFTfile.numChunks++].len;
|
||||
}
|
||||
|
||||
// File SHA-256
|
||||
if (getGFTchunk(bRdr, _TAG_SHA256_HASH))
|
||||
{
|
||||
if (verifyGFTsha(bRdr))
|
||||
parsedGFTfile.FileSHA256Status = "Valid";
|
||||
else
|
||||
parsedGFTfile.FileSHA256Status = "Invalid";
|
||||
}
|
||||
else
|
||||
parsedGFTfile.FileSHA256Status = "Not Present";
|
||||
|
||||
// File Signature
|
||||
if (getGFTchunk(bRdr, _TAG_SIGNATURE))
|
||||
{
|
||||
if (FWKeyPair.valid == false)
|
||||
{
|
||||
parsedGFTfile.FileSignatureStatus = "Signed, not verified (no cert)";
|
||||
}
|
||||
else if (verifyGFTsig(bRdr))
|
||||
parsedGFTfile.FileSignatureStatus = "Valid";
|
||||
else
|
||||
parsedGFTfile.FileSignatureStatus = "Invalid";
|
||||
}
|
||||
else
|
||||
parsedGFTfile.FileSignatureStatus = "Not Present";
|
||||
|
||||
// Parse the transfer chuck
|
||||
if (!getGFTchunk(bRdr, _TAG_TRANSFER))
|
||||
return "Transfer Chunk Not Present in File";
|
||||
|
||||
// Parse the electic transfer chuck based on transfer type
|
||||
if (transfChunk.getTransferType().Equals("FWDL"))
|
||||
{
|
||||
if ((!getGFTchunk(bRdr, _TAG_TRANSFER_ELECTRIC_FWDL)) && (!getGFTchunk(bRdr, _TAG_TRANSFER_NA2W_FWDL)))
|
||||
return "Electric or NA2W FWDL Transfer Data not Present in File";
|
||||
}
|
||||
else if (transfChunk.getTransferType().Equals("OTA CONFIG"))
|
||||
{
|
||||
if (!getGFTchunk(bRdr, _TAG_TRANSFER_ELECTRIC_CONFIG))
|
||||
return "Electric OTA Config Transfer Data not Present in File";
|
||||
}
|
||||
else if (transfChunk.getTransferType().Equals("DUMMY"))
|
||||
{
|
||||
if (!getGFTchunk(bRdr, _TAG_TRANSFER_ELECTRIC_DUMMY))
|
||||
return "Electric Dummy Transfer Data not Present in File";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Unrecognized OTA Transfer Type Specfied in File";
|
||||
}
|
||||
|
||||
// Grab the block data
|
||||
if (!getGFTchunk(bRdr, _TAG_BLOCKS))
|
||||
{
|
||||
return "Blocks Chunk Not Present in File";
|
||||
}
|
||||
|
||||
// Verify the block SHA-256 or ECDsa signature
|
||||
parsedGFTfile.BlockSignatureStatus = verifyBlocksig();
|
||||
|
||||
// Passed all format checks above, file parsed into objects
|
||||
return "GFT Format Pass";
|
||||
}
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return "GFT File Already Open by Another Program";
|
||||
}
|
||||
}
|
||||
|
||||
public const String _TAG_TRANSFER = "transf";
|
||||
public const String _TAG_BLOCKS = "blocks";
|
||||
public const String _TAG_SHA256_HASH = "sha256";
|
||||
public const String _TAG_SIGNATURE = "ecP256";
|
||||
public const String _TAG_TRANSFER_ELECTRIC_FWDL = "elecfw";
|
||||
public const String _TAG_TRANSFER_ELECTRIC_CONFIG = "eleccf";
|
||||
public const String _TAG_TRANSFER_ELECTRIC_DUMMY = "elecdm";
|
||||
public const String _TAG_TRANSFER_NA2W_FWDL = "na2wfw";
|
||||
|
||||
public static Boolean getGFTchunk(BinaryReader bRdr, String tag)
|
||||
{
|
||||
for (int i=0; i<parsedGFTfile.numChunks; i++)
|
||||
{
|
||||
// Search for chunk by tag
|
||||
if (parsedGFTfile._chunk[i].tag.Equals(tag))
|
||||
{
|
||||
switch (parsedGFTfile._chunk[i].tag)
|
||||
{
|
||||
case _TAG_TRANSFER:
|
||||
parseGFTtransf(bRdr, parsedGFTfile._chunk[i]);
|
||||
break;
|
||||
case _TAG_BLOCKS:
|
||||
parseGFTblocks(bRdr, parsedGFTfile._chunk[i]);
|
||||
break;
|
||||
case _TAG_SHA256_HASH:
|
||||
parseGFTsha(bRdr, parsedGFTfile._chunk[i]);
|
||||
break;
|
||||
case _TAG_SIGNATURE:
|
||||
parseGFTsig(bRdr, parsedGFTfile._chunk[i]);
|
||||
break;
|
||||
case _TAG_TRANSFER_ELECTRIC_FWDL:
|
||||
parseGFTelectfw(bRdr, parsedGFTfile._chunk[i]);
|
||||
break;
|
||||
case _TAG_TRANSFER_ELECTRIC_CONFIG:
|
||||
parseGFTelectcf(bRdr, parsedGFTfile._chunk[i]);
|
||||
break;
|
||||
case _TAG_TRANSFER_ELECTRIC_DUMMY:
|
||||
parseGFTelectdm(bRdr, parsedGFTfile._chunk[i]);
|
||||
break;
|
||||
case _TAG_TRANSFER_NA2W_FWDL:
|
||||
parseGFTna2wfw(bRdr, parsedGFTfile._chunk[i]);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false; // tag does not exist
|
||||
}
|
||||
|
||||
public const byte _TRANS_TYPE_FWDL = 0;
|
||||
public const byte _TRANS_TYPE_OTA_CFG = 1;
|
||||
public const byte _TRANS_TYPE_DUMMY = 2;
|
||||
public static class transfChunk
|
||||
{
|
||||
public static byte devType;
|
||||
public static byte otaTransType;
|
||||
public static byte otaBlockSize;
|
||||
public static ushort otaTotalBlocks;
|
||||
|
||||
// Methods
|
||||
public static String getTransferType()
|
||||
{
|
||||
if (_TRANS_TYPE_FWDL == (byte)(otaTransType & 0x03))
|
||||
return "FWDL";
|
||||
else if (_TRANS_TYPE_OTA_CFG == (byte)(otaTransType & 0x03))
|
||||
return "OTA CONFIG";
|
||||
else if (_TRANS_TYPE_DUMMY == (byte)(otaTransType & 0x03))
|
||||
return "DUMMY";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
}
|
||||
|
||||
public static void parseGFTtransf(BinaryReader bRdr, chunk c)
|
||||
{
|
||||
bRdr.BaseStream.Position = c.dataOffset;
|
||||
transfChunk.devType = bRdr.ReadByte();
|
||||
transfChunk.otaTransType = bRdr.ReadByte();
|
||||
transfChunk.otaBlockSize = bRdr.ReadByte();
|
||||
transfChunk.otaTotalBlocks = bRdr.ReadUInt16();
|
||||
}
|
||||
|
||||
public const byte _COMP_NONE = 0;
|
||||
public const byte _COMP_LZS = 1;
|
||||
public const byte _VERF_SHA256 = 0;
|
||||
public const byte _VERF_ECDSA = 1;
|
||||
public const int _KST_LEN = 3;
|
||||
public const int _KID_LEN = 4;
|
||||
public static class elecfwChunk
|
||||
{
|
||||
public static byte startVersion = 0xff;
|
||||
public static ushort fwVersion;
|
||||
public static byte comp_verif;
|
||||
public static byte[] certKeyID;
|
||||
public static byte[] certState;
|
||||
public static ushort numFileBlocks;
|
||||
public static byte validBytesLastFileBlocks;
|
||||
public static byte numControlBlocks;
|
||||
public static byte validBytesLastControlBlock;
|
||||
public static byte numVerificationBlocks;
|
||||
public static byte validBytesLastVerificationBlock;
|
||||
public static ushort numCompressedBlocks;
|
||||
public static byte validBytesLastCompressedBlock;
|
||||
|
||||
// methods
|
||||
public static String getCompressionType()
|
||||
{
|
||||
if (_COMP_NONE == (byte)(comp_verif & 0x0F))
|
||||
return "None";
|
||||
else if (_COMP_LZS == (byte)(comp_verif & 0x0F))
|
||||
return "LZS";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
public static String getVerificationType()
|
||||
{
|
||||
if (_VERF_SHA256 == (byte)(comp_verif >> 4))
|
||||
return "SHA-256";
|
||||
else if (_VERF_ECDSA == (byte)(comp_verif >> 4))
|
||||
return "ECDsa";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
public static void setVerificationType(byte type)
|
||||
{
|
||||
comp_verif &= 0x0F; // Clear verification type
|
||||
comp_verif |= (byte)(type << 4);
|
||||
}
|
||||
public static void setCompressionType(byte type)
|
||||
{
|
||||
comp_verif &= 0xF0; // Clear compression type
|
||||
comp_verif |= (byte)(type & 0xF);
|
||||
}
|
||||
}
|
||||
|
||||
public static void parseGFTelectfw(BinaryReader bRdr, chunk c)
|
||||
{
|
||||
bRdr.BaseStream.Position = c.dataOffset;
|
||||
elecfwChunk.startVersion = bRdr.ReadByte();
|
||||
elecfwChunk.fwVersion = bRdr.ReadUInt16();
|
||||
elecfwChunk.comp_verif = bRdr.ReadByte();
|
||||
elecfwChunk.certKeyID = bRdr.ReadBytes(_KID_LEN);
|
||||
elecfwChunk.certState = bRdr.ReadBytes(_KST_LEN);
|
||||
elecfwChunk.numFileBlocks = bRdr.ReadUInt16();
|
||||
elecfwChunk.validBytesLastFileBlocks = bRdr.ReadByte();
|
||||
elecfwChunk.numControlBlocks = bRdr.ReadByte();
|
||||
elecfwChunk.validBytesLastControlBlock = bRdr.ReadByte();
|
||||
elecfwChunk.numVerificationBlocks = bRdr.ReadByte();
|
||||
elecfwChunk.validBytesLastVerificationBlock = bRdr.ReadByte();
|
||||
elecfwChunk.numCompressedBlocks = bRdr.ReadUInt16();
|
||||
elecfwChunk.validBytesLastCompressedBlock = bRdr.ReadByte();
|
||||
}
|
||||
|
||||
public static class eleccfChunk
|
||||
{
|
||||
public static byte startVersion;
|
||||
public static uint activationTime;
|
||||
public static byte comp_verif;
|
||||
public static byte[] certKeyID;
|
||||
public static byte[] certState;
|
||||
public static ushort numFileBlocks;
|
||||
public static byte validBytesLastFileBlocks;
|
||||
public static byte numVerificationBlocks;
|
||||
public static byte validBytesLastVerificationBlock;
|
||||
public static ushort numCompressedBlocks;
|
||||
public static byte validBytesLastCompressedBlock;
|
||||
|
||||
// methods
|
||||
public static String getCompressionType()
|
||||
{
|
||||
if (_COMP_NONE == (byte)(comp_verif & 0x0F))
|
||||
return "None";
|
||||
else if (_COMP_LZS == (byte)(comp_verif & 0x0F))
|
||||
return "LZS";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
public static String getVerificationType()
|
||||
{
|
||||
if (_VERF_SHA256 == (byte)(comp_verif >> 4))
|
||||
return "SHA-256";
|
||||
else if (_VERF_ECDSA == (byte)(comp_verif >> 4))
|
||||
return "ECDsa";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
public static void setVerificationType(byte type)
|
||||
{
|
||||
comp_verif &= 0x0F; // Clear verification type
|
||||
comp_verif |= (byte)(type << 4);
|
||||
}
|
||||
public static void setCompressionType(byte type)
|
||||
{
|
||||
comp_verif &= 0xF0; // Clear compression type
|
||||
comp_verif |= (byte)(type & 0xF);
|
||||
}
|
||||
}
|
||||
|
||||
public static void parseGFTelectcf(BinaryReader bRdr, chunk c)
|
||||
{
|
||||
bRdr.BaseStream.Position = c.dataOffset;
|
||||
eleccfChunk.startVersion = bRdr.ReadByte();
|
||||
eleccfChunk.activationTime = bRdr.ReadUInt32();
|
||||
eleccfChunk.comp_verif = bRdr.ReadByte();
|
||||
eleccfChunk.certKeyID = bRdr.ReadBytes(_KID_LEN);
|
||||
eleccfChunk.certState = bRdr.ReadBytes(_KST_LEN);
|
||||
eleccfChunk.numFileBlocks = bRdr.ReadUInt16();
|
||||
eleccfChunk.validBytesLastFileBlocks = bRdr.ReadByte();
|
||||
eleccfChunk.numVerificationBlocks = bRdr.ReadByte();
|
||||
eleccfChunk.validBytesLastVerificationBlock = bRdr.ReadByte();
|
||||
eleccfChunk.numCompressedBlocks = bRdr.ReadUInt16();
|
||||
eleccfChunk.validBytesLastCompressedBlock = bRdr.ReadByte();
|
||||
}
|
||||
|
||||
public static class elecdmChunk
|
||||
{
|
||||
public static byte startVersion;
|
||||
public static byte comp_verif;
|
||||
public static byte[] certKeyID;
|
||||
public static byte[] certState;
|
||||
public static ushort numFileBlocks;
|
||||
public static byte validBytesLastFileBlocks;
|
||||
public static byte numVerificationBlocks;
|
||||
public static byte validBytesLastVerificationBlock;
|
||||
public static ushort numCompressedBlocks;
|
||||
public static byte validBytesLastCompressedBlock;
|
||||
|
||||
// methods
|
||||
public static String getCompressionType()
|
||||
{
|
||||
if (_COMP_NONE == (byte)(comp_verif & 0x0F))
|
||||
return "None";
|
||||
else if (_COMP_LZS == (byte)(comp_verif & 0x0F))
|
||||
return "LZS";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
public static String getVerificationType()
|
||||
{
|
||||
if (_VERF_SHA256 == (byte)(comp_verif >> 4))
|
||||
return "SHA-256";
|
||||
else if (_VERF_ECDSA == (byte)(comp_verif >> 4))
|
||||
return "ECDsa";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
public static void setVerificationType(byte type)
|
||||
{
|
||||
comp_verif &= 0x0F; // Clear verification type
|
||||
comp_verif |= (byte)(type << 4);
|
||||
}
|
||||
public static void setCompressionType(byte type)
|
||||
{
|
||||
comp_verif &= 0xF0; // Clear compression type
|
||||
comp_verif |= (byte)(type & 0xF);
|
||||
}
|
||||
}
|
||||
|
||||
public static void parseGFTelectdm(BinaryReader bRdr, chunk c)
|
||||
{
|
||||
bRdr.BaseStream.Position = c.dataOffset;
|
||||
elecdmChunk.startVersion = bRdr.ReadByte();
|
||||
elecdmChunk.comp_verif = bRdr.ReadByte();
|
||||
elecdmChunk.certKeyID = bRdr.ReadBytes(_KID_LEN);
|
||||
elecdmChunk.certState = bRdr.ReadBytes(_KST_LEN);
|
||||
elecdmChunk.numFileBlocks = bRdr.ReadUInt16();
|
||||
elecdmChunk.validBytesLastFileBlocks = bRdr.ReadByte();
|
||||
elecdmChunk.numVerificationBlocks = bRdr.ReadByte();
|
||||
elecdmChunk.validBytesLastVerificationBlock = bRdr.ReadByte();
|
||||
elecdmChunk.numCompressedBlocks = bRdr.ReadUInt16();
|
||||
elecdmChunk.validBytesLastCompressedBlock = bRdr.ReadByte();
|
||||
}
|
||||
|
||||
public static class na2wfwChunk
|
||||
{
|
||||
public static byte startVersion = 0xff;
|
||||
public static ushort fwVersion;
|
||||
public static ushort fromVersion;
|
||||
public static ushort toVersion;
|
||||
public static byte compatibilityId;
|
||||
public static byte comp_verif;
|
||||
public static byte[] certKeyID;
|
||||
public static byte[] certState;
|
||||
public static uint crc32;
|
||||
public static uint fileBytes;
|
||||
public static uint controlBytes;
|
||||
public static uint verificationBytes;
|
||||
public static uint compressedBytes;
|
||||
|
||||
// methods
|
||||
public static String getCompressionType()
|
||||
{
|
||||
if (_COMP_NONE == (byte)(comp_verif & 0x0F))
|
||||
return "None";
|
||||
else if (_COMP_LZS == (byte)(comp_verif & 0x0F))
|
||||
return "LZS";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
public static String getVerificationType()
|
||||
{
|
||||
if (_VERF_SHA256 == (byte)(comp_verif >> 4))
|
||||
return "SHA-256";
|
||||
else if (_VERF_ECDSA == (byte)(comp_verif >> 4))
|
||||
return "ECDsa";
|
||||
else
|
||||
return "Undefined";
|
||||
}
|
||||
public static void setVerificationType(byte type)
|
||||
{
|
||||
comp_verif &= 0x0F; // Clear verification type
|
||||
comp_verif |= (byte)(type << 4);
|
||||
}
|
||||
public static void setCompressionType(byte type)
|
||||
{
|
||||
comp_verif &= 0xF0; // Clear compression type
|
||||
comp_verif |= (byte)(type & 0xF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void parseGFTna2wfw(BinaryReader bRdr, chunk c)
|
||||
{
|
||||
bRdr.BaseStream.Position = c.dataOffset;
|
||||
na2wfwChunk.startVersion = bRdr.ReadByte();
|
||||
na2wfwChunk.compatibilityId = bRdr.ReadByte();
|
||||
if (na2wfwChunk.startVersion == 0x00)
|
||||
{
|
||||
na2wfwChunk.fwVersion = bRdr.ReadUInt16();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Version 1 contains from and to firmware version numbers to support patch upgrades
|
||||
na2wfwChunk.fromVersion = bRdr.ReadUInt16();
|
||||
na2wfwChunk.toVersion = bRdr.ReadUInt16();
|
||||
|
||||
na2wfwChunk.fwVersion = na2wfwChunk.fromVersion;
|
||||
}
|
||||
na2wfwChunk.comp_verif = bRdr.ReadByte();
|
||||
na2wfwChunk.certKeyID = bRdr.ReadBytes(_KID_LEN);
|
||||
na2wfwChunk.certState = bRdr.ReadBytes(_KST_LEN);
|
||||
na2wfwChunk.crc32 = bRdr.ReadUInt32();
|
||||
na2wfwChunk.fileBytes = bRdr.ReadUInt32();
|
||||
na2wfwChunk.controlBytes = bRdr.ReadUInt32();
|
||||
na2wfwChunk.verificationBytes = bRdr.ReadUInt32();
|
||||
na2wfwChunk.compressedBytes = bRdr.ReadUInt32();
|
||||
}
|
||||
|
||||
public static byte[] blockData;
|
||||
public static void parseGFTblocks(BinaryReader bRdr, chunk c)
|
||||
{
|
||||
bRdr.BaseStream.Position = c.dataOffset;
|
||||
blockData = bRdr.ReadBytes(c.len);
|
||||
}
|
||||
|
||||
public static class sha256Chunk
|
||||
{
|
||||
public static int numBytesInSHA;
|
||||
public static byte[] fileSHA256;
|
||||
}
|
||||
|
||||
public static void parseGFTsha(BinaryReader bRdr, chunk c)
|
||||
{
|
||||
bRdr.BaseStream.Position = c.dataOffset;
|
||||
sha256Chunk.numBytesInSHA = (int)bRdr.BaseStream.Position;
|
||||
sha256Chunk.fileSHA256 = bRdr.ReadBytes(c.len);
|
||||
}
|
||||
|
||||
public const int _SIG_LEN = 64;
|
||||
public static class ecP256Chunk
|
||||
{
|
||||
public static int numBytesInSig;
|
||||
public static byte[] certKeyID;
|
||||
public static byte[] certState;
|
||||
public static byte[] signature;
|
||||
}
|
||||
|
||||
public static void parseGFTsig(BinaryReader bRdr, chunk c)
|
||||
{
|
||||
bRdr.BaseStream.Position = c.dataOffset;
|
||||
ecP256Chunk.certKeyID = bRdr.ReadBytes(_KID_LEN);
|
||||
ecP256Chunk.certState = bRdr.ReadBytes(_KST_LEN);
|
||||
ecP256Chunk.numBytesInSig = (int)bRdr.BaseStream.Position;
|
||||
ecP256Chunk.signature = bRdr.ReadBytes(_SIG_LEN);
|
||||
}
|
||||
|
||||
public static Boolean verifyGFTsha(BinaryReader bRdr)
|
||||
{
|
||||
using (SHA256Cng fileSHA = new SHA256Cng())
|
||||
{
|
||||
bRdr.BaseStream.Position = 0;
|
||||
byte[] computedSHA = fileSHA.ComputeHash(bRdr.ReadBytes(sha256Chunk.numBytesInSHA));
|
||||
for (int i = 0; i < computedSHA.Length; i++)
|
||||
{
|
||||
if (computedSHA[i] != sha256Chunk.fileSHA256[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] calcGFTsig(byte[] data)
|
||||
{
|
||||
// Populate the ECDsa signing object
|
||||
ecdsa_s_p.keyPair = FWKeyPair;
|
||||
ecdsa_s_p.buffer = data;
|
||||
ecdsa_s_p.data_idx = 0;
|
||||
ecdsa_s_p.data_len = ecdsa_s_p.buffer.Length;
|
||||
ecdsa_s_p.signature = new byte[FNv2_ECDsaP256_wSHA256._ECC_SIG_SIZE];
|
||||
|
||||
// Generate the signature
|
||||
FNv2_ECDsaP256_wSHA256.ECDsaSign(ecdsa_s_p);
|
||||
|
||||
// Return the signature
|
||||
return ecdsa_s_p.signature;
|
||||
}
|
||||
|
||||
public static Boolean verifyGFTsig(BinaryReader bRdr)
|
||||
{
|
||||
// Populate the ECDsa verify object
|
||||
bRdr.BaseStream.Position = 0;
|
||||
ecdsa_v_p.pubKey = FWKeyPair.pubKey;
|
||||
ecdsa_v_p.buffer = bRdr.ReadBytes(ecP256Chunk.numBytesInSig);
|
||||
ecdsa_v_p.data_idx = 0;
|
||||
ecdsa_v_p.data_len = ecdsa_v_p.buffer.Length;
|
||||
ecdsa_v_p.signature = ecP256Chunk.signature;
|
||||
|
||||
// Verify the signature
|
||||
if (FNv2_ECDsaP256_wSHA256.ECDsaVerify(ecdsa_v_p) == FNv2_ECDsaP256_wSHA256.ERR_NO_ERROR)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String verifyBlocksig()
|
||||
{
|
||||
String compType = null;
|
||||
String verfType = null;
|
||||
int numFileBlocks = 0;
|
||||
int numControlBlocks = 0;
|
||||
int numVerfBlocks = 0;
|
||||
|
||||
if (Gft.transfChunk.getTransferType().Equals("FWDL"))
|
||||
{
|
||||
if (Gft.elecfwChunk.startVersion != 0xff)
|
||||
{
|
||||
compType = Gft.elecfwChunk.getCompressionType();
|
||||
verfType = Gft.elecfwChunk.getVerificationType();
|
||||
numFileBlocks = Gft.elecfwChunk.numFileBlocks;
|
||||
numControlBlocks = Gft.elecfwChunk.numControlBlocks;
|
||||
numVerfBlocks = Gft.elecfwChunk.numVerificationBlocks;
|
||||
}
|
||||
else
|
||||
{
|
||||
compType = Gft.na2wfwChunk.getCompressionType();
|
||||
verfType = Gft.na2wfwChunk.getVerificationType();
|
||||
numFileBlocks = (int)(Gft.na2wfwChunk.fileBytes / Gft.transfChunk.otaBlockSize);
|
||||
numControlBlocks = (int)(Gft.na2wfwChunk.controlBytes / Gft.transfChunk.otaBlockSize) ;
|
||||
numVerfBlocks = (int)Math.Ceiling((decimal)(Gft.na2wfwChunk.verificationBytes / Gft.transfChunk.otaBlockSize));
|
||||
}
|
||||
}
|
||||
else if (Gft.transfChunk.getTransferType().Equals("OTA CONFIG"))
|
||||
{
|
||||
compType = Gft.eleccfChunk.getCompressionType();
|
||||
verfType = Gft.eleccfChunk.getVerificationType();
|
||||
numFileBlocks = Gft.eleccfChunk.numFileBlocks;
|
||||
numControlBlocks = 0;
|
||||
numVerfBlocks = Gft.eleccfChunk.numVerificationBlocks;
|
||||
}
|
||||
else if (Gft.transfChunk.getTransferType().Equals("DUMMY"))
|
||||
{
|
||||
compType = Gft.elecdmChunk.getCompressionType();
|
||||
verfType = Gft.elecdmChunk.getVerificationType();
|
||||
numFileBlocks = Gft.elecdmChunk.numFileBlocks;
|
||||
numControlBlocks = 0;
|
||||
numVerfBlocks = Gft.elecdmChunk.numVerificationBlocks;
|
||||
}
|
||||
|
||||
// Compressed
|
||||
byte[] decompBlockData = null;
|
||||
if (compType == "LZS")
|
||||
{
|
||||
// Calculate the number of decompressed bytes
|
||||
decompBlockData = new byte[(numFileBlocks + numControlBlocks + numVerfBlocks) * Gft.transfChunk.otaBlockSize];
|
||||
LZS lzs = new LZS(blockData, decompBlockData);
|
||||
// No need to trim the 0xFF pad as the EOF should terminate the decompression
|
||||
lzs.Decompress();
|
||||
}
|
||||
else // not compressed
|
||||
{
|
||||
// Copy the non-compressed blocks to the decompBlockData buffer
|
||||
decompBlockData = new byte[Gft.transfChunk.otaTotalBlocks * Gft.transfChunk.otaBlockSize];
|
||||
Array.Copy(blockData, decompBlockData, blockData.Length);
|
||||
}
|
||||
|
||||
// Calculate the number of bytes in the block signature
|
||||
int numBytesInSignature = 0;
|
||||
numBytesInSignature = (numFileBlocks + numControlBlocks) * Gft.transfChunk.otaBlockSize;
|
||||
|
||||
// Grab the signature or SHA-256
|
||||
byte[] verfBuf = new byte[_SIG_LEN];
|
||||
|
||||
// Verification Type
|
||||
if (verfType == "ECDsa")
|
||||
{
|
||||
// Signature starts at numBytesInSignature + 1 because the verification block version number is fisrt
|
||||
Array.Copy(decompBlockData, numBytesInSignature + 1, verfBuf, 0, _SIG_LEN);
|
||||
|
||||
ecdsa_v_p.pubKey = FWKeyPair.pubKey;
|
||||
ecdsa_v_p.buffer = decompBlockData;
|
||||
ecdsa_v_p.data_idx = 0;
|
||||
ecdsa_v_p.data_len = numBytesInSignature;
|
||||
ecdsa_v_p.signature = verfBuf;
|
||||
|
||||
// Verify the signature
|
||||
if (FWKeyPair.valid == false)
|
||||
{
|
||||
return "Signed (ECDsa), not verified (no cert)";
|
||||
}
|
||||
else if (FNv2_ECDsaP256_wSHA256.ECDsaVerify(ecdsa_v_p) == FNv2_ECDsaP256_wSHA256.ERR_NO_ERROR)
|
||||
return "Valid (ECDsa)";
|
||||
else
|
||||
return "Invalid (ECDsa)";
|
||||
}
|
||||
else // SHA-256
|
||||
{
|
||||
// SHA-256 starts at numBytesInSignature + 1 because the verification block version number is fisrt
|
||||
Array.Copy(decompBlockData, numBytesInSignature + 1, verfBuf, 0, _SIG_LEN/2);
|
||||
|
||||
using (SHA256Cng blockSHA = new SHA256Cng())
|
||||
{
|
||||
byte[] computedSHA = blockSHA.ComputeHash(decompBlockData, 0, numBytesInSignature);
|
||||
for (int i = 0; i < computedSHA.Length; i++)
|
||||
{
|
||||
if (computedSHA[i] != verfBuf[i])
|
||||
{
|
||||
return "Invalid (SHA-256)";
|
||||
}
|
||||
}
|
||||
return "Valid (SHA-256)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Sensus;
|
||||
using Sensus.Protocols.FlexNet.Serial;
|
||||
using Sensus.Protocols.FlexNet.Serial.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
interface ISerialConnection
|
||||
{
|
||||
bool IsConnected { get; }
|
||||
|
||||
void Open();
|
||||
|
||||
void Close();
|
||||
|
||||
event EventHandler<ReceptionEventArgs<ISerialMessageFrame>> MessageReceived;
|
||||
|
||||
event EventHandler<EventArgs> Disconnected;
|
||||
|
||||
ClassicSerialMessageFrame SendFlexNetSerial(ISerialCommandFrame cmd, bool responseExpected, UInt32 timeoutMs);
|
||||
|
||||
NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected);
|
||||
|
||||
NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected, UInt32 timeoutMs);
|
||||
|
||||
NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, byte responseCommmandCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,502 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
// Token Class (compress)
|
||||
public class TokenC
|
||||
{
|
||||
public byte lenInBits;
|
||||
public uint token;
|
||||
}
|
||||
|
||||
// Token Class (decompress)
|
||||
public enum TokenType
|
||||
{
|
||||
EOF,
|
||||
RAW_BYTE,
|
||||
STRING
|
||||
}
|
||||
|
||||
public class TokenD
|
||||
{
|
||||
public TokenType type;
|
||||
public byte rawByte;
|
||||
public int offset;
|
||||
public byte len;
|
||||
}
|
||||
|
||||
// LZS Class
|
||||
public class LZS
|
||||
{
|
||||
public static String VERSION = "170105-1.1";
|
||||
|
||||
// Version 1.0 - Released 05.20.2016 - Stephen Schamber - Sensus USA Inc
|
||||
// Initial Release
|
||||
|
||||
// Version 1.1 - Released 01.05.2017 - Stephen Schamber - Sensus USA Inc
|
||||
// Added decompression
|
||||
|
||||
// Constants
|
||||
private const byte _BIT_WRITE_MASK_INIT = 0x80;
|
||||
private const byte _BIT_READ_MASK_INIT = 0x80;
|
||||
public const int _LZS_MAX_HISTORY = 2048;
|
||||
public const int _LZS_MIN_MATCH = 2;
|
||||
public const int _LZS_MAX_MATCH = 52;
|
||||
|
||||
// Input/Output Buffers
|
||||
private byte[] inBuf;
|
||||
private byte[] outBuf;
|
||||
|
||||
// Output Stream Bit Write Indices (Compress)
|
||||
private int outByteIdx;
|
||||
private byte bitWriteMask;
|
||||
|
||||
// Input Stream Bit Read Indices (Decompress)
|
||||
private int inByteIdx;
|
||||
private byte bitReadMask;
|
||||
|
||||
// Constructor
|
||||
public LZS (byte[] inBuf, byte[] outBuf)
|
||||
{
|
||||
this.inBuf = inBuf;
|
||||
this.outBuf = outBuf;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// writeTokenToBitStream - writes a token to the output bitstream - Compress
|
||||
/*****************************************************************************/
|
||||
private Boolean writeTokenToBitStream(TokenC t)
|
||||
{
|
||||
// Length check
|
||||
if (t.lenInBits > 32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Shift token to MSBits
|
||||
t.token <<= (32 - t.lenInBits);
|
||||
|
||||
// Write bit (MSB First)
|
||||
for (; t.lenInBits > 0; t.lenInBits--)
|
||||
{
|
||||
if ((t.token & 0x80000000) > 0)
|
||||
{
|
||||
// Check for writing past the outBuf
|
||||
if (!(outByteIdx < outBuf.Length))
|
||||
return false;
|
||||
else
|
||||
outBuf[outByteIdx] |= bitWriteMask;
|
||||
}
|
||||
|
||||
// Next bit, Next Mask
|
||||
t.token <<= 1;
|
||||
bitWriteMask >>= 1;
|
||||
|
||||
// Time to wrap mask and increment outByteIdx
|
||||
if (!(bitWriteMask > 0))
|
||||
{
|
||||
bitWriteMask = _BIT_WRITE_MASK_INIT;
|
||||
outByteIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
// Value successfully written
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// buildToken - builds a raw byte token (non-compressed) - Compress
|
||||
/*****************************************************************************/
|
||||
private TokenC buildToken(byte rawByte)
|
||||
{
|
||||
TokenC t = new TokenC();
|
||||
// Insert b'0 | rawByte
|
||||
t.token = rawByte;
|
||||
t.lenInBits = 9; // 1-bit (0) indicates raw byte + raw byte (8)
|
||||
return t;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// buildToken - builds a string token (compressed) - Compress
|
||||
/*****************************************************************************/
|
||||
private TokenC buildToken(int offset, int length)
|
||||
{
|
||||
TokenC t = new TokenC();
|
||||
|
||||
// >>> Offset
|
||||
// Insert b'1
|
||||
t.token = 1;
|
||||
t.lenInBits = 1;
|
||||
if (offset < 128)
|
||||
{
|
||||
// Insert b'1
|
||||
t.token = (t.token << 1) | 1;
|
||||
// Insert 7-bit offset
|
||||
t.token = (t.token << 7) | (uint)(offset & 0x7F);
|
||||
t.lenInBits += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Insert b'0
|
||||
t.token <<= 1;
|
||||
// Insert 11-bit offset
|
||||
t.token = (t.token << 11) | (uint)(offset & 0x7FF);
|
||||
t.lenInBits += 12;
|
||||
}
|
||||
|
||||
// >>> LENGTH
|
||||
if (length < 5)
|
||||
{
|
||||
// Insert 2-bit length
|
||||
t.token = (t.token << 2) | (uint)(length - 2);
|
||||
t.lenInBits += 2;
|
||||
}
|
||||
else if (length < 8)
|
||||
{
|
||||
// Insert b'11
|
||||
t.token = (t.token << 2) | 3;
|
||||
// Insert 2-bit length
|
||||
t.token = (t.token << 2) | (uint)(length - 5);
|
||||
t.lenInBits += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Insert b'1111
|
||||
t.token = (t.token << 4) | 15;
|
||||
length -= 8;
|
||||
t.lenInBits += 4;
|
||||
while (!(length < 15))
|
||||
{
|
||||
// Insert b'1111
|
||||
t.token = (t.token << 4) | 15;
|
||||
t.lenInBits += 4;
|
||||
length -= 15;
|
||||
}
|
||||
// Insert 4-bit length
|
||||
t.token = (t.token << 4) | (uint)length;
|
||||
t.lenInBits += 4;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// buildEOF - builds an EOF token - Compress
|
||||
/*****************************************************************************/
|
||||
private TokenC buildEOFToken()
|
||||
{
|
||||
TokenC t = new TokenC();
|
||||
// Insert b'110000000
|
||||
t.token = 0x180;
|
||||
t.lenInBits = 9;
|
||||
return t;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// searchHistory - searches history buffer for source pattern match - Compress
|
||||
/*****************************************************************************/
|
||||
private int searchHistory(int histStartIdx, int histLen, int sourceIdx, int sourceLen)
|
||||
{
|
||||
// Serach history starting at the end to find the minimum offset
|
||||
int offset = 1;
|
||||
int searchIdx = histStartIdx + histLen - sourceLen;
|
||||
while (!(searchIdx < histStartIdx))
|
||||
{
|
||||
Boolean match = true;
|
||||
// Attempt to match sting of sourceLen, break on first char mismatch
|
||||
for (int i = 0; i < sourceLen; i++)
|
||||
{
|
||||
if (inBuf[searchIdx + i] != inBuf[sourceIdx + i])
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Return the offset into the history buffer on match
|
||||
if (match)
|
||||
return offset;
|
||||
// If no match, back up the searchIdx and check for match
|
||||
else
|
||||
{
|
||||
offset++;
|
||||
searchIdx--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// Compress
|
||||
/*****************************************************************************/
|
||||
public int Compress()
|
||||
{
|
||||
// Clear the outBuf since only b'1 bits are written
|
||||
Array.Clear(outBuf, 0, outBuf.Length);
|
||||
|
||||
// Init the output bit stream writing
|
||||
outByteIdx = 0;
|
||||
bitWriteMask = _BIT_WRITE_MASK_INIT;
|
||||
|
||||
// Write first byte as a raw byte token since there isn't any history yet
|
||||
if (!writeTokenToBitStream(buildToken(inBuf[0])))
|
||||
return 0; // Attempted to write past outBuf
|
||||
|
||||
// History
|
||||
int histStartIdx = 0;
|
||||
int histLen = 2;
|
||||
|
||||
// Source
|
||||
int sourceIdx = 1;
|
||||
int sourceLen = _LZS_MIN_MATCH;
|
||||
|
||||
int offset;
|
||||
int lastOffset = 0;
|
||||
// Compression Loop:
|
||||
// Loop until there is one byte left in the buffer or
|
||||
// we have already matched at least two bytes and are including the last byte in a potential match
|
||||
while (sourceIdx < (inBuf.Length - 1) || (sourceLen > _LZS_MIN_MATCH))
|
||||
{
|
||||
// Check for source string match
|
||||
// Returns 0 for no match
|
||||
// Returns "offset" when match is detected
|
||||
if ((sourceLen > _LZS_MAX_MATCH) || (offset = searchHistory(histStartIdx, histLen, sourceIdx, sourceLen)) == 0)
|
||||
{
|
||||
// No Match Case 1: No match of _LZS_MIN_MATCH detected
|
||||
if (!(sourceLen > _LZS_MIN_MATCH))
|
||||
{
|
||||
// WRITE RAW BYTE TOKEN
|
||||
if (!writeTokenToBitStream(buildToken(inBuf[sourceIdx])))
|
||||
return 0; // Attempted to write past outBuf
|
||||
}
|
||||
// No Match Case 2: Match of at least _LZS_MIN_MATCH or match of _LZS_MAX_MATCH detected
|
||||
else
|
||||
{
|
||||
// WRITE STRING TOKEN
|
||||
if (!writeTokenToBitStream(buildToken(lastOffset, sourceLen - 1)))
|
||||
return 0; // Attempted to write past outBuf
|
||||
}
|
||||
|
||||
// Increment Source Index
|
||||
sourceIdx += (sourceLen - 1);
|
||||
// Reset the Source Length
|
||||
sourceLen = _LZS_MIN_MATCH;
|
||||
|
||||
// Handle Sliding History Window
|
||||
histLen++;
|
||||
if (!(histLen < _LZS_MAX_HISTORY))
|
||||
{
|
||||
histStartIdx += (histLen - _LZS_MAX_HISTORY);
|
||||
histLen = _LZS_MAX_HISTORY;
|
||||
}
|
||||
}
|
||||
// Match of at least _LZS_MIN_MATCH detected
|
||||
else
|
||||
{
|
||||
// No input data remaining
|
||||
if (!((sourceIdx + sourceLen) < inBuf.Length))
|
||||
{
|
||||
// WRITE STRING TOKEN
|
||||
if (!writeTokenToBitStream(buildToken(offset, sourceLen)))
|
||||
return 0; // Attempted to write past outBuf
|
||||
|
||||
// No input data remaining
|
||||
// Increment source index so that no bytes are "flushed"
|
||||
sourceIdx += sourceLen;
|
||||
break;
|
||||
}
|
||||
// Try to match a longer string
|
||||
// Increment the source length
|
||||
sourceLen++;
|
||||
// History length can grow as long as a match has been detected
|
||||
histLen++;
|
||||
// Remember the lastOffset for string tokens
|
||||
lastOffset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
// Need to flush any remaining bytes
|
||||
while (sourceIdx < inBuf.Length)
|
||||
{
|
||||
// WRITE RAW BYTE TOKEN
|
||||
if (!writeTokenToBitStream(buildToken(inBuf[sourceIdx])))
|
||||
return 0; // Attempted to write past outBuf
|
||||
sourceIdx++;
|
||||
}
|
||||
|
||||
// Write EOF token
|
||||
// No need to pad to byte boundary since buffer has already been cleared
|
||||
if (!writeTokenToBitStream(buildEOFToken()))
|
||||
return 0; // Attempted to write past outBuf
|
||||
|
||||
// Return the compressed length:
|
||||
// If a complete byte was previous written, len = outByteIdx
|
||||
// If a partial byte was written, len = outByteIdx + 1
|
||||
return (bitWriteMask == 0x80) ? outByteIdx : outByteIdx + 1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// readBitFromBitStream - reads a bit from the input bitstream - Decompress
|
||||
/*****************************************************************************/
|
||||
private byte readBitFromBitStream()
|
||||
{
|
||||
byte bit = 0;
|
||||
|
||||
if ((inBuf[inByteIdx] & bitReadMask) > 0)
|
||||
bit++;
|
||||
|
||||
bitReadMask >>= 1;
|
||||
// Time to wrap mask and increment outByteIdx
|
||||
if (!(bitReadMask > 0))
|
||||
{
|
||||
bitReadMask = _BIT_READ_MASK_INIT;
|
||||
inByteIdx++;
|
||||
}
|
||||
|
||||
return bit;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// readTokenFromBitStream - reads a token from the input bitstream - Decompress
|
||||
/*****************************************************************************/
|
||||
private TokenD readTokenFromBitStream()
|
||||
{
|
||||
TokenD t = new TokenD();
|
||||
|
||||
// Raw Byte Token
|
||||
if (readBitFromBitStream() == 0)
|
||||
{
|
||||
t.type = TokenType.RAW_BYTE;
|
||||
|
||||
t.rawByte = 0;
|
||||
// Read the raw byte from the input stream
|
||||
for (int i = 7; !(i < 0); i--)
|
||||
t.rawByte |= (byte)(readBitFromBitStream() << i);
|
||||
}
|
||||
// String or EOF Token
|
||||
else
|
||||
{
|
||||
t.type = TokenType.STRING;
|
||||
t.offset = 0;
|
||||
t.len = 0;
|
||||
|
||||
// Grab the offset:
|
||||
// 7-bit offset
|
||||
if (readBitFromBitStream() == 1)
|
||||
{
|
||||
// Read 7-bit offset from the input stream
|
||||
for (int i = 6; !(i < 0); i--)
|
||||
t.offset |= (readBitFromBitStream() << i);
|
||||
|
||||
// Check for EOF (7-bit offset == 0)
|
||||
if (t.offset == 0)
|
||||
{
|
||||
t.type = TokenType.EOF;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
// 11-bit offset
|
||||
else
|
||||
{
|
||||
// Read 11-bit offset from the input stream
|
||||
for (int i = 10; !(i < 0); i--)
|
||||
t.offset |= (readBitFromBitStream() << i);
|
||||
}
|
||||
|
||||
// Grab the length: (Max Length <= 52)
|
||||
// Read 2-bit length from the input stream
|
||||
for (int i = 1; !(i < 0); i--)
|
||||
t.len |= (byte)(readBitFromBitStream() << i);
|
||||
|
||||
// 2 <= len <= 4
|
||||
if (t.len < 3)
|
||||
t.len += 2;
|
||||
// 5 <= len <= 7
|
||||
else
|
||||
{
|
||||
t.len = 0;
|
||||
// Read 2-bit length from the input stream
|
||||
for (int i = 1; !(i < 0); i--)
|
||||
t.len |= (byte)(readBitFromBitStream() << i);
|
||||
|
||||
if (t.len < 3)
|
||||
t.len += 5;
|
||||
// 8 <= len <= 22
|
||||
else
|
||||
{
|
||||
t.len = 0;
|
||||
// Read 4-bit length from the input stream
|
||||
for (int i = 3; !(i < 0); i--)
|
||||
t.len |= (byte)(readBitFromBitStream() << i);
|
||||
|
||||
if (t.len < 15)
|
||||
t.len += 8;
|
||||
// 23 <= len <= 37
|
||||
else
|
||||
{
|
||||
t.len = 0;
|
||||
// Read 4-bit length from the input stream
|
||||
for (int i = 3; !(i < 0); i--)
|
||||
t.len |= (byte)(readBitFromBitStream() << i);
|
||||
|
||||
if (t.len < 15)
|
||||
t.len += 23;
|
||||
// 38 <= len <= 52
|
||||
else
|
||||
{
|
||||
t.len = 0;
|
||||
// Read 4-bit length from the input stream
|
||||
for (int i = 3; !(i < 0); i--)
|
||||
t.len |= (byte)(readBitFromBitStream() << i);
|
||||
|
||||
if (t.len < 15)
|
||||
t.len += 38;
|
||||
else
|
||||
t.len = 0; // Set len = 0 to indicate a length > 52 was detected
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// Decompress
|
||||
/*****************************************************************************/
|
||||
public int Decompress()
|
||||
{
|
||||
// Init the input bit stream reading
|
||||
inByteIdx = 0;
|
||||
bitReadMask = _BIT_READ_MASK_INIT;
|
||||
|
||||
// Init the output byte stream writing
|
||||
outByteIdx = 0;
|
||||
|
||||
TokenD td = new TokenD();
|
||||
Boolean EOFDetected = false;
|
||||
// Decompress loop
|
||||
while (EOFDetected == false)
|
||||
{
|
||||
td = readTokenFromBitStream();
|
||||
switch (td.type)
|
||||
{
|
||||
case TokenType.EOF:
|
||||
EOFDetected = true;
|
||||
break;
|
||||
case TokenType.RAW_BYTE:
|
||||
outBuf[outByteIdx++] = td.rawByte;
|
||||
break;
|
||||
case TokenType.STRING:
|
||||
int idx = outByteIdx - td.offset;
|
||||
while(td.len-- > 0)
|
||||
{
|
||||
outBuf[outByteIdx++] = outBuf[idx++];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the number of decompressed bytes
|
||||
return outByteIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//using FlexNetCommand;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This class provides logging facilities for the <b>whole</b> application.
|
||||
/// All logging activities should go through this class's methods. This class
|
||||
/// can be used to log in the standard Sensus logging format.
|
||||
/// </summary>
|
||||
/// @todo Find a link to the standard Sensus logging format specification document
|
||||
/// and edit the documentation to include it.
|
||||
public static partial class Log
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Writes a LogQueueEntry item to the log.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The item will be written to the log followed by
|
||||
/// Environment.NewLine. If LogBox is non-null, the logAppend method will be
|
||||
/// called on the box's thread using Control.BeginInvoke().
|
||||
///
|
||||
/// To ensure thread-safety, this method locks on _q before modifying _q.
|
||||
/// </remarks>
|
||||
/// <param name="item">the item to write</param>
|
||||
public static void Write(string str)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
#region Fields
|
||||
readonly Action<object> _execute;
|
||||
readonly Predicate<object> _canExecute;
|
||||
#endregion // Fields
|
||||
#region Constructors
|
||||
public RelayCommand(Action<object> execute) : this(execute, null) { }
|
||||
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
|
||||
{
|
||||
if (execute == null)
|
||||
throw new ArgumentNullException("execute");
|
||||
_execute = execute; _canExecute = canExecute;
|
||||
}
|
||||
#endregion // Constructors
|
||||
#region ICommand Members
|
||||
[DebuggerStepThrough]
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return _canExecute == null ? true : _canExecute(parameter);
|
||||
}
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
public void Execute(object parameter) { _execute(parameter); }
|
||||
#endregion // ICommand Members
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class SensusRFKey
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public byte[] Key;
|
||||
|
||||
|
||||
public static bool CheckKey(string keyStr)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
string[] check = keyStr.Split(' ');
|
||||
if(check.Length != 16)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < check.Length; i++)
|
||||
{
|
||||
byte testResult;
|
||||
if (!(byte.TryParse(check[i], System.Globalization.NumberStyles.HexNumber, null, out testResult))) //Check each bit.
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (testResult > 0xFF)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
bool ParseKey(string keyStr)
|
||||
{
|
||||
bool result = true;
|
||||
string[] check = keyStr.Split(' ');
|
||||
byte[] key = new byte[check.Length];
|
||||
//Check the length
|
||||
if(key.Length != 16)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < check.Length; i++) //Attempt to parse the key and shove it into a byte array
|
||||
{
|
||||
byte testResult;
|
||||
if (!(byte.TryParse(check[i], System.Globalization.NumberStyles.HexNumber, null, out testResult))) //Check each bit.
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
if (testResult > 0xFF)
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
key[i] = testResult;
|
||||
}
|
||||
|
||||
|
||||
if (result) //If we didn't fail, load it into the actual Key.
|
||||
{
|
||||
Key = key;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public SensusRFKey(string name, byte[] key)
|
||||
{
|
||||
Name = name;
|
||||
Key = key;
|
||||
|
||||
}
|
||||
|
||||
public SensusRFKey(string name, string keyStr)
|
||||
{
|
||||
Name = name;
|
||||
if (!ParseKey(keyStr))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Bad Key");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SensusRFKeyManager
|
||||
{
|
||||
public List<SensusRFKey> KeyList;
|
||||
|
||||
public bool AddKey(string name, string keyStr)
|
||||
{
|
||||
bool result = true;
|
||||
foreach(SensusRFKey key in KeyList)
|
||||
{
|
||||
if(key.Name == name)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
try
|
||||
{
|
||||
KeyList.Add(new SensusRFKey(name, keyStr));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool AddKey(string name, byte[] newKey)
|
||||
{
|
||||
bool result = true;
|
||||
foreach (SensusRFKey key in KeyList)
|
||||
{
|
||||
if (key.Name == name)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(result)
|
||||
{
|
||||
try
|
||||
{
|
||||
KeyList.Add(new SensusRFKey(name, newKey));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<string> GetNameList()
|
||||
{
|
||||
List<string> nameList = new List<string>();
|
||||
foreach(SensusRFKey key in KeyList)
|
||||
{
|
||||
nameList.Add(key.Name);
|
||||
}
|
||||
|
||||
return nameList;
|
||||
}
|
||||
|
||||
public byte[] GetKey(string name)
|
||||
{
|
||||
foreach(SensusRFKey key in KeyList)
|
||||
{
|
||||
if(key.Name == name)
|
||||
{
|
||||
return key.Key;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public SensusRFKeyManager()
|
||||
{
|
||||
KeyList = new List<SensusRFKey>();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FactoryKey
|
||||
{
|
||||
public static byte[] Value { get { return new byte[] { 0x90, 0xbe, 0x46, 0xa2, 0xc7, 0xb3, 0x09, 0x02, 0x28, 0xcf, 0x74, 0x96, 0x61, 0x10, 0xd8, 0xf2 }; } }
|
||||
}
|
||||
|
||||
class DefaultKey
|
||||
{
|
||||
public static byte[] Value { get { return new byte[] { 0xE6, 0xC8, 0x88, 0x00, 0xDE, 0xB8, 0x68, 0xC0, 0xD6, 0xA8, 0x48, 0x80, 0xCE, 0x98, 0x28, 0x40 }; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
using System.IO.Ports;
|
||||
using Sensus;
|
||||
using Sensus.CommunicationDevices;
|
||||
using Sensus.Protocols.FlexNet.Serial;
|
||||
using Sensus.Protocols.FlexNet.Serial.FNv2;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a transaction manager for a CommandLink
|
||||
/// </summary>
|
||||
public class SerialManager: ISerialConnection, IDisposable
|
||||
{
|
||||
public FlexNetSerialConnection FactoryUart = null;
|
||||
public string ComPortString { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets up Serial for communication
|
||||
/// </summary>
|
||||
/// <param name="serialComPort">Serial COM port</param>
|
||||
public SerialManager(string serialcomPort)
|
||||
{
|
||||
// Initialize Serial Port
|
||||
SerialPort factoryUart = new SerialPort(serialcomPort, 115200, Parity.None, 8, StopBits.One);
|
||||
FactoryUart = new FlexNetSerialConnection(serialcomPort);
|
||||
FactoryUart.SetBaudRate(115200);
|
||||
ComPortString = serialcomPort;
|
||||
}
|
||||
public void Open()
|
||||
{
|
||||
// Open Factory UART
|
||||
if (!FactoryUart.IsConnected)
|
||||
{
|
||||
FactoryUart.Connect(null);
|
||||
}
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
FactoryUart.Disconnect();
|
||||
}
|
||||
|
||||
public bool IsConnected { get { return FactoryUart.IsConnected; } }
|
||||
|
||||
object objectLock = new Object();
|
||||
|
||||
public event EventHandler<ReceptionEventArgs<ISerialMessageFrame>> MessageReceived
|
||||
{
|
||||
add
|
||||
{
|
||||
lock (objectLock)
|
||||
{
|
||||
FactoryUart.MessageReceived += value;
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
lock (objectLock)
|
||||
{
|
||||
FactoryUart.MessageReceived -= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<EventArgs> Disconnected
|
||||
{
|
||||
add
|
||||
{
|
||||
lock (objectLock)
|
||||
{
|
||||
FactoryUart.Disconnected += value;
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
lock (objectLock)
|
||||
{
|
||||
FactoryUart.Disconnected -= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ClassicSerialMessageFrame SendFlexNetSerial(ISerialCommandFrame cmd, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
ClassicSerialMessageFrame response = null;
|
||||
|
||||
if(responseExpected)
|
||||
{
|
||||
try
|
||||
{
|
||||
response = FactoryUart.Send(cmd, TimeSpan.FromMilliseconds(timeoutMs)) as ClassicSerialMessageFrame;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Log.Write("No response before timeout\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FactoryUart.Send(cmd);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected, UInt32 timeoutMs)
|
||||
{
|
||||
NA2WSerialFrame response = null;
|
||||
|
||||
if (responseExpected)
|
||||
{
|
||||
try
|
||||
{
|
||||
response = FactoryUart.Send(cmdFrame, TimeSpan.FromMilliseconds(timeoutMs)) as NA2WSerialFrame;
|
||||
}
|
||||
catch (TimeoutException e)
|
||||
{
|
||||
Log.Write("No response before timeout\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FactoryUart.Send(cmdFrame);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, bool responseExpected)
|
||||
{
|
||||
return SendNa2wSerial(cmdFrame, responseExpected, 5000);
|
||||
}
|
||||
|
||||
public NA2WSerialFrame SendNa2wSerial(ISerialCommandFrame cmdFrame, byte responseCommandCode)
|
||||
{
|
||||
ISerialMessageFrame response = null;
|
||||
|
||||
using (AutoResetEvent e = new AutoResetEvent(false))
|
||||
{
|
||||
EventHandler<ReceptionEventArgs<ISerialMessageFrame>> ackChecker = (mrs, mre) =>
|
||||
{
|
||||
if (mre.Frame.CommandCode == responseCommandCode)
|
||||
{
|
||||
response = mre.Frame;
|
||||
e.Set();
|
||||
}
|
||||
};
|
||||
|
||||
bool foundResponse = false;
|
||||
|
||||
try
|
||||
{
|
||||
FactoryUart.MessageReceived += ackChecker;
|
||||
FactoryUart.Send(cmdFrame);
|
||||
foundResponse = e.WaitOne(TimeSpan.FromSeconds(8));
|
||||
}
|
||||
finally
|
||||
{
|
||||
FactoryUart.MessageReceived -= ackChecker;
|
||||
}
|
||||
|
||||
if (!foundResponse)
|
||||
{
|
||||
Log.Write("No response before timeout\n");
|
||||
}
|
||||
}
|
||||
|
||||
if ((response != null) && (response is NA2WSerialFrame))
|
||||
{
|
||||
return ((NA2WSerialFrame) response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
bool disposed = false;
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed)
|
||||
return;
|
||||
|
||||
Close();
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public enum WMBusDeviceType
|
||||
{
|
||||
Other = 0x00,
|
||||
Oil = 0x01,
|
||||
Electricity = 0x02,
|
||||
Gas = 0x03,
|
||||
Head = 0x04,
|
||||
Stream = 0x05,
|
||||
WarmWater_30_90 = 0x06,
|
||||
Water = 0x07,
|
||||
HeatCostAllocator = 0x08,
|
||||
#if false
|
||||
static String (self):
|
||||
|
||||
if (self.address[5] >= 0x40):
|
||||
return 'Reserved'
|
||||
|
||||
return {
|
||||
0x00: 'Other',
|
||||
0x01: 'Oil',
|
||||
0x02: 'Electricity',
|
||||
0x03: 'Gas',
|
||||
0x04: 'Head',
|
||||
0x05: 'Steam ',
|
||||
0x06: 'Warm water (30-90 °C)',
|
||||
0x07: 'Water ',
|
||||
0x08: 'Heat cost allocator ',
|
||||
0x09: 'Compressed air ',
|
||||
0x0A: 'Cooling load meter (Volume measured at return temperature: outlet)',
|
||||
0x0B: 'Cooling load meter (Volume measured at flow temperature: inlet)',
|
||||
0x0C: 'Heat (Volume measured at flow temperature: inlet)',
|
||||
0x0D: 'Heat / Cooling load meter',
|
||||
0x0E: 'Bus / System component',
|
||||
0x0F: 'Unknown medium',
|
||||
0x10: 'Reserved for consumption meter',
|
||||
0x11: 'Reserved for consumption meter',
|
||||
0x12: 'Reserved for consumption meter',
|
||||
0x13: 'Reserved for consumption meter',
|
||||
0x14: 'Calorific value',
|
||||
0x15: 'Hot water (≥ 90 °C)',
|
||||
0x16: 'Cold water',
|
||||
0x17: 'Dual register (hot/cold) water meter',
|
||||
0x18: 'Pressure',
|
||||
0x19: 'A/D Converter',
|
||||
0x1A: 'Smoke detector',
|
||||
0x1B: 'Room sensor (eg temperature or humidity)',
|
||||
0x1C: 'Gas detector',
|
||||
0x1D: 'Reserved for sensors',
|
||||
0x1F: 'Reserved for sensors',
|
||||
0x20: 'Breaker (electricity)',
|
||||
0x21: 'Valve (gas or water)',
|
||||
0x22: 'Reserved for switching devices',
|
||||
0x23: 'Reserved for switching devices',
|
||||
0x24: 'Reserved for switching devices',
|
||||
0x25: 'Customer unit (display device)',
|
||||
0x26: 'Reserved for customer units',
|
||||
0x27: 'Reserved for customer units',
|
||||
0x28: 'Waste water',
|
||||
0x29: 'Garbage',
|
||||
0x2A: 'Reserved for Carbon dioxide',
|
||||
0x2B: 'Reserved for environmental meter',
|
||||
0x2C: 'Reserved for environmental meter',
|
||||
0x2D: 'Reserved for environmental meter',
|
||||
0x2E: 'Reserved for environmental meter',
|
||||
0x2F: 'Reserved for environmental meter',
|
||||
0x30: 'Reserved for system devices',
|
||||
0x31: 'Reserved for communication controller',
|
||||
0x32: 'Reserved for unidirectional repeater',
|
||||
0x33: 'Reserved for bidirectional repeater',
|
||||
0x34: 'Reserved for system devices',
|
||||
0x35: 'Reserved for system devices',
|
||||
0x36: 'Radio converter (system side)',
|
||||
0x37: 'Radio converter (meter side)',
|
||||
0x38: 'Reserved for system devices',
|
||||
0x39: 'Reserved for system devices',
|
||||
0x3A: 'Reserved for system devices',
|
||||
0x3B: 'Reserved for system devices',
|
||||
0x3C: 'Reserved for system devices',
|
||||
0x3D: 'Reserved for system devices',
|
||||
0x3E: 'Reserved for system devices',
|
||||
0x3F: 'Reserved for system devices'
|
||||
}.get(self.address[5], 'get_device_type(): type unknown')
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("NfcC7_DLL")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NfcC7_DLL")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("A27EE8F2-46F8-43B1-82C7-F49D5DE392EC")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user