FwVersion calculation generalized
This commit is contained in:
@@ -1255,11 +1255,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
fwVersion += (UInt32)(((lsb & 0xF0) >> 4) * 10 + (lsb & 0x0F));
|
||||
//skip leading 0
|
||||
var msbPartString = (msb & 0xF0) > 0 ? $"{(msb & 0xF0) >> 4:X0}." : "";
|
||||
return msbPartString + $"{msb & 0x0F:X0}" + "." + $"{(lsb & 0xF0) >> 4:X1}" + $"{lsb & 0x0F:X1}";
|
||||
msbPartString += $"{msb & 0x0F:X0}" + "." + $"{(lsb & 0xF0) >> 4:X1}" + $"{lsb & 0x0F:X1}";
|
||||
return msbPartString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Building the FW Version string out of UInt32 as hexadecimal input like 0x1107 (meaning 1.1.07).
|
||||
/// Example:
|
||||
/// Input fwVersion = 0x1107,
|
||||
/// Outputs string "1.1.07"
|
||||
/// </summary>
|
||||
/// <param name="fwVersion">firmware version as hex</param>
|
||||
/// <returns>converted "to "2.34" or "2.0C" </returns>
|
||||
@@ -1267,12 +1271,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
{
|
||||
//skip leading 0
|
||||
var msbPartString = (fwVersion & 0xF000) > 0 ? $"{(fwVersion & 0xF000) >> 12:X0}." : "";
|
||||
return msbPartString + $"{(fwVersion & 0xF00) >> 8:X0}.{(fwVersion & 0x0F0) >> 4:X0}" +
|
||||
msbPartString += $"{(fwVersion & 0xF00) >> 8:X0}.{(fwVersion & 0x0F0) >> 4:X0}" +
|
||||
$"{fwVersion & 0x00F:X0}";
|
||||
return msbPartString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Building the FW Version string out of Int32 as decimal input.
|
||||
/// Example:
|
||||
/// Input fwVersion = 238,
|
||||
/// Outputs string "2.38"
|
||||
/// </summary>
|
||||
/// <param name="fwVersion">firmware version as hex</param>
|
||||
/// <returns>converted to "2.34" or "2.01" </returns>
|
||||
|
||||
@@ -63,6 +63,19 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
|
||||
/// <summary>
|
||||
/// Threshold for power correction EMEA version
|
||||
/// </summary>
|
||||
public const UInt32 EmeaFwThresholdForPowCorr= 0x1300;
|
||||
/// <summary>
|
||||
/// Threshold for power correction NA version
|
||||
/// </summary>
|
||||
public const UInt32 NaFNaFwThresholdForPowCorr = 0x2006;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Maintenance readout
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1427,16 +1427,31 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// Extracts version from binary application file.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Apr-04" author="Thomas Wiedebusch">
|
||||
/// <remarks date="2024-May-07" author="Thomas Wiedebusch">
|
||||
/// - Initial extracted from <see cref="CheckFileApp"/>
|
||||
/// </remarks>
|
||||
public static UInt32 GetFileAppVersion(Byte[] binData)
|
||||
public static UInt32 GetFileAppVersion(Byte[] binData, out String strVersion)
|
||||
{
|
||||
return (UInt32)((binData[FileAppVersionIndex] & 0x0F)
|
||||
+ ((binData[FileAppVersionIndex] & 0xF0) >> 4) * 10
|
||||
+ (binData[FileAppVersionIndex + 1] & 0x0F) * 100
|
||||
+ ((binData[FileAppVersionIndex + 1] & 0xF0) >> 4) * 1000);
|
||||
var appId = binData[FileAppAppIdIndex];
|
||||
strVersion = "0.00";
|
||||
UInt32 version;
|
||||
|
||||
if (appId == 0x18) //FLEXNETVERSION
|
||||
{
|
||||
strVersion = GenesisMeter.BuildFlexnetFwVersion(out version, null,
|
||||
binData[FileAppVersionIndex + 1],
|
||||
binData[FileAppVersionIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
strVersion = GenesisMeter.BuildFwVersion(out version,
|
||||
binData[FileAppVersionIndex + 1],
|
||||
binData[FileAppVersionIndex]);
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the content of the binaries:
|
||||
/// - begins with "APP>",
|
||||
@@ -1455,25 +1470,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2024-May-06" author="Thomas Wiedebusch">
|
||||
/// - File version as hex number to handle .
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-May-07" author="Thomas Wiedebusch">
|
||||
/// - Uses <see cref="GetFileAppVersion"/>.
|
||||
/// </remarks>
|
||||
private static Boolean CheckFileApp(FileApplications fileApp)
|
||||
{
|
||||
var binData = fileApp.BinData.ToArray();
|
||||
fileApp.AppId = binData[FileAppAppIdIndex];
|
||||
fileApp.Version = GetFileAppVersion(binData, out fileApp.StrVersion);
|
||||
fileApp.Crc = (UInt16)(binData[FileAppCrcIndex] + (binData[FileAppCrcIndex + 1] << 8));
|
||||
|
||||
if (fileApp.AppId == 0x18) //FLEXNETVERSION
|
||||
{
|
||||
fileApp.StrVersion = GenesisMeter.BuildFlexnetFwVersion(out fileApp.Version, null,
|
||||
binData[FileAppVersionIndex + 1],
|
||||
binData[FileAppVersionIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileApp.StrVersion = GenesisMeter.BuildFwVersion(out fileApp.Version,
|
||||
binData[FileAppVersionIndex + 1],
|
||||
binData[FileAppVersionIndex]);
|
||||
}
|
||||
|
||||
var fileAppStartId = Encoding.UTF8.GetString(binData, 0, 4);
|
||||
//check update file start identifier
|
||||
if (fileAppStartId != StrFileAppStartId)
|
||||
@@ -2016,7 +2021,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
#region PackageFile
|
||||
|
||||
/// <summary>
|
||||
/// Load package control file
|
||||
/// Load package control file - ADF (application description file)
|
||||
/// </summary>
|
||||
/// <param name="filePathName">to binary files</param>
|
||||
/// <returns></returns>
|
||||
@@ -2035,7 +2040,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load package control file
|
||||
/// Load package control file - ADF (application description file)
|
||||
/// </summary>
|
||||
/// <param name="text">control file content</param>
|
||||
/// <returns></returns>
|
||||
@@ -2049,7 +2054,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate package file with update files
|
||||
/// Validate package file (ADF - application description file)
|
||||
/// with update files (ABC - application binary container)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2019-Jun-24" author="Thomas Wiedebusch">
|
||||
|
||||
@@ -29,6 +29,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
//error mask for unsuccessfully written LUT CRC
|
||||
private const UInt32 LutCrcErrorMask = 0x8000000;
|
||||
|
||||
/// <summary>
|
||||
/// Threshold for power correction EMEA version
|
||||
/// </summary>
|
||||
public const UInt32 EmeaFwThresholdForLutFile= 0x1200;
|
||||
/// <summary>
|
||||
/// Threshold for power correction NA version
|
||||
/// </summary>
|
||||
public const UInt32 NaFwThresholdForLutFile = 0x2000;
|
||||
|
||||
//trigger update retries
|
||||
private const Int32 RegisterWriteRetries = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user