MeterResetPsu: - corrected FLEXNETVERSION raw file based on hexadecimal version instead of previously used decimal version
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -493,6 +492,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2022-Aug-11" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-May-07" author="Thomas Wiedebusch">
|
||||
/// - Changed to take the new hexadecimal version into account as
|
||||
/// version is already preprocessed at connection time.
|
||||
/// </remarks>
|
||||
private Boolean BuildUpgradeFile()
|
||||
{
|
||||
if (_genesisMeter == null)
|
||||
@@ -503,11 +506,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
// search FLEXNETVERSION
|
||||
var flexnetversionFound = false;
|
||||
var strVersion = "";
|
||||
UInt32 version = 0;
|
||||
UInt16 fileAppCrc = 0;
|
||||
foreach (var app in _genesisMeter.MeterAppListVersion.Where(app => app.AppName == "FLEXNETVERSION"))
|
||||
foreach (var app in _genesisMeter.MeterAppListVersion.Where(app => app.AppId == FlexnetVersionAppId))
|
||||
{
|
||||
strVersion = app.StrVersion;
|
||||
fileAppCrc = app.Crc;
|
||||
version = app.Version;
|
||||
flexnetversionFound = true;
|
||||
}
|
||||
|
||||
@@ -520,36 +525,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
_upgradeFile = new Byte[TemplateUpgradeFile.Length];
|
||||
Buffer.BlockCopy(TemplateUpgradeFile, 0, _upgradeFile, 0, _upgradeFile.Length);
|
||||
|
||||
// rebuild numerical version out of the string because the FLEXNETVERSION version cannot be used
|
||||
// as it does lose the "B" information on conversion which is represented with the mask 0x80.
|
||||
// Later the file contains the preceding "B" or "R" instead of a number higher than 0x80.
|
||||
// The expected version string is 12.47 or 92.47 from app.StrVersion. Convert to R1.2.47 or B.2.47
|
||||
|
||||
// remove all points
|
||||
strVersion = strVersion.Replace(".", "");
|
||||
|
||||
// to insert the correct naming in the string, all characters have to be separated
|
||||
var charVersion = strVersion.ToCharArray();
|
||||
|
||||
// for the hex number needed in the upgrade file
|
||||
int.TryParse(strVersion, NumberStyles.HexNumber, null, out var hexVersion);
|
||||
|
||||
// add the "B" for test versions and the "R" for release versions
|
||||
if ((hexVersion & 0x8000) == 0x8000)
|
||||
{
|
||||
strVersion = "B";
|
||||
charVersion[0] = Convert.ToChar($"{(hexVersion & ~0x8000) >> 12}");
|
||||
}
|
||||
else
|
||||
{
|
||||
strVersion = "R";
|
||||
}
|
||||
|
||||
_upgradeFile[MeterFwUpdate.FileAppVersionIndex] = (Byte)(hexVersion & 0xFF);
|
||||
_upgradeFile[MeterFwUpdate.FileAppVersionIndex + 1] = (Byte)((hexVersion & 0xFF00) >> 8);
|
||||
_upgradeFile[MeterFwUpdate.FileAppVersionIndex] = (Byte)(version & 0xFF);
|
||||
_upgradeFile[MeterFwUpdate.FileAppVersionIndex + 1] = (Byte)((version & 0xFF00) >> 8);
|
||||
|
||||
// build the version string and copy it to the upgrade file
|
||||
strVersion += $"{charVersion[0]}.{charVersion[1]}.{charVersion[2]}{charVersion[3]}";
|
||||
//strVersion += $"{charVersion[0]}.{charVersion[1]}.{charVersion[2]}{charVersion[3]}";
|
||||
var upg18Idx = FlexVersionStringIndex;
|
||||
foreach (var t in strVersion)
|
||||
{
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
bf6bb8fceb3db5a9977dadc407cf576684bf7127
|
||||
8fbe991b217e7692af4817ad205b768685aa5a72
|
||||
|
||||
Reference in New Issue
Block a user