mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-06 03:28:58 +00:00
Created class for dealing with unknown HAN port of Kaifa meter
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Crc16.cs" />
|
||||
<Compile Include="KaifaHanBeta.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Reader.cs" />
|
||||
|
||||
47
Code/HanDebugger/HanDebugger/KaifaHanBeta.cs
Normal file
47
Code/HanDebugger/HanDebugger/KaifaHanBeta.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HanDebugger
|
||||
{
|
||||
// As it seems Kaifa/Valider put some premature firmware on my AMS,
|
||||
// there's need for some dirty hacks to get any information
|
||||
public class KaifaHanBeta
|
||||
{
|
||||
public const byte ListUnknown = 0x00;
|
||||
public const byte List1 = 0x01;
|
||||
public const byte List2 = 0x0D;
|
||||
public const byte List3 = 0x12;
|
||||
|
||||
public static byte GetPackageID(byte[] package, int start, int length)
|
||||
{
|
||||
switch (package[start + 23])
|
||||
{
|
||||
case List1:
|
||||
case List2:
|
||||
case List3:
|
||||
return package[start + 23];
|
||||
default:
|
||||
return 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
public static double GetPackageTime(byte[] package, int start, int length)
|
||||
{
|
||||
const int timeStart = 10;
|
||||
int year = package[start + timeStart] << 8 |
|
||||
package[start + timeStart + 1];
|
||||
|
||||
int month = package[start + timeStart + 2];
|
||||
int day = package[start + timeStart + 3];
|
||||
int hour = package[start + timeStart + 5];
|
||||
int minute = package[start + timeStart + 6];
|
||||
int second = package[start + timeStart + 7];
|
||||
|
||||
|
||||
return new DateTime(year, month, day, hour, minute, second).Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user