diff --git a/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vcxproj b/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vcxproj index f51e33f..7707037 100644 --- a/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vcxproj +++ b/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vcxproj @@ -238,14 +238,15 @@ NotUsing - Level3 + Level4 Disabled - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate OldStyle MultiThreadedDebugDLL + true Windows @@ -261,9 +262,9 @@ NotUsing - Level3 + Level4 Disabled - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) @@ -271,6 +272,7 @@ ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate MultiThreadedDebugDLL + true Windows @@ -286,9 +288,9 @@ NotUsing - Level3 + Level4 Disabled - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) @@ -296,6 +298,7 @@ ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate MultiThreadedDebug + true Windows @@ -311,9 +314,9 @@ NotUsing - Level3 + Level4 Disabled - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) @@ -321,6 +324,7 @@ ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate MultiThreadedDebug + true Windows @@ -336,12 +340,15 @@ NotUsing - Level3 + Level4 Disabled - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate OldStyle MultiThreadedDebugDLL + + + true Windows @@ -357,12 +364,15 @@ NotUsing - Level3 + Level4 Disabled - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate MultiThreadedDebug + + + true Windows @@ -377,14 +387,15 @@ - Level3 + Level4 NotUsing MaxSpeed true true - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + true Windows @@ -401,14 +412,15 @@ - Level3 + Level4 NotUsing MaxSpeed true true - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + true Windows @@ -425,15 +437,16 @@ - Level3 + Level4 NotUsing MaxSpeed true true - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate MultiThreaded + true Windows @@ -450,15 +463,16 @@ - Level3 + Level4 NotUsing MaxSpeed true true - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate MultiThreaded + true Windows @@ -475,14 +489,17 @@ - Level3 + Level4 NotUsing MaxSpeed true true - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + + + true Windows @@ -499,15 +516,18 @@ - Level3 + Level4 NotUsing MaxSpeed true true - WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;WIN_API_TARGET_VERSION=81000000L;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON;%(PreprocessorDefinitions) ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate MultiThreaded + + + true Windows @@ -544,6 +564,8 @@ + + @@ -586,6 +608,8 @@ + + diff --git a/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vcxproj.filters b/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vcxproj.filters index b3d416d..9084a62 100644 --- a/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vcxproj.filters +++ b/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vcxproj.filters @@ -138,6 +138,12 @@ Header Files + + Header Files + + + Header Files + @@ -242,5 +248,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vpj b/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vpj new file mode 100644 index 0000000..0c9b1ef --- /dev/null +++ b/Make/VS.2017/opensea-parser/opensea-parser/opensea-parser.vpj @@ -0,0 +1,1257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.sln b/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.sln new file mode 100644 index 0000000..878732f --- /dev/null +++ b/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.sln @@ -0,0 +1,100 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opensea-parser", "opensea-parser.vcxproj", "{D7A121F5-30B5-4CA9-A272-3B6469FF8F46}" + ProjectSection(ProjectDependencies) = postProject + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF} = {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opensea-common", "..\..\..\..\..\opensea-common\Make\VS.2017\opensea-common\opensea-common\opensea-common.vcxproj", "{FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + Static-Debug|ARM = Static-Debug|ARM + Static-Debug|ARM64 = Static-Debug|ARM64 + Static-Debug|x64 = Static-Debug|x64 + Static-Debug|x86 = Static-Debug|x86 + Static-Release|ARM = Static-Release|ARM + Static-Release|ARM64 = Static-Release|ARM64 + Static-Release|x64 = Static-Release|x64 + Static-Release|x86 = Static-Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Debug|ARM.ActiveCfg = Debug|ARM + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Debug|ARM.Build.0 = Debug|ARM + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Debug|ARM64.ActiveCfg = Debug|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Debug|x64.ActiveCfg = Debug|x64 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Debug|x64.Build.0 = Debug|x64 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Debug|x86.ActiveCfg = Debug|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Debug|x86.Build.0 = Debug|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Release|ARM.ActiveCfg = Release|ARM + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Release|ARM.Build.0 = Release|ARM + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Release|ARM64.ActiveCfg = Release|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Release|x64.ActiveCfg = Release|x64 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Release|x64.Build.0 = Release|x64 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Release|x86.ActiveCfg = Release|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Release|x86.Build.0 = Release|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Debug|ARM.ActiveCfg = Static-Debug|ARM + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Debug|ARM.Build.0 = Static-Debug|ARM + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Debug|ARM64.ActiveCfg = Static-Debug|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Debug|x64.ActiveCfg = Static-Debug|x64 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Debug|x64.Build.0 = Static-Debug|x64 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Debug|x86.ActiveCfg = Static-Debug|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Debug|x86.Build.0 = Static-Debug|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Release|ARM.ActiveCfg = Static-Release|ARM + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Release|ARM.Build.0 = Static-Release|ARM + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Release|ARM64.ActiveCfg = Static-Release|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Release|x64.ActiveCfg = Static-Release|x64 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Release|x64.Build.0 = Static-Release|x64 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Release|x86.ActiveCfg = Static-Release|Win32 + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46}.Static-Release|x86.Build.0 = Static-Release|Win32 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Debug|ARM.ActiveCfg = Debug|ARM + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Debug|ARM.Build.0 = Debug|ARM + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Debug|ARM64.Build.0 = Debug|ARM64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Debug|x64.ActiveCfg = Debug|x64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Debug|x64.Build.0 = Debug|x64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Debug|x86.ActiveCfg = Debug|Win32 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Debug|x86.Build.0 = Debug|Win32 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Release|ARM.ActiveCfg = Release|ARM + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Release|ARM.Build.0 = Release|ARM + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Release|ARM64.ActiveCfg = Release|ARM64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Release|ARM64.Build.0 = Release|ARM64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Release|x64.ActiveCfg = Release|x64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Release|x64.Build.0 = Release|x64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Release|x86.ActiveCfg = Release|Win32 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Release|x86.Build.0 = Release|Win32 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Debug|ARM.ActiveCfg = Static-Debug|ARM + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Debug|ARM.Build.0 = Static-Debug|ARM + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Debug|ARM64.ActiveCfg = Static-Debug|ARM64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Debug|ARM64.Build.0 = Static-Debug|ARM64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Debug|x64.ActiveCfg = Static-Debug|x64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Debug|x64.Build.0 = Static-Debug|x64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Debug|x86.ActiveCfg = Static-Debug|Win32 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Debug|x86.Build.0 = Static-Debug|Win32 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Release|ARM.ActiveCfg = Static-Release|ARM + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Release|ARM.Build.0 = Static-Release|ARM + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Release|ARM64.ActiveCfg = Static-Release|ARM64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Release|ARM64.Build.0 = Static-Release|ARM64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Release|x64.ActiveCfg = Static-Release|x64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Release|x64.Build.0 = Static-Release|x64 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Release|x86.ActiveCfg = Static-Release|Win32 + {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}.Static-Release|x86.Build.0 = Static-Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6A601820-17AE-4AC9-BD11-6073FE6CA375} + EndGlobalSection +EndGlobal diff --git a/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vcxproj b/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vcxproj new file mode 100644 index 0000000..fbe0ce1 --- /dev/null +++ b/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vcxproj @@ -0,0 +1,611 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + Static-Debug + ARM + + + Static-Debug + Win32 + + + Static-Debug + x64 + + + Static-Release + ARM + + + Static-Release + Win32 + + + Static-Release + x64 + + + + {D7A121F5-30B5-4CA9-A272-3B6469FF8F46} + Win32Proj + openseaparser + 10.0 + + + + StaticLibrary + true + v142 + NotSet + + + StaticLibrary + true + v142 + NotSet + + + StaticLibrary + true + v142 + NotSet + + + StaticLibrary + true + v142 + NotSet + + + StaticLibrary + true + v142 + NotSet + + + StaticLibrary + true + v142 + NotSet + + + StaticLibrary + false + v142 + true + NotSet + + + StaticLibrary + false + v142 + true + NotSet + + + StaticLibrary + false + v142 + true + NotSet + + + StaticLibrary + false + v142 + true + NotSet + + + StaticLibrary + false + v142 + true + NotSet + + + StaticLibrary + false + v142 + true + NotSet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + $(ProjectDir)\..\$(Platform)\$(Configuration)\LIB\ + opensea-parser + $(Platform)\$(Configuration)\ + + + + NotUsing + Level4 + Disabled + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + + + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + EditAndContinue + MultiThreadedDebugDLL + + + Windows + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + NotUsing + Level4 + Disabled + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + + + + + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + EditAndContinue + MultiThreadedDebugDLL + + + Windows + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + NotUsing + Level4 + Disabled + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + + + + + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + EditAndContinue + MultiThreadedDebug + + + Windows + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + NotUsing + Level4 + Disabled + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + + + + + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + EditAndContinue + MultiThreadedDebug + + + Windows + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + NotUsing + Level4 + Disabled + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + EditAndContinue + MultiThreadedDebugDLL + + + Windows + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration) + + + + + NotUsing + Level4 + Disabled + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + EditAndContinue + MultiThreadedDebug + + + Windows + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + Level4 + NotUsing + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + None + + + Windows + true + true + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + Level4 + NotUsing + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + None + + + Windows + true + true + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + Level4 + NotUsing + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + MultiThreaded + None + + + Windows + true + true + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + Level4 + NotUsing + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + MultiThreaded + None + + + Windows + true + true + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + Level4 + NotUsing + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + None + + + Windows + true + true + true + + + opensea-common.lib + + + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + Level4 + NotUsing + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;SEAPARSER_EXPORTS;STATIC_OPENSEA_COMMON + ..\..\..\..\include;..\..\..\..\..\libjson;..\..\..\..\..\opensea-common\include;..\..\..\..\..\opensea-parser\include;..\..\..\..\..\opensea-parser\include\Seagate + MultiThreaded + None + + + Windows + true + true + true + + + opensea-common.lib + ..\..\..\..\..\opensea-common\Make\VS.2019\opensea-common\$(Platform)\$(Configuration);..\..\..\..\..\opensea-operations\Make\VS.2019\opensea-operations\$(Platform)\$(Configuration)\LIB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vcxproj.filters b/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vcxproj.filters new file mode 100644 index 0000000..9084a62 --- /dev/null +++ b/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vcxproj.filters @@ -0,0 +1,258 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vpj b/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vpj new file mode 100644 index 0000000..0c9b1ef --- /dev/null +++ b/Make/VS.2019/opensea-parser/opensea-parser/opensea-parser.vpj @@ -0,0 +1,1257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Make/gcc/Makefile b/Make/gcc/Makefile index 9ad9968..6785350 100644 --- a/Make/gcc/Makefile +++ b/Make/gcc/Makefile @@ -14,7 +14,7 @@ NAME=opensea-parser #Change the Major version when major interface changes are made. MAJOR=0 #Change the Minor version when new features are added. -MINOR=0 +MINOR=1 #Change the patch version when only bug fixes are made. PATCH=14 @@ -31,9 +31,11 @@ VERSION=$(MAJOR).$(MINOR).$(PATCH) SRC_DIR=../../src/ INC_DIR=-I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson CXX ?= g++ -CXXFLAGS ?= -Wall +CXXFLAGS ?= -Wall -Wextra -Werror=old-style-cast -Wshadow -Wmaybe-uninitialized -Wvla -Wfloat-equal \ + -Wlogical-op -Wdouble-promotion -Wformat-security CXXFLAGS += -c -fPIC -std=c++98 -I. ARCHIVE ?= ar +LFLAGS ?= -Wall-Wl,--whole-archive ../../../opensea-common/Make/gcc/lib/$(FILE_OUTPUT_DIR)/libopensea-common.a -Wl,--no-whole-archive LIB_SRC_FILES = \ $(SRC_DIR)Opensea_Parser_Helper.cpp\ $(SRC_DIR)CLog.cpp\ @@ -57,6 +59,8 @@ LIB_SRC_FILES = \ $(SRC_DIR)CScsi_Informational_Exeptions_Log.cpp\ $(SRC_DIR)CScsi_Logical_Block_Provisioning_Log.cpp\ $(SRC_DIR)CScsi_Non_Medium_Error_Count_Log.cpp\ + $(SRC_DIR)CScsi_Page_19h_Cache_Memory_Statistics_Log.cpp\ + $(SRC_DIR)CScsi_Page_19h_Command_Duration_Limits_Log.cpp\ $(SRC_DIR)CScsi_Pending_Defects_Log.cpp\ $(SRC_DIR)CScsi_Power_Condition_Transitions_Log.cpp\ $(SRC_DIR)CScsi_Protocol_Specific_Port_Log.cpp\ @@ -82,7 +86,37 @@ FILE_OUTPUT_DIR=lib #-include $(DEPFILES) -.PHONY: all +#Add more warnings for the GCC versions that support them +#gcc 5.5 and up : -Wlogical-not-parentheses +# 6.5 and up : -Wnull-dereference -Wduplicated-cond -Wshift-overflow=2 +ifeq ($(UNAME),Linux) + GCC_VERSION_STRING = $(shell $(CC) -dumpversion) + GCC_VER = $(subst ., ,$(GCC_VERSION_STRING)) + GCC_MAJOR = $(word 1,$(GCC_VER)) + GCC_MINOR = $(word 2,$(GCC_VER)) + GCC_SUBMINOR = $(word 3,$(GCC_VER)) + ifeq ($(GCC_MINOR),) + GCC_MINOR = 0 + endif + ifeq ($(GCC_SUBMINOR),) + GCC_SUBMINOR = 0 + endif + ifeq ($(shell test $(GCC_MAJOR) -gt 4; echo $$?),0) + ifeq ($(shell test $(GCC_MINOR) -gt 4; echo $$?),0) + CXXFLAGS += -Wlogical-not-parentheses + endif + endif + ifeq ($(shell test $(GCC_MAJOR) -gt 5; echo $$?),0) + ifeq ($(shell test $(GCC_MINOR) -gt 4; echo $$?),0) + CXXFLAGS += -Wnull-dereference -Wduplicated-cond -Wshift-overflow=2 + endif + endif +endif + +.PHONY: all + +python: PROJECT_DEFINES += -DPREPYTHON +python: all all: clean mkoutputdir $(LIBS) done @@ -94,6 +128,8 @@ $(LIBS): $(LIB_OBJ_FILES) $(ARCHIVE) cq $(FILE_OUTPUT_DIR)/$@ $(LIB_OBJ_FILES) # Removing the line below since we don't need a shared object for this right now...a static library is enough for the common stuff $(CXX) $(LXXFLAGS) $(LIB_OBJ_FILES) -o lib$(NAME).so.$(VERSION) + cd $(FILE_OUTPUT_DIR) && ln -s lib$(NAME).so* lib$(NAME).so + clean: banner rm -f $(SRC_DIR)*.o rm -f $(SRC_DIR)Seagate/*.o diff --git a/Make/gcc/Makefile.old b/Make/gcc/Makefile.old new file mode 100644 index 0000000..9ad9968 --- /dev/null +++ b/Make/gcc/Makefile.old @@ -0,0 +1,117 @@ +# +# +# Do NOT modify or remove this copyright and license +# +# Copyright (c) 2017 - 2019 Seagate Technology LLC and/or its Affiliates, All Rights Reserved +# +# This software is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# ****************************************************************************************** + +NAME=opensea-parser +#Change the Major version when major interface changes are made. +MAJOR=0 +#Change the Minor version when new features are added. +MINOR=0 +#Change the patch version when only bug fixes are made. +PATCH=14 + +UNAME := $(shell uname -s) +OS=$(shell uname) + +ifeq ($(UNAME),Darwin) + LXXFLAGS += -shared -undefined dynamic_lookup -Wall +else + LXXFLAGS += -shared -Wall +endif + +VERSION=$(MAJOR).$(MINOR).$(PATCH) +SRC_DIR=../../src/ +INC_DIR=-I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson +CXX ?= g++ +CXXFLAGS ?= -Wall +CXXFLAGS += -c -fPIC -std=c++98 -I. +ARCHIVE ?= ar +LIB_SRC_FILES = \ + $(SRC_DIR)Opensea_Parser_Helper.cpp\ + $(SRC_DIR)CLog.cpp\ + $(SRC_DIR)CAta_Ext_DST_Log.cpp\ + $(SRC_DIR)CAta_Device_Stat_Log.cpp\ + $(SRC_DIR)CAta_Ext_Comprehensive_Log.cpp\ + $(SRC_DIR)CAta_Identify_Log.cpp\ + $(SRC_DIR)CAta_Power_Condition_Log.cpp\ + $(SRC_DIR)CAta_NCQ_Command_Error_Log.cpp\ + $(SRC_DIR)CAta_SMART_Log_Dir.cpp\ + $(SRC_DIR)CScsi_Log.cpp\ + $(SRC_DIR)CScsi_Application_Client_Log.cpp\ + $(SRC_DIR)CScsi_Background_Operation_Log.cpp\ + $(SRC_DIR)CScsi_Background_Scan_Log.cpp\ + $(SRC_DIR)CScsi_Cache_Statistics_Log.cpp\ + $(SRC_DIR)CScsi_Environmental_Logs.cpp\ + $(SRC_DIR)CScsi_Temperature_Log.cpp\ + $(SRC_DIR)CScsi_Error_Counter_Log.cpp\ + $(SRC_DIR)CScsi_Factory_Log.cpp\ + $(SRC_DIR)CScsi_Format_Status_Log.cpp\ + $(SRC_DIR)CScsi_Informational_Exeptions_Log.cpp\ + $(SRC_DIR)CScsi_Logical_Block_Provisioning_Log.cpp\ + $(SRC_DIR)CScsi_Non_Medium_Error_Count_Log.cpp\ + $(SRC_DIR)CScsi_Pending_Defects_Log.cpp\ + $(SRC_DIR)CScsi_Power_Condition_Transitions_Log.cpp\ + $(SRC_DIR)CScsi_Protocol_Specific_Port_Log.cpp\ + $(SRC_DIR)CScsi_Self_Test_Results_Log.cpp\ + $(SRC_DIR)CScsi_Solid_State_Drive_Log.cpp\ + $(SRC_DIR)CScsi_Start_Stop_Cycle_Counter_Log.cpp\ + $(SRC_DIR)CScsi_Supported_LogPages_Log.cpp\ + $(SRC_DIR)CScsi_Zoned_Device_Statistics_Log.cpp\ + $(SRC_DIR)/Seagate/Farm_Common.cpp\ + $(SRC_DIR)/Seagate/CFARM_Log.cpp\ + $(SRC_DIR)/Seagate/CAta_Farm_Log.cpp\ + $(SRC_DIR)/Seagate/CScsi_Farm_Log.cpp\ + +PROJECT_DEFINES += #-D_DEBUG + +#All of the source files have associated object files +LIB_OBJ_FILES = $(LIB_SRC_FILES:.cpp=.o) +LIBS = lib$(NAME).a + +FILE_OUTPUT_DIR=lib + +#DEPFILES = $(LIB_SRC_FILES:.c=.d) + +#-include $(DEPFILES) + +.PHONY: all + +all: clean mkoutputdir $(LIBS) done + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(PROJECT_DEFINES) $(INC_DIR) $< -o $@ + +$(LIBS): $(LIB_OBJ_FILES) + rm -f $(FILE_OUTPUT_DIR)/$@ + $(ARCHIVE) cq $(FILE_OUTPUT_DIR)/$@ $(LIB_OBJ_FILES) +# Removing the line below since we don't need a shared object for this right now...a static library is enough for the common stuff + $(CXX) $(LXXFLAGS) $(LIB_OBJ_FILES) -o lib$(NAME).so.$(VERSION) +clean: banner + rm -f $(SRC_DIR)*.o + rm -f $(SRC_DIR)Seagate/*.o + rm -f $(FILE_OUTPUT_DIR)/lib$(NAME).a $(FILE_OUTPUT_DIR)/lib$(NAME).so.$(VERSION) *.o ../../src/*.o ../../src/Seagate/*.o + rm -rf $(FILE_OUTPUT_DIR) + @echo "============================================================" + @echo " CLEANED" + @echo "============================================================" + +mkoutputdir: + mkdir -p $(FILE_OUTPUT_DIR) + +banner: + @echo "============================================================" + @echo "opensea-parser Makefile version: "$(MAJOR).$(MINOR).$(PATCH) "OS: "$(OS) + @echo "============================================================" + +done: + @echo "============================================================" + @echo "Build of opensea-parser has completed " + @echo "============================================================" diff --git a/Make/gcc/makeout.txt b/Make/gcc/makeout.txt new file mode 100644 index 0000000..6f57964 --- /dev/null +++ b/Make/gcc/makeout.txt @@ -0,0 +1,127 @@ +============================================================ +opensea-parser Makefile version: 0.0.14 OS: Linux +============================================================ +rm -f ../../src/*.o +rm -f ../../src/Seagate/*.o +rm -f lib/libopensea-parser.a lib/libopensea-parser.so.0.0.14 *.o ../../src/*.o ../../src/Seagate/*.o +rm -rf lib +============================================================ + CLEANED +============================================================ +mkdir -p lib +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/Opensea_Parser_Helper.cpp -o ../../src/Opensea_Parser_Helper.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CLog.cpp -o ../../src/CLog.o +../../src/CLog.cpp: In member function ‘void opensea_parser::CLog::get_CLog(const string&)’: +../../src/CLog.cpp:106:41: warning: unused parameter ‘fileName’ [-Wunused-parameter] + void CLog::get_CLog(const std::string & fileName) + ~~~~~~~~~~~~~~~~~~~~^~~~~~~~ +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CAta_Ext_DST_Log.cpp -o ../../src/CAta_Ext_DST_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CAta_Device_Stat_Log.cpp -o ../../src/CAta_Device_Stat_Log.o +../../src/CAta_Device_Stat_Log.cpp: In member function ‘void opensea_parser::CAtaDeviceStatisticsLogs::logPage00(uint64_t*)’: +../../src/CAta_Device_Stat_Log.cpp:720:52: warning: unused parameter ‘value’ [-Wunused-parameter] + void CAtaDeviceStatisticsLogs::logPage00(uint64_t *value) + ~~~~~~~~~~^~~~~ +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CAta_Ext_Comprehensive_Log.cpp -o ../../src/CAta_Ext_Comprehensive_Log.o +../../src/CAta_Ext_Comprehensive_Log.cpp: In member function ‘eReturnValues opensea_parser::CExtComp::parse_Ext_Comp_Structure(uint32_t, uint32_t, void*)’: +../../src/CAta_Ext_Comprehensive_Log.cpp:213:14: warning: variable ‘reserved’ set but not used [-Wunused-but-set-variable] + uint8_t reserved = 0; + ^~~~~~~~ +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CAta_Identify_Log.cpp -o ../../src/CAta_Identify_Log.o +../../src/CAta_Identify_Log.cpp: In member function ‘eReturnValues opensea_parser::CAta_Identify_Log_00::get_Log_Page00(uint8_t*, void*)’: +../../src/CAta_Identify_Log.cpp:1103:61: warning: unused parameter ‘pData’ [-Wunused-parameter] + eReturnValues CAta_Identify_Log_00::get_Log_Page00(uint8_t *pData, JSONNODE *masterData) + ~~~~~~~~~^~~~~ +../../src/CAta_Identify_Log.cpp: In member function ‘eReturnValues opensea_parser::CAta_Identify_Log_02::get_Log_Page02(uint8_t*, void*)’: +../../src/CAta_Identify_Log.cpp:1344:44: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘opensea_parser::sLogPage02’ {aka ‘struct opensea_parser::_sLogPage02’}; use assignment or value-initialization instead [-Wclass-memaccess] + memset(pCapacity, 0, sizeof(sLogPage02)); + ^ +In file included from ../../include/CAta_Identify_Log.h:21, + from ../../src/CAta_Identify_Log.cpp:11: +../../include/Identify_Log_Types.h:179:17: note: ‘opensea_parser::sLogPage02’ {aka ‘struct opensea_parser::_sLogPage02’} declared here + typedef struct _sLogPage02 + ^~~~~~~~~~~ +../../src/CAta_Identify_Log.cpp: In member function ‘eReturnValues opensea_parser::CAta_Identify_Log_03::get_Log_Page03(uint8_t*, void*)’: +../../src/CAta_Identify_Log.cpp:2664:40: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘opensea_parser::sLogPage03’ {aka ‘struct opensea_parser::_sLogPage03’}; use assignment or value-initialization instead [-Wclass-memaccess] + memset(m_pCap, 0, sizeof(logPage03)); + ^ +In file included from ../../include/CAta_Identify_Log.h:21, + from ../../src/CAta_Identify_Log.cpp:11: +../../include/Identify_Log_Types.h:189:17: note: ‘opensea_parser::sLogPage03’ {aka ‘struct opensea_parser::_sLogPage03’} declared here + typedef struct _sLogPage03 + ^~~~~~~~~~~ +../../src/CAta_Identify_Log.cpp: In member function ‘eReturnValues opensea_parser::CAta_Identify_log::parse_Device_Info()’: +../../src/CAta_Identify_Log.cpp:371:16: warning: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 13 bytes from a string of the same length [-Wstringop-truncation] + strncpy((char*)m_sDriveInfo.worldWideName.c_str(), "Not Supported", strlen("Not Supported")); + ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CAta_Power_Condition_Log.cpp -o ../../src/CAta_Power_Condition_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CAta_NCQ_Command_Error_Log.cpp -o ../../src/CAta_NCQ_Command_Error_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CAta_SMART_Log_Dir.cpp -o ../../src/CAta_SMART_Log_Dir.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Log.cpp -o ../../src/CScsi_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Application_Client_Log.cpp -o ../../src/CScsi_Application_Client_Log.o +../../src/CScsi_Application_Client_Log.cpp: In member function ‘void opensea_parser::CScsiApplicationLog::process_Client_Data(void*)’: +../../src/CScsi_Application_Client_Log.cpp:156:28: warning: ‘char* strncat(char*, const char*, size_t)’ specified bound 1 equals source length [-Wstringop-overflow=] + strncat(innerMsg, " ", 1); + ~~~~~~~^~~~~~~~~~~~~~~~~~ +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Background_Operation_Log.cpp -o ../../src/CScsi_Background_Operation_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Background_Scan_Log.cpp -o ../../src/CScsi_Background_Scan_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Cache_Statistics_Log.cpp -o ../../src/CScsi_Cache_Statistics_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Environmental_Logs.cpp -o ../../src/CScsi_Environmental_Logs.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Temperature_Log.cpp -o ../../src/CScsi_Temperature_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Error_Counter_Log.cpp -o ../../src/CScsi_Error_Counter_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Factory_Log.cpp -o ../../src/CScsi_Factory_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Format_Status_Log.cpp -o ../../src/CScsi_Format_Status_Log.o +../../src/CScsi_Format_Status_Log.cpp: In member function ‘void opensea_parser::CScsiFormatStatusLog::process_Format_Status_Data_Variable_Length(void*)’: +../../src/CScsi_Format_Status_Log.cpp:257:24: warning: ‘char* strncat(char*, const char*, size_t)’ specified bound 1 equals source length [-Wstringop-overflow=] + strncat(innerMsg, " ", 1); + ~~~~~~~^~~~~~~~~~~~~~~~~~ +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Informational_Exeptions_Log.cpp -o ../../src/CScsi_Informational_Exeptions_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Logical_Block_Provisioning_Log.cpp -o ../../src/CScsi_Logical_Block_Provisioning_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Non_Medium_Error_Count_Log.cpp -o ../../src/CScsi_Non_Medium_Error_Count_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Pending_Defects_Log.cpp -o ../../src/CScsi_Pending_Defects_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Power_Condition_Transitions_Log.cpp -o ../../src/CScsi_Power_Condition_Transitions_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Protocol_Specific_Port_Log.cpp -o ../../src/CScsi_Protocol_Specific_Port_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Self_Test_Results_Log.cpp -o ../../src/CScsi_Self_Test_Results_Log.o +../../src/CScsi_Self_Test_Results_Log.cpp: In member function ‘void opensea_parser::CScsi_DST_Results::get_Self_Test_Results_String(std::__cxx11::string&, uint8_t)’: +../../src/CScsi_Self_Test_Results_Log.cpp:278:23: warning: this statement may fall through [-Wimplicit-fallthrough=] + meaning = "Completed having handling damage"; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +../../src/CScsi_Self_Test_Results_Log.cpp:280:9: note: here + case DST_FAILURE_SUSPECTED_HANDLING_DAMAGE: + ^~~~ +../../src/CScsi_Self_Test_Results_Log.cpp:282:23: warning: this statement may fall through [-Wimplicit-fallthrough=] + meaning = "Completed having suspected handling damage"; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +../../src/CScsi_Self_Test_Results_Log.cpp:284:3: note: here + case DST_IN_PROGRESS: + ^~~~ +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Solid_State_Drive_Log.cpp -o ../../src/CScsi_Solid_State_Drive_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Start_Stop_Cycle_Counter_Log.cpp -o ../../src/CScsi_Start_Stop_Cycle_Counter_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Supported_LogPages_Log.cpp -o ../../src/CScsi_Supported_LogPages_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src/CScsi_Zoned_Device_Statistics_Log.cpp -o ../../src/CScsi_Zoned_Device_Statistics_Log.o +../../src/CScsi_Zoned_Device_Statistics_Log.cpp: In member function ‘bool opensea_parser::CScsiZonedDeviceStatisticsLog::get_ZDS_Parameter_Code_Description(uint16_t, std::__cxx11::string*)’: +../../src/CScsi_Zoned_Device_Statistics_Log.cpp:116:81: warning: unused parameter ‘paramCode’ [-Wunused-parameter] + bool CScsiZonedDeviceStatisticsLog::get_ZDS_Parameter_Code_Description(uint16_t paramCode, std::string *zdsString) + ~~~~~~~~~^~~~~~~~~ +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src//Seagate/Farm_Common.cpp -o ../../src//Seagate/Farm_Common.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src//Seagate/CFARM_Log.cpp -o ../../src//Seagate/CFARM_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src//Seagate/CAta_Farm_Log.cpp -o ../../src//Seagate/CAta_Farm_Log.o +g++ -Wall -Wextra -c -fPIC -std=c++98 -I. -I../../include -I../../include/Seagate -I../../../opensea-common/include -I../../../libjson ../../src//Seagate/CScsi_Farm_Log.cpp -o ../../src//Seagate/CScsi_Farm_Log.o +../../src//Seagate/CScsi_Farm_Log.cpp: In member function ‘eReturnValues opensea_parser::CSCSI_Farm_Log::print_LUN_Actuator_Information(void*, uint32_t, uint32_t, uint16_t)’: +../../src//Seagate/CScsi_Farm_Log.cpp:3258:108: warning: unused parameter ‘index’ [-Wunused-parameter] + eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Information(JSONNODE *masterData, uint32_t page, uint32_t index, uint16_t actNum) + ~~~~~~~~~^~~~~ +../../src//Seagate/CScsi_Farm_Log.cpp: In member function ‘eReturnValues opensea_parser::CSCSI_Farm_Log::print_LUN_Actuator_FLED_Info(void*, uint32_t, uint32_t, uint16_t)’: +../../src//Seagate/CScsi_Farm_Log.cpp:3361:106: warning: unused parameter ‘index’ [-Wunused-parameter] + eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_FLED_Info(JSONNODE *masterData, uint32_t page, uint32_t index, uint16_t actNum) + ~~~~~~~~~^~~~~ +../../src//Seagate/CScsi_Farm_Log.cpp: In member function ‘eReturnValues opensea_parser::CSCSI_Farm_Log::print_LUN_Actuator_Reallocation(void*, uint32_t, uint32_t, uint16_t)’: +../../src//Seagate/CScsi_Farm_Log.cpp:3465:109: warning: unused parameter ‘index’ [-Wunused-parameter] + eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Reallocation(JSONNODE *masterData, uint32_t page, uint32_t index,uint16_t actNum) + ~~~~~~~~~^~~~~ +rm -f lib/libopensea-parser.a +ar cq lib/libopensea-parser.a ../../src/Opensea_Parser_Helper.o ../../src/CLog.o ../../src/CAta_Ext_DST_Log.o ../../src/CAta_Device_Stat_Log.o ../../src/CAta_Ext_Comprehensive_Log.o ../../src/CAta_Identify_Log.o ../../src/CAta_Power_Condition_Log.o ../../src/CAta_NCQ_Command_Error_Log.o ../../src/CAta_SMART_Log_Dir.o ../../src/CScsi_Log.o ../../src/CScsi_Application_Client_Log.o ../../src/CScsi_Background_Operation_Log.o ../../src/CScsi_Background_Scan_Log.o ../../src/CScsi_Cache_Statistics_Log.o ../../src/CScsi_Environmental_Logs.o ../../src/CScsi_Temperature_Log.o ../../src/CScsi_Error_Counter_Log.o ../../src/CScsi_Factory_Log.o ../../src/CScsi_Format_Status_Log.o ../../src/CScsi_Informational_Exeptions_Log.o ../../src/CScsi_Logical_Block_Provisioning_Log.o ../../src/CScsi_Non_Medium_Error_Count_Log.o ../../src/CScsi_Pending_Defects_Log.o ../../src/CScsi_Power_Condition_Transitions_Log.o ../../src/CScsi_Protocol_Specific_Port_Log.o ../../src/CScsi_Self_Test_Results_Log.o ../../src/CScsi_Solid_State_Drive_Log.o ../../src/CScsi_Start_Stop_Cycle_Counter_Log.o ../../src/CScsi_Supported_LogPages_Log.o ../../src/CScsi_Zoned_Device_Statistics_Log.o ../../src//Seagate/Farm_Common.o ../../src//Seagate/CFARM_Log.o ../../src//Seagate/CAta_Farm_Log.o ../../src//Seagate/CScsi_Farm_Log.o +g++ -shared -Wall ../../src/Opensea_Parser_Helper.o ../../src/CLog.o ../../src/CAta_Ext_DST_Log.o ../../src/CAta_Device_Stat_Log.o ../../src/CAta_Ext_Comprehensive_Log.o ../../src/CAta_Identify_Log.o ../../src/CAta_Power_Condition_Log.o ../../src/CAta_NCQ_Command_Error_Log.o ../../src/CAta_SMART_Log_Dir.o ../../src/CScsi_Log.o ../../src/CScsi_Application_Client_Log.o ../../src/CScsi_Background_Operation_Log.o ../../src/CScsi_Background_Scan_Log.o ../../src/CScsi_Cache_Statistics_Log.o ../../src/CScsi_Environmental_Logs.o ../../src/CScsi_Temperature_Log.o ../../src/CScsi_Error_Counter_Log.o ../../src/CScsi_Factory_Log.o ../../src/CScsi_Format_Status_Log.o ../../src/CScsi_Informational_Exeptions_Log.o ../../src/CScsi_Logical_Block_Provisioning_Log.o ../../src/CScsi_Non_Medium_Error_Count_Log.o ../../src/CScsi_Pending_Defects_Log.o ../../src/CScsi_Power_Condition_Transitions_Log.o ../../src/CScsi_Protocol_Specific_Port_Log.o ../../src/CScsi_Self_Test_Results_Log.o ../../src/CScsi_Solid_State_Drive_Log.o ../../src/CScsi_Start_Stop_Cycle_Counter_Log.o ../../src/CScsi_Supported_LogPages_Log.o ../../src/CScsi_Zoned_Device_Statistics_Log.o ../../src//Seagate/Farm_Common.o ../../src//Seagate/CFARM_Log.o ../../src//Seagate/CAta_Farm_Log.o ../../src//Seagate/CScsi_Farm_Log.o -o libopensea-parser.so.0.0.14 +cd lib && ln -s libopensea-parser.so* libopensea-parser.so +============================================================ +Build of opensea-parser has completed +============================================================ diff --git a/include/CAta_Device_Stat_Log.h b/include/CAta_Device_Stat_Log.h index 7f614b4..dbcbd69 100644 --- a/include/CAta_Device_Stat_Log.h +++ b/include/CAta_Device_Stat_Log.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/CAta_Ext_Comprehensive_Log.h b/include/CAta_Ext_Comprehensive_Log.h index 54baf00..f5daa84 100644 --- a/include/CAta_Ext_Comprehensive_Log.h +++ b/include/CAta_Ext_Comprehensive_Log.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -31,7 +31,7 @@ namespace opensea_parser { size_t m_logSize; //!< size of the log. std::string m_name; //!< name of the class eReturnValues m_status; //!< holds the status of the class - bool fileName; //!< set to true if the file name is set + bool m_fileName; //!< set to true if the file name is set eReturnValues parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t sector, JSONNODE *structureData); diff --git a/include/CAta_Ext_DST_Log.h b/include/CAta_Ext_DST_Log.h index 4475065..a6ca477 100644 --- a/include/CAta_Ext_DST_Log.h +++ b/include/CAta_Ext_DST_Log.h @@ -4,7 +4,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/CAta_Identify_Log.h b/include/CAta_Identify_Log.h index 4773d15..2b70bba 100644 --- a/include/CAta_Identify_Log.h +++ b/include/CAta_Identify_Log.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -59,7 +59,7 @@ namespace opensea_parser { CAta_Identify_Log_00(uint8_t *Buffer); ~CAta_Identify_Log_00(); bool is_Page_Supported(uint8_t pageNumber); - eReturnValues get_Log_Page00(uint8_t *pData, JSONNODE *masterData); + eReturnValues get_Log_Page00(JSONNODE *masterData); }; @@ -80,7 +80,7 @@ namespace opensea_parser { public: CAta_Identify_Log_02(uint8_t *Buffer); ~CAta_Identify_Log_02(); - eReturnValues get_Log_Page02(uint8_t *pData, JSONNODE *masterData); + eReturnValues get_Log_Page02(uint8_t *lp2pData, JSONNODE *masterData); }; class CAta_Identify_Log_03 @@ -119,7 +119,7 @@ namespace opensea_parser { public: CAta_Identify_Log_03(uint8_t *Buffer); ~CAta_Identify_Log_03(); - eReturnValues get_Log_Page03(uint8_t *pData, JSONNODE *masterData); + eReturnValues get_Log_Page03(uint8_t *lp3pData, JSONNODE *masterData); }; class CAta_Identify_Log_04 @@ -146,7 +146,7 @@ namespace opensea_parser { public: CAta_Identify_Log_04(uint8_t *Buffer); ~CAta_Identify_Log_04(); - eReturnValues get_Log_Page04(uint8_t *pData, JSONNODE *masterData); + eReturnValues get_Log_Page04(uint8_t *lp4pData, JSONNODE *masterData); }; class CAta_Identify_Log_05 @@ -168,6 +168,9 @@ namespace opensea_parser { uint8_t productInformation[LOG5_PRODUCT_INFO]; //(m_bufferData); }; + char * get_log() { return m_bufferData; }; inline eReturnValues get_Log_Status(){ return m_logStatus; }; inline void set_Log_Status(eReturnValues status){ m_logStatus = status; }; }; diff --git a/include/CScsi_Application_Client_Log.h b/include/CScsi_Application_Client_Log.h index 84161da..a83bf71 100644 --- a/include/CScsi_Application_Client_Log.h +++ b/include/CScsi_Application_Client_Log.h @@ -40,10 +40,13 @@ namespace opensea_parser { } _sApplicationClientParameters(uint8_t* buffer) { +#define byte2 2 +#define byte3 3 +#define byte4 4 paramCode = *(reinterpret_cast(buffer)); - paramControlByte = buffer[2]; - paramLength = buffer[3]; - data = &buffer[4]; + paramControlByte = static_cast(buffer[byte2]); + paramLength = static_cast(buffer[byte3]); + data = static_cast(&buffer[byte4]); } } sApplicationParams; @@ -68,7 +71,10 @@ namespace opensea_parser { CScsiApplicationLog(uint8_t * buffer, size_t bufferSize, uint16_t pageLength); virtual ~CScsiApplicationLog(); virtual eReturnValues get_Log_Status() { return m_ApplicationStatus; }; - virtual eReturnValues parse_Application_Client_Log(JSONNODE *masterData) { return get_Client_Data(masterData); }; + virtual eReturnValues parse_Application_Client_Log(JSONNODE *masterData) + { + return get_Client_Data(masterData); + }; }; #endif diff --git a/include/CScsi_Background_Operation_Log.h b/include/CScsi_Background_Operation_Log.h index 8c6ba3c..7ddbe2f 100644 --- a/include/CScsi_Background_Operation_Log.h +++ b/include/CScsi_Background_Operation_Log.h @@ -2,7 +2,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -45,7 +45,7 @@ namespace opensea_parser { sOperationParams *m_Operation; // +#include +#include "common.h" +#include "libjson.h" +#include "Opensea_Parser_Helper.h" + +namespace opensea_parser { +#ifndef SCSICACHMEMSTATLOG +#define SCSICACHMEMSTATLOG + + class CScsiCacheMemStatLog + { + private: + protected: + +#pragma pack(push, 1) + + //Time From Last Hard Reset + typedef struct _sTimeIntervalDescriptors + { + uint16_t paramCode; // Paramcode + uint8_t controlByte; // Controlbyte + uint8_t paramLength; // Param Length + int32_t intervalExponent; // Number of Reads + uint32_t intervalInteger; // Number of Writes + } sTimeIntervalDescriptors; + +#pragma pack(pop) + + uint8_t *pData; // +#include +#include "common.h" +#include "libjson.h" +#include "Opensea_Parser_Helper.h" + + +namespace opensea_parser { +#ifndef SCSICOMMANDDURATIONLIMITSLOG +#define SCSICOMMANDDURATIONLIMITSLOG + + class CScsiCmdDurationLimitsLog + { + private: + protected: +#define PARAMLENGTH 4 +#pragma pack(push, 1) + + typedef struct _sCommandDurationLimitsParameter + { + uint16_t paramCode; // Paramcode + uint8_t controlByte; // Controlbyte + uint8_t paramLength; // Param Length + uint32_t inactiveMiss; // NUMBER OF INACTIVE TARGET MISS COMMANDS + uint32_t activeMiss; // NUMBER OF ACTIVE TARGET MISS COMMANDS + uint32_t latencyMiss; // NUMBER OF LATENCY MISS COMMANDS + uint32_t nonconformingMiss; // NUMBER OF NONCONFORMING MISS COMMANDS + uint32_t predictiveLatencyMiss; // NUMBER OF PREDICTIVE LATENCY MISS COMMANDS + uint32_t latencyMissesDoToError; // NUMBER OF LATENCY MISSES ATTRIBUTABLE TO ERRORS + uint32_t latencyMissesDeferredErrors; // NUMBER LATENCY MISSES ATTRIBUTABLE TO DEFERRED ERRORS + uint32_t missedDoToBackgroundOperations; // NUMBER OF LATENCY MISSES ATTRIBUTABLE TO BACKGROUND OPERATIONS + } sCommandDurationLimits; + + +#pragma pack(pop) + + uint8_t *pData; // #include "common.h" #include "libjson.h" +#include + +#include +#include +#include +#include +#include + extern eVerbosityLevels g_verbosity; +extern eDataFormat g_dataformat; +extern bool g_parseUnknown; extern time_t g_currentTime; extern char g_currentTimeString[64]; extern char *g_currentTimeStringPtr; @@ -41,6 +51,15 @@ namespace opensea_parser { #ifndef OPENSEA_PARSER #define OPENSEA_PARSER + // quick size for of the ints for case statements +#define ONE_INT_SIZE 1 +#define TWO_INT_SIZE 2 +#define FOUR_INT_SIZE 4 +#define EIGHT_INT_SIZE 8 + +#define LOGPAGESIZE 4 +#define PARAMSIZE 4 + #define RELISTAT 24 #define WORLD_WIDE_NAME_LEN 19 #define DEVICE_INTERFACE_LEN 4 @@ -50,6 +69,27 @@ namespace opensea_parser { #define SAS_FIRMWARE_REV_LEN 4 #define BASIC 80 +#define SAS_SUBPAGE_ZERO 0x00 +#define SAS_SUBPAGE_ONE 0x01 +#define SAS_SUBPAGE_TWO 0x02 +#define SAS_SUBPAGE_THREE 0x03 +#define SAS_SUBPAGE_FOUR 0x04 +#define SAS_SUBPAGE_FIVE 0x05 +#define SAS_SUBPAGE_SIX 0x06 +#define SAS_SUBPAGE_SEVEN 0x07 +#define SAS_SUBPAGE_EIGHT 0x08 +#define SAS_SUBPAGE_NINE 0x09 +#define SAS_SUBPAGE_A 0x0A +#define SAS_SUBPAGE_B 0x0B +#define SAS_SUBPAGE_C 0x0C +#define SAS_SUBPAGE_D 0x0D +#define SAS_SUBPAGE_E 0x0E +#define SAS_SUBPAGE_F 0x0F +#define SAS_SUBPAGE_20 0x20 +#define SAS_SUBPAGE_21 0x21 +#define SAS_SUBPAGE_FF 0xFF + +#define COMMAND_DURATION_LIMITS_LOG 0x19 // output file types typedef enum _eOpensea_print_Types @@ -59,7 +99,9 @@ namespace opensea_parser { OPENSEA_LOG_PRINT_CSV, OPENSEA_LOG_PRINT_FLAT_CSV, OPENSEA_LOG_PRINT_PROM, + OPENSEA_LOG_PRINT_PYTHON_DICTIONARY, }eOpensea_print_Types; + // SCSI Parameter Control Bytes typedef enum _eOpenSea_SCSI_Log_Parameter_Types { @@ -136,6 +178,15 @@ namespace opensea_parser { } } }sLogPageStruct; + + typedef struct _sLogPageParamStruct + { + uint16_t paramCode; //(M_DoubleWord0(value)))); + json_push_back(nowNode, json_new_i(myStr.c_str(), value)); } else { // if the vale is greater then a unsigned 32 bit number print it as a string - snprintf(printStr, BASIC, "%" PRIu64"", value); - json_push_back(nowNode, json_new_a((char *)myStr.c_str(), printStr)); + temp << std::dec << value; + json_push_back(nowNode, json_new_a(myStr.c_str(), temp.str().c_str())); } } - safe_Free(printStr); } //----------------------------------------------------------------------------- // @@ -307,28 +357,26 @@ namespace opensea_parser { //----------------------------------------------------------------------------- inline void set_json_64bit(JSONNODE *nowNode, const std::string & myStr, uint64_t value, bool hexPrint) { - char *printStr = (char*)calloc((BASIC), sizeof(char)); - + std::ostringstream temp; if (hexPrint) { //json does not support 64 bit numbers. Therefore we will print it as a string - snprintf(printStr, BASIC, "0x%016" PRIx64"", value); - json_push_back(nowNode, json_new_a((char *)myStr.c_str(), printStr)); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << value; + json_push_back(nowNode, json_new_a(myStr.c_str(), temp.str().c_str())); } else { if (M_IGETBITRANGE(value,63,32) == 0) { - json_push_back(nowNode, json_new_i((char *)myStr.c_str(), static_cast(M_DoubleWord0(value)))); + json_push_back(nowNode, json_new_i(myStr.c_str(), value)); } else { // if the vale is greater then a unsigned 32 bit number print it as a string - snprintf(printStr, BASIC, "%" PRIu64"", value); - json_push_back(nowNode, json_new_a((char *)myStr.c_str(), printStr)); + temp << std::dec << value; + json_push_back(nowNode, json_new_a(myStr.c_str(), temp.str().c_str())); } } - safe_Free(printStr); } //----------------------------------------------------------------------------- // @@ -349,9 +397,9 @@ namespace opensea_parser { inline void set_Json_Bool(JSONNODE *nowNode, const std::string & myStr, bool workingValue) { if (workingValue) - json_push_back(nowNode, json_new_b((char*)myStr.c_str(), true)); + json_push_back(nowNode, json_new_b(myStr.c_str(), true)); else - json_push_back(nowNode, json_new_b((char*)myStr.c_str(), false)); + json_push_back(nowNode, json_new_b(myStr.c_str(), false)); } //----------------------------------------------------------------------------- // @@ -410,6 +458,60 @@ namespace opensea_parser { return false; } void get_SMART_Save_Flages(JSONNODE *headerNode, uint8_t flag); + void get_SMART_Save_Flages_String(std::string &reason, uint8_t flag); + void prePython_unknown_params(JSONNODE* masterData, uint64_t value, uint16_t logPage, uint8_t subPage, uint16_t paramCode, uint32_t offset); + void prePython_int(JSONNODE* masterData, const char* name, const char* statType, const char* unit, uint64_t value, uint16_t logPage, uint8_t subPage, uint16_t paramCode, uint32_t offset); + void prePython_float(JSONNODE* masterData, const char* name, const char* statType, const char* unit, double value, uint16_t logPage, uint8_t subPage, uint16_t paramCode, uint32_t offset); + + inline void byte_swap_std_string(std::string &stringToSwap) + { + std::stringstream tempString; + for (size_t strOffset = 0; (strOffset + 1) < stringToSwap.size(); strOffset += 2) + { + tempString << stringToSwap.at(strOffset + 1); + tempString << stringToSwap.at(strOffset); + } + stringToSwap.clear();//clear out the old byte swapped string + stringToSwap = tempString.str();//assign it to the correctly swapped string + } + + inline void remove_trailing_whitespace_std_string(std::string &stringToTrim) + { + //search for the last of ASCII characters...so use find_last_of the printable characters that are NOT spaces should do the trick...-TJE + size_t lastChar = stringToTrim.find_last_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=~!@#$%^&*()_+[]{};':\"\\|,./<>?`") + 1; + if(lastChar != std::string::npos) + stringToTrim.erase(lastChar, stringToTrim.size() - lastChar); + } + + inline void std_string_to_lowercase(std::string &stringToLowercase) + { + for(size_t iter = 0; iter < stringToLowercase.size(); ++iter) + { + stringToLowercase.at(iter) = static_cast(std::tolower(stringToLowercase.at(iter))); + } + //Below is c++11: + // std::transform(stringToLowercase.begin(), stringToLowercase.end(), stringToLowercase.begin(), + // [](unsigned char c) { return static_cast(std::tolower(c)); }); + } + inline eReturnValues fill_Log_Params(sLogParams &myStruct, uint8_t *buffer ) + { + + myStruct.paramCode = M_BytesTo2ByteValue(buffer[0],buffer[1]); + myStruct.paramControlByte = buffer[2]; + myStruct.paramLength = buffer[3]; + return SUCCESS; + + } + + inline double remove_Double_Transfer_Digits(double* decimalValue) + { + double newValue = 0.0; + std::ostringstream temp; + temp << std::fixed << std::setprecision(6) << *decimalValue; + newValue = std::atof(temp.str().c_str()); + return newValue; + } + #endif // !OPENSEA_PARSER } diff --git a/include/Opensea_Parser_Version.h b/include/Opensea_Parser_Version.h index b0a5a0b..8ca5671 100644 --- a/include/Opensea_Parser_Version.h +++ b/include/Opensea_Parser_Version.h @@ -1,7 +1,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -18,9 +18,9 @@ #define COMBINE_PARSER_VERSIONS_(x,y,z) #x "." #y "." #z #define COMBINE_PARSER_VERSIONS(x,y,z) COMBINE_PARSER_VERSIONS_(x,y,z) -#define OPENSEA_PARSER_MAJOR_VERSION 1 -#define OPENSEA_PARSER_MINOR_VERSION 1 -#define OPENSEA_PARSER_PATCH_VERSION 1 +#define OPENSEA_PARSER_MAJOR_VERSION 2 +#define OPENSEA_PARSER_MINOR_VERSION 0 +#define OPENSEA_PARSER_PATCH_VERSION 3 #define OPENSEA_PARSER_VERSION COMBINE_PARSER_VERSIONS(OPENSEA_PARSER_MAJOR_VERSION,OPENSEA_PARSER_MINOR_VERSION,OPENSEA_PARSER_PATCH_VERSION) diff --git a/include/Seagate/Ata_Farm_Types.h b/include/Seagate/Ata_Farm_Types.h index 1be0566..9ff3805 100644 --- a/include/Seagate/Ata_Farm_Types.h +++ b/include/Seagate/Ata_Farm_Types.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -//Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +//Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -37,12 +37,12 @@ typedef struct _sDriveInfo uint64_t rotationRate; //!< Rotational Rate of Device (ID Word 217) uint64_t firmware; //!< firmware uint64_t firmwareRev; //!< firmware Rev - uint64_t security; //!< ATA Security State (ID Word 128) - uint64_t featuresSupported; //!< ATA Features Supported (ID Word 78) - uint64_t featuresEnabled; //!< ATA Features Enabled (ID Word 79) + uint64_t security; //!< ATA Security State (ID Word 128) + uint64_t featuresSupported; //!< ATA Features Supported (ID Word 78) + uint64_t featuresEnabled; //!< ATA Features Enabled (ID Word 79) uint64_t poh; //!< Power-on Hours - uint64_t spoh; //!< Spindle Power-on Hours - uint64_t headFlightHours; //!< Head Flight Hours + uint64_t spoh; //!< Spindle Power-on Hours + uint64_t headFlightHours; //!< Head Flight Hours uint64_t headLoadEvents; //!< Head Load Events uint64_t powerCycleCount; //!< Power Cycle Count uint64_t resetCount; //!< Hardware Reset Count @@ -51,14 +51,17 @@ typedef struct _sDriveInfo uint64_t timeAvailable; //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) uint64_t timeStamp1; //!< Timestamp of most recent SMART Summary Frame in Power-On Hours Milliseconds uint64_t timeStamp2; //!< Timestamp of last SMART Summary Frame in Power-On Hours Milliseconds - uint64_t timeToReady; //!< time to ready of the last power cycle - uint64_t timeHeld; //!< time drive is held in staggered spin during the last power on sequence + uint64_t timeToReady; //!< time to ready of the last power cycle + uint64_t timeHeld; //!< time drive is held in staggered spin during the last power on sequence uint64_t modelNumber[10]; //!< lower 32 Model Number (started support in 2.14 ) uint64_t driveRecordingType; //!< 0 for SMR and 1 for CMR (started support in 2.15 ) uint64_t depopped; //!< has the drive been depopped 1= depopped and 0 = not depopped(started support in 2.15 ) uint64_t maxNumberForReasign; //!< Max Number of Available Sectors for Reassignment – Value in disc sectors(started in 3.3 ) uint64_t dateOfAssembly; //!< Date of Assembly in ASCII “YYWW” where YY is the year and WW is the calendar week(started in 4.2) uint64_t depopulationHeadMask; //!< Depopulation Head Mask(started in 4.7) + uint64_t headFlightHoursAct1; //!< Head Flight Hours, Actuator1 + uint64_t headLoadEventsAct1; //!< Head Load Events, Actuator 1 + uint64_t HAMRProtectStatus; }sDriveInfo; typedef struct _sErrorStat @@ -93,6 +96,16 @@ typedef struct _sErrorStat uint64_t cumLifeTimeECCReadDueErrorRecovery; // namespace opensea_parser { #ifndef ATAFARM #define ATAFARM - class CATA_Farm_Log + class CATA_Farm_Log : public CFarmCommon { protected: @@ -48,8 +49,7 @@ namespace opensea_parser { uint8_t *pBuf; //!< pointer to the buffer data that is the binary of FARM LOG uint32_t m_MajorRev; //!< holds the Major Revision number uint32_t m_MinorRev; //!< holds the minor revision number - CFarmCommon _common; - + eReturnValues print_Header(JSONNODE *masterData); eReturnValues print_Drive_Information(JSONNODE *masterData, uint32_t page); eReturnValues print_Work_Load(JSONNODE *masterData, uint32_t page); @@ -57,154 +57,13 @@ namespace opensea_parser { eReturnValues print_Enviroment_Information(JSONNODE *masterData, uint32_t page); eReturnValues print_Reli_Information(JSONNODE *masterData, uint32_t page); eReturnValues print_Head_Information(JSONNODE *masterData, uint32_t page); - //----------------------------------------------------------------------------- - // - //! \fn Create_Serial_Number() - // - //! \brief - //! Description: takes the two uint64 bit seiral number values and create a string serial number - // - // Entry: - //! \param serialNumber - string for holding the serial number of the drive ( putting it all together) - //! \param idInfo = pointer to the drive info structure that holds the infromation needed - // - // Exit: - //! \return serialNumber = the string serialNumber - // - //--------------------------------------------------------------------------- - inline void create_Serial_Number(std::string &serialNumber, const sDriveInfo * const idInfo) - { - uint64_t sn = 0; - sn = (idInfo->serialNumber & 0x00FFFFFFFFFFFFFFLL) | ((idInfo->serialNumber2 & 0x00FFFFFFFFFFFFFFLL) << 32); - serialNumber.resize(SERIAL_NUMBER_LEN); - memset((char*)serialNumber.c_str(), 0, SERIAL_NUMBER_LEN); - strncpy((char *)serialNumber.c_str(), (char*)&sn, SERIAL_NUMBER_LEN); - byte_Swap_String((char *)serialNumber.c_str()); - } - //----------------------------------------------------------------------------- - // - //! \fn Create_World_Wide_Name() - // - //! \brief - //! Description: takes the two uint64 bit world wide name values and create a string world wide name - // - // Entry: - //! \param worldwideName - string to hold the world wide name ... putting it all together - //! \param idInfo = pointer to the drive info structure that holds the infromation needed - // - // Exit: - //! \return wordWideName = the string wordWideName - // - //--------------------------------------------------------------------------- - inline void create_World_Wide_Name(std::string &worldWideName, const sDriveInfo * const idInfo) - { - uint64_t wwn = 0; - uint64_t wwn1 = idInfo->worldWideName2 & 0x00FFFFFFFFFFFFFFLL; - uint64_t wwn2 = idInfo->worldWideName & 0x00FFFFFFFFFFFFFFLL; - word_Swap_64(&wwn1); - word_Swap_64(&wwn2); - wwn = (wwn2) | ((wwn1) >> 32); - worldWideName.resize(WORLD_WIDE_NAME_LEN); - memset((char *)worldWideName.c_str(), 0, WORLD_WIDE_NAME_LEN); - snprintf((char *)worldWideName.c_str(), WORLD_WIDE_NAME_LEN, "0x%" PRIX64"", wwn); - } - //----------------------------------------------------------------------------- - // - //! \fn Create_Firmware_String() - // - //! \brief - //! Description: takes the two uint64 bit firmware Rev values and create a string firmware Rev - // - // Entry: - //! \param firmwareRev - string for holding the firmware rev - //! \param idInfo = pointer to the drive info structure that holds the infromation needed - // - // Exit: - //! \return firmwareRev = the string firmwareRev - // - //--------------------------------------------------------------------------- - inline void create_Firmware_String(std::string &firmwareRev, const sDriveInfo * const idInfo) - { - uint64_t firm = 0; - firm = (idInfo->firmware & 0x00FFFFFFFFFFFFFFLL); - firmwareRev.resize(FIRMWARE_REV_LEN); - memset((char *)firmwareRev.c_str(), 0, FIRMWARE_REV_LEN); - strncpy((char *)firmwareRev.c_str(), (char*)&firm, FIRMWARE_REV_LEN); - byte_Swap_String((char *)firmwareRev.c_str()); - } - //----------------------------------------------------------------------------- - // - //! \fn Create_Model_Number_String() - // - //! \brief - //! Description: takes the 10 uint64 bit Model number field values and create a string - // - // Entry: - //! \param modelNumber - string for holding the Model number - //! \param idInfo = pointer to the drive info structure that holds the infromation needed - // - // Exit: - //! \return modelNumber = the string Model number - // - //--------------------------------------------------------------------------- - inline void create_Model_Number_String(std::string &modelNumber, const sDriveInfo * const idInfo) - { - #define MAXSIZE 10 - uint64_t model[MAXSIZE] = { 0,0,0,0,0,0,0,0,0,0 }; - // loop for string the 0xc0 off - for (uint8_t i = 0; i < MAXSIZE; i++) - { - model[i] = idInfo->modelNumber[i] & 0x00FFFFFFFFFFFFFFLL; - } - // temp string for coping the hex to text, have to resize for c98 issues - std::string tempStr = ""; - tempStr.resize(BASIC); - modelNumber.resize(BASIC); - // memset them to 0 - memset((char *)modelNumber.c_str(), 0, BASIC); - memset((char *)tempStr.c_str(), 0, BASIC); - // loop to copy the info into the modeleNumber string - for (uint8_t n = 0; n < MAXSIZE; n++) - { - model[n] = idInfo->modelNumber[n] & 0x00FFFFFFFFFFFFFFLL; - strncpy((char *)tempStr.c_str(), (char*)&model[n], 10); - byte_Swap_String((char *)tempStr.c_str()); - strncat((char *)modelNumber.c_str(), (char*)tempStr.c_str(), sizeof(tempStr)); - } - remove_Trailing_Whitespace((char *)modelNumber.c_str()); - } - //----------------------------------------------------------------------------- - // - //! \fn Create_Device_Interface_String() - // - //! \brief - //! Description: takes the two uint64 bit Devie interface string values and create a string device interface - // - // Entry: - //! \param dInterface - pointer to the Devie interface v, where once constructed, will hold the Devie interface of the drive - //! \param idInfo = pointer to the drive info structure that holds the infromation needed - // - // Exit: - //! \return dInterface = the string dInterface - // - //--------------------------------------------------------------------------- - inline void create_Device_Interface_String(std::string &dInterface, const sDriveInfo * const idInfo) - { - uint64_t dFace = 0; - dFace = (idInfo->deviceInterface & 0x00FFFFFFFFFFFFFFLL); - byte_Swap_64(&dFace); - dFace = (dFace >> 32); - dInterface.resize(DEVICE_INTERFACE_LEN); - memset((char *)dInterface.c_str(), 0, DEVICE_INTERFACE_LEN); - strncpy((char *)dInterface.c_str(), (char*)&dFace, DEVICE_INTERFACE_LEN); - } public: CATA_Farm_Log(); CATA_Farm_Log( uint8_t *bufferData, size_t bufferSize, bool showStatus); virtual ~CATA_Farm_Log(); eReturnValues parse_Farm_Log(); - void get_Reallocated_Sector_By_Cause(std::string *description, uint64_t readWriteRetry); + //void get_Reallocated_Sector_By_Cause(std::string *description, uint64_t readWriteRetry); void print_All_Pages(JSONNODE *masterData); void print_Page(JSONNODE *masterData, uint32_t page); void print_Page_Without_Drive_Info(JSONNODE *masterData, uint32_t page); diff --git a/include/Seagate/CFARM_Log.h b/include/Seagate/CFARM_Log.h index ac1945b..9cd3f35 100644 --- a/include/Seagate/CFARM_Log.h +++ b/include/Seagate/CFARM_Log.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -39,7 +39,7 @@ namespace opensea_parser { CFARMLog(); CFARMLog(const std::string & fileName,bool showStatus); CFARMLog(const std::string & fileName); - CFARMLog(uint8_t *bufferData, size_t bufferSize, bool showStatus); + CFARMLog(uint8_t *farmbufferData, size_t bufferSize, bool showStatus); virtual ~CFARMLog(); eReturnValues get_FARM_Status() { return m_status; }; eReturnValues parse_Device_Farm_Log( JSONNODE *masterData); diff --git a/include/Seagate/CScsi_Farm_Log.h b/include/Seagate/CScsi_Farm_Log.h index c00181d..a851b5c 100644 --- a/include/Seagate/CScsi_Farm_Log.h +++ b/include/Seagate/CScsi_Farm_Log.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -28,7 +28,38 @@ namespace opensea_parser { #ifndef SCSIFARM #define SCSIFARM - class CSCSI_Farm_Log +#define FARMLOGPAGE 0x3D +#define FARMSUBPAGE 0x03 +#define FARMSUBPAGEFACTORY 0x04 + +#define FARM_LOG_PAGE 0x03 +#define FARM_FACTORY_LOG_PAGE 0x04 +#define FARM_TIME_SERIES_0 0x10 +#define FARM_TIME_SERIES_1 0x11 +#define FARM_TIME_SERIES_2 0x12 +#define FARM_TIME_SERIES_3 0x13 +#define FARM_TIME_SERIES_4 0x14 +#define FARM_TIME_SERIES_5 0x15 +#define FARM_TIME_SERIES_6 0x16 +#define FARM_TIME_SERIES_7 0x17 +#define FARM_TIME_SERIES_8 0x18 +#define FARM_TIME_SERIES_9 0x19 +#define FARM_TIME_SERIES_10 0x1A +#define FARM_TIME_SERIES_11 0x1B +#define FARM_TIME_SERIES_12 0x1C +#define FARM_TIME_SERIES_13 0x1D +#define FARM_TIME_SERIES_14 0x1E +#define FARM_TIME_SERIES_15 0x1F +#define FARM_LONG_TERM_SAVES_0 0xC0 +#define FARM_LONG_TERM_SAVES_1 0xC1 +#define FARM_GLIST_ENTRIES 0xC2 +#define FARM_FIRST_UNRECOVERABLE 0xC3 +#define FARM_TENTH_UNRECOVERABLE 0xC4 +#define FARM_FIRST_CTO 0xC5 +#define FARM_LAST_FRAME 0xC6 +#define FARM_TEMP_TRIGGER_LOG_PAGE 0xC7 + + class CSCSI_Farm_Log : public CFarmCommon { protected: @@ -50,30 +81,30 @@ namespace opensea_parser { sScsiDriveInfo *m_pDriveInfo; //!< Drive information pointer with header information bool m_alreadySet; //!< set true one it's already set.. (APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_OUTER) bool m_showStatusBits; //!< show the status bits of each entry - CFarmCommon _common; + bool m_fromScsiLogPages; //!< bool if passed from scsi log pages set as true. We will be off by 4 bytes + uint8_t m_farmSubPage; //!< the subpage for the farm so we know which one it is - void create_Serial_Number(std::string &serialNumber, const sScsiDriveInfo * const idInfo); - void create_World_Wide_Name(std::string &worldWideName, const sScsiDriveInfo * const idInfo); - void create_Firmware_String(std::string &firmwareRev, const sScsiDriveInfo * const idInfo); - void create_Device_Interface_String(std::string &dInterface, const sScsiDriveInfo * const idInfo); - void create_Model_Number_String(std::string &model, sGeneralDriveInfoPage06 * const idInfo); + + bool strip_Active_Status(uint64_t *value); - bool swap_Bytes_sFarmHeader(sScsiFarmHeader *fh); + bool swap_Bytes_sFarmHeader(sScsiFarmHeader *fh, uint8_t* pData); bool swap_Bytes_sDriveInfo(sScsiDriveInfo *di); bool swap_Bytes_sDrive_Info_Page_06(sGeneralDriveInfoPage06 *gd); bool swap_Bytes_sWorkLoadStat(sScsiWorkLoadStat *wl); bool swap_Bytes_sErrorStat(sScsiErrorFrame * es); bool swap_Bytes_sEnvironmentStat(sScsiEnvironmentStat *es); bool swap_Bytes_EnvironmentPage07(sScsiEnvStatPage07 *ep); + bool swap_Bytes_WorkloadPage08(sScsiWorkloadStatPage08 *ep); bool swap_Bytes_sScsiReliabilityStat(sScsiReliablility *ss); bool swap_Bytes_sLUNStruct(sLUNStruct *LUN); bool swap_Bytes_Flash_LED(sActuatorFLEDInfo *fled); bool swap_Bytes_Reallocation_Data(sActReallocationData *real); bool get_Head_Info(sHeadInformation *phead, uint8_t *buffer); - void set_Head_Header(std::string &headerName, eLogPageTypes index); + bool set_Head_Header(std::string &headerName, eLogPageTypes index); void get_LUN_Info(sLUNStruct *pLUN, uint8_t *buffer); eReturnValues init_Header_Data(); + //eReturnValues init_buffer_Header_Data(); eReturnValues print_Header(JSONNODE *masterData); eReturnValues print_Drive_Information(JSONNODE *masterData, uint32_t page); eReturnValues print_General_Drive_Information_Continued(JSONNODE *masterData, uint32_t page); @@ -82,14 +113,25 @@ namespace opensea_parser { eReturnValues print_Error_Information_Version_4(JSONNODE *masterData, uint32_t page); eReturnValues print_Enviroment_Information(JSONNODE *masterData, uint32_t page); eReturnValues print_Enviroment_Statistics_Page_07(JSONNODE *masterData, uint32_t page); + eReturnValues print_Workload_Statistics_Page_08(JSONNODE *masterData, uint32_t page); eReturnValues print_Reli_Information(JSONNODE *masterData, uint32_t page); eReturnValues print_Head_Information(eLogPageTypes type, JSONNODE *masterData, uint32_t page); - eReturnValues print_LUN_Actuator_Information(JSONNODE *masterData, uint32_t page, uint32_t index, uint16_t actNum); - eReturnValues print_LUN_Actuator_FLED_Info(JSONNODE *masterData, uint32_t page, uint32_t index, uint16_t actNum); - eReturnValues print_LUN_Actuator_Reallocation(JSONNODE *masterData, uint32_t page, uint32_t index, uint16_t actNum); + eReturnValues print_LUN_Actuator_Information(JSONNODE * LUNData, uint32_t page, uint16_t actNum); + eReturnValues print_LUN_Actuator_FLED_Info(JSONNODE * LUNFLED, uint32_t page, uint16_t actNum); + eReturnValues print_LUN_Actuator_Reallocation(JSONNODE * LUNNReallocation, uint32_t page, uint16_t actNum); + void farm_PrePython_Str(JSONNODE* masterData, const char* name, const char* statType, const char* unit, const char* location, int pageNum, const char* value); + void farm_PrePython_Int(JSONNODE* masterData, const char* name, const char* statType, const char* header, \ + const char* unit, int pageNum, int64_t value); + void farm_PrePython_Float(JSONNODE* masterData, const char* name, const char* statType, const char* header, \ + const char* unit, int pageNum, double value); + void prePython_Head_Float(JSONNODE* masterData, const char* name, const char* statType, uint32_t headNumber, \ + const char* unit, int pageNum, double value); + void prePython_Head_Int(JSONNODE* masterData, const char* name, const char* statType, uint32_t headNumber, \ + const char* unit, int pageNum, int64_t value); public: CSCSI_Farm_Log(); - CSCSI_Farm_Log(uint8_t *bufferData, size_t bufferSize,bool showStatus); + CSCSI_Farm_Log(uint8_t* bufferData, size_t bufferSize, uint8_t subPage, bool m_fromScsiLogPages); + CSCSI_Farm_Log(uint8_t *bufferData, size_t bufferSize, uint8_t subpage, bool m_fromScsiLogPages, bool showStatus); virtual ~CSCSI_Farm_Log(); eReturnValues parse_Farm_Log(); void print_All_Pages(JSONNODE *masterData); diff --git a/include/Seagate/Farm_Common.h b/include/Seagate/Farm_Common.h index 67dc88d..ede5f23 100644 --- a/include/Seagate/Farm_Common.h +++ b/include/Seagate/Farm_Common.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,9 +14,9 @@ // \file Farm_Helper.h #pragma once -#include #include #include "common.h" +#include "Opensea_Parser_Helper.h" #include "Farm_Types.h" @@ -27,11 +27,19 @@ namespace opensea_parser { class CFarmCommon { public: + CFarmCommon(); virtual ~CFarmCommon(); + void create_Serial_Number(std::string& serialNumberStr, uint32_t serialNumber, uint32_t serialNumber2, uint32_t majorRev, bool sas); + void create_World_Wide_Name(std::string& worldWideName, uint64_t wwn, uint64_t wwn2, bool sas); + void create_Firmware_String(std::string& firmwareRevStr, uint32_t firmware, uint32_t firmware2, bool sas); + void create_Device_Interface_String(std::string& dInterfaceStr, uint32_t deviceInterface, bool sas); + void create_Model_Number_String(std::string& modelStr, uint64_t* productID, bool sas); void get_Reallocation_Cause_Meanings(std::string &meaning, uint16_t code); void get_Assert_Code_Meaning(std::string &meaning, uint16_t code); void create_Year_Assembled_String(std::string &dateStr, uint16_t date, bool isSAS); + void Get_NVC_Status(JSONNODE* NVC_Node, uint64_t status); + void Get_FARM_Reason_For_Capture(std::string* reason, uint8_t flag); }; #endif diff --git a/include/Seagate/Farm_Helper.h b/include/Seagate/Farm_Helper.h index 1863926..18ee907 100644 --- a/include/Seagate/Farm_Helper.h +++ b/include/Seagate/Farm_Helper.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,6 +19,8 @@ #include "libjson.h" #include "Opensea_Parser_Helper.h" #include "Farm_Types.h" +#include +#include namespace opensea_parser { @@ -45,8 +47,6 @@ namespace opensea_parser { //----------------------------------------------------------------------------- inline void set_json_64_bit_With_Status(JSONNODE *nowNode, const std::string & myStr, uint64_t value, bool hexPrint, bool showStatusBits) { - std::string printStr = " "; - printStr.resize(BASIC); std::string lowStr = "64 bit Value Lower value"; std::string upperStr = "64 bit Value Upper value"; //value = check_Status_Strip_Status(value); @@ -55,12 +55,13 @@ namespace opensea_parser { { if (hexPrint) { - snprintf((char*)printStr.c_str(), BASIC, "0x%08" PRIx32"", static_cast(M_DoubleWord0(value))); - json_push_back(nowNode, json_new_a((char *)myStr.c_str(), (char*)printStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << static_cast(M_DoubleWord0(value)); + json_push_back(nowNode, json_new_a(myStr.c_str(), temp.str().c_str())); } else { - json_push_back(nowNode, json_new_i((char *)myStr.c_str(), static_cast(M_DoubleWord0(value)))); + json_push_back(nowNode, json_new_i(myStr.c_str(), static_cast(M_DoubleWord0(value)))); } return; } @@ -69,7 +70,7 @@ namespace opensea_parser { if (showStatusBits) { JSONNODE *bigBit = json_new(JSON_NODE); - json_set_name(bigBit, (char *)myStr.c_str()); + json_set_name(bigBit, myStr.c_str()); if ((value & BIT63) == BIT63) { set_Json_Bool(bigBit, "Field Supported", true); @@ -114,12 +115,10 @@ namespace opensea_parser { //----------------------------------------------------------------------------- inline void set_json_int_With_Status(JSONNODE *nowNode, const std::string & myStr, int64_t value, bool showStatusBits) { - std::string printStr = " "; - printStr.resize(BASIC); if (showStatusBits) { JSONNODE *bigBit = json_new(JSON_NODE); - json_set_name(bigBit, (char *)myStr.c_str()); + json_set_name(bigBit, myStr.c_str()); if ((value & BIT63) == BIT63) { set_Json_Bool(bigBit, "Field Supported", true); @@ -137,13 +136,13 @@ namespace opensea_parser { set_Json_Bool(bigBit, "Field Valid", false); } value = check_Status_Strip_Status(value); - json_push_back(bigBit, json_new_i((char *)myStr.c_str(), static_cast(M_DoubleWord0(value)))); + json_push_back(bigBit, json_new_i(myStr.c_str(), static_cast(M_DoubleWord0(value)))); json_push_back(nowNode, bigBit); } else { value = check_Status_Strip_Status(value); - json_push_back(nowNode, json_new_i((char *)myStr.c_str(), static_cast(M_DoubleWord0(value)))); + json_push_back(nowNode, json_new_i(myStr.c_str(), static_cast(M_DoubleWord0(value)))); } } //----------------------------------------------------------------------------- @@ -166,13 +165,10 @@ namespace opensea_parser { //----------------------------------------------------------------------------- inline void set_json_string_With_Status(JSONNODE *nowNode, const std::string & myStr, const std::string & strValue, uint64_t value, bool showStatusBits) { - std::string printStr = " "; - printStr.resize(BASIC); - if (showStatusBits) { JSONNODE *bigBit = json_new(JSON_NODE); - json_set_name(bigBit, (char *)myStr.c_str()); + json_set_name(bigBit, myStr.c_str()); if ((value & BIT63) == BIT63) { set_Json_Bool(bigBit, "Field Supported", true); @@ -189,14 +185,138 @@ namespace opensea_parser { { set_Json_Bool(bigBit, "Field Valid", false); } - json_push_back(bigBit, json_new_a((char *)myStr.c_str(), (char *)strValue.c_str())); + json_push_back(bigBit, json_new_a(myStr.c_str(), strValue.c_str())); json_push_back(nowNode, bigBit); } else { - json_push_back(nowNode, json_new_a((char *)myStr.c_str(), (char *)strValue.c_str())); + json_push_back(nowNode, json_new_a(myStr.c_str(), strValue.c_str())); + } + } + //----------------------------------------------------------------------------- + // + //! \fn set_json_float_With_Status() + // + //! \brief + //! Description: set the json values for a intiger value and will show status bits if the flag is set + // + // Entry: + //! \param nowNode = the Json node that the data will be added to + //! \param myStr = the string data what will be adding to + //! \param value = double for pushing to the float + //! \param value = 64 bit value to check to see if the bit is set or not + //! \param showStatusBits = flag to force showing the status bits on the value + // + // Exit: + //! \return void + // + //----------------------------------------------------------------------------- + inline void set_json_float_With_Status(JSONNODE* nowNode, const std::string& myStr, double value, uint64_t fullValue, bool showStatusBits) + { + if (showStatusBits) + { + JSONNODE* statusBit = json_new(JSON_NODE); + json_set_name(statusBit, myStr.c_str()); + if ((fullValue & BIT63) == BIT63) + { + set_Json_Bool(statusBit, "Field Supported", true); + } + else + { + set_Json_Bool(statusBit, "Field Supported", false); + } + if ((fullValue & BIT62) == BIT62) + { + set_Json_Bool(statusBit, "Field Valid", true); + } + else + { + set_Json_Bool(statusBit, "Field Valid", false); + } + if (!check_For_Active_Status(&fullValue)) + { + json_push_back(statusBit, json_new_f(myStr.c_str(), 0.0)); + } + else + { + json_push_back(statusBit, json_new_f(myStr.c_str(), value)); + } + json_push_back(nowNode, statusBit); + } + else + { + if (!check_For_Active_Status(&fullValue)) + { + json_push_back(nowNode, json_new_f(myStr.c_str(), 0.0)); + } + else + { + json_push_back(nowNode, json_new_f(myStr.c_str(), value)); + } + } + } + //----------------------------------------------------------------------------- +// +//! \fn set_json_int_Check_Status() +// +//! \brief +//! Description: set the json values for a intiger value and will show status bits if the flag is set +// +// Entry: +//! \param nowNode = the Json node that the data will be added to +//! \param myStr = the string data what will be adding to +//! \param value = int value that would have already been calculated. +//! \param value = 64 bit value to check to see if the bit is set or not +//! \param showStatusBits = flag to force showing the status bits on the value +// +// Exit: +//! \return void +// +//----------------------------------------------------------------------------- + inline void set_json_int_Check_Status(JSONNODE* nowNode, const std::string& myStr, long value, uint64_t fullValue, bool showStatusBits) + { + if (showStatusBits) + { + JSONNODE* statusBit = json_new(JSON_NODE); + json_set_name(statusBit, myStr.c_str()); + if ((fullValue & BIT63) == BIT63) + { + set_Json_Bool(statusBit, "Field Supported", true); + } + else + { + set_Json_Bool(statusBit, "Field Supported", false); + } + if ((fullValue & BIT62) == BIT62) + { + set_Json_Bool(statusBit, "Field Valid", true); + } + else + { + set_Json_Bool(statusBit, "Field Valid", false); + } + if (!check_For_Active_Status(&fullValue)) + { + json_push_back(statusBit, json_new_i(myStr.c_str(), 0)); + } + else + { + json_push_back(statusBit, json_new_i(myStr.c_str(), value)); + } + json_push_back(nowNode, statusBit); + } + else + { + if (!check_For_Active_Status(&fullValue)) + { + json_push_back(nowNode, json_new_i(myStr.c_str(), 0)); + } + else + { + json_push_back(nowNode, json_new_i(myStr.c_str(), value)); + } } } - + #endif } diff --git a/include/Seagate/Farm_Types.h b/include/Seagate/Farm_Types.h index fe2a1a9..f9f8872 100644 --- a/include/Seagate/Farm_Types.h +++ b/include/Seagate/Farm_Types.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,18 +15,18 @@ #pragma once #include -//#include "Opensea_Parser_Helper.h" -//#include "Farm_Helper.h" #define MAX_HEAD_COUNT 24 #define FARMSIGNATURE 0x00004641524D4552 #define MAJORVERSION2 2 #define MAJORVERSION3 3 #define MAJORVERSION4 4 -#define FACTORYCOPY 0xc0464143544f5259 +#define FACTORYCOPY 0x00464143544f5259 +#define FARMEMPTYSIGNATURE 0x00FFFFFFFFFFFFFF #define DATE_YEAR_DATE_SIZE 2 #define FLASH_EVENTS 8 #define REALLOCATIONEVENTS 15 +#define PRINTABLE_MODEL_NUMBER 12 #define ASSERT_UNKNOWN 0x00 #define MICROPROCESSOR_FAILED 0x08 @@ -100,7 +100,24 @@ #define SERIAL_PORT_DUMP_MODE 0xF5 -#pragma pack(push, 1) +// Frame Type Identification 0x0 - 0xF +#define CURRENT_FRAME 0x00 +#define TIME_SERIES_FRAME 0x01 +#define LONG_TERM_FRAME 0x02 +#define GLIST_DISC_ENTRIES_FRAME 0x03 +#define FIRST_UNRECOVERED_READ_ERROR_FRAME 0x04 +#define TENTH_UNRECOVERED_READ_ERROR_FRAME 0x05 +#define FIRST_FATAL_CTO_FRAME 0x06 +#define BEFORE_CFW_UPDATE_FRAME 0x07 +#define TEMP_EXCEDED_FRAME 0x08 +#define RESERVED_FRAME 0x09 +#define FACTORY_COPY_FRAME 0x0A +#define FARM_LOG_DISC_COPY_FRAME 0x0B //sata only +#define IDD_FARM_LOG_DISC_FRAME 0x0C //sata only +#define FARM_DRAM_COPY_FARME 0x0D //sata only +#define FARM_DRAM_COPY_DIAG_FRAME 0x0E +#define FARM_UDS_COPY_FRAME 0x0F + typedef enum _eReallocationCauses { HOST_READ_GENERIC, @@ -130,6 +147,7 @@ typedef struct _sStringIdentifyData std::string modelNumber; //!< Model Number (4.3 and newer will have this) }sStringIdentifyData; +#pragma pack(push, 1) typedef struct _sFarmHeader { uint64_t signature; //!< Log Signature = 0x00004641524D4552 @@ -140,8 +158,8 @@ typedef struct _sFarmHeader uint64_t pageSize; //!< page size in bytes uint64_t headsSupported; //!< Maximum Drive Heads Supported uint64_t copies; //!< Number of Historical Copies - uint64_t reasonForFrameCpature; //!< Reason for Frame Capture (added 4.14) - _sFarmHeader() : signature(0), majorRev(0), minorRev(0), pagesSupported(0), logSize(0), pageSize(0), headsSupported(0), copies(0), reasonForFrameCpature(0) {}; + uint64_t reasonForFrameCapture; //!< Reason for Frame Capture (added 4.14) + _sFarmHeader() : signature(0), majorRev(0), minorRev(0), pagesSupported(0), logSize(0), pageSize(0), headsSupported(0), copies(0), reasonForFrameCapture(0) {}; }sFarmHeader; typedef struct _sWorkLoadStat @@ -196,13 +214,72 @@ typedef struct _sWorkLoadStat uint64_t numberOfWriteCmds1; //!< ATA - Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames (added 4.4) uint64_t totalWriteCmdsFromFrames4; //!< SCSI - Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames (added 4.4) }; - uint64_t numberOfWriteCmds2; //!< ATA - Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames (added 4.4) - uint64_t numberOfWriteCmds3; //!< ATA - Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames (added 4.4) - uint64_t numberOfWriteCmds4; //!< ATA - Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames (added 4.4) - _sWorkLoadStat() : pageNumber(0), copyNumber(0), workloadPercentage(0), totalReadCommands(0), totalWriteCommands(0), totalRandomReads(0), totalRandomWrites(0), \ - totalNumberofOtherCMDS(0), logicalSecWritten(0), logicalSecRead(0), dither(0), ditherRandom(0), ditherSequential(0), numberOfReadCmds1(0), numberOfReadCmds2(0), \ - numberOfReadCmds3(0), numberOfReadCmds4(0), numberOfWriteCmds1(0), numberOfWriteCmds2(0), numberOfWriteCmds3(0), numberOfWriteCmds4(0) {}; + union + { + uint64_t numberOfWriteCmds2; //!< ATA - Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames (added 4.4) + uint64_t numReadTransferSmall; //!< SCSI - Number of Write Commands of transfer length <=16KB for last 3 SMART Summary Frames + }; + union + { + uint64_t numberOfWriteCmds3; //!< ATA - Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames (added 4.4) + uint64_t numReadTransferMid1; //!< SCSI - Number of Read Commands of transfer length (16KB – 512KB] for last 3 SMART Summary Frames + }; + union + { + uint64_t numberOfWriteCmds4; //!< ATA - Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames (added 4.4) + uint64_t numReadTransferMid2; //!< SCSI - Number of read Commands of transfer length (512KB – 2MB] for last 3 SMART Summary Frames + }; + union + { + uint64_t numReadTransferLarge; //!< SCSI - Number of Read Commands of transfer length > 2MB for last 3 SMART Summary Frames + uint64_t numReadTransferSmallATA; //!< ATA - Number of Write Commands of transfer length <=16KB for last 3 SMART Summary Frames + }; + + union + { + uint64_t numWriteTransferSmall; //!< SCSI - Number of Write Commands of transfer length <=16KB for last 3 SMART Summary Frames + uint64_t numReadTransferMid1ATA; //!< ATA - Number of Read Commands of transfer length (16KB – 512KB] for last 3 SMART Summary Frames + }; + union + { + uint64_t numWriteTransferMid1; //!< SCSI - Number of Write Commands of transfer length (16KB – 512KB] for last 3 SMART Summary Frames + uint64_t numReadTransferMid2ATA; //!< ATA - Number of Read Commands of transfer length (512KB – 2MB] for last 3 SMART Summary Frames + }; + union + { + uint64_t numWriteTransferMid2; //!< SCSI - Number of Write Commands of transfer length (512KB – 2MB] for last 3 SMART Summary Frames + uint64_t numReadTransferLargeATA; //!< ATA - Number of Read Commands of transfer length > 2MB for last 3 SMART Summary Frames }; + }; + union + { + uint64_t numWriteTransferLarge; //!< SCSI - Number of Write Commands of transfer length > 2MB for last 3 SMART Summary Frames + uint64_t numWriteTransferSmallATA; //!< ATA - Number of Write Commands of transfer length <=16KB for last 3 SMART Summary Frames + }; + + uint64_t numWriteTransferMid1ATA; //!< ATA - Number of Read Commands of transfer length (16KB – 512KB] for last 3 SMART Summary Frames + uint64_t numWriteTransferMid2ATA; //!< ATA - Number of Read Commands of transfer length (512KB – 2MB] for last 3 SMART Summary Frames + uint64_t numWriteTransferLargeATA; //!< ATA - Number of Read Commands of transfer length > 2MB for last 3 SMART Summary Frames + uint64_t cntQueueDepth1; //!< ATA - Count of Queue Depth =1 at 30s intervals for last 3 SMART Summary Frames + uint64_t cntQueueDepth2; //!< ATA - Count of Queue Depth =2 at 30s intervals for last 3 SMART Summary Frames + uint64_t cntQueueDepth3to4; //!< ATA - Count of Queue Depth =3-4 at 30s intervals for last 3 SMART Summary Frames + uint64_t cntQueueDepth5to8; //!< ATA - Count of Queue Depth =5-8 at 30s intervals for last 3 SMART Summary Frames + uint64_t cntQueueDepth9to16; //!< ATA - Count of Queue Depth =9-16 at 30s intervals for last 3 SMART Summary Frames + uint64_t cntQueueDepth17to32; //!< ATA - Count of Queue Depth =17-32 at 30s intervals for last 3 SMART Summary Frames + uint64_t cntQueueDepth33to64; //!< ATA - Count of Queue Depth =33-64 at 30s intervals for last 3 SMART Summary Frames + uint64_t cntQueueDepthmorethan64; //!< ATA - Count of Queue Depth >64 at 30s intervals for last 3 SMART Summary Frames + uint64_t numDithEvtAct1; //!< ATA - Number of dither events during current power cycle, Actuator 1 + uint64_t numRandWLDitherHoldOffAct1; //!< ATA - Number of times dither was held off during random workloads during current power cycle, Actuator 1 + uint64_t numSequentialWLDitherHoldOffAct1; //!< ATA - Number of times dither was held off during sequential workloads during current power cycle, Actuator 1 + uint64_t hotWriteStatistics; //!< ATA - Hot write statistics: including metadata and 2400-band/region workload rating data + + + _sWorkLoadStat() : pageNumber(0), copyNumber(0), workloadPercentage(0), totalReadCommands(0), totalWriteCommands(0), totalRandomReads(0), totalRandomWrites(0), + totalNumberofOtherCMDS(0), logicalSecWritten(0), logicalSecRead(0), dither(0), ditherRandom(0), ditherSequential(0), numberOfReadCmds1(0), numberOfReadCmds2(0), + numberOfReadCmds3(0), numberOfReadCmds4(0), numberOfWriteCmds1(0), numberOfWriteCmds2(0), numberOfWriteCmds3(0), numberOfWriteCmds4(0), + numReadTransferLarge(0), numWriteTransferSmall(0), numWriteTransferMid1(0), numWriteTransferMid2(0), numWriteTransferLarge(0), + numWriteTransferMid1ATA(0), numWriteTransferMid2ATA(0), numWriteTransferLargeATA(0), cntQueueDepth1(0), cntQueueDepth2(0), + cntQueueDepth3to4(0), cntQueueDepth5to8(0), cntQueueDepth9to16(0), cntQueueDepth17to32(0), cntQueueDepth33to64(0), + cntQueueDepthmorethan64(0), numDithEvtAct1(0), numRandWLDitherHoldOffAct1(0), numSequentialWLDitherHoldOffAct1(0), hotWriteStatistics(0) {}; }sWorkLoadStat; #pragma pack(pop) - diff --git a/include/Seagate/Scsi_Farm_Types.h b/include/Seagate/Scsi_Farm_Types.h index 948bb0d..1cb1ed0 100644 --- a/include/Seagate/Scsi_Farm_Types.h +++ b/include/Seagate/Scsi_Farm_Types.h @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -//Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +//Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -29,7 +29,7 @@ typedef enum _eLogPageTypes RELIABILITY_STATISTICS_PARAMETER, GENERAL_DRIVE_INFORMATION_06, ENVIRONMENT_STATISTICS_PAMATER_07, - RESERVED_FOR_FUTURE_STATISTICS_3, + WORKLOAD_STATISTICS_PAMATER_08, RESERVED_FOR_FUTURE_STATISTICS_4, RESERVED_FOR_FUTURE_STATISTICS_5, RESERVED_FOR_FUTURE_STATISTICS_6, @@ -63,28 +63,28 @@ typedef enum _eLogPageTypes DOS_WRITE_COUNT_THRESHOLD_PER_HEAD, CUM_LIFETIME_UNRECOVERALBE_READ_REPET_PER_HEAD, CUM_LIFETIME_UNRECOVERABLE_READ_UNIQUE_PER_HEAD, - RESERVED_FOR_FUTURE_EXPANSION_4, - RESERVED_FOR_FUTURE_EXPANSION_5, - RESERVED_FOR_FUTURE_EXPANSION_6, - RESERVED_FOR_FUTURE_EXPANSION_7, - RESERVED_FOR_FUTURE_EXPANSION_8, - RESERVED_FOR_FUTURE_EXPANSION_9, + TOTAL_LASER_FIELD_ADJUST_ITERATIONS, + TOTAL_READER_WRITER_OFFSET_ITERATIONS_PERFORMED, + PRE_LFA_ZONE_0, + PRE_LFA_ZONE_1, + PRE_LFA_ZONE_2, + ZERO_PERCENT_SHIFT, CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_0, CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_1, CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_2, CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_0, CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_1, CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_2, - RESERVED_FOR_FUTURE_EXPANSION_10, - RESERVED_FOR_FUTURE_EXPANSION_11, - RESERVED_FOR_FUTURE_EXPANSION_12, - RESERVED_FOR_FUTURE_EXPANSION_13, - RESERVED_FOR_FUTURE_EXPANSION_14, - RESERVED_FOR_FUTURE_EXPANSION_15, - RESERVED_FOR_FUTURE_EXPANSION_16, - RESERVED_FOR_FUTURE_EXPANSION_17, - RESERVED_FOR_FUTURE_EXPANSION_18, - RESERVED_FOR_FUTURE_EXPANSION_19, + LASER_OPERATING_ZONE_0, + LASER_OPERATING_ZONE_1, + LASER_OPERATING_ZONE_2, + POST_LFA_OPTIMAL_BER_ZONE_0, + POST_LFA_OPTIMAL_BER_ZONE_1, + POST_LFA_OPTIMAL_BER_ZONE_2, + MICRO_JOG_OFFSET_ZONE_0, + MICRO_JOG_OFFSET_ZONE_1, + MICRO_JOG_OFFSET_ZONE_2, + ZERO_PERCENT_SHIFT_ZONE_1, APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_OUTER, APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_INNER, APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_MIDDLE, @@ -100,7 +100,7 @@ typedef enum _eLogPageTypes FAFH_HIGH_FREQUENCY_0, // FAFH High Frequency Passive Clearance in ADC counts Diameter 0 : outer FAFH_HIGH_FREQUENCY_1, // FAFH High Frequency Passive Clearance in ADC counts Diameter 1 : outer FAFH_HIGH_FREQUENCY_2, // FAFH High Frequency Passive Clearance in ADC counts Diameter 2 : outer - RESERVED_FOR_FUTURE_EXPANSION_31, + ZERO_PERCENT_SHIFT_ZONE_2, LUN_0_ACTUATOR, LUN_0_FLASH_LED, LUN_REALLOCATION_0, @@ -219,10 +219,14 @@ typedef struct _sScsiDriveInfo uint64_t poh; //!< Power-on Hours uint64_t reserved3; //!< reserved uint64_t reserved4; //!< reserved - uint64_t headLoadEvents; //!< Head Load Events + union { + uint64_t headLoadEvents; //!< Head Load Events + uint64_t reserved5; //!< reserved + }; + uint64_t powerCycleCount; //!< Power Cycle Count uint64_t resetCount; //!< Hardware Reset Count - uint64_t reserved5; //!< reserved + uint64_t reserved6; //!< reserved uint64_t NVC_StatusATPowerOn; //!< NVC Status on Power-on uint64_t timeAvailable; //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) uint64_t firstTimeStamp; //!< Timestamp of first SMART Summary Frame in Power-On Hours Milliseconds @@ -230,13 +234,14 @@ typedef struct _sScsiDriveInfo uint64_t dateOfAssembly; //!< Date of Assembly in ASCII “YYWW” where YY is the year and WW is the calendar week _sScsiDriveInfo() :pageNumber(0), copyNumber(0), serialNumber(0), serialNumber2(0), worldWideName(0), worldWideName2(0), deviceInterface(0), deviceCapacity(0), \ psecSize(0), lsecSize(0), deviceBufferSize(0), heads(0), factor(0), rotationRate(0), firmware(0), firmwareRev(0), reserved(0), reserved1(0), reserved2(0), poh(0), reserved3(0), \ - reserved4(0), headLoadEvents(0), powerCycleCount(0), resetCount(0), reserved5(0), NVC_StatusATPowerOn(0), timeAvailable(0), firstTimeStamp(0), lastTimeStamp(0), dateOfAssembly(0) {}; + reserved4(0), headLoadEvents(0), powerCycleCount(0), resetCount(0), reserved6(0), NVC_StatusATPowerOn(0), timeAvailable(0), firstTimeStamp(0), lastTimeStamp(0), dateOfAssembly(0) {}; }sScsiDriveInfo; typedef struct _sScsiWorkLoadStat { - sScsiPageParameter PageHeader; //!< pointer the farm header page parameter - sWorkLoadStat workLoad; //!< structure of the work load Stat + sScsiPageParameter PageHeader; //!< pointer the farm header page parameter + sWorkLoadStat workLoad; //!< structure of the work load Stat + }sScsiWorkLoadStat; typedef struct _sScsiErrorStat @@ -261,8 +266,14 @@ typedef struct _sScsiErrorStat uint64_t reserved8; //!< Reserved uint64_t totalFlashLED; //!< Total Flash LED (Assert) Events uint64_t reserved9; //!< Reserved + uint64_t reserved10; //!< Reserved uint64_t FRUCode; //!< FRU code if smart trip from most recent SMART Frame (SAS only) uint64_t parity; //!< Super Parity on the Fly Recovery + /* + _sScsiErrorStat() :pageNumber(0), copyNumber(0), totalReadECC(0), totalWriteECC(0), totalReallocations(0), reserved(0), totalMechanicalFails(0), totalReallocatedCanidates(0), + reserved1(0), reserved2(0), reserved3(0), reserved4(0), reserved5(0), attrIOEDCErrors(0), reserved6(0), reserved7(0), reserved8(0), totalFlashLED(0), + reserved9(0), reserved10(0), FRUCode(0), parity(0) {}; + */ }sScsiErrorStat; typedef struct _sScsiErrorStatVersion4 @@ -287,6 +298,7 @@ typedef struct _sScsiErrorStatVersion4 uint64_t reserved10; //!< Reserved uint64_t reserved11; //!< reserved uint64_t reserved12; //!< Reserved + uint64_t reserved13; //!< Reserved uint64_t FRUCode; //!< FRU code if smart trip from most recent SMART Frame (SAS only) uint64_t portAInvalidDwordCount; //!< Invalid DWord Count (Port A) uint64_t portBInvalidDwordCount; //!< Invalid DWord Count (Port B) @@ -295,7 +307,14 @@ typedef struct _sScsiErrorStatVersion4 uint64_t portALossDwordSync; //!< Loss of DWord Sync (Port A) uint64_t portBLossDwordSync; //!< Loss of DWord Sync (Port B) uint64_t portAPhyResetProblem; //!< Phy Reset Problem (Port A) - uint64_t portBPhyResetProblem; //!< Phy Reset Problem (Port B) + uint64_t portBPhyResetProblem; //!< Phy Reset Problem (Port B() + + _sScsiErrorStatVersion4() : pageNumber(0), copyNumber(0), totalReadECC(0), totalWriteECC(0), reserved(0), reserved1(0), + totalMechanicalFails(0), reserved2(0), reserved3(0), reserved4(0), reserved5(0), reserved6(0), + reserved7(0), attrIOEDCErrors(0), reserved8(0), reserved9(0), reserved10(0), reserved11(0), + reserved12(0), reserved13(0), FRUCode(0), portAInvalidDwordCount(0), portBInvalidDwordCount(0), + portADisparityErrorCount(0), portBDisparityErrorCount(0), portALossDwordSync(0), + portBLossDwordSync(0), portAPhyResetProblem(0), portBPhyResetProblem(0) {}; }sScsiErrorVersion4; typedef struct _sScsiErrorFrame @@ -364,8 +383,8 @@ typedef struct _sScsiReliabilityStat uint64_t microActuatorLockOut; //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames8 uint64_t diskSlipRecalPerformed; //!< Number of disc slip recalibrations performed uint64_t heliumPressuretThreshold; //!< helium Pressure Threshold Trip - uint64_t rvAbsuluteMean; //!< RV Absulute Mean - uint64_t maxRVAbsuluteMean; //!< Max RV absulute Mean + uint64_t rvAbsoluteMean; //!< RV Absolute Mean + uint64_t maxRVAbsoluteMean; //!< Max RV absolute Mean uint64_t idleTime; //!< idle Time value from the most recent SMART Summary Frame }sScsiReliabilityStat; @@ -437,6 +456,21 @@ typedef struct _sScsiEnvironmentStatPage07 uint64_t max5v; //!< 5V Power Max(mw) - Highest of last 3 SMART summary frames }sScsiEnvStatPage07; +typedef struct _sScsiWorkloadStatPage08 +{ + sScsiPageParameter pPageHeader; //!< pointer the farm header page parameter + uint64_t pageNumber; //!< Page Number = 8 + uint64_t copyNumber; //!< Copy Number + uint64_t countQueDepth1; //!< Count of Queue Depth =1 at 30s intervals for last 3 SMART Summary Frames + uint64_t countQueDepth2; //!< Count of Queue Depth =2 at 30s intervals for last 3 SMART Summary Frames + uint64_t countQueDepth3_4; //!< Count of Queue Depth 3-4 at 30s intervals for last 3 SMART Summary Frames + uint64_t countQueDepth5_8; //!< Count of Queue Depth 5-8 at 30s intervals for last 3 SMART Summary Frames + uint64_t countQueDepth9_16; //!< Count of Queue Depth 9-16 at 30s intervals for last 3 SMART Summary Frames + uint64_t countQueDepth17_32; //!< Count of Queue Depth 17-32 at 30s intervals for last 3 SMART Summary Frames + uint64_t countQueDepth33_64; //!< Count of Queue Depth 33-64 at 30s intervals for last 3 SMART Summary Frames + uint64_t countQueDepth_gt_64; //!< Count of Queue Depth greater than 64 at 30s intervals for last 3 SMART Summary Frames +}sScsiWorkloadStatPage08; + typedef struct _sHeadInformation { sScsiPageParameter pageHeader; //!< header page parameters @@ -450,8 +484,14 @@ typedef struct _sLUNStruct uint64_t copyNumber; //!< Copy Number uint64_t LUNID; //!< LUN ID uint64_t headLoadEvents; //!< Head Load Events - uint64_t reallocatedSectors; //!< Number of Reallocated Sectors - uint64_t reallocatedCandidates; //!< Number of Reallocated Candidate Sectors + union { + uint64_t reallocatedSectors; //!< Number of Reallocated Sectors + uint64_t reserved; //!< Number of Reallocated Sectors + }; + union { + uint64_t reallocatedCandidates; //!< Number of Reallocated Candidate Sectors + uint64_t reserved1; //!< Number of Reallocated Sectors + }; uint64_t timeStampOfIDD; //!< Timestamp of last IDD test uint64_t subCmdOfIDD; //!< Sub - command of last IDD test uint64_t reclamedGlist; //!< Number of G - list reclamations @@ -468,7 +508,15 @@ typedef struct _sLUNStruct uint64_t RVabsolue; //!< RV Absolute Mean, value from most recent SMART Summary Frame uint64_t maxRVabsolue; //!< Max RV Absolute Mean, value from most recent SMART Summary Frame uint64_t idleTime; //!< Idle Time, value from most recent SMART Summary Frame in seconds - uint64_t lbasCorrectedByParity; //!< Number of LBAs Corrected by Parity Sector + uint64_t lbasCorrectedByParity; //!< total valid parity sectors + uint64_t currentLowFrequencyVibe; //!< Current Low Frequency Vibe Score + uint64_t currentMidFrequencyVibe; //!< Current Mid Frequency Vibe Score + uint64_t currentHighFrequencyVibe; //!< Current High Frequency Vibe Score + uint64_t worstLowFrequencyVibe; //!< Worst Low Frequency Vibe Score + uint64_t worstMidFrequencyVibe; //!< Worst Mid Frequency Vibe Score + uint64_t worstHighFrequencyVibe; //!< Worst High Frequency Vibe Score + uint64_t primarySPCovPercentage; //!< Primary Super Parity Coverage Percentage + uint64_t primarySPCovPercentageSMR; //!< Primary Super Parity Coverage Percentage SMR }sLUNStruct; typedef struct _sActuatorFLEDInfo @@ -506,7 +554,8 @@ typedef struct _sScsiFarmFrame sScsiReliablility reliPage; //!< reliability data sGeneralDriveInfoPage06 gDPage06; //!< Gerneral Drive Information Page 06 sScsiEnvStatPage07 envStatPage07; //!< Environment Stat Page 07 - sHeadInformation discSlipPerHead; + sScsiWorkloadStatPage08 workloadStatPage08; //!< Workload Stat Page 08 + sHeadInformation discSlipPerHead; sHeadInformation bitErrorRateByHead; sHeadInformation dosWriteRefreshCountByHead; sHeadInformation dvgaSkipWriteDetectByHead; @@ -532,12 +581,28 @@ typedef struct _sScsiFarmFrame sHeadInformation dosWriteCount; sHeadInformation cumECCReadRepeat; sHeadInformation cumECCReadUnique; + sHeadInformation totalLaserFieldAdjustIterations; + sHeadInformation totalReaderWriteerOffsetIterationsPerformed; + sHeadInformation pre_lfaZone_0; + sHeadInformation pre_lfaZone_1; + sHeadInformation pre_lfaZone_2; + sHeadInformation zeroPercentShift; sHeadInformation currentH2STTrimmedbyHeadZone0; sHeadInformation currentH2STTrimmedbyHeadZone1; sHeadInformation currentH2STTrimmedbyHeadZone2; sHeadInformation currentH2STIterationsByHeadZone0; sHeadInformation currentH2STIterationsByHeadZone1; sHeadInformation currentH2STIterationsByHeadZone2; + sHeadInformation laser_operatingZone_0; + sHeadInformation laser_operatingZone_1; + sHeadInformation laserOperatingZone_2; + sHeadInformation postLFAOptimalBERZone_0; + sHeadInformation postLFAOptimalBERZone_1; + sHeadInformation postLFAOptimalBERZone_2; + sHeadInformation microJogOffsetZone_0; + sHeadInformation microJogOffsetZone_1; + sHeadInformation microJogOffsetZone_2; + sHeadInformation zeroPercentShiftZone_1; sHeadInformation appliedFlyHeightByHeadOuter; sHeadInformation appliedFlyHeightByHeadInner; sHeadInformation appliedFlyHeightByHeadMiddle; @@ -553,6 +618,7 @@ typedef struct _sScsiFarmFrame sHeadInformation fafhHighFrequency_0; //!< FAFH High Frequency Passive Clearance in ADC counts Diameter 0 : outer sHeadInformation fafhHighFrequency_1; //!< FAFH High Frequency Passive Clearance in ADC counts Diameter 1 : outer sHeadInformation fafhHighFrequency_2; //!< FAFH High Frequency Passive Clearance in ADC counts Diameter 2 : outer + sHeadInformation zeroPercentShiftZone_2; sLUNStruct vLUN50; sActuatorFLEDInfo fled51; sActReallocationData reall52; @@ -569,4 +635,4 @@ typedef struct _sScsiFarmFrame std::vector vFramesFound; }sScsiFarmFrame; -#pragma pack(pop) \ No newline at end of file +#pragma pack(pop) diff --git a/src/CAta_Device_Stat_Log.cpp b/src/CAta_Device_Stat_Log.cpp index 5b55da7..8558ae5 100644 --- a/src/CAta_Device_Stat_Log.cpp +++ b/src/CAta_Device_Stat_Log.cpp @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,6 +13,9 @@ #include "CAta_Device_Stat_Log.h" +#include +#include + using namespace opensea_parser; using namespace std; @@ -101,13 +104,13 @@ CSAtaDevicStatisticsTempLogs::CSAtaDevicStatisticsTempLogs(const std::string &fi { m_logSize = cCLog->get_Size(); pData = new uint8_t[m_logSize]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, cCLog->get_Buffer(), m_logSize); #else memcpy_s(pData, m_logSize, cCLog->get_Buffer(), m_logSize);// copy the buffer data to the class member pBuf #endif sLogPageStruct *idCheck; - idCheck = (sLogPageStruct *)&pData[0]; + idCheck = reinterpret_cast(&pData[0]); byte_Swap_16(&idCheck->pageLength); if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) { @@ -181,19 +184,19 @@ eReturnValues CSAtaDevicStatisticsTempLogs::parse_SCT_Temp_Log() JSONNODE *sctTemp = json_new(JSON_NODE); json_set_name(sctTemp, "SCT Temp Log"); - if (m_dataSize > 0 && m_dataSize < (size_t)(34 + CBIndex)) // check the size fo the data + if (m_dataSize > 0 && m_dataSize < static_cast(34 + CBIndex)) // check the size fo the data { json_push_back(JsonData, sctTemp); return static_cast(INVALID_LENGTH); } - SamplePeriod = ((uint16_t)pData[3] << 8) | ((uint16_t)pData[2] << 0); - Interval = ((uint16_t)pData[5] << 8) | ((uint16_t)pData[4] << 0); + SamplePeriod = M_BytesTo2ByteValue(pData[3], pData[2]); + Interval = M_BytesTo2ByteValue(pData[5], pData[4]); MaxOpLimit = pData[6]; OverLimit = pData[7]; MinOpLimit = pData[8]; UnderLimit = pData[9]; - CBSize = ((uint16_t)pData[31] << 8) | ((uint16_t)pData[30] << 0); - CBIndex = ((uint16_t)pData[33] << 8) | ((uint16_t)pData[32] << 0); + CBSize = M_BytesTo2ByteValue(pData[31], pData[30]); + CBIndex = M_BytesTo2ByteValue(pData[33], pData[32]); Temperature = pData[(34 + CBIndex)]; @@ -209,33 +212,35 @@ eReturnValues CSAtaDevicStatisticsTempLogs::parse_SCT_Temp_Log() printf("\t%s%" PRId16" \n", "Temp Log CB Index (current entry): ", CBIndex); printf("\t%s%" PRId8" \n", "Temp Log Temperature of CB Index (Celsius): ", Temperature); #endif - snprintf((char*)myStr.c_str(), BASIC, "%" PRId16"", SamplePeriod); - json_push_back(sctTemp, json_new_a("Temp Log Sample Period (in minutes)", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRId16"", Interval); - json_push_back(sctTemp, json_new_a("Temp Log Interval (in minutes)", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%d", MaxOpLimit); - json_push_back(sctTemp, json_new_a("Temp Log Max Op Limit", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%d", OverLimit); - json_push_back(sctTemp, json_new_a("Temp Log Over Limit", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%d", MinOpLimit); - json_push_back(sctTemp, json_new_a("Temp Log Min Op Limit", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%d", UnderLimit); - json_push_back(sctTemp, json_new_a("Temp Log Under Limit", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRId16"", CBSize); - json_push_back(sctTemp, json_new_a("Temp Log CB Size (in entries)", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRId16"", CBIndex); - json_push_back(sctTemp, json_new_a("Temp Log CB Index (current entry)", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%d", Temperature); - json_push_back(sctTemp, json_new_a("Temp Log Temperature of CB Index (Celsius)", (char*)myStr.c_str())); - + std::ostringstream temp; + + temp << std::dec << SamplePeriod; + json_push_back(sctTemp, json_new_a("Temp Log Sample Period (in minutes)", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << Interval; + json_push_back(sctTemp, json_new_a("Temp Log Interval (in minutes)", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << MaxOpLimit; + json_push_back(sctTemp, json_new_a("Temp Log Max Op Limit", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << OverLimit; + json_push_back(sctTemp, json_new_a("Temp Log Over Limit", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << MinOpLimit; + json_push_back(sctTemp, json_new_a("Temp Log Min Op Limit", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << UnderLimit; + json_push_back(sctTemp, json_new_a("Temp Log Under Limit", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << CBSize; + json_push_back(sctTemp, json_new_a("Temp Log CB Size (in entries)", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << CBIndex; + json_push_back(sctTemp, json_new_a("Temp Log CB Index (current entry)", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << Temperature; + json_push_back(sctTemp, json_new_a("Temp Log Temperature of CB Index (Celsius)", temp.str().c_str())); + temp.str("");temp.clear(); json_push_back(JsonData, sctTemp); return SUCCESS; } @@ -255,6 +260,9 @@ eReturnValues CSAtaDevicStatisticsTempLogs::parse_SCT_Temp_Log() CAtaDeviceStatisticsLogs::CAtaDeviceStatisticsLogs() :m_name("Device Stat Log") , m_status(IN_PROGRESS) + , pData(NULL) + , m_deviceLogSize(0) + , m_Response() { m_deviceLogSize = 0; } @@ -279,6 +287,7 @@ CAtaDeviceStatisticsLogs::CAtaDeviceStatisticsLogs(uint32_t logSize, JSONNODE *m , m_status(IN_PROGRESS) , pData(buffer) , m_deviceLogSize(logSize) + , m_Response() { if (pData != NULL) { @@ -309,6 +318,7 @@ CAtaDeviceStatisticsLogs::CAtaDeviceStatisticsLogs(const std::string &fileName, , m_status(IN_PROGRESS) , pData() , m_deviceLogSize(0) + , m_Response() { CLog *cCLog; cCLog = new CLog(fileName); @@ -318,13 +328,13 @@ CAtaDeviceStatisticsLogs::CAtaDeviceStatisticsLogs(const std::string &fileName, { m_deviceLogSize = cCLog->get_Size(); pData = new uint8_t[m_deviceLogSize]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, cCLog->get_Buffer(), m_deviceLogSize); #else memcpy_s(pData, m_deviceLogSize, cCLog->get_Buffer(), m_deviceLogSize);// copy the buffer data to the class member pBuf #endif sLogPageStruct *idCheck; - idCheck = (sLogPageStruct *)&pData[0]; + idCheck = reinterpret_cast(&pData[0]); byte_Swap_16(&idCheck->pageLength); if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) { @@ -381,8 +391,8 @@ CAtaDeviceStatisticsLogs::~CAtaDeviceStatisticsLogs() //--------------------------------------------------------------------------- eReturnValues CAtaDeviceStatisticsLogs::ParseSCTDeviceStatLog(JSONNODE *masterData) { - sHeader *pDeviceHeader = {0}; - uint64_t *pLogPage = {0}; + sHeader *pDeviceHeader = NULL; + uint64_t *pLogPage = NULL; if (VERBOSITY_DEFAULT < g_verbosity) { printf("\nStarting Device Statistics Parsing \n"); @@ -395,8 +405,8 @@ eReturnValues CAtaDeviceStatisticsLogs::ParseSCTDeviceStatLog(JSONNODE *masterDa //Define each valid log page. for (uint32_t offset = 0; offset < m_deviceLogSize; offset += 512) { - pDeviceHeader = (sHeader*)&pData[offset]; - pLogPage = (uint64_t*)&pData[offset]; + pDeviceHeader = reinterpret_cast(&pData[offset]); + pLogPage = reinterpret_cast(&pData[offset]); //The members of the sHeader were updated - LogPageNum is corrected from uint16_t to uint8_t as per the spec //Nayana Commented the below ifcheck and kept it to know if any such scenario that satisfies this condition @@ -576,7 +586,7 @@ bool CAtaDeviceStatisticsLogs::isBit63Set(uint64_t *value) //--------------------------------------------------------------------------- void CAtaDeviceStatisticsLogs::DeviceStatFlag(uint64_t *value, JSONNODE *masterData) { - std::string myStr = "Device stat flag"; + //std::string myStr = "Device stat flag"; JSONNODE *sctFlag = json_new(JSON_NODE); json_set_name(sctFlag, "Device Statistic Flags"); @@ -651,7 +661,7 @@ uint8_t CAtaDeviceStatisticsLogs::CheckStatusAndValid_8(uint64_t *value) //Bit 62 : Valid value and 63 bit needs to be set if (isBit62Set(value) && isBit63Set(value)) { - retValue = (uint8_t)(*value); + retValue = static_cast(*value); } return retValue; } @@ -675,7 +685,7 @@ int8_t CAtaDeviceStatisticsLogs::CheckStatusAndValidSigned_8(uint64_t *value) //Bit 62 : Valid value and 63 bit needs to be set if (isBit62Set(value) && isBit63Set(value)) { - retValue = (int8_t)(*value); + retValue = static_cast(*value); } return retValue; } @@ -699,7 +709,7 @@ uint32_t CAtaDeviceStatisticsLogs::CheckStatusAndValid_32(uint64_t *value) //Bit 62 : Valid value and 63 bit needs to be set if (isBit62Set(value) && isBit63Set(value)) { - retValue = (uint32_t)(*value); + retValue = static_cast(*value); } return retValue; } @@ -719,15 +729,16 @@ uint32_t CAtaDeviceStatisticsLogs::CheckStatusAndValid_32(uint64_t *value) //--------------------------------------------------------------------------- void CAtaDeviceStatisticsLogs::logPage00(uint64_t *value) { -#if defined _DEBUG - uint64_t *cData = &value[0]; - uint8_t *pEntries = (uint8_t *)&value[0]; + + uint8_t *pEntries = reinterpret_cast(&value[0]); uint8_t TotalEntries = 0; TotalEntries = pEntries[8]; +#if defined _DEBUG printf("*****List Of Supported Device(log Page 00h)*****"); printf("\t%s %d \n\n", "Number of entries : ", TotalEntries); - +#else + M_USE_UNUSED(TotalEntries); #endif } //----------------------------------------------------------------------------- @@ -748,8 +759,8 @@ void CAtaDeviceStatisticsLogs::logPage01(uint64_t *value, JSONNODE *masterData) { //General Statistics(log page 01) contains general information about the device. sLogPage01 *dsLog; - dsLog = (sLogPage01 *)&value[0]; - string myStr = "Statistics"; + dsLog = reinterpret_cast(&value[0]); + //string myStr = "Statistics"; JSONNODE *sctStat = json_new(JSON_NODE); json_set_name(sctStat, "General Statistics(log Page 01h)"); #if defined _DEBUG @@ -901,7 +912,7 @@ void CAtaDeviceStatisticsLogs::logPage03(uint64_t *value, JSONNODE *masterData) void CAtaDeviceStatisticsLogs::logPage04(uint64_t *value, JSONNODE *masterData) { //General Errors Statistics(log page 04) contains general error infomation about the device. - sDeviceLog04 *dslog04 = (sDeviceLog04*)&value[0]; + sDeviceLog04 *dslog04 = reinterpret_cast(&value[0]); JSONNODE *sctError = json_new(JSON_NODE); json_set_name(sctError, "General Errors Statistics(log Page 04h)"); @@ -909,9 +920,9 @@ void CAtaDeviceStatisticsLogs::logPage04(uint64_t *value, JSONNODE *masterData) printf("\t%s \n", "*****General Errors Statistics(log Page 04h)*****"); #endif - json_push_back(sctError, json_new_i("Number of Reported Uncorrectable Errors", (uint32_t)check_Status_Strip_Status(dslog04->numberReportedECC))); - json_push_back(sctError, json_new_i("Number of Resets btw Cmd Completion", (uint32_t)check_Status_Strip_Status(dslog04->resets))); - json_push_back(sctError, json_new_i("Physical Element Status Changed", (uint32_t)check_Status_Strip_Status(dslog04->statusChanged))); + json_push_back(sctError, json_new_i("Number of Reported Uncorrectable Errors", static_cast(check_Status_Strip_Status(dslog04->numberReportedECC)))); + json_push_back(sctError, json_new_i("Number of Resets btw Cmd Completion", static_cast(check_Status_Strip_Status(dslog04->resets)))); + json_push_back(sctError, json_new_i("Physical Element Status Changed", static_cast(check_Status_Strip_Status(dslog04->statusChanged)))); json_push_back(masterData, sctError); @@ -963,7 +974,7 @@ void CAtaDeviceStatisticsLogs::logPage05(uint64_t *value, JSONNODE *masterData) TimeInUndTemp = CheckStatusAndValid_32(&cData[12]); MinOperTemp = CheckStatusAndValidSigned_8(&cData[13]); - string myStr = "Temperature Statistics"; + //string myStr = "Temperature Statistics"; JSONNODE *sctTemp = json_new(JSON_NODE); json_set_name(sctTemp, "Temperature Statistics(log Page 05h)"); #if defined _DEBUG diff --git a/src/CAta_Ext_Comprehensive_Log.cpp b/src/CAta_Ext_Comprehensive_Log.cpp index 67386c9..8b0fc1e 100644 --- a/src/CAta_Ext_Comprehensive_Log.cpp +++ b/src/CAta_Ext_Comprehensive_Log.cpp @@ -27,9 +27,10 @@ using namespace opensea_parser; //--------------------------------------------------------------------------- CExtComp::CExtComp() :pData() - , m_logSize(0) - , m_name("Ext Comp Log") - , m_status(IN_PROGRESS) + , m_logSize(0) + , m_name("Ext Comp Log") + , m_status(IN_PROGRESS) + , m_fileName(false) { } @@ -43,22 +44,22 @@ CExtComp::CExtComp() // //--------------------------------------------------------------------------- CExtComp::CExtComp(uint8_t *buffer, size_t logSize, JSONNODE *masterData) - :pData(buffer) - , m_logSize(logSize) - , m_name("Ext Comp Log") - , m_status(IN_PROGRESS) - , fileName(false) + :pData(buffer) + , m_logSize(logSize) + , m_name("Ext Comp Log") + , m_status(IN_PROGRESS) + , m_fileName(false) { - if (buffer != NULL) // if the buffer is null then exit something did go right - { - m_status = IN_PROGRESS; - m_status = parse_Ext_Comp_Log( masterData); - } - else - { - m_status = FAILURE; - } + if (buffer != NULL) // if the buffer is null then exit something did go right + { + m_status = IN_PROGRESS; + m_status = parse_Ext_Comp_Log(masterData); + } + else + { + m_status = FAILURE; + } } //----------------------------------------------------------------------------- @@ -72,49 +73,49 @@ CExtComp::CExtComp(uint8_t *buffer, size_t logSize, JSONNODE *masterData) //--------------------------------------------------------------------------- CExtComp::CExtComp(const std::string &fileName, JSONNODE *masterData) :pData() - , m_logSize() + , m_logSize() , m_name("Ext Comp Log") , m_status(IN_PROGRESS) - , fileName(true) + , m_fileName(true) { - CLog *cCLog; - cCLog = new CLog(fileName); - if (cCLog->get_Log_Status() == SUCCESS) - { - if (cCLog->get_Buffer() != NULL) - { - m_logSize = cCLog->get_Size(); - pData = new uint8_t[m_logSize]; // new a buffer to the point -#ifndef _WIN64 - memcpy(pData, cCLog->get_Buffer(), m_logSize); + CLog *cCLog; + cCLog = new CLog(fileName); + if (cCLog->get_Log_Status() == SUCCESS) + { + if (cCLog->get_Buffer() != NULL) + { + m_logSize = cCLog->get_Size(); + pData = new uint8_t[m_logSize]; // new a buffer to the point +#ifndef __STDC_SECURE_LIB__ + memcpy(pData, cCLog->get_Buffer(), m_logSize); #else - memcpy_s(pData, m_logSize, cCLog->get_Buffer(), m_logSize);// copy the buffer data to the class member pBuf + memcpy_s(pData, m_logSize, cCLog->get_Buffer(), m_logSize);// copy the buffer data to the class member pBuf #endif - sLogPageStruct *idCheck; - idCheck = (sLogPageStruct *)&pData[0]; - byte_Swap_16(&idCheck->pageLength); - if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) - { - byte_Swap_16(&idCheck->pageLength); // now that we know it's not scsi we need to flip the bytes back - m_status = parse_Ext_Comp_Log(masterData); - m_status = SUCCESS; - } - else - { - m_status = BAD_PARAMETER; - } - } - else - { + sLogPageStruct *idCheck; + idCheck = reinterpret_cast(&pData[0]); + byte_Swap_16(&idCheck->pageLength); + if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) + { + byte_Swap_16(&idCheck->pageLength); // now that we know it's not scsi we need to flip the bytes back + m_status = parse_Ext_Comp_Log(masterData); + m_status = SUCCESS; + } + else + { + m_status = BAD_PARAMETER; + } + } + else + { - m_status = FAILURE; - } - } - else - { - m_status = cCLog->get_Log_Status(); - } - delete (cCLog); + m_status = FAILURE; + } + } + else + { + m_status = cCLog->get_Log_Status(); + } + delete (cCLog); } //----------------------------------------------------------------------------- // @@ -127,7 +128,7 @@ CExtComp::CExtComp(const std::string &fileName, JSONNODE *masterData) //--------------------------------------------------------------------------- CExtComp::~CExtComp() { - if (fileName) + if (m_fileName) { if (pData != NULL) { @@ -152,37 +153,37 @@ CExtComp::~CExtComp() //--------------------------------------------------------------------------- eReturnValues CExtComp::get_State_Meaning(std::string *stateMeaning, uint8_t state) { - switch (state) - { - case 0x0: - { - stateMeaning->assign("Unknown"); - break; - } - case 0x1: - { - stateMeaning->assign("Sleep"); - break; - } - case 0x2: - { - stateMeaning->assign("Standby"); - break; - } - case 0x3: - { - stateMeaning->assign("Active/Idle"); - break; - } - case 0x4: - default: - { - stateMeaning->assign("Vendor Specific"); - break; - } + switch (state) + { + case 0x0: + { + stateMeaning->assign("Unknown"); + break; + } + case 0x1: + { + stateMeaning->assign("Sleep"); + break; + } + case 0x2: + { + stateMeaning->assign("Standby"); + break; + } + case 0x3: + { + stateMeaning->assign("Active/Idle"); + break; + } + case 0x4: + default: + { + stateMeaning->assign("Vendor Specific"); + break; + } - } - return SUCCESS; + } + return SUCCESS; } //----------------------------------------------------------------------------- // @@ -201,7 +202,6 @@ eReturnValues CExtComp::get_State_Meaning(std::string *stateMeaning, uint8_t sta eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t sector, JSONNODE *structureData) { std::string myStr = "Parse Ext Comp Log"; - myStr.resize(BASIC); uint8_t deviceControl = 0; uint16_t featureField = 0; uint16_t countField = 0; @@ -210,7 +210,7 @@ eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t uint16_t hiLBA = 0; uint8_t deviceHead = 0; uint8_t commandField = 0; - uint8_t reserved = 0; + //uint8_t reserved = 0; uint32_t timeStamp = 0; uint8_t errorField = 0; uint8_t status = 0; @@ -221,9 +221,11 @@ eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t uint64_t LBA = 0; uint16_t deviceErrorCount = 0; - snprintf((char*)myStr.c_str(), BASIC, "Ext Comp SMART Log Sturcture %" PRId16"", structNumber); + std::ostringstream temp; + temp << "Ext Comp SMART Log Sturcture " << std::dec << structNumber; + JSONNODE *EComp = json_new(JSON_NODE); - json_set_name(EComp, (char*)myStr.c_str()); + json_set_name(EComp, temp.str().c_str()); if (sector == 0) { @@ -235,16 +237,18 @@ eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t deviceErrorCount = pData[500]; json_push_back(EComp, json_new_i("Ext Comp Device Error Count", static_cast(deviceErrorCount))); } + temp.str("");temp.clear(); for (uint16_t z = 1; z < 5; z++) { - snprintf((char*)myStr.c_str(), BASIC, "Opcode Content %" PRId16"", (z + (structNumber* 4))); + temp << "Opcode Content " << std::dec << (z + (structNumber * 4)); JSONNODE *opcode = json_new(JSON_NODE); - json_set_name(opcode, (char*)myStr.c_str()); + json_set_name(opcode, temp.str().c_str()); for (int cmddata = 1; cmddata < 6; cmddata++) { - snprintf((char*)myStr.c_str(), BASIC, "Command Data Structure %" PRId16"", cmddata); + temp.str("");temp.clear(); + temp << "Command Data Structure " << std::dec << cmddata; JSONNODE *cmdNode = json_new(JSON_NODE); - json_set_name(cmdNode, (char*)myStr.c_str()); + json_set_name(cmdNode, temp.str().c_str()); deviceControl = pData[wOffset]; featureField = pData[wOffset + 1]; countField = pData[wOffset + 3]; @@ -253,13 +257,13 @@ eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t hiLBA = pData[wOffset + 9]; deviceHead = pData[wOffset + 11]; commandField = pData[wOffset + 12]; - reserved = pData[wOffset + 13]; + //reserved = pData[wOffset + 13]; timeStamp = pData[wOffset + 14]; word_Swap_32(&timeStamp); wOffset += 18; #if defined _DEBUG - printf("\nControl Feature Count lowLBA midLBA hiLBA device command timeStamp"); - printf("\n0x%02x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%02x 0x%02x %d \n", \ + printf("\nControl Feature Count lowLBA midLBA hiLBA device command timeStamp"); + printf("\n0x%02x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%02x 0x%02x %u \n", \ deviceControl, \ featureField, \ countField, \ @@ -270,31 +274,40 @@ eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t commandField, \ timeStamp); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", deviceControl); - json_push_back(cmdNode, json_new_a("Device Control", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", featureField); - json_push_back(cmdNode, json_new_a("Feature Field", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", countField); - json_push_back(cmdNode, json_new_a("Count Field", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", lowLBA); - json_push_back(cmdNode, json_new_a("lowLBA", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", midLBA); - json_push_back(cmdNode, json_new_a("CmidLBA", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", hiLBA); - json_push_back(cmdNode, json_new_a("hiLBA", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", deviceHead); - json_push_back(cmdNode, json_new_a("Device Head", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", commandField); - json_push_back(cmdNode, json_new_a("Command Field", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(deviceControl); + json_push_back(cmdNode, json_new_a("Device Control", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << featureField; + json_push_back(cmdNode, json_new_a("Feature Field", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << countField; + json_push_back(cmdNode, json_new_a("Count Field", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << lowLBA; + json_push_back(cmdNode, json_new_a("lowLBA", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << midLBA; + json_push_back(cmdNode, json_new_a("CmidLBA", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << hiLBA; + json_push_back(cmdNode, json_new_a("hiLBA", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(deviceHead); + json_push_back(cmdNode, json_new_a("Device Head", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(commandField); + json_push_back(cmdNode, json_new_a("Command Field", temp.str().c_str())); + temp.str("");temp.clear(); - json_push_back(cmdNode, json_new_i("Time Stamp", static_cast(timeStamp))); + json_push_back(cmdNode, json_new_i("Time Stamp", static_cast(timeStamp))); - json_push_back(opcode, cmdNode); + json_push_back(opcode, cmdNode); } //printf("offset = %d \n",wOffset); - reserved = pData[wOffset]; + //reserved = pData[wOffset]; errorField = pData[wOffset + 1]; countField = pData[wOffset + 3]; lowLBA = pData[wOffset + 5]; @@ -304,9 +317,7 @@ eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t status = pData[wOffset + 11]; state = pData[wOffset + 30]; lifeTime = pData[wOffset + 32]; - LBA = ((uint64_t)(((uint64_t)hiLBA << 32) + - ((uint64_t)midLBA << 16) + - (lowLBA))); + LBA = M_WordsTo8ByteValue(0, hiLBA, midLBA, lowLBA); byte_Swap_16(&lifeTime); wOffset += 34; #if defined _DEBUG @@ -322,24 +333,27 @@ eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t state, \ lifeTime); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%x", errorField); - json_push_back(opcode, json_new_a("Error", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%" PRIx16"", countField); - json_push_back(opcode, json_new_a("Count", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(errorField); + json_push_back(opcode, json_new_a("Error", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << countField; + json_push_back(opcode, json_new_a("Count", temp.str().c_str())); + temp.str("");temp.clear(); opensea_parser::set_json_64bit(opcode, "LBA", LBA, false); json_push_back(opcode, json_new_i("Device", static_cast(deviceControl))); - snprintf((char*)myStr.c_str(), BASIC, "0x%x", status); - json_push_back(opcode, json_new_a("Status", (char*)myStr.c_str())); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(status); + json_push_back(opcode, json_new_a("Status", temp.str().c_str())); + temp.str("");temp.clear(); get_State_Meaning(&myStr, state); - json_push_back(opcode, json_new_a("Ext Comp Error Log State", (char*)myStr.c_str())); + json_push_back(opcode, json_new_a("Ext Comp Error Log State", myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRId16"", lifeTime); - json_push_back(opcode, json_new_a("Ext Comp Error Log Life Timestamp", (char*)myStr.c_str())); + temp << std::dec << lifeTime; + json_push_back(opcode, json_new_a("Ext Comp Error Log Life Timestamp", temp.str().c_str())); json_push_back(EComp, opcode); } @@ -365,21 +379,21 @@ eReturnValues CExtComp::parse_Ext_Comp_Structure(uint32_t structNumber, uint32_t //--------------------------------------------------------------------------- eReturnValues CExtComp::parse_Ext_Comp_Log(JSONNODE *masterData) { - eReturnValues retStatus = IN_PROGRESS; - uint32_t sectorNumber = 0; - JSONNODE *ExtCompData = json_new(JSON_NODE); - json_set_name(ExtCompData, "Extended Comperhensive SMART Error Log"); - for (uint32_t sector = 0; sector < m_logSize; sector += 512) - { - // call the structure for each sector(512) of data - retStatus = parse_Ext_Comp_Structure(sectorNumber, sector, ExtCompData); - if (retStatus != SUCCESS) - { - break; - } - sectorNumber++; - } - json_push_back(masterData, ExtCompData); - return retStatus; + eReturnValues retStatus = IN_PROGRESS; + uint32_t sectorNumber = 0; + JSONNODE *ExtCompData = json_new(JSON_NODE); + json_set_name(ExtCompData, "Extended Comperhensive SMART Error Log"); + for (uint32_t sector = 0; sector < m_logSize; sector += 512) + { + // call the structure for each sector(512) of data + retStatus = parse_Ext_Comp_Structure(sectorNumber, sector, ExtCompData); + if (retStatus != SUCCESS) + { + break; + } + sectorNumber++; + } + json_push_back(masterData, ExtCompData); + return retStatus; } diff --git a/src/CAta_Ext_DST_Log.cpp b/src/CAta_Ext_DST_Log.cpp index 64861e1..68a41dc 100644 --- a/src/CAta_Ext_DST_Log.cpp +++ b/src/CAta_Ext_DST_Log.cpp @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -32,28 +32,28 @@ CAta_Ext_DST_Log::CAta_Ext_DST_Log(const std::string &fileName, JSONNODE *master , m_logSize(0) , m_status(IN_PROGRESS) { - CLog *cCLog; - cCLog = new CLog(fileName); - if (cCLog->get_Log_Status() == SUCCESS) - { - if (cCLog->get_Buffer() != NULL) - { - m_logSize = cCLog->get_Size(); - pData = new uint8_t[m_logSize]; // new a buffer to the point -#ifndef _WIN64 - memcpy(pData, cCLog->get_Buffer(), m_logSize); + CLog *cCLog; + cCLog = new CLog(fileName); + if (cCLog->get_Log_Status() == SUCCESS) + { + if (cCLog->get_Buffer() != NULL) + { + m_logSize = cCLog->get_Size(); + pData = new uint8_t[m_logSize]; // new a buffer to the point +#ifndef __STDC_SECURE_LIB__ + memcpy(pData, cCLog->get_Buffer(), m_logSize); #else - memcpy_s(pData, m_logSize, cCLog->get_Buffer(), m_logSize);// copy the buffer data to the class member pBuf + memcpy_s(pData, m_logSize, cCLog->get_Buffer(), m_logSize);// copy the buffer data to the class member pBuf #endif - sLogPageStruct *idCheck; - idCheck = (sLogPageStruct *)&pData[0]; - byte_Swap_16(&idCheck->pageLength); - if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) - { - byte_Swap_16(&idCheck->pageLength); // now that we know it's not scsi we need to flip the bytes back - m_status = parse_Ext_Self_Test_Log( masterData); - } - delete [] pData; + sLogPageStruct *idCheck; + idCheck = reinterpret_cast(&pData[0]); + byte_Swap_16(&idCheck->pageLength); + if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) + { + byte_Swap_16(&idCheck->pageLength); // now that we know it's not scsi we need to flip the bytes back + m_status = parse_Ext_Self_Test_Log(masterData); + } + delete[] pData; } } else @@ -61,7 +61,7 @@ CAta_Ext_DST_Log::CAta_Ext_DST_Log(const std::string &fileName, JSONNODE *master m_status = IN_PROGRESS; m_logSize = 0; } - delete (cCLog); + delete (cCLog); } //----------------------------------------------------------------------------- // @@ -79,9 +79,9 @@ CAta_Ext_DST_Log::CAta_Ext_DST_Log(uint8_t *pBufferData, JSONNODE *masterData) :m_name("Ext DST Log") //!< name of the class , m_status(IN_PROGRESS) { - pData = pBufferData; + pData = pBufferData; m_logSize = 0; - m_status = parse_Ext_Self_Test_Log( masterData); + m_status = parse_Ext_Self_Test_Log(masterData); pData = NULL; } //----------------------------------------------------------------------------- @@ -115,9 +115,8 @@ CAta_Ext_DST_Log::~CAta_Ext_DST_Log() //! \return eReturnValues success // //--------------------------------------------------------------------------- -void CAta_Ext_DST_Log::Get_Status_Meaning(std::string &meaning,uint8_t status) +void CAta_Ext_DST_Log::Get_Status_Meaning(std::string &meaning, uint8_t status) { - meaning.resize(BASIC); if (status == 0x00) { meaning = "Self Test completed without error."; @@ -164,7 +163,7 @@ void CAta_Ext_DST_Log::Get_Status_Meaning(std::string &meaning,uint8_t status) } else { - meaning ="Reserved"; + meaning = "Reserved"; } } //----------------------------------------------------------------------------- @@ -181,7 +180,7 @@ void CAta_Ext_DST_Log::Get_Status_Meaning(std::string &meaning,uint8_t status) //! \return eReturnValues success // //--------------------------------------------------------------------------- -eReturnValues CAta_Ext_DST_Log::parse_Ext_Self_Test_Log( JSONNODE *masterData) +eReturnValues CAta_Ext_DST_Log::parse_Ext_Self_Test_Log(JSONNODE *masterData) { std::string myStr = "Start of Ext DST"; JSONNODE *DstJson = json_new(JSON_NODE); @@ -193,38 +192,36 @@ eReturnValues CAta_Ext_DST_Log::parse_Ext_Self_Test_Log( JSONNODE *masterData) uint64_t LBA = 0; json_set_name(DstJson, "DST Log"); - uint16_t index = ((uint16_t)pData[3] << 8) | ((uint16_t)pData[2] << 0); + uint16_t index = M_BytesTo2ByteValue(pData[3], pData[2]); json_push_back(DstJson, json_new_i("Self Test Index", static_cast(index))); DSTIndex += 4; for (int i = 1; i <= 19; i++) { - - StatusByte = pData[DSTIndex + 1]; - timeStamp = ((uint16_t)pData[DSTIndex + 3] << 8) | ((uint16_t)pData[DSTIndex + 2] << 0); - compTime = ((uint16_t)pData[DSTIndex + 13] << 8) | ((uint16_t)pData[DSTIndex + 12] << 0); + timeStamp = M_BytesTo2ByteValue(pData[DSTIndex + 3], pData[DSTIndex + 2]); + compTime = M_BytesTo2ByteValue(pData[DSTIndex + 13], pData[DSTIndex + 12]); checkPointByte = pData[DSTIndex + 4]; - LBA = ((uint64_t)pData[DSTIndex + 10] << 40) | - ((uint64_t)pData[DSTIndex + 9] << 32) | - ((uint64_t)pData[DSTIndex + 8] << 24) | - ((uint64_t)pData[DSTIndex + 7] << 16) | - ((uint64_t)pData[DSTIndex + 6] << 8) | - ((uint64_t)pData[DSTIndex + 5] << 0); - + LBA = M_BytesTo8ByteValue(0,0, pData[DSTIndex + 10], pData[DSTIndex + 9], pData[DSTIndex + 8], pData[DSTIndex + 7], pData[DSTIndex + 6], pData[DSTIndex + 5]); JSONNODE *runInfo = json_new(JSON_NODE); - snprintf((char*)myStr.c_str(), BASIC, "Run %3d ", i); - json_set_name(runInfo, (char*)myStr.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "%u", timeStamp); - json_push_back(runInfo, json_new_a("Timestamp", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02x", int(StatusByte)); - json_push_back(runInfo, json_new_a("Status Byte", (char*)myStr.c_str())); + + std::ostringstream temp; + temp << "Run " << std::dec << std::setw(3) << i; + json_set_name(runInfo, temp.str().c_str()); + temp.str("");temp.clear(); + temp << std::dec << timeStamp; + json_push_back(runInfo, json_new_a("Timestamp", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(StatusByte); + json_push_back(runInfo, json_new_a("Status Byte", temp.str().c_str())); Get_Status_Meaning(myStr,StatusByte); - json_push_back(runInfo, json_new_a("Status Meaning",(char*)myStr.c_str())); + json_push_back(runInfo, json_new_a("Status Meaning", myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02x", checkPointByte); - json_push_back(runInfo, json_new_a("CheckPoint Byte", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%u", compTime); - json_push_back(runInfo, json_new_a("Completion Time", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(checkPointByte); + json_push_back(runInfo, json_new_a("CheckPoint Byte", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << compTime; + json_push_back(runInfo, json_new_a("Completion Time", temp.str().c_str())); set_json_64bit(runInfo, "LBA", LBA, false); DSTIndex += 26; diff --git a/src/CAta_Identify_Log.cpp b/src/CAta_Identify_Log.cpp index 59a0556..a276f49 100644 --- a/src/CAta_Identify_Log.cpp +++ b/src/CAta_Identify_Log.cpp @@ -1,6 +1,6 @@ // Do NOT modify or remove this copyright and license // -//Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +//Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,6 +9,8 @@ // ****************************************************************************************** #include "CAta_Identify_Log.h" +#include +#include #define ATA_SERIAL_NUMBER_LEN 20 #define ATA_MODEL_NUMBER_LEN 40 @@ -29,7 +31,7 @@ using namespace opensea_parser; // // //--------------------------------------------------------------------------- -inline std::string& ltrim(std::string& s, const char* t = " \t\r\f\v") +inline std::string ltrim(std::string& s, const char* t = " \t\r\f\v") { s.erase(0, s.find_first_not_of(t)); return s; @@ -46,7 +48,7 @@ inline std::string& ltrim(std::string& s, const char* t = " \t\r\f\v") // // //--------------------------------------------------------------------------- -inline std::string& rtrim(std::string& s, const char* t = " \t\r\f\v") +inline std::string rtrim(std::string& s, const char* t = " \t\r\f\v") { s.erase(s.find_last_not_of(t) + 1); return s; @@ -65,7 +67,7 @@ inline std::string& rtrim(std::string& s, const char* t = " \t\r\f\v") //! \return bool - false or true // //--------------------------------------------------------------------------- -inline bool check_For_Active_Status(uint64_t *value) +inline bool check_For_Active_Status(const uint64_t *value) { if (*value & BIT63) { @@ -77,7 +79,9 @@ inline bool check_For_Active_Status(uint64_t *value) // ***************************************************************************** CAta_Identify_log::CAta_Identify_log() : m_name("ATA Identify Log") + , pData(NULL) , m_status(IN_PROGRESS) + , m_sDriveInfo() { //m_sDriveInfo = {}; } @@ -99,9 +103,10 @@ CAta_Identify_log::CAta_Identify_log() //--------------------------------------------------------------------------- CAta_Identify_log::CAta_Identify_log(uint8_t *buffer) : m_name("ATA Identify Log") + , pData(buffer) , m_status(IN_PROGRESS) + , m_sDriveInfo() { - pData = buffer; if (pData != NULL) { parse_Device_Info(); @@ -129,7 +134,9 @@ CAta_Identify_log::CAta_Identify_log(uint8_t *buffer) //--------------------------------------------------------------------------- CAta_Identify_log::CAta_Identify_log(const std::string & fileName) : m_name("ATA Identify Log") + , pData(NULL) , m_status(IN_PROGRESS) + , m_sDriveInfo() { CLog *cCLog; cCLog = new CLog(fileName); @@ -139,13 +146,13 @@ CAta_Identify_log::CAta_Identify_log(const std::string & fileName) { size_t bufferSize = cCLog->get_Size(); pData = new uint8_t[cCLog->get_Size()]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, cCLog->get_Buffer(), bufferSize); #else memcpy_s(pData, bufferSize, cCLog->get_Buffer(), bufferSize);// copy the buffer data to the class member pBuf #endif sLogPageStruct *idCheck; - idCheck = (sLogPageStruct *)&pData[0]; + idCheck = reinterpret_cast(&pData[0]); byte_Swap_16(&idCheck->pageLength); if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) { @@ -202,11 +209,11 @@ CAta_Identify_log::~CAta_Identify_log() void CAta_Identify_log::create_Serial_Number(uint16_t offset) { - m_sDriveInfo.serialNumber.resize(ATA_SERIAL_NUMBER_LEN); - strncpy((char*)m_sDriveInfo.serialNumber.c_str(), (char*)&pData[512 + offset], ATA_SERIAL_NUMBER_LEN); - byte_Swap_String((char*)m_sDriveInfo.serialNumber.c_str()); + + m_sDriveInfo.serialNumber.assign(reinterpret_cast(&pData[512 + offset]), ATA_SERIAL_NUMBER_LEN); + byte_swap_std_string(m_sDriveInfo.serialNumber); ltrim(m_sDriveInfo.serialNumber); - m_sDriveInfo.serialNumber.resize(ATA_SERIAL_NUMBER_LEN); + m_sDriveInfo.serialNumber.resize(ATA_SERIAL_NUMBER_LEN);//don't know why this was here, but assuming there is a reason - TJE } //----------------------------------------------------------------------------- @@ -224,9 +231,8 @@ void CAta_Identify_log::create_Serial_Number(uint16_t offset) //--------------------------------------------------------------------------- void CAta_Identify_log::create_Firmware_String(uint16_t offset) { - m_sDriveInfo.firmware.resize(ATA_FIRMWARE_REV_LEN); - strncpy((char*)m_sDriveInfo.firmware.c_str(), (char*)&pData[512 + offset], ATA_FIRMWARE_REV_LEN); - byte_Swap_String((char*)m_sDriveInfo.firmware.c_str()); + m_sDriveInfo.firmware.assign(reinterpret_cast(&pData[512 + offset]), ATA_FIRMWARE_REV_LEN); + byte_swap_std_string(m_sDriveInfo.firmware); rtrim(m_sDriveInfo.firmware); m_sDriveInfo.firmware.resize(ATA_FIRMWARE_REV_LEN); } @@ -245,9 +251,8 @@ void CAta_Identify_log::create_Firmware_String(uint16_t offset) //--------------------------------------------------------------------------- void CAta_Identify_log::create_Model_Number(uint16_t offset) { - m_sDriveInfo.modelNumber.resize(ATA_MODEL_NUMBER_LEN); - strncpy((char*)m_sDriveInfo.modelNumber.c_str(), (char*)&pData[512 + offset], ATA_MODEL_NUMBER_LEN); - byte_Swap_String((char*)m_sDriveInfo.modelNumber.c_str()); + m_sDriveInfo.modelNumber.assign(reinterpret_cast(&pData[512 + offset]), ATA_MODEL_NUMBER_LEN); + byte_swap_std_string(m_sDriveInfo.modelNumber); rtrim(m_sDriveInfo.modelNumber); m_sDriveInfo.modelNumber.resize(ATA_MODEL_NUMBER_LEN); } @@ -272,11 +277,19 @@ void CAta_Identify_log::create_WWN_Info() m_sDriveInfo.ieeeOUI.resize(WORLD_WIDE_NAME_LEN); m_sDriveInfo.uniqueID.resize(WORLD_WIDE_NAME_LEN); uint64_t wwn = M_WordsTo8ByteValue(identWordPtr[108], identWordPtr[109], identWordPtr[110], identWordPtr[111]); - snprintf((char*)m_sDriveInfo.worldWideName.c_str(), WORLD_WIDE_NAME_LEN, "%" PRIX64"", wwn); - uint64_t ieeeOUI = (uint64_t)((wwn & 0x0FFFFFF000000000ULL) >> 36); - uint64_t uniqueID = (uint64_t)(wwn & 0x0000000FFFFFFFFFULL); - snprintf((char*)m_sDriveInfo.ieeeOUI.c_str(), WORLD_WIDE_NAME_LEN, "0x%06" PRIX64"", ieeeOUI); - snprintf((char*)(m_sDriveInfo.uniqueID.c_str()), WORLD_WIDE_NAME_LEN, "0x%09" PRIX64"", uniqueID); + std::ostringstream temp; + temp << std::hex << std::uppercase << wwn; + m_sDriveInfo.worldWideName.assign(temp.str()); + uint64_t ieeeOUI = static_cast((wwn & UINT64_C(0x0FFFFFF000000000)) >> 36); + uint64_t uniqueID = static_cast(wwn & UINT64_C(0x0000000FFFFFFFFF)); + + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::uppercase << std::setfill('0') << std::setw(6) << ieeeOUI; + m_sDriveInfo.ieeeOUI.assign(temp.str()); + + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::uppercase << std::setfill('0') << std::setw(9) << uniqueID; + m_sDriveInfo.uniqueID.assign(temp.str()); m_sDriveInfo.worldWideName.resize(WORLD_WIDE_NAME_LEN); m_sDriveInfo.ieeeOUI.resize(WORLD_WIDE_NAME_LEN); m_sDriveInfo.uniqueID.resize(WORLD_WIDE_NAME_LEN); @@ -331,9 +344,9 @@ eReturnValues CAta_Identify_log::parse_Device_Info() { m_sDriveInfo.smartFeatureEnabled = true; } - if (((uint32_t)(identWordPtr[117] << 8) & identWordPtr[118]) > 0) + if ((static_cast(identWordPtr[117] << 8) & identWordPtr[118]) > 0) { - m_sDriveInfo.ataReportedLogicalSectorSize = (uint32_t)(identWordPtr[117] << 8) & identWordPtr[118]; + m_sDriveInfo.ataReportedLogicalSectorSize = static_cast(identWordPtr[117] << 8) & identWordPtr[118]; } if ((identWordPtr[206] & BIT0) > 0) { @@ -367,8 +380,7 @@ eReturnValues CAta_Identify_log::parse_Device_Info() } else { - m_sDriveInfo.worldWideName.resize(WORLD_WIDE_NAME_LEN); - strncpy((char*)m_sDriveInfo.worldWideName.c_str(), "Not Supported", strlen("Not Supported")); + m_sDriveInfo.worldWideName.assign("Not Supported"); } //maxLBA @@ -384,7 +396,7 @@ eReturnValues CAta_Identify_log::parse_Device_Info() //word 117 is only valid when word 106 bit 12 is set if ((identWordPtr[106] & BIT12) == BIT12) { - m_sDriveInfo.sSizes.logicalSectorSize = identWordPtr[117] | ((uint32_t)identWordPtr[118] << 16); + m_sDriveInfo.sSizes.logicalSectorSize = M_WordsTo4ByteValue(identWordPtr[118], identWordPtr[117]); m_sDriveInfo.sSizes.logicalSectorSize *= 2; //convert to words to bytes } else //means that logical sector size is 512bytes @@ -397,11 +409,10 @@ eReturnValues CAta_Identify_log::parse_Device_Info() } else //multiple logical sectors per physical sector { - - uint8_t logicalPerPhysical = 1; m_sDriveInfo.sSizes.sectorSizeExponent = identWordPtr[106] & 0x000F; //get the number of logical blocks per physical blocks if (m_sDriveInfo.sSizes.sectorSizeExponent != 0) { + uint8_t logicalPerPhysical = 1; uint8_t shiftCounter = 0; while (shiftCounter < m_sDriveInfo.sSizes.sectorSizeExponent) { @@ -416,15 +427,16 @@ eReturnValues CAta_Identify_log::parse_Device_Info() } - m_sDriveInfo.sCapInfo.capUnit = (double)(m_sDriveInfo.maxLBA48 * m_sDriveInfo.sSizes.logicalSectorSize); + m_sDriveInfo.sCapInfo.capUnit = static_cast(m_sDriveInfo.maxLBA48 * m_sDriveInfo.sSizes.logicalSectorSize); m_sDriveInfo.sCapInfo.capacityUnit.resize(3); - char * capUnit = (char*)&m_sDriveInfo.sCapInfo.capacityUnit.c_str()[0]; - capacity_Unit_Convert((double *)&m_sDriveInfo.sCapInfo.capUnit, &capUnit); - + char capUnitBuf[5] = { 0 }; + char * capUnit = &capUnitBuf[0]; + capacity_Unit_Convert(&m_sDriveInfo.sCapInfo.capUnit, &capUnit); + m_sDriveInfo.sCapInfo.capacityUnit.assign(capUnit); //sata speeds - m_sDriveInfo.sataGenSupported = (uint8_t)(identWordPtr[76] & 0x000F) >> 1; //we only care about the lower bits right now - m_sDriveInfo.sataNegotiated = (uint8_t)(identWordPtr[77] & 0x000F) >> 1; //coded value + m_sDriveInfo.sataGenSupported = static_cast((identWordPtr[76] & 0x000F) >> 1); //we only care about the lower bits right now + m_sDriveInfo.sataNegotiated = static_cast((identWordPtr[77] & 0x000F) >> 1); //coded value //ATA spec supported m_sDriveInfo.ataSpecBits = identWordPtr[80]; @@ -469,25 +481,26 @@ eReturnValues CAta_Identify_log::parse_Device_Info() uint8_t page = 2; //nothing in first pages //fill in data for page 2 - m_sDriveInfo.IDDevCap = ((uint64_t) 0 << 56) | ((uint64_t)IDptr[page * 512 + 14] << 48) | ((uint64_t)IDptr[page * 512 + 13] << 40) | ((uint64_t)IDptr[page * 512 + 12] << 32) | ((uint64_t)IDptr[page * 512 + 11] << 24) | ((uint64_t)IDptr[page * 512 + 10] << 16) | ((uint64_t)IDptr[page * 512 + 9] << 8) | ((uint64_t)IDptr[page * 512 + 8]); - m_sDriveInfo.IDPhySecSize = ((uint64_t)IDptr[page * 512 + 23] << 56) | ((uint64_t)IDptr[page * 512 + 22] << 48) | ((uint64_t)IDptr[page * 512 + 21] << 40) | ((uint64_t)IDptr[page * 512 + 20] << 32) | ((uint64_t)IDptr[page * 512 + 19] << 24) | ((uint64_t)IDptr[page * 512 + 18] << 16) | ((uint64_t)IDptr[page * 512 + 17] << 8) | ((uint64_t)IDptr[page * 512 + 16]); - m_sDriveInfo.IDLogSecSize = ((uint64_t)IDptr[page * 512 + 31] << 56) | ((uint64_t)IDptr[page * 512 + 30] << 48) | ((uint64_t)IDptr[page * 512 + 29] << 40) | ((uint64_t)IDptr[page * 512 + 28] << 32) | ((uint64_t)IDptr[page * 512 + 27] << 24) | ((uint64_t)IDptr[page * 512 + 26] << 16) | ((uint64_t)IDptr[page * 512 + 25] << 8) | ((uint64_t)IDptr[page * 512 + 24]); - m_sDriveInfo.IDBufSize = ((uint64_t)IDptr[page * 512 + 39] << 56) | ((uint64_t)IDptr[page * 512 + 38] << 48) | ((uint64_t)IDptr[page * 512 + 37] << 40) | ((uint64_t)IDptr[page * 512 + 36] << 32) | ((uint64_t)IDptr[page * 512 + 35] << 24) | ((uint64_t)IDptr[page * 512 + 34] << 16) | ((uint64_t)IDptr[page * 512 + 33] << 8) | ((uint64_t)IDptr[page * 512 + 32]); + m_sDriveInfo.IDDevCap = M_BytesTo8ByteValue(0, IDptr[page * 512 + 14], IDptr[page * 512 + 13], IDptr[page * 512 + 12], IDptr[page * 512 + 11], IDptr[page * 512 + 10], IDptr[page * 512 + 9], IDptr[page * 512 + 8]); + + m_sDriveInfo.IDPhySecSize = M_BytesTo8ByteValue(IDptr[page * 512 + 23], IDptr[page * 512 + 22], IDptr[page * 512 + 21], IDptr[page * 512 + 20], IDptr[page * 512 + 19], IDptr[page * 512 + 18], IDptr[page * 512 + 17], IDptr[page * 512 + 16]); + m_sDriveInfo.IDLogSecSize = M_BytesTo8ByteValue(IDptr[page * 512 + 31], IDptr[page * 512 + 30], IDptr[page * 512 + 29], IDptr[page * 512 + 28], IDptr[page * 512 + 27], IDptr[page * 512 + 26], IDptr[page * 512 + 25], IDptr[page * 512 + 24]); + m_sDriveInfo.IDBufSize = M_BytesTo8ByteValue(IDptr[page * 512 + 39], IDptr[page * 512 + 38], IDptr[page * 512 + 37], IDptr[page * 512 + 36], IDptr[page * 512 + 35], IDptr[page * 512 + 34], IDptr[page * 512 + 33], IDptr[page * 512 + 32]); //fill in data for page 3 page = 3; - m_sDriveInfo.IDCapabilities = ((uint64_t)IDptr[page * 512 + 15] << 56) | ((uint64_t)IDptr[page * 512 + 14] << 48) | ((uint64_t)IDptr[page * 512 + 13] << 40) | ((uint64_t)IDptr[page * 512 + 12] << 32) | ((uint64_t)IDptr[page * 512 + 11] << 24) | ((uint64_t)IDptr[page * 512 + 10] << 16) | ((uint64_t)IDptr[page * 512 + 9] << 8) | ((uint64_t)IDptr[page * 512 + 8]); - m_sDriveInfo.IDMicrocode = ((uint64_t)IDptr[page * 512 + 23] << 56) | ((uint64_t)IDptr[page * 512 + 22] << 48) | ((uint64_t)IDptr[page * 512 + 21] << 40) | ((uint64_t)IDptr[page * 512 + 20] << 32) | ((uint64_t)IDptr[page * 512 + 19] << 24) | ((uint64_t)IDptr[page * 512 + 18] << 16) | ((uint64_t)IDptr[page * 512 + 17] << 8) | ((uint64_t)IDptr[page * 512 + 16]); - m_sDriveInfo.IDMediaRotRate = ((uint64_t)IDptr[page * 512 + 31] << 56) | ((uint64_t)IDptr[page * 512 + 30] << 48) | ((uint64_t)IDptr[page * 512 + 29] << 40) | ((uint64_t)IDptr[page * 512 + 28] << 32) | ((uint64_t)IDptr[page * 512 + 27] << 24) | ((uint64_t)IDptr[page * 512 + 26] << 16) | ((uint64_t)IDptr[page * 512 + 25] << 8) | ((uint64_t)IDptr[page * 512 + 24]); - m_sDriveInfo.IDFormFactor = ((uint64_t)IDptr[page * 512 + 39] << 56) | ((uint64_t)IDptr[page * 512 + 38] << 48) | ((uint64_t)IDptr[page * 512 + 37] << 40) | ((uint64_t)IDptr[page * 512 + 36] << 32) | ((uint64_t)IDptr[page * 512 + 35] << 24) | ((uint64_t)IDptr[page * 512 + 34] << 16) | ((uint64_t)IDptr[page * 512 + 33] << 8) | ((uint64_t)IDptr[page * 512 + 32]); - m_sDriveInfo.IDWRVSecCount2 = ((uint64_t)IDptr[page * 512 + 47] << 56) | ((uint64_t)IDptr[page * 512 + 46] << 48) | ((uint64_t)IDptr[page * 512 + 45] << 40) | ((uint64_t)IDptr[page * 512 + 44] << 32) | ((uint64_t)IDptr[page * 512 + 43] << 24) | ((uint64_t)IDptr[page * 512 + 42] << 16) | ((uint64_t)IDptr[page * 512 + 41] << 8) | ((uint64_t)IDptr[page * 512 + 40]); - m_sDriveInfo.IDWRVSecCount3 = ((uint64_t)IDptr[page * 512 + 55] << 56) | ((uint64_t)IDptr[page * 512 + 54] << 48) | ((uint64_t)IDptr[page * 512 + 53] << 40) | ((uint64_t)IDptr[page * 512 + 52] << 32) | ((uint64_t)IDptr[page * 512 + 51] << 24) | ((uint64_t)IDptr[page * 512 + 50] << 16) | ((uint64_t)IDptr[page * 512 + 49] << 8) | ((uint64_t)IDptr[page * 512 + 48]); - m_sDriveInfo.IDWWN = ((uint64_t)IDptr[page * 512 + 71] << 56) | ((uint64_t)IDptr[page * 512 + 70] << 48) | ((uint64_t)IDptr[page * 512 + 69] << 40) | ((uint64_t)IDptr[page * 512 + 68] << 32) | ((uint64_t)IDptr[page * 512 + 67] << 24) | ((uint64_t)IDptr[page * 512 + 66] << 16) | ((uint64_t)IDptr[page * 512 + 65] << 8) | ((uint64_t)IDptr[page * 512 + 64]); + m_sDriveInfo.IDCapabilities = M_BytesTo8ByteValue(IDptr[page * 512 + 15], IDptr[page * 512 + 14], IDptr[page * 512 + 13], IDptr[page * 512 + 12], IDptr[page * 512 + 11], IDptr[page * 512 + 10], IDptr[page * 512 + 9], IDptr[page * 512 + 8]); + m_sDriveInfo.IDMicrocode = M_BytesTo8ByteValue(IDptr[page * 512 + 23], IDptr[page * 512 + 22], IDptr[page * 512 + 21], IDptr[page * 512 + 20], IDptr[page * 512 + 19], IDptr[page * 512 + 18], IDptr[page * 512 + 17], IDptr[page * 512 + 16]); + m_sDriveInfo.IDMediaRotRate = M_BytesTo8ByteValue(IDptr[page * 512 + 31], IDptr[page * 512 + 30], IDptr[page * 512 + 29], IDptr[page * 512 + 28], IDptr[page * 512 + 27], IDptr[page * 512 + 26], IDptr[page * 512 + 25], IDptr[page * 512 + 24]); + m_sDriveInfo.IDFormFactor = M_BytesTo8ByteValue(IDptr[page * 512 + 39], IDptr[page * 512 + 38], IDptr[page * 512 + 37], IDptr[page * 512 + 36], IDptr[page * 512 + 35], IDptr[page * 512 + 34], IDptr[page * 512 + 33], IDptr[page * 512 + 32]); + m_sDriveInfo.IDWRVSecCount2 = M_BytesTo8ByteValue(IDptr[page * 512 + 47], IDptr[page * 512 + 46], IDptr[page * 512 + 45], IDptr[page * 512 + 44], IDptr[page * 512 + 43], IDptr[page * 512 + 42], IDptr[page * 512 + 41], IDptr[page * 512 + 40]); + m_sDriveInfo.IDWRVSecCount3 = M_BytesTo8ByteValue(IDptr[page * 512 + 55], IDptr[page * 512 + 54], IDptr[page * 512 + 53], IDptr[page * 512 + 52], IDptr[page * 512 + 51], IDptr[page * 512 + 50], IDptr[page * 512 + 49], IDptr[page * 512 + 48]); + m_sDriveInfo.IDWWN = M_BytesTo8ByteValue(IDptr[page * 512 + 71], IDptr[page * 512 + 70], IDptr[page * 512 + 69], IDptr[page * 512 + 68], IDptr[page * 512 + 67], IDptr[page * 512 + 66], IDptr[page * 512 + 65], IDptr[page * 512 + 64]); //fill in data for page 6 //data in page 6 page = 6; - m_sDriveInfo.IDSecurityStatus = ((uint64_t)IDptr[page * 512 + 23] << 56) | ((uint64_t)IDptr[page * 512 + 22] << 48) | ((uint64_t)IDptr[page * 512 + 21] << 40) | ((uint64_t)IDptr[page * 512 + 20] << 32) | ((uint64_t)IDptr[page * 512 + 19] << 24) | ((uint64_t)IDptr[page * 512 + 18] << 16) | ((uint64_t)IDptr[page * 512 + 17] << 8) | ((uint64_t)IDptr[page * 512 + 16]); + m_sDriveInfo.IDSecurityStatus = M_BytesTo8ByteValue(IDptr[page * 512 + 23], IDptr[page * 512 + 22], IDptr[page * 512 + 21], IDptr[page * 512 + 20], IDptr[page * 512 + 19], IDptr[page * 512 + 18], IDptr[page * 512 + 17], IDptr[page * 512 + 16]); // Device Capabilities: if (m_sDriveInfo.IDCapabilities & BIT45) //bit 45 @@ -692,115 +705,121 @@ eReturnValues CAta_Identify_log::parse_Device_Info() //--------------------------------------------------------------------------- eReturnValues CAta_Identify_log::print_Identify_Information(JSONNODE *masterData) { - std::string myStr = "Print Idenify Info"; - myStr.resize(BASIC); - JSONNODE *identifyInfo = json_new(JSON_NODE); json_set_name(identifyInfo, "Identify Device Information"); //print the strings - json_push_back(identifyInfo, json_new_a("Model Number", (char*)m_sDriveInfo.modelNumber.c_str())); + json_push_back(identifyInfo, json_new_a("Model Number", m_sDriveInfo.modelNumber.c_str())); - json_push_back(identifyInfo, json_new_a("Serial Number", (char*)m_sDriveInfo.serialNumber.c_str())); + json_push_back(identifyInfo, json_new_a("Serial Number", m_sDriveInfo.serialNumber.c_str())); - json_push_back(identifyInfo, json_new_a("Firmware Revision", (char*)m_sDriveInfo.firmware.c_str())); + json_push_back(identifyInfo, json_new_a("Firmware Revision", m_sDriveInfo.firmware.c_str())); // world wide name - json_push_back(identifyInfo, json_new_a("World Wide Name", (char*)m_sDriveInfo.worldWideName.c_str())); + json_push_back(identifyInfo, json_new_a("World Wide Name", m_sDriveInfo.worldWideName.c_str())); JSONNODE *IEEEinfo = json_new(JSON_NODE); json_set_name(IEEEinfo, "IEEE Registered"); - json_push_back(IEEEinfo, json_new_a("IEEE Company ID", (char*)m_sDriveInfo.ieeeOUI.c_str())); - json_push_back(IEEEinfo, json_new_a("Vendor Specific ID", (char*)m_sDriveInfo.uniqueID.c_str())); + json_push_back(IEEEinfo, json_new_a("IEEE Company ID", m_sDriveInfo.ieeeOUI.c_str())); + json_push_back(IEEEinfo, json_new_a("Vendor Specific ID", m_sDriveInfo.uniqueID.c_str())); json_push_back(identifyInfo, IEEEinfo); //maxLBA - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", m_sDriveInfo.maxLBA28); - json_push_back(identifyInfo, json_new_a("MaxLBA (28bit)", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64"", m_sDriveInfo.maxLBA48); - json_push_back(identifyInfo, json_new_a("MaxLBA (48bit)", (char*)myStr.c_str())); + std::ostringstream temp; + temp << std::dec << m_sDriveInfo.maxLBA28; + json_push_back(identifyInfo, json_new_a("MaxLBA (28bit)", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_sDriveInfo.maxLBA48; + json_push_back(identifyInfo, json_new_a("MaxLBA (48bit)", temp.str().c_str())); + temp.str("");temp.clear(); // sector sizes JSONNODE *sectorSize = json_new(JSON_NODE); json_set_name(sectorSize, "Sector Sizes"); if (m_sDriveInfo.sSizes.sectorSizeReported) { - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", m_sDriveInfo.sSizes.logicalSectorSize); - json_push_back(sectorSize, json_new_a("Logical", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", m_sDriveInfo.sSizes.sectorSizeExponent); - json_push_back(sectorSize, json_new_a("Sector Size Exponent", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32" ", m_sDriveInfo.sSizes.physicalSectorSize); - json_push_back(sectorSize, json_new_a("Physical", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", m_sDriveInfo.logicalSectorAlignment); - json_push_back(sectorSize, json_new_a("Logical Sector alignment", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_sDriveInfo.sSizes.logicalSectorSize; + json_push_back(sectorSize, json_new_a("Logical", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_sDriveInfo.sSizes.sectorSizeExponent; + json_push_back(sectorSize, json_new_a("Sector Size Exponent", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_sDriveInfo.sSizes.physicalSectorSize; + json_push_back(sectorSize, json_new_a("Physical", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_sDriveInfo.logicalSectorAlignment; + json_push_back(sectorSize, json_new_a("Logical Sector alignment", temp.str().c_str())); } else { - snprintf((char*)myStr.c_str(), BASIC, "512 byte assumed"); - json_push_back(sectorSize, json_new_a("Sector Size", (char*)myStr.c_str())); + json_push_back(sectorSize, json_new_a("Sector Size", "512 byte assumed")); } json_push_back(identifyInfo, sectorSize); - // capacity - snprintf((char*)myStr.c_str(), BASIC, "%0.02f %s ", m_sDriveInfo.sCapInfo.capUnit, (char*)m_sDriveInfo.sCapInfo.capacityUnit.c_str()); - json_push_back(identifyInfo, json_new_a("Identify Log Device Capacity", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << m_sDriveInfo.sCapInfo.capUnit << " " << m_sDriveInfo.sCapInfo.capacityUnit; + json_push_back(identifyInfo, json_new_a("Identify Log Device Capacity", temp.str().c_str())); // Spec + temp.str("");temp.clear(); switch (m_sDriveInfo.ataSpecCounter) { case 15: - snprintf((char*)myStr.c_str(), BASIC, "ACS-8"); + temp << "ACS-8"; break; case 14: - snprintf((char*)myStr.c_str(), BASIC, "ACS-7"); + temp << "ACS-7"; break; case 13: - snprintf((char*)myStr.c_str(), BASIC, "ACS-6"); + temp << "ACS-6"; break; case 12: - snprintf((char*)myStr.c_str(), BASIC, "ACS-5"); + temp << "ACS-5"; break; case 11: - snprintf((char*)myStr.c_str(), BASIC, "ACS-4"); + temp << "ACS-4"; break; case 10: - snprintf((char*)myStr.c_str(), BASIC, "ACS-3"); + temp << "ACS-3"; break; case 9: - snprintf((char*)myStr.c_str(), BASIC, "ACS-2"); + temp << "ACS-2"; break; case 8: - snprintf((char*)myStr.c_str(), BASIC, "ATA8 - ACS"); + temp << "ATA8 - ACS"; break; case 7: - snprintf((char*)myStr.c_str(), BASIC, "ATA/ATAPI-7"); + temp << "ATA/ATAPI-7"; break; case 6: - snprintf((char*)myStr.c_str(), BASIC, "ATA/ATAPI-6"); + temp << "ATA/ATAPI-6"; break; case 5: - snprintf((char*)myStr.c_str(), BASIC, "ATA/ATAPI-5"); + temp << "ATA/ATAPI-5"; break; case 4: - snprintf((char*)myStr.c_str(), BASIC, "ATA/ATAPI-4"); + temp << "ATA/ATAPI-4"; break; case 3: - snprintf((char*)myStr.c_str(), BASIC, "ATA-3"); + temp << "ATA-3"; break; case 2: - snprintf((char*)myStr.c_str(), BASIC, "ATA-2"); + temp << "ATA-2"; break; case 1: - snprintf((char*)myStr.c_str(), BASIC, "ATA-1"); + temp << "ATA-1"; break; default: - snprintf((char*)myStr.c_str(), BASIC, " Unknown / Not Reported "); + temp << " Unknown / Not Reported "; break; } - json_push_back(identifyInfo, json_new_a("ATA Spec Supported", (char*)myStr.c_str())); + json_push_back(identifyInfo, json_new_a("ATA Spec Supported", temp.str().c_str())); //minor spec version number - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", m_sDriveInfo.minorSpecVersionNumber); - json_push_back(identifyInfo, json_new_a("ATA Spec Minor Version Number", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_sDriveInfo.minorSpecVersionNumber; + json_push_back(identifyInfo, json_new_a("ATA Spec Minor Version Number", temp.str().c_str())); //Transport + temp.str("");temp.clear(); if (m_sDriveInfo.sTrans.transportReported) { switch (m_sDriveInfo.sTrans.transportType) @@ -809,13 +828,13 @@ eReturnValues CAta_Identify_log::print_Identify_Information(JSONNODE *masterData switch (m_sDriveInfo.sTrans.transportCounter) { case 1: - snprintf((char*)myStr.c_str(), BASIC, "ATA/ATAPI-7"); + temp << "ATA/ATAPI-7"; break; case 0: - snprintf((char*)myStr.c_str(), BASIC, "ATA8-APT"); + temp << "ATA8-APT"; break; default: - snprintf((char*)myStr.c_str(), BASIC, "Reserved"); + temp << "Reserved"; break; } break; @@ -823,77 +842,79 @@ eReturnValues CAta_Identify_log::print_Identify_Information(JSONNODE *masterData switch (m_sDriveInfo.sTrans.transportCounter) { case 8: - snprintf((char*)myStr.c_str(), BASIC, "SATA 3.3"); + temp << "SATA 3.3"; break; case 7: - snprintf((char*)myStr.c_str(), BASIC, "SATA 3.2"); + temp << "SATA 3.2"; break; case 6: - snprintf((char*)myStr.c_str(), BASIC, "SATA 3.1"); + temp << "SATA 3.1"; break; case 5: - snprintf((char*)myStr.c_str(), BASIC, "SATA 3.0"); + temp << "SATA 3.0"; break; case 4: - snprintf((char*)myStr.c_str(), BASIC, "SATA 2.6"); + temp << "SATA 2.6"; break; case 3: - snprintf((char*)myStr.c_str(), BASIC, "SATA 2.5"); + temp << "SATA 2.5"; break; case 2: - snprintf((char*)myStr.c_str(), BASIC, "SATA II - Extensions"); + temp << "SATA II - Extensions"; break; case 1: - snprintf((char*)myStr.c_str(), BASIC, "SATA 1.0a"); + temp << "SATA 1.0a"; break; case 0: - snprintf((char*)myStr.c_str(), BASIC, "ATA8-AST"); + temp << "ATA8-AST"; break; default: - snprintf((char*)myStr.c_str(), BASIC, "Reserved"); + temp << "Reserved"; } break; default://unknown/undefined, just dump the bits - snprintf((char*)myStr.c_str(), BASIC, "Unknown Transport"); + temp << "Unknown Transport"; break; } } else { - snprintf((char*)myStr.c_str(), BASIC, "Not Reported"); + temp << "Not Reported"; } - json_push_back(identifyInfo, json_new_a("Transport Supported", (char*)myStr.c_str())); + json_push_back(identifyInfo, json_new_a("Transport Supported", temp.str().c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", m_sDriveInfo.sTrans.transportMinorVersion); - json_push_back(identifyInfo, json_new_a("Transport Minor Version", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_sDriveInfo.sTrans.transportMinorVersion; + json_push_back(identifyInfo, json_new_a("Transport Minor Version", temp.str().c_str())); // Form Factor + temp.str("");temp.clear(); switch (m_sDriveInfo.formFactor) { case 0: - snprintf((char*)myStr.c_str(), BASIC, "Not Reported"); + temp << "Not Reported"; break; case 1: - snprintf((char*)myStr.c_str(), BASIC, "5.25 inch"); + temp << "5.25 inch"; break; case 2: - snprintf((char*)myStr.c_str(), BASIC, "3.5 inch"); + temp << "3.5 inch"; break; case 3: - snprintf((char*)myStr.c_str(), BASIC, "2.5 inch"); + temp << "2.5 inch"; break; case 4: - snprintf((char*)myStr.c_str(), BASIC, "1.8 inch"); + temp << "1.8 inch"; break; case 5: - snprintf((char*)myStr.c_str(), BASIC, "Less than 1.8 inch"); + temp << "Less than 1.8 inch"; break; default: - snprintf((char*)myStr.c_str(), BASIC, "Reserved"); + temp << "Reserved"; break; } - json_push_back(identifyInfo, json_new_a("Form Factor", (char*)myStr.c_str())); + json_push_back(identifyInfo, json_new_a("Form Factor", temp.str().c_str())); // Drives Capablilities JSONNODE *driveCap = json_new(JSON_NODE); @@ -983,8 +1004,9 @@ eReturnValues CAta_Identify_log::print_Identify_Information(JSONNODE *masterData JSONNODE *secruity = json_new(JSON_NODE); json_set_name(secruity, "Device Security"); - snprintf((char*)myStr.c_str(), BASIC, "0x%04x", m_sDriveInfo.SecurityID); - json_push_back(secruity, json_new_a("Security Status Bit:", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_sDriveInfo.SecurityID; + json_push_back(secruity, json_new_a("Security Status Bit:", temp.str().c_str())); opensea_parser::set_Json_Bool(secruity, "Security Supported", m_sDriveInfo.sSecurityInfo.supported); @@ -1028,7 +1050,7 @@ CAta_Identify_Log_00::CAta_Identify_Log_00(uint8_t *Buffer) pData = Buffer; if (pData != NULL) { - m_pLog0 = (sLogPage00 *)pData; + m_pLog0 = reinterpret_cast(pData); m_status = SUCCESS; } else @@ -1100,17 +1122,15 @@ bool CAta_Identify_Log_00::is_Page_Supported(uint8_t pageNumber) //! \return string the interface type // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_00::get_Log_Page00(uint8_t *pData, JSONNODE *masterData) +eReturnValues CAta_Identify_Log_00::get_Log_Page00(JSONNODE *masterData) { #define LOG_PAGE_00 0x0000 uint16_t pageNumber = 0; uint16_t revision = 0; eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - myStr.resize(BASIC); - pageNumber = (uint16_t)M_Word1(m_pLog0->header); - revision = (uint16_t)(M_Word0(m_pLog0->header)); + pageNumber = M_Word1(m_pLog0->header); + revision = M_Word0(m_pLog0->header); if (pageNumber == LOG_PAGE_00) { JSONNODE *pageInfo = json_new(JSON_NODE); @@ -1119,21 +1139,23 @@ eReturnValues CAta_Identify_Log_00::get_Log_Page00(uint8_t *pData, JSONNODE *mas printf("Log Page 00h \n"); printf("\tHeader = 0x%016" PRIx64" \n", m_pLog0->header); #endif - - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog0->header); - json_push_back(pageInfo, json_new_a("Page Header", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", pageNumber); - json_push_back(pageInfo, json_new_a("Page Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", revision); - json_push_back(pageInfo, json_new_a("Revision Number", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog0->header; + json_push_back(pageInfo, json_new_a("Page Header", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << pageNumber; + json_push_back(pageInfo, json_new_a("Page Number", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << revision; + json_push_back(pageInfo, json_new_a("Revision Number", temp.str().c_str())); // get the pages supported - for (uint8_t pageNumber = 0; pageNumber <= MAX_NUMBER_OF_ENTRIES; pageNumber++) + for (uint8_t pageNumber_1 = 0; pageNumber_1 <= MAX_NUMBER_OF_ENTRIES; pageNumber_1++) { - snprintf((char*)myStr.c_str(), BASIC, "Page Number 0x%02" PRIx8"", pageNumber); - opensea_parser::set_Json_Bool(pageInfo, (char*)myStr.c_str(), is_Page_Supported(pageNumber)); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(pageNumber_1);//cast is to make sure it doesn't try interpretting a uint8 as a char instead of a decimal - TJE + opensea_parser::set_Json_Bool(pageInfo, temp.str().c_str(), is_Page_Supported(pageNumber_1)); } - json_push_back(masterData, pageInfo); retStatus = SUCCESS; } @@ -1206,62 +1228,62 @@ CAta_Identify_Log_02::~CAta_Identify_Log_02() //--------------------------------------------------------------------------- bool CAta_Identify_Log_02::get_Device_Capacity(JSONNODE *capData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Device Capacity \n"); printf("\tDevice Capacity = 0x%016" PRIx64" \n", pCapacity->deviceCapacity); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pCapacity->deviceCapacity); - json_push_back(capData, json_new_a("Device Capacity Header", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase <deviceCapacity; + json_push_back(capData, json_new_a("Device Capacity Header", temp.str().c_str())); if (check_For_Active_Status(&pCapacity->deviceCapacity)) { uint64_t myUint48 = pCapacity->deviceCapacity & MAX_48_BIT_LBA; - double capacity = (double)myUint48; + double capacity = static_cast(myUint48); uint8_t unitCounter = 0; while ((capacity / 1024.0) >= 1 && (unitCounter + 1) < 8) { capacity = capacity / 1024.00; unitCounter += 1; } + temp.str("");temp.clear(); switch (unitCounter) { case 0: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64" B", myUint48); + temp << std::dec << myUint48 << "B"; break; case 1: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64" KiB", myUint48); + temp << std::dec << myUint48 << "KiB"; break; case 2: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIx64" MiB", myUint48); + temp << std::dec << myUint48 << "MiB"; break; case 3: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64" GiB", myUint48); + temp << std::dec << myUint48 << "GiB"; break; case 4: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64" TiB", myUint48); + temp << std::dec << myUint48 << "TiB"; break; case 5: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64" PiB", myUint48); + temp << std::dec << myUint48 << "PiB"; break; case 6: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64" EiB", myUint48); + temp << std::dec << myUint48 << "EiB"; break; case 7: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64" ZiB", myUint48); + temp << std::dec << myUint48 << "ZiB"; break; case 8: - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64" YiB", myUint48); + temp << std::dec << myUint48 << "YiB"; break; default: - snprintf((char*)myStr.c_str(), BASIC, "unknown size"); + temp << "unknown size"; break; } #if defined _DEBUG printf("\tDevice Capacity = %" PRIu64" \n", myUint48); - printf("\tCapacity = %s \n", (char*)myStr.c_str()); + printf("\tCapacity = %s \n", temp.str().c_str()); #endif - json_push_back(capData, json_new_a("Capacity", (char*)myStr.c_str())); + json_push_back(capData, json_new_a("Capacity", temp.str().c_str())); } else @@ -1273,14 +1295,13 @@ bool CAta_Identify_Log_02::get_Device_Capacity(JSONNODE *capData) bool CAta_Identify_Log_02::get_Sector_Size(JSONNODE *sectorData) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Physical / Logical sector size \n"); printf("\tSector Size = 0x%016" PRIx64" \n", pCapacity->sectorSize); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pCapacity->sectorSize); - json_push_back(sectorData, json_new_a("Pysical and Logical Sector Size", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pCapacity->sectorSize; + json_push_back(sectorData, json_new_a("Pysical and Logical Sector Size", temp.str().c_str())); if (check_For_Active_Status(&pCapacity->deviceCapacity)) { if (pCapacity->sectorSize & BIT62) @@ -1313,8 +1334,9 @@ bool CAta_Identify_Log_02::get_Sector_Size(JSONNODE *sectorData) opensea_parser::set_Json_Bool(sectorData, "Long Physical Sector Alignment Error reporting is enabled", false); } uint16_t sectorOffset = M_Word0(pCapacity->sectorSize); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", sectorOffset); - json_push_back(sectorData, json_new_a("Logical Sector Offset", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << sectorOffset; + json_push_back(sectorData, json_new_a("Logical Sector Offset", temp.str().c_str())); } return true; @@ -1333,18 +1355,15 @@ bool CAta_Identify_Log_02::get_Sector_Size(JSONNODE *sectorData) //! \return string the interface type // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_02::get_Log_Page02(uint8_t *pData, JSONNODE *masterData) +eReturnValues CAta_Identify_Log_02::get_Log_Page02(uint8_t *lp2pData, JSONNODE *masterData) { #define LOG_PAGE_02 0x0002 eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - //myStr.resize(BASIC); sLogPage02 logPage02; pCapacity = &logPage02; - memset(pCapacity, 0, sizeof(sLogPage02)); - pCapacity = (sLogPage02 *)&pData[0]; - uint16_t pageNumber = (uint16_t)(M_Word1(pCapacity->header)); - uint16_t revision = (uint16_t)(M_Word0(pCapacity->header)); + pCapacity = reinterpret_cast(&lp2pData[0]); + uint16_t pageNumber = M_Word1(pCapacity->header); + uint16_t revision = M_Word0(pCapacity->header); if (pageNumber == LOG_PAGE_02) { JSONNODE *pageInfo = json_new(JSON_NODE); @@ -1353,12 +1372,15 @@ eReturnValues CAta_Identify_Log_02::get_Log_Page02(uint8_t *pData, JSONNODE *mas printf("Log Page 02h \n"); printf("\tHeader = 0x%016" PRIx64" \n", pCapacity->header); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pCapacity->header); - json_push_back(pageInfo, json_new_a("Page Header", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", pageNumber); - json_push_back(pageInfo, json_new_a("Page Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", revision); - json_push_back(pageInfo, json_new_a("Revision Number", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pCapacity->header; + json_push_back(pageInfo, json_new_a("Page Header", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << pageNumber; + json_push_back(pageInfo, json_new_a("Page Number", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << revision; + json_push_back(pageInfo, json_new_a("Revision Number", temp.str().c_str())); get_Device_Capacity(pageInfo); get_Sector_Size(pageInfo); @@ -1663,14 +1685,13 @@ bool CAta_Identify_Log_03::set_DownLoad_MicroCode(uint64_t *value) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Supported_Capabilities(JSONNODE *currentData) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Current Settings \n"); printf("\tCurrent Settings = 0x%016" PRIx64" \n", m_pCap->supportedCapabilities); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->supportedCapabilities); - json_push_back(currentData, json_new_a("Supported Capabilities", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->supportedCapabilities; + json_push_back(currentData, json_new_a("Supported Capabilities", temp.str().c_str())); if (set_Supported_Capabilities(&m_pCap->supportedCapabilities)) { JSONNODE *currentSettings = json_new(JSON_NODE); @@ -1737,14 +1758,13 @@ bool CAta_Identify_Log_03::get_Supported_Capabilities(JSONNODE *currentData) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_DownLoad_MicroCode(JSONNODE *DM) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Download Microcode \n"); printf("\tDownload Microcode = 0x%016" PRIx64" \n", m_pCap->download); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->download); - json_push_back(DM, json_new_a("Download Microcode ", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->download; + json_push_back(DM, json_new_a("Download Microcode ", temp.str().c_str())); if (set_DownLoad_MicroCode(&m_pCap->download)) { JSONNODE *download = json_new(JSON_NODE); @@ -1752,10 +1772,12 @@ bool CAta_Identify_Log_03::get_DownLoad_MicroCode(JSONNODE *DM) opensea_parser::set_Json_Bool(download, "DM Offsets Deferred Supported", m_sDownloadMicrocode.dmDefferedSupported); opensea_parser::set_Json_Bool(download, "DM Immediate Supported", m_sDownloadMicrocode.dmImmedaiateSupported); opensea_parser::set_Json_Bool(download, "DM Offsets Immediate Supported", m_sDownloadMicrocode.dmOffsetsImmediateSupported); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_sDownloadMicrocode.dmMaxTransferSize); - json_push_back(download, json_new_a("Dm Maximum Transfer Size", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_sDownloadMicrocode.dmMinTranserSize); - json_push_back(download, json_new_a("Dm Minimum Transfer Size", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_sDownloadMicrocode.dmMaxTransferSize; + json_push_back(download, json_new_a("Dm Maximum Transfer Size", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_sDownloadMicrocode.dmMinTranserSize; + json_push_back(download, json_new_a("Dm Minimum Transfer Size", temp.str().c_str())); json_push_back(DM, download); } @@ -1784,17 +1806,16 @@ bool CAta_Identify_Log_03::get_Media_Rotation_Rate(JSONNODE *MRR) #define NOT_REPORTED 0x0000 #define NON_ROTATING_MEDIA 0x0001 #define RESERVED_RATE 0xFFFF - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Media Rotation Rate \n"); printf("\tMedia Rotation Rate = 0x%016" PRIx64" \n", m_pCap->rotationRate); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->rotationRate); - json_push_back(MRR, json_new_a("Media Rotation Rate", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->rotationRate; + json_push_back(MRR, json_new_a("Media Rotation Rate", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->rotationRate)) { - uint16_t rate = (uint16_t)(M_Word0(m_pCap->rotationRate)); + uint16_t rate = M_Word0(m_pCap->rotationRate); if (rate == NOT_REPORTED) { @@ -1810,8 +1831,9 @@ bool CAta_Identify_Log_03::get_Media_Rotation_Rate(JSONNODE *MRR) } else { - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", rate); - json_push_back(MRR, json_new_a("Nominal Media Rotation Rate", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << rate; + json_push_back(MRR, json_new_a("Nominal Media Rotation Rate", temp.str().c_str())); } } else @@ -1836,14 +1858,13 @@ bool CAta_Identify_Log_03::get_Media_Rotation_Rate(JSONNODE *MRR) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Form_Factor(JSONNODE *ff) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Form Factor \n"); printf("\tForm Factor = 0x%016" PRIx64" \n", m_pCap->formFactor); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->formFactor); - json_push_back(ff, json_new_a("Form Factor", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->formFactor; + json_push_back(ff, json_new_a("Form Factor", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->formFactor)) { @@ -1874,8 +1895,9 @@ bool CAta_Identify_Log_03::get_Form_Factor(JSONNODE *ff) } else { - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", form); - json_push_back(ff, json_new_a("Nominal Form Factor", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(form); + json_push_back(ff, json_new_a("Nominal Form Factor", temp.str().c_str())); } } else @@ -1900,20 +1922,20 @@ bool CAta_Identify_Log_03::get_Form_Factor(JSONNODE *ff) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Write_Read_Verify_Mode3(JSONNODE *mode3) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Write Read Verify Mode 3 \n"); printf("\tWrite Read Verify = 0x%016" PRIx64" \n", m_pCap->mode3); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->mode3); - json_push_back(mode3, json_new_a("Write Read Verify Mode 3", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->mode3; + json_push_back(mode3, json_new_a("Write Read Verify Mode 3", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->mode3)) { JSONNODE *wrv = json_new(JSON_NODE); json_set_name(wrv, "Write Read Verify sector count Mode 3"); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", M_DoubleWord0(m_pCap->mode3)); - json_push_back(wrv, json_new_a("WRV Mode 3 count", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(m_pCap->mode3); + json_push_back(wrv, json_new_a("WRV Mode 3 count", temp.str().c_str())); json_push_back(mode3, wrv); } @@ -1939,20 +1961,20 @@ bool CAta_Identify_Log_03::get_Write_Read_Verify_Mode3(JSONNODE *mode3) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Write_Read_Verify_Mode2(JSONNODE *mode2) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Write Read Verify Mode 2 \n"); printf("\tWrite Read Verify = 0x%016" PRIx64" \n", m_pCap->mode2); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->mode2); - json_push_back(mode2, json_new_a("Write Read Verify Mode 2", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->mode2; + json_push_back(mode2, json_new_a("Write Read Verify Mode 2", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->mode2)) { JSONNODE *wrv = json_new(JSON_NODE); json_set_name(wrv, "Write Read Verify sector count Mode 2"); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", M_DoubleWord0(m_pCap->mode2)); - json_push_back(wrv, json_new_a("WRV Mode 2 count", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(m_pCap->mode2); + json_push_back(wrv, json_new_a("WRV Mode 2 count", temp.str().c_str())); json_push_back(mode2, wrv); } @@ -1978,8 +2000,6 @@ bool CAta_Identify_Log_03::get_Write_Read_Verify_Mode2(JSONNODE *mode2) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::world_Wide_Name(JSONNODE *WWN) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("World Wide Name \n"); printf("\tWorld Wide Name = 0x%04" PRIx16" \n", m_pCap->wwn); @@ -1987,14 +2007,15 @@ bool CAta_Identify_Log_03::world_Wide_Name(JSONNODE *WWN) #endif if (check_For_Active_Status(&m_pCap->wwnStatus)) { - uint64_t wwnReal = 0; - wwnReal = (((uint64_t)m_pCap->wwn) << 48) + ((uint64_t)m_pCap->wwn1 << 32) + ((uint64_t)m_pCap->wwn2 << 16) + (uint64_t)m_pCap->wwn3; - snprintf((char*)myStr.c_str(), WORLD_WIDE_NAME_LEN, "%" PRIX64"", wwnReal); - ltrim(myStr); - rtrim(myStr); + uint64_t wwnReal = M_WordsTo8ByteValue(m_pCap->wwn, m_pCap->wwn1, m_pCap->wwn2, m_pCap->wwn3); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << wwnReal; + std::string wwnStr = temp.str(); + ltrim(wwnStr); + rtrim(wwnStr); // world wide name - json_push_back(WWN, json_new_a("World Wide Name", (char*)myStr.c_str())); + json_push_back(WWN, json_new_a("World Wide Name", wwnStr.c_str())); } else { @@ -2018,14 +2039,13 @@ bool CAta_Identify_Log_03::world_Wide_Name(JSONNODE *WWN) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Data_Set_Managment(JSONNODE *setManagement) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Data Set Management \n"); printf("\tData Set Management = 0x%016" PRIx64" \n", m_pCap->dataSet); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->dataSet); - json_push_back(setManagement, json_new_a("Data Set Management Value", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->dataSet; + json_push_back(setManagement, json_new_a("Data Set Management Value", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->dataSet)) { if (m_pCap->dataSet & BIT0) @@ -2059,31 +2079,36 @@ bool CAta_Identify_Log_03::get_Data_Set_Managment(JSONNODE *setManagement) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Utilization_Unit_Time(JSONNODE *unitTime) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Utilization Per Unit Time \n"); printf("\tUtilization Per Unit Time = 0x%016" PRIx64" \n", m_pCap->utilization); printf("\tUtilization Per Unit Time2 = 0x%016" PRIx64" \n", m_pCap->utilTime2); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->utilTime2); - json_push_back(unitTime, json_new_a("Utilization Per Unit Time", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->utilTime2); - json_push_back(unitTime, json_new_a("Utilization Per Unit Time2", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->utilization; + json_push_back(unitTime, json_new_a("Utilization Per Unit Time", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->utilTime2; + json_push_back(unitTime, json_new_a("Utilization Per Unit Time2", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->utilization)) { JSONNODE *data = json_new(JSON_NODE); json_set_name(data, "Utilization Per Unit Time"); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", M_Byte2(m_pCap->utilization)); - json_push_back(data, json_new_a("Utiliztion Type field", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", M_Byte1(m_pCap->utilization)); - json_push_back(data, json_new_a("Utiliztion Unites Field", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", M_Byte0(m_pCap->utilization)); - json_push_back(data, json_new_a("Utiliztion Interval Field", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", M_DoubleWord1(m_pCap->utilTime2)); - json_push_back(data, json_new_a("Utiliztion B Field", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", M_DoubleWord0(m_pCap->utilTime2)); - json_push_back(data, json_new_a("Utiliztion A Field", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(M_Byte2(m_pCap->utilization)); + json_push_back(data, json_new_a("Utiliztion Type field", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(M_Byte1(m_pCap->utilization)); + json_push_back(data, json_new_a("Utiliztion Unites Field", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(M_Byte0(m_pCap->utilization)); + json_push_back(data, json_new_a("Utiliztion Interval Field", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord1(m_pCap->utilTime2); + json_push_back(data, json_new_a("Utiliztion B Field", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(m_pCap->utilTime2); + json_push_back(data, json_new_a("Utiliztion A Field", temp.str().c_str())); json_push_back(unitTime, data); } @@ -2109,15 +2134,13 @@ bool CAta_Identify_Log_03::get_Utilization_Unit_Time(JSONNODE *unitTime) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Utilization_Usage_Rate_Support(JSONNODE *rate) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Utilization Usage Rate Support \n"); printf("\tUtilization Usage Rate Support = 0x%016" PRIx64" \n", m_pCap->utilRate); #endif - - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->utilRate); - json_push_back(rate, json_new_a("Utilization Usage Rate Support", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->utilRate; + json_push_back(rate, json_new_a("Utilization Usage Rate Support", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->utilRate)) { @@ -2179,15 +2202,13 @@ bool CAta_Identify_Log_03::get_Utilization_Usage_Rate_Support(JSONNODE *rate) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Zoned_Capabilities(JSONNODE *zoned) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Zoned Capabilities \n"); printf("\tZoned Capabilities = 0x%016" PRIx64" \n", m_pCap->zoned); #endif - - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->zoned); - json_push_back(zoned, json_new_a("Zoned Capabilities", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->zoned; + json_push_back(zoned, json_new_a("Zoned Capabilities", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->zoned)) { @@ -2234,15 +2255,13 @@ bool CAta_Identify_Log_03::get_Zoned_Capabilities(JSONNODE *zoned) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Supported_ZAC_Capabilities(JSONNODE *zac) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Supported ZAC Capabilitiest \n"); printf("\tSupported ZAC Capabilities= 0x%016" PRIx64" \n", m_pCap->ZAC); #endif - - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->ZAC); - json_push_back(zac, json_new_a("Supported ZAC Capabilities", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->ZAC; + json_push_back(zac, json_new_a("Supported ZAC Capabilities", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->ZAC)) { @@ -2312,14 +2331,13 @@ bool CAta_Identify_Log_03::get_Supported_ZAC_Capabilities(JSONNODE *zac) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Background_Operations_Capabilities(JSONNODE *bgOperation) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Advanced Background Operations Capabilities \n"); printf("\tAdvanced Background Operations Capabilities = 0x%016" PRIx64" \n", m_pCap->backgroundOpsCapabilities); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->backgroundOpsCapabilities); - json_push_back(bgOperation, json_new_a("Advanced Background Operations Capabilities", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->backgroundOpsCapabilities; + json_push_back(bgOperation, json_new_a("Advanced Background Operations Capabilities", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->backgroundOpsCapabilities)) { JSONNODE *data = json_new(JSON_NODE); @@ -2340,10 +2358,13 @@ bool CAta_Identify_Log_03::get_Background_Operations_Capabilities(JSONNODE *bgOp { opensea_parser::set_Json_Bool(data, "ABO IR Mode Supported", false); } - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", ((uint32_t)M_Word2(m_pCap->backgroundOpsCapabilities) << 16) + (uint32_t)M_Word1(m_pCap->backgroundOpsCapabilities)); - json_push_back(data, json_new_a("ABO Minimum Fraction field", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", M_Word0(m_pCap->backgroundOpsCapabilities)); - json_push_back(data, json_new_a("ABO Minimum Supported Timelimit field", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_WordsTo4ByteValue(M_Word2(m_pCap->backgroundOpsCapabilities), M_Word1(m_pCap->backgroundOpsCapabilities)); + json_push_back(data, json_new_a("ABO Minimum Fraction field", temp.str().c_str())); + + temp.str("");temp.clear(); + temp << std::dec << M_Word0(m_pCap->backgroundOpsCapabilities); + json_push_back(data, json_new_a("ABO Minimum Supported Timelimit field", temp.str().c_str())); json_push_back(bgOperation, data); } else @@ -2368,23 +2389,23 @@ bool CAta_Identify_Log_03::get_Background_Operations_Capabilities(JSONNODE *bgOp //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Background_Operations_Recommendations(JSONNODE *recommendations) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Advanced Background Operations Recommendations \n"); printf("\tAdvanced Background Operations Recommendations = 0x%016" PRIx64" \n", m_pCap->backgroundOpsRecommendations); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->backgroundOpsRecommendations); - json_push_back(recommendations, json_new_a("Advanced Background Operations Recommendations", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->backgroundOpsRecommendations; + json_push_back(recommendations, json_new_a("Advanced Background Operations Recommendations", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->backgroundOpsRecommendations)) { JSONNODE *data = json_new(JSON_NODE); json_set_name(data, "Advanced Background Operations Recommendations"); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", M_Word1(m_pCap->backgroundOpsRecommendations)); - json_push_back(data, json_new_a("Device Maintenance Polling Time field", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", M_Word0(m_pCap->backgroundOpsRecommendations)); - json_push_back(data, json_new_a("ABO Recommended Abo Start Interval field", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_Word1(m_pCap->backgroundOpsRecommendations); + json_push_back(data, json_new_a("Device Maintenance Polling Time field", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_Word0(m_pCap->backgroundOpsRecommendations); + json_push_back(data, json_new_a("ABO Recommended Abo Start Interval field", temp.str().c_str())); json_push_back(recommendations, data); } else @@ -2409,21 +2430,20 @@ bool CAta_Identify_Log_03::get_Background_Operations_Recommendations(JSONNODE *r //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Queue_Depth(JSONNODE *qd) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Queue Depth \n"); printf("\tQueue Depth = 0x%016" PRIx64" \n", m_pCap->queueDepth); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->queueDepth); - json_push_back(qd, json_new_a("Queue Depth", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->queueDepth; + json_push_back(qd, json_new_a("Queue Depth", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->queueDepth)) { JSONNODE *data = json_new(JSON_NODE); json_set_name(data, "Queue Depth"); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", M_Byte0(m_pCap->queueDepth)); - json_push_back(data, json_new_a("Queue Depth", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_Byte0(m_pCap->queueDepth); + json_push_back(data, json_new_a("Queue Depth", temp.str().c_str())); json_push_back(qd, data); } @@ -2518,14 +2538,13 @@ bool CAta_Identify_Log_03::set_SCT_Capabilities(uint64_t *value) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_SCT_Capabilities(JSONNODE *sct) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Supported SCT Capabilities \n"); printf("\tSupported SCT Capabilities = 0x%016" PRIx64" \n", m_pCap->sctCapabilities); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->sctCapabilities); - json_push_back(sct, json_new_a("Supported SCT Capabilities", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->sctCapabilities; + json_push_back(sct, json_new_a("Supported SCT Capabilities", temp.str().c_str())); if (set_Supported_Capabilities(&m_pCap->sctCapabilities)) { JSONNODE *data = json_new(JSON_NODE); @@ -2565,14 +2584,13 @@ bool CAta_Identify_Log_03::get_SCT_Capabilities(JSONNODE *sct) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Depop_Capabilities(JSONNODE *depop) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Depopulation Capabilities \n"); printf("\tDepopulation Capabilities = 0x%016" PRIx64" \n", m_pCap->depopCapabilities); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->depopCapabilities); - json_push_back(depop, json_new_a("Depopulation Capabilities", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->depopCapabilities; + json_push_back(depop, json_new_a("Depopulation Capabilities", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->depopCapabilities)) { JSONNODE *data = json_new(JSON_NODE); @@ -2617,20 +2635,20 @@ bool CAta_Identify_Log_03::get_Depop_Capabilities(JSONNODE *depop) //--------------------------------------------------------------------------- bool CAta_Identify_Log_03::get_Depopulation_Execution_Time(JSONNODE *depop) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Depopulation Execution Times \n"); printf("\tDepopulation Execution Time = 0x%016" PRIx64" \n", m_pCap->depopExTime); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->depopExTime); - json_push_back(depop, json_new_a("Depopulation Execution Time", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->depopExTime; + json_push_back(depop, json_new_a("Depopulation Execution Time", temp.str().c_str())); if (check_For_Active_Status(&m_pCap->depopExTime)) { JSONNODE *data = json_new(JSON_NODE); json_set_name(data, "Depopulation Execution Time"); - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", (uint64_t)(m_pCap->depopExTime & 0x00FFFFFFFFFFFFFFULL)); - json_push_back(depop, json_new_a("Depopulation Time", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << (m_pCap->depopExTime & UINT64_C(0x00FFFFFFFFFFFFFF)); + json_push_back(depop, json_new_a("Depopulation Time", temp.str().c_str())); json_push_back(depop, data); } else @@ -2653,18 +2671,15 @@ bool CAta_Identify_Log_03::get_Depopulation_Execution_Time(JSONNODE *depop) //! \return string the interface type // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_03::get_Log_Page03(uint8_t *pData, JSONNODE *masterData) +eReturnValues CAta_Identify_Log_03::get_Log_Page03(uint8_t *lp3pData, JSONNODE *masterData) { #define LOG_PAGE_03 0x0003 eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - //myStr.resize(BASIC); sLogPage03 logPage03; m_pCap = &logPage03; - memset(m_pCap, 0, sizeof(logPage03)); - m_pCap = (sLogPage03 *)&pData[0]; - uint16_t pageNumber = (uint16_t)(M_Word1(m_pCap->header)); - uint16_t revision = (uint16_t)(M_Word0(m_pCap->header)); + m_pCap = reinterpret_cast(&lp3pData[0]); + uint16_t pageNumber = M_Word1(m_pCap->header); + uint16_t revision = M_Word0(m_pCap->header); if (pageNumber == LOG_PAGE_03) { JSONNODE *pageInfo = json_new(JSON_NODE); @@ -2673,14 +2688,16 @@ eReturnValues CAta_Identify_Log_03::get_Log_Page03(uint8_t *pData, JSONNODE *mas printf("Log Page 03h \n"); printf("\tHeader = 0x%016" PRIx64" \n", m_pCap->header); #endif - - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pCap->header); - json_push_back(pageInfo, json_new_a("Page Header", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", pageNumber); - json_push_back(pageInfo, json_new_a("Page Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", revision); - json_push_back(pageInfo, json_new_a("Revision Number", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pCap->header; + json_push_back(pageInfo, json_new_a("Page Header", temp.str().c_str())); + + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << pageNumber; + json_push_back(pageInfo, json_new_a("Page Number", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << revision; + json_push_back(pageInfo, json_new_a("Revision Number", temp.str().c_str())); get_Supported_Capabilities(pageInfo); get_DownLoad_MicroCode(pageInfo); get_Media_Rotation_Rate(pageInfo); @@ -2853,15 +2870,14 @@ bool CAta_Identify_Log_04::set_Current_Settings(uint64_t *value) //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_Current_Settings(JSONNODE *currentData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Current Settings \n"); printf("\tCurrent Settings = 0x%016" PRId64" \n", pLog->currentSettings); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->currentSettings); - json_push_back(currentData, json_new_a("Current Settings", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->currentSettings; + json_push_back(currentData, json_new_a("Current Settings", temp.str().c_str())); if (set_Current_Settings(&pLog->currentSettings)) { JSONNODE *currentSettings = json_new(JSON_NODE); @@ -2931,43 +2947,43 @@ bool CAta_Identify_Log_04::set_Feature_Settings(uint64_t *value) //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_Feature_Settings(JSONNODE *featureData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Feature Settings \n"); printf("\tFeature Settings = 0x%016" PRIx64" \n", pLog->featureSettings); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->featureSettings); - json_push_back(featureData, json_new_a("Feature Settings", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->featureSettings; + json_push_back(featureData, json_new_a("Feature Settings", temp.str().c_str())); if (set_Feature_Settings(&pLog->featureSettings)) { JSONNODE *featSettings = json_new(JSON_NODE); json_set_name(featSettings, "Feature Settings breakdown"); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_FS.wrvMode); - json_push_back(featSettings, json_new_a("Write Read Verify", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_FS.apmLevel); - json_push_back(featSettings, json_new_a("APM Level", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_FS.wrvMode; + json_push_back(featSettings, json_new_a("Write Read Verify", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_FS.apmLevel; + json_push_back(featSettings, json_new_a("APM Level", temp.str().c_str())); + + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_FS.powerScource; if (m_FS.powerScource & BIT1) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_FS.powerScource); - json_push_back(featSettings, json_new_a("Power Source Battery", (char*)myStr.c_str())); + json_push_back(featSettings, json_new_a("Power Source Battery", temp.str().c_str())); } else if (m_FS.powerScource & BIT2) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_FS.powerScource); - json_push_back(featSettings, json_new_a("Power Source NOT Battery", (char*)myStr.c_str())); + json_push_back(featSettings, json_new_a("Power Source NOT Battery", temp.str().c_str())); } else if (m_FS.powerScource & BIT1 && m_FS.powerScource & BIT2) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_FS.powerScource); - json_push_back(featSettings, json_new_a("Power Source Reserved", (char*)myStr.c_str())); + json_push_back(featSettings, json_new_a("Power Source Reserved", temp.str().c_str())); } else { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_FS.powerScource); - json_push_back(featSettings, json_new_a("Power Source Unknown", (char*)myStr.c_str())); + json_push_back(featSettings, json_new_a("Power Source Unknown", temp.str().c_str())); } json_push_back(featureData, featSettings); @@ -2994,18 +3010,18 @@ bool CAta_Identify_Log_04::get_Feature_Settings(JSONNODE *featureData) //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_DMS_Times(JSONNODE *dmaData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("DMA Host Interface Sector Times \n"); printf("\tDMA Host Interface Sector Times = 0x%016" PRIx64" \n", pLog->DMAHostInterfaceSectorTimes); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->DMAHostInterfaceSectorTimes); - json_push_back(dmaData, json_new_a("DMA Host Interface Sector Times", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->DMAHostInterfaceSectorTimes; + json_push_back(dmaData, json_new_a("DMA Host Interface Sector Times", temp.str().c_str())); if (set_Feature_Settings(&pLog->DMAHostInterfaceSectorTimes)) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", (uint16_t)(M_Word0(pLog->DMAHostInterfaceSectorTimes))); - json_push_back(dmaData, json_new_a("DMA Sector Time ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word0(pLog->DMAHostInterfaceSectorTimes); + json_push_back(dmaData, json_new_a("DMA Sector Time ", temp.str().c_str())); } else { @@ -3029,18 +3045,18 @@ bool CAta_Identify_Log_04::get_DMS_Times(JSONNODE *dmaData) //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_PIO_Times(JSONNODE *pioData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("PIO Host Interface Sector Times \n"); printf("\tPIO Host Interface Sector Times = 0x%016" PRIx64" \n", pLog->PioHostInterfaceSectorTImes); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->PioHostInterfaceSectorTImes); - json_push_back(pioData, json_new_a("PIO Host Interface Sector Times", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->PioHostInterfaceSectorTImes; + json_push_back(pioData, json_new_a("PIO Host Interface Sector Times", temp.str().c_str())); if (set_Feature_Settings(&pLog->PioHostInterfaceSectorTImes)) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", (uint16_t)(M_Word0(pLog->PioHostInterfaceSectorTImes))); - json_push_back(pioData, json_new_a("PIO Sector Time ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word0(pLog->PioHostInterfaceSectorTImes); + json_push_back(pioData, json_new_a("PIO Sector Time ", temp.str().c_str())); } else { @@ -3064,18 +3080,18 @@ bool CAta_Identify_Log_04::get_PIO_Times(JSONNODE *pioData) //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_Streaming_Min_Request_Times(JSONNODE *streamMinData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Streaming Minimum request Times \n"); printf("\tStreaming Minimum request Times = 0x%016" PRIx64" \n", pLog->streamingMinRequestSize); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->streamingMinRequestSize); - json_push_back(streamMinData, json_new_a("Streaming Minimum request Times", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->streamingMinRequestSize; + json_push_back(streamMinData, json_new_a("Streaming Minimum request Times", temp.str().c_str())); if (set_Feature_Settings(&pLog->streamingMinRequestSize)) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", (uint16_t)(M_Word0(pLog->streamingMinRequestSize))); - json_push_back(streamMinData, json_new_a("Steaming Min Request Size", (char*)myStr.c_str())); + temp.str(""); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word0(pLog->streamingMinRequestSize); + json_push_back(streamMinData, json_new_a("Steaming Min Request Size", temp.str().c_str())); } else { @@ -3099,18 +3115,18 @@ bool CAta_Identify_Log_04::get_Streaming_Min_Request_Times(JSONNODE *streamMinDa //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_Streaming_Access_Latency(JSONNODE *accessData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Streaming Access Latency \n"); printf("\tStreaming Access Latency = 0x%016" PRIx64" \n", pLog->streamingAccessLatency); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->streamingAccessLatency); - json_push_back(accessData, json_new_a("Streaming Access Latency", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->streamingAccessLatency; + json_push_back(accessData, json_new_a("Streaming Access Latency", temp.str().c_str())); if (set_Feature_Settings(&pLog->streamingAccessLatency)) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", (uint16_t)(M_Word0(pLog->streamingAccessLatency))); - json_push_back(accessData, json_new_a("Steaming Access Latency data", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word0(pLog->streamingAccessLatency); + json_push_back(accessData, json_new_a("Steaming Access Latency data", temp.str().c_str())); } else { @@ -3134,20 +3150,20 @@ bool CAta_Identify_Log_04::get_Streaming_Access_Latency(JSONNODE *accessData) //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_Streaming_Performance_Granularity(JSONNODE *performanceData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Streaming Performance Granularity \n"); printf("\tStreaming Performance Granularity = 0x%016" PRIx64" \n", pLog->streamingPerformanceGranularity); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->streamingPerformanceGranularity); - json_push_back(performanceData, json_new_a("Streaming Performance Granularity", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->streamingPerformanceGranularity; + json_push_back(performanceData, json_new_a("Streaming Performance Granularity", temp.str().c_str())); if (set_Feature_Settings(&pLog->streamingPerformanceGranularity)) { - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", (uint32_t)(M_DoubleWord0(pLog->streamingPerformanceGranularity))); - json_push_back(performanceData, json_new_a("Steaming Granularity", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << M_DoubleWord0(pLog->streamingPerformanceGranularity); + json_push_back(performanceData, json_new_a("Steaming Granularity", temp.str().c_str())); } else { @@ -3172,18 +3188,19 @@ bool CAta_Identify_Log_04::get_Streaming_Performance_Granularity(JSONNODE *perfo //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_Free_Fall_Control(JSONNODE *freeFallData) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Free Fall control sensitivity \n"); printf("\tFree Fall control sensitivity = 0x%016" PRIx64" \n", pLog->freeFallControlSensitivity); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->freeFallControlSensitivity); - json_push_back(freeFallData, json_new_a("Free Fall control sensitivity ", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->freeFallControlSensitivity; + json_push_back(freeFallData, json_new_a("Free Fall control sensitivity ", temp.str().c_str())); if (set_Feature_Settings(&pLog->freeFallControlSensitivity)) { - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", (uint32_t)(M_Byte0(pLog->freeFallControlSensitivity))); - json_push_back(freeFallData, json_new_a("Free Fall control sensitivity settings", (char*)myStr.c_str())); + temp.str(""); + temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(M_Byte0(pLog->freeFallControlSensitivity)); + json_push_back(freeFallData, json_new_a("Free Fall control sensitivity settings", temp.str().c_str())); } else { @@ -3207,22 +3224,25 @@ bool CAta_Identify_Log_04::get_Free_Fall_Control(JSONNODE *freeFallData) //--------------------------------------------------------------------------- bool CAta_Identify_Log_04::get_Device_Maintenance_Schedule(JSONNODE *maintenaceData) { - std::string myStr = ""; - //myStr.resize(BASIC); + std::string myStr; #if defined _DEBUG printf("Device Maintenance Schedule \n"); printf("\tDevice Maintenance Schedule = 0x%016" PRIx64" \n", pLog->deviceMaintenaceSchedule); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->deviceMaintenaceSchedule); - json_push_back(maintenaceData, json_new_a("Device Maintenace Schedule", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->deviceMaintenaceSchedule; + json_push_back(maintenaceData, json_new_a("Device Maintenace Schedule", temp.str().c_str())); if (set_Feature_Settings(&pLog->deviceMaintenaceSchedule)) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", (uint16_t)(M_Word0(pLog->deviceMaintenaceSchedule))); - json_push_back(maintenaceData, json_new_a("Minimum Inactive Time", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", (uint16_t)(M_Word1(pLog->deviceMaintenaceSchedule))); - json_push_back(maintenaceData, json_new_a("Time to Preformance Degradation", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", (uint16_t)(M_Word2(pLog->deviceMaintenaceSchedule))); - json_push_back(maintenaceData, json_new_a("Time Scheduled for Device Maintenance", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word0(pLog->deviceMaintenaceSchedule); + json_push_back(maintenaceData, json_new_a("Minimum Inactive Time", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word1(pLog->deviceMaintenaceSchedule); + json_push_back(maintenaceData, json_new_a("Time to Preformance Degradation", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word2(pLog->deviceMaintenaceSchedule); + json_push_back(maintenaceData, json_new_a("Time Scheduled for Device Maintenance", temp.str().c_str())); JSONNODE *deviceMaintenace = json_new(JSON_NODE); json_set_name(deviceMaintenace, "Device Maintenace Meaning"); @@ -3275,7 +3295,7 @@ bool CAta_Identify_Log_04::get_Device_Maintenance_Schedule(JSONNODE *maintenaceD { myStr = "unknown"; } - json_push_back(deviceMaintenace, json_new_a("MC Level", (char*)myStr.c_str())); + json_push_back(deviceMaintenace, json_new_a("MC Level", myStr.c_str())); json_push_back(maintenaceData, deviceMaintenace); } @@ -3299,18 +3319,16 @@ bool CAta_Identify_Log_04::get_Device_Maintenance_Schedule(JSONNODE *maintenaceD //! \return string the interface type // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_04::get_Log_Page04(uint8_t *pData, JSONNODE *masterData) +eReturnValues CAta_Identify_Log_04::get_Log_Page04(uint8_t *lp4pData, JSONNODE *masterData) { #define LOG_PAGE_04 0x0004 eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - //myStr.resize(BASIC); sLogPage04 logPage; pLog = &logPage; memset(pLog, 0, sizeof(sLogPage04)); - pLog = (sLogPage04 *)&pData[0]; - uint16_t pageNumber = (uint16_t)(M_Word1(pLog->header)); - uint16_t revision = (uint16_t)(M_Word0(pLog->header)); + pLog = reinterpret_cast(&lp4pData[0]); + uint16_t pageNumber = M_Word1(pLog->header); + uint16_t revision = M_Word0(pLog->header); if (pageNumber == LOG_PAGE_04) { JSONNODE *pageInfo = json_new(JSON_NODE); @@ -3319,12 +3337,15 @@ eReturnValues CAta_Identify_Log_04::get_Log_Page04(uint8_t *pData, JSONNODE *mas printf("Log Page 04h \n"); printf("\tHeader = 0x%016" PRIx64" \n", pLog->header); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", pLog->header); - json_push_back(pageInfo, json_new_a("Page Header", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", pageNumber); - json_push_back(pageInfo, json_new_a("Page Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", revision); - json_push_back(pageInfo, json_new_a("Revision Number", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << pLog->header; + json_push_back(pageInfo, json_new_a("Page Header", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << pageNumber; + json_push_back(pageInfo, json_new_a("Page Number", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << revision; + json_push_back(pageInfo, json_new_a("Revision Number", temp.str().c_str())); get_Current_Settings(pageInfo); get_Feature_Settings(pageInfo); @@ -3412,9 +3433,8 @@ bool CAta_Identify_Log_05::create_Serial_Number() { if (m_pLog->serialNumber != NULL) { - m_pPrintable->serialStr.resize(LOG5_SERIAL_NUMBER); - strncpy((char*)m_pPrintable->serialStr.c_str(), (char*)&m_pLog->serialNumber, LOG5_SERIAL_NUMBER); - byte_Swap_String((char*)m_pPrintable->serialStr.c_str()); + m_pPrintable->serialStr.assign(reinterpret_cast(&m_pLog->serialNumber), LOG5_SERIAL_NUMBER); + byte_swap_std_string(m_pPrintable->serialStr); m_pPrintable->serialStr.resize(LOG5_SERIAL_NUMBER); ltrim(m_pPrintable->serialStr); } @@ -3442,9 +3462,8 @@ bool CAta_Identify_Log_05::create_Firmware_Rev() { if (m_pLog->firmwareRev != NULL) { - m_pPrintable->firmwareStr.resize(LOG5_FIRMWARE_REV); - strncpy((char*)m_pPrintable->firmwareStr.c_str(), (char*)&m_pLog->firmwareRev, LOG5_FIRMWARE_REV); - byte_Swap_String((char*)m_pPrintable->firmwareStr.c_str()); + m_pPrintable->firmwareStr.assign(reinterpret_cast(&m_pLog->firmwareRev), LOG5_FIRMWARE_REV); + byte_swap_std_string(m_pPrintable->firmwareStr); m_pPrintable->firmwareStr.resize(LOG5_FIRMWARE_REV); ltrim(m_pPrintable->firmwareStr); rtrim(m_pPrintable->firmwareStr); @@ -3473,9 +3492,8 @@ bool CAta_Identify_Log_05::create_Model_Number() { if (m_pLog->modelNumber != NULL) { - m_pPrintable->modelNumberStr.resize(LOG5_MODEL_NUMBER); - strncpy((char*)m_pPrintable->modelNumberStr.c_str(), (char*)&m_pLog->modelNumber, LOG5_MODEL_NUMBER); - byte_Swap_String((char*)m_pPrintable->modelNumberStr.c_str()); + m_pPrintable->modelNumberStr.assign(reinterpret_cast(&m_pLog->modelNumber), LOG5_MODEL_NUMBER); + byte_swap_std_string(m_pPrintable->modelNumberStr); m_pPrintable->modelNumberStr.resize(LOG5_MODEL_NUMBER); ltrim(m_pPrintable->modelNumberStr); rtrim(m_pPrintable->modelNumberStr); @@ -3503,9 +3521,8 @@ bool CAta_Identify_Log_05::create_Product_string() { if (m_pLog->productInformation != NULL) { - m_pPrintable->productStr.resize(LOG5_PRODUCT_INFO); - strncpy((char*)m_pPrintable->productStr.c_str(), (char*)&m_pLog->productInformation, LOG5_PRODUCT_INFO); - byte_Swap_String((char*)m_pPrintable->productStr.c_str()); + m_pPrintable->productStr.assign(reinterpret_cast(&m_pLog->productInformation), LOG5_PRODUCT_INFO); + byte_swap_std_string(m_pPrintable->productStr); m_pPrintable->productStr.resize(LOG5_PRODUCT_INFO); ltrim(m_pPrintable->productStr); rtrim(m_pPrintable->productStr); @@ -3531,8 +3548,6 @@ bool CAta_Identify_Log_05::create_Product_string() //--------------------------------------------------------------------------- bool CAta_Identify_Log_05::get_printables(JSONNODE *pageInfo) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Device String Page \n"); @@ -3560,19 +3575,19 @@ bool CAta_Identify_Log_05::get_printables(JSONNODE *pageInfo) if (m_pPrintable->serialStr != "") { - json_push_back(deviceInfo, json_new_a("Serial Number", (char*)m_pPrintable->serialStr.c_str())); + json_push_back(deviceInfo, json_new_a("Serial Number", m_pPrintable->serialStr.c_str())); } if (m_pPrintable->firmwareStr != "") { - json_push_back(deviceInfo, json_new_a("Firmware Revision", (char*)m_pPrintable->firmwareStr.c_str())); + json_push_back(deviceInfo, json_new_a("Firmware Revision", m_pPrintable->firmwareStr.c_str())); } if (m_pPrintable->modelNumberStr != "") { - json_push_back(deviceInfo, json_new_a("Model Number", (char*)m_pPrintable->modelNumberStr.c_str())); + json_push_back(deviceInfo, json_new_a("Model Number", m_pPrintable->modelNumberStr.c_str())); } if (m_pPrintable->productStr != "") { - json_push_back(deviceInfo, json_new_a("Product Identifier", (char*)m_pPrintable->productStr.c_str())); + json_push_back(deviceInfo, json_new_a("Product Identifier", m_pPrintable->productStr.c_str())); } json_push_back(pageInfo, deviceInfo); @@ -3593,20 +3608,18 @@ bool CAta_Identify_Log_05::get_printables(JSONNODE *pageInfo) //! \return string the interface type // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_05::get_Log_Page05(uint8_t *pData, JSONNODE *masterData) +eReturnValues CAta_Identify_Log_05::get_Log_Page05(uint8_t *lp5pData, JSONNODE *masterData) { #define LOG_PAGE_05 0x0005 eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - myStr.resize(BASIC); sLogPage05 logPage; m_pLog = &logPage; memset(m_pLog, 0, sizeof(sLogPage05)); - m_pLog = (sLogPage05 *)&pData[0]; + m_pLog = reinterpret_cast(&lp5pData[0]); sPrintablePage05 printLog; m_pPrintable = &printLog; - uint16_t pageNumber = (uint16_t)(M_Word1(m_pLog->header)); - uint16_t revision = (uint16_t)(M_Word0(m_pLog->header)); + uint16_t pageNumber = M_Word1(m_pLog->header); + uint16_t revision = M_Word0(m_pLog->header); if (pageNumber == LOG_PAGE_05) { JSONNODE *pageInfo = json_new(JSON_NODE); @@ -3615,12 +3628,15 @@ eReturnValues CAta_Identify_Log_05::get_Log_Page05(uint8_t *pData, JSONNODE *mas printf("Log Page 05h \n"); printf("\tHeader = 0x%016" PRIx64" \n", m_pLog->header); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->header); - json_push_back(pageInfo, json_new_a("Page Header", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", pageNumber); - json_push_back(pageInfo, json_new_a("Page Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", revision); - json_push_back(pageInfo, json_new_a("Revision Number", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->header; + json_push_back(pageInfo, json_new_a("Page Header", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << pageNumber; + json_push_back(pageInfo, json_new_a("Page Number", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << revision; + json_push_back(pageInfo, json_new_a("Revision Number", temp.str().c_str())); get_printables(pageInfo); @@ -3755,14 +3771,13 @@ bool CAta_Identify_Log_06::set_Security_Settings(uint64_t *value) //--------------------------------------------------------------------------- bool CAta_Identify_Log_06::get_Security_Settings(JSONNODE *si) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Security Settings \n"); printf("\tSecurity Settings = 0x%016" PRIx64" \n", m_pLog->securitySetting); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->securitySetting); - json_push_back(si, json_new_a("Security Settings", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->securitySetting; + json_push_back(si, json_new_a("Security Settings", temp.str().c_str())); if (set_Security_Settings(&m_pLog->securitySetting)) { @@ -3803,19 +3818,19 @@ bool CAta_Identify_Log_06::get_Security_Settings(JSONNODE *si) //--------------------------------------------------------------------------- bool CAta_Identify_Log_06::get_Master_Password_Identifier(JSONNODE *mpIdent) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Master Password Identifier \n"); printf("\tMaster Password Identifier = 0x%016" PRIx64" \n", m_pLog->masterPassword); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->masterPassword); - json_push_back(mpIdent, json_new_a("Master Password Identifier", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->masterPassword; + json_push_back(mpIdent, json_new_a("Master Password Identifier", temp.str().c_str())); if (check_For_Active_Status(&m_pLog->masterPassword)) { - uint16_t master = (uint16_t)(M_Word0(m_pLog->masterPassword)); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx16"", master); - json_push_back(mpIdent, json_new_a("Master Password Identifier field", (char*)myStr.c_str())); + uint16_t master = M_Word0(m_pLog->masterPassword); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(master); + json_push_back(mpIdent, json_new_a("Master Password Identifier field", temp.str().c_str())); if (master & BIT0) { opensea_parser::set_Json_Bool(mpIdent, "Master Password Capability is Maximum", true); @@ -3843,14 +3858,13 @@ bool CAta_Identify_Log_06::get_Master_Password_Identifier(JSONNODE *mpIdent) //--------------------------------------------------------------------------- bool CAta_Identify_Log_06::get_Time_for_Enhanced_Erase(JSONNODE *enhanced) { - std::string myStr = ""; - // myStr.resize(BASIC); #if defined _DEBUG printf("Time for Enhanced Erase \n"); printf("\tTime for Enhanced Erase = 0x%016" PRIx64" \n", m_pLog->timeEnhancedErase); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->timeEnhancedErase); - json_push_back(enhanced, json_new_a("Time for Enhanced Erase", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->timeEnhancedErase; + json_push_back(enhanced, json_new_a("Time for Enhanced Erase", temp.str().c_str())); if (check_For_Active_Status(&m_pLog->timeEnhancedErase)) { if (m_pLog->timeEnhancedErase & BIT15) @@ -3861,8 +3875,9 @@ bool CAta_Identify_Log_06::get_Time_for_Enhanced_Erase(JSONNODE *enhanced) { opensea_parser::set_Json_Bool(enhanced, "Enhanced Security Erased Time format bit", false); } - snprintf((char*)myStr.c_str(), BASIC, "%" PRId16"", ((uint16_t)(M_Word0(m_pLog->timeEnhancedErase)) & 0x0FFF) * 2); - json_push_back(enhanced, json_new_a("Time for Enhanced Erase in Minutes", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << (static_cast(M_Word0(m_pLog->timeEnhancedErase)) & 0x0FFF) * 2; + json_push_back(enhanced, json_new_a("Time for Enhanced Erase in Minutes", temp.str().c_str())); } return true; } @@ -3882,14 +3897,13 @@ bool CAta_Identify_Log_06::get_Time_for_Enhanced_Erase(JSONNODE *enhanced) //--------------------------------------------------------------------------- bool CAta_Identify_Log_06::get_Time_for_Normal_Erase(JSONNODE *normal) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Time for Normal Erase \n"); printf("\tTime for Normal Erase = 0x%016" PRIx64" \n", m_pLog->timeNormalErase); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->timeNormalErase); - json_push_back(normal, json_new_a("Time for Normal Erase", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->timeNormalErase; + json_push_back(normal, json_new_a("Time for Normal Erase", temp.str().c_str())); if (check_For_Active_Status(&m_pLog->timeNormalErase)) { if (m_pLog->timeNormalErase & BIT15) @@ -3900,8 +3914,9 @@ bool CAta_Identify_Log_06::get_Time_for_Normal_Erase(JSONNODE *normal) { opensea_parser::set_Json_Bool(normal, "Normal Security Time format bit", false); } - snprintf((char*)myStr.c_str(), BASIC, "%" PRId16"", ((uint16_t)(M_Word0(m_pLog->timeNormalErase)) & 0x0FFF) * 2); - json_push_back(normal, json_new_a("Time for Normal Erase in Minutes", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << (static_cast(M_Word0(m_pLog->timeNormalErase)) & 0x0FFF) * 2; + json_push_back(normal, json_new_a("Time for Normal Erase in Minutes", temp.str().c_str())); } return true; } @@ -3921,14 +3936,13 @@ bool CAta_Identify_Log_06::get_Time_for_Normal_Erase(JSONNODE *normal) //--------------------------------------------------------------------------- bool CAta_Identify_Log_06::get_Trusted_Computing_Feature_Set(JSONNODE *tdc) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Trusted Computing Feature Set \n"); printf("\tTrusted Computing Feature Set = 0x%016" PRIx64" \n", m_pLog->tcfeatures); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->tcfeatures); - json_push_back(tdc, json_new_a("Trusted Computing Feature Set", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->tcfeatures; + json_push_back(tdc, json_new_a("Trusted Computing Feature Set", temp.str().c_str())); if (check_For_Active_Status(&m_pLog->tcfeatures)) { if (m_pLog->tcfeatures & BIT0) @@ -4012,14 +4026,13 @@ bool CAta_Identify_Log_06::set_Security_Capabilities() //--------------------------------------------------------------------------- bool CAta_Identify_Log_06::get_Security_Capabilities(JSONNODE *sCap) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Trusted Computing Feature Set \n"); printf("\tTrusted Computing Feature Set = 0x%016" PRIx64" \n", m_pLog->tcfeatures); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->tcfeatures); - json_push_back(sCap, json_new_a("Trusted Computing Feature Se", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->tcfeatures; + json_push_back(sCap, json_new_a("Trusted Computing Feature Set", temp.str().c_str())); if (set_Security_Capabilities()) { JSONNODE *securityBits = json_new(JSON_NODE); @@ -4049,19 +4062,17 @@ bool CAta_Identify_Log_06::get_Security_Capabilities(JSONNODE *sCap) //! \return string the interface type // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_06::get_Log_Page06(uint8_t *pData, JSONNODE *masterData) +eReturnValues CAta_Identify_Log_06::get_Log_Page06(uint8_t *lp6pData, JSONNODE *masterData) { #define LOG_PAGE_06 0x0006 eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - //myStr.resize(BASIC); sLogPage06 logPage; m_pLog = &logPage; memset(m_pLog, 0, sizeof(sLogPage06)); - m_pLog = (sLogPage06 *)&pData[0]; + m_pLog = reinterpret_cast(&lp6pData[0]); - uint16_t pageNumber = (uint16_t)(M_Word1(m_pLog->header)); - uint16_t revision = (uint16_t)(M_Word0(m_pLog->header)); + uint16_t pageNumber = M_Word1(m_pLog->header); + uint16_t revision = M_Word0(m_pLog->header); if (pageNumber == LOG_PAGE_06) { JSONNODE *pageInfo = json_new(JSON_NODE); @@ -4070,13 +4081,16 @@ eReturnValues CAta_Identify_Log_06::get_Log_Page06(uint8_t *pData, JSONNODE *mas printf("Log Page 06h \n"); printf("\tHeader = 0x%016" PRIx64" \n", m_pLog->header); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->header); - json_push_back(pageInfo, json_new_a("Page Header", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", pageNumber); - json_push_back(pageInfo, json_new_a("Page Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", revision); - json_push_back(pageInfo, json_new_a("Revision Number", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->header; + json_push_back(pageInfo, json_new_a("Page Header", temp.str().c_str())); + + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << pageNumber; + json_push_back(pageInfo, json_new_a("Page Number", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << revision; + json_push_back(pageInfo, json_new_a("Revision Number", temp.str().c_str())); get_Master_Password_Identifier(pageInfo); get_Security_Settings(pageInfo); get_Time_for_Enhanced_Erase(pageInfo); @@ -4155,19 +4169,17 @@ CAta_Identify_Log_07::~CAta_Identify_Log_07() //! \return string the interface type // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_07::get_Log_Page07(uint8_t *pData, JSONNODE *masterData) +eReturnValues CAta_Identify_Log_07::get_Log_Page07(uint8_t *lp7pData, JSONNODE *masterData) { #define LOG_PAGE_07 0x0007 eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - //myStr.resize(BASIC); sLogPage07 logPage; m_pLog = &logPage; memset(m_pLog, 0, sizeof(sLogPage07)); - m_pLog = (sLogPage07 *)&pData[0]; + m_pLog = reinterpret_cast(&lp7pData[0]); - uint16_t pageNumber = (uint16_t)(M_Word1(m_pLog->header)); - uint16_t revision = (uint16_t)(M_Word0(m_pLog->header)); + uint16_t pageNumber = M_Word1(m_pLog->header); + uint16_t revision = M_Word0(m_pLog->header); if (pageNumber == LOG_PAGE_07) { JSONNODE *pageInfo = json_new(JSON_NODE); @@ -4176,12 +4188,15 @@ eReturnValues CAta_Identify_Log_07::get_Log_Page07(uint8_t *pData, JSONNODE *mas printf("Log Page 07h \n"); printf("\tHeader = 0x%016" PRIx64" \n", m_pLog->header); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->header); - json_push_back(pageInfo, json_new_a("Page Header", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", pageNumber); - json_push_back(pageInfo, json_new_a("Page Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", revision); - json_push_back(pageInfo, json_new_a("Revision Number", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->header; + json_push_back(pageInfo, json_new_a("Page Header", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << pageNumber; + json_push_back(pageInfo, json_new_a("Page Number", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << revision; + json_push_back(pageInfo, json_new_a("Revision Number", temp.str().c_str())); json_push_back(masterData, pageInfo); @@ -4395,15 +4410,14 @@ bool CAta_Identify_Log_08::set_Sata_Capabilities() //--------------------------------------------------------------------------- bool CAta_Identify_Log_08::get_Sata_Capabilities(JSONNODE *cap) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("SATA Capabilities\n"); printf("\tSATA Capabilities = 0x%016" PRIx64" \n", m_pLog->sataCapabilities); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->sataCapabilities); - json_push_back(cap, json_new_a("SATA Capabilities QWord", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->sataCapabilities; + json_push_back(cap, json_new_a("SATA Capabilities QWord", temp.str().c_str())); if (set_Sata_Capabilities()) { @@ -4549,14 +4563,13 @@ bool CAta_Identify_Log_08::set_Current_Sata() //--------------------------------------------------------------------------- bool CAta_Identify_Log_08::get_Current_Sata(JSONNODE *current) { - std::string myStr = ""; - //myStr.resize(BASIC); #if defined _DEBUG printf("Current SATA Settings\n"); printf("\tCurrent SATA Settingss = 0x%016" PRIx64" \n", m_pLog->currentSata); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->currentSata); - json_push_back(current, json_new_a("Current SATA Settings QWord", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->currentSata; + json_push_back(current, json_new_a("Current SATA Settings QWord", temp.str().c_str())); if (set_Current_Sata()) { JSONNODE *currentSettings = json_new(JSON_NODE); @@ -4648,16 +4661,16 @@ void CAta_Identify_Log_08::get_Supported_Hardware(JSONNODE *supported) //--------------------------------------------------------------------------- void CAta_Identify_Log_08::get_Device_Sleep_Timing_Variables(JSONNODE *sleep) { - std::string myStr = ""; - //myStr.resize(BASIC); if (m_pLog->deviceSleepTiming &BIT63) { opensea_parser::set_Json_Bool(sleep, "DEVSLP Timing Variables Supported", true); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRId16"", (uint16_t)M_GETBITRANGE(m_pLog->deviceSleepTiming, 15, 8)); - json_push_back(sleep, json_new_a("DEVSLEEP Exit Timeout Field (DETO)", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_GETBITRANGE(m_pLog->deviceSleepTiming, 15, 8); + json_push_back(sleep, json_new_a("DEVSLEEP Exit Timeout Field (DETO)", temp.str().c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRId16"", (uint16_t)M_GETBITRANGE(m_pLog->deviceSleepTiming, 4, 0)); - json_push_back(sleep, json_new_a("Minimum DEVSLP Assertion Time Field (MDAT)", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << M_GETBITRANGE(m_pLog->deviceSleepTiming, 4, 0); + json_push_back(sleep, json_new_a("Minimum DEVSLP Assertion Time Field (MDAT)", temp.str().c_str())); } else @@ -4680,19 +4693,17 @@ void CAta_Identify_Log_08::get_Device_Sleep_Timing_Variables(JSONNODE *sleep) //! \return string the interface type // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_08::get_Log_Page08(uint8_t *pData, JSONNODE *masterData) +eReturnValues CAta_Identify_Log_08::get_Log_Page08(uint8_t *lp8pData, JSONNODE *masterData) { #define LOG_PAGE_08 0x0008 eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - //myStr.resize(BASIC); sLogPage08 logPage; m_pLog = &logPage; memset(m_pLog, 0, sizeof(sLogPage08)); - m_pLog = (sLogPage08 *)&pData[0]; + m_pLog = reinterpret_cast(&lp8pData[0]); - uint16_t pageNumber = (uint16_t)(M_Word1(m_pLog->header)); - uint16_t revision = (uint16_t)(M_Word0(m_pLog->header)); + uint16_t pageNumber = M_Word1(m_pLog->header); + uint16_t revision = M_Word0(m_pLog->header); if (pageNumber == LOG_PAGE_08) { JSONNODE *pageInfo = json_new(JSON_NODE); @@ -4701,13 +4712,15 @@ eReturnValues CAta_Identify_Log_08::get_Log_Page08(uint8_t *pData, JSONNODE *mas printf("Log Page 08h \n"); printf("\tHeader = 0x%016" PRIx64" \n", m_pLog->header); #endif - snprintf((char*)myStr.c_str(), BASIC, "0x%016" PRIx64"", m_pLog->header); - json_push_back(pageInfo, json_new_a("Page Header", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", pageNumber); - json_push_back(pageInfo, json_new_a("Page Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", revision); - json_push_back(pageInfo, json_new_a("Revision Number", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << m_pLog->header; + json_push_back(pageInfo, json_new_a("Page Header", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << pageNumber; + json_push_back(pageInfo, json_new_a("Page Number", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << revision; + json_push_back(pageInfo, json_new_a("Revision Number", temp.str().c_str())); get_Sata_Capabilities(pageInfo); get_Current_Sata(pageInfo); @@ -4779,13 +4792,13 @@ CAta_Identify_Log_30::CAta_Identify_Log_30(const std::string & fileName) { size_t bufferSize = cCLog->get_Size(); pData = new uint8_t[cCLog->get_Size()]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, cCLog->get_Buffer(), bufferSize); #else memcpy_s(pData, bufferSize, cCLog->get_Buffer(), bufferSize);// copy the buffer data to the class member pBuf #endif sLogPageStruct *idCheck; - idCheck = (sLogPageStruct *)&pData[0]; + idCheck = reinterpret_cast(&pData[0]); byte_Swap_16(&idCheck->pageLength); if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) { @@ -4843,7 +4856,7 @@ CAta_Identify_Log_30::~CAta_Identify_Log_30() // //--------------------------------------------------------------------------- -eReturnValues CAta_Identify_Log_30::get_Interface_Type() +/*eReturnValues CAta_Identify_Log_30::get_Interface_Type() { std::string interfaceType("unknow"); uint16_t interfaceOffset = 0x0180 + 512; @@ -4870,14 +4883,14 @@ eReturnValues CAta_Identify_Log_30::get_Interface_Type() } return SUCCESS; -} +}*/ eReturnValues CAta_Identify_Log_30::parse_Identify_Log_30(JSONNODE *masterData) { // Parse the log page 00. CAta_Identify_Log_00 *cLogPage00; cLogPage00 = new CAta_Identify_Log_00(&pData[0x000]); - cLogPage00->get_Log_Page00(&pData[0x000], masterData); + cLogPage00->get_Log_Page00(masterData); // Parse the Log page 01h if (cLogPage00->is_Page_Supported(1)) @@ -4943,7 +4956,7 @@ eReturnValues CAta_Identify_Log_30::parse_Identify_Log_30(JSONNODE *masterData) cLogPage08->get_Log_Page08(&pData[0x1000], masterData); delete (cLogPage08); } - get_Interface_Type(); + //get_Interface_Type(); delete (cLogPage00); return SUCCESS; diff --git a/src/CAta_NCQ_Command_Error_Log.cpp b/src/CAta_NCQ_Command_Error_Log.cpp index 33aa77e..e3e61ab 100644 --- a/src/CAta_NCQ_Command_Error_Log.cpp +++ b/src/CAta_NCQ_Command_Error_Log.cpp @@ -2,7 +2,7 @@ // CAta_NCQ_Command_Error_Log.cpp // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -58,13 +58,13 @@ CAta_NCQ_Command_Error_Log::CAta_NCQ_Command_Error_Log(const std::string & fileN { size_t logSize = cCLog->get_Size(); pBuf = new uint8_t[logSize]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pBuf, cCLog->get_Buffer(), logSize); #else memcpy_s(pBuf, logSize, cCLog->get_Buffer(), logSize);// copy the buffer data to the class member pBuf #endif sLogPageStruct *idCheck; - idCheck = (sLogPageStruct *)&pBuf[0]; + idCheck = reinterpret_cast(&pBuf[0]); byte_Swap_16(&idCheck->pageLength); if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) { @@ -152,8 +152,6 @@ CAta_NCQ_Command_Error_Log::~CAta_NCQ_Command_Error_Log() //--------------------------------------------------------------------------- bool CAta_NCQ_Command_Error_Log::get_Bit_Name_Info(JSONNODE *NCQInfo) { - std::string myStr = " "; - myStr.resize(BASIC); bool validNCQ = true; bool idleCmd = false; uint8_t ncqTag = M_GETBITRANGE(ncqError->NCQbit, 4, 0); @@ -190,7 +188,7 @@ bool CAta_NCQ_Command_Error_Log::get_Bit_Name_Info(JSONNODE *NCQInfo) //--------------------------------------------------------------------------- bool CAta_NCQ_Command_Error_Log::create_LBA() { - m_LBA = ((uint64_t)ncqError->lba6 << 40) | ((uint64_t)ncqError->lba5 << 32) | ((uint64_t)ncqError->lba4 << 24) | ((uint64_t)ncqError->lba3 << 16) | ((uint64_t)ncqError->lba2 << 8) | ((uint64_t)ncqError->lba1); + m_LBA = M_BytesTo8ByteValue(0, 0, ncqError->lba6, ncqError->lba5, ncqError->lba4, ncqError->lba3, ncqError->lba2, ncqError->lba1); return true; } //----------------------------------------------------------------------------- @@ -211,7 +209,7 @@ eReturnValues CAta_NCQ_Command_Error_Log::get_NCQ_Command_Error_Log(JSONNODE *ma { JSONNODE *NCQInfo = json_new(JSON_NODE); json_set_name(NCQInfo, "NCQ Command Error Log"); - ncqError = (sNCQError *)&pBuf[0]; + ncqError = reinterpret_cast(&pBuf[0]); get_Bit_Name_Info(NCQInfo); create_LBA(); json_push_back(NCQInfo, json_new_i("Status", static_cast(ncqError->status))); diff --git a/src/CAta_Power_Condition_Log.cpp b/src/CAta_Power_Condition_Log.cpp index 66e38a0..c165683 100644 --- a/src/CAta_Power_Condition_Log.cpp +++ b/src/CAta_Power_Condition_Log.cpp @@ -2,7 +2,7 @@ // CAta_Power_Conditions_Log.cpp Implementation of Base class CAtaLog // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,9 +14,9 @@ // #include "CAta_Power_Conditions_Log.h" -#if !defined BASIC +/*#if !defined BASIC #define BASIC (80) -#endif +#endif*/ using namespace opensea_parser; #define OFFSET_IDLE_A 0 @@ -39,11 +39,15 @@ using namespace opensea_parser; // //--------------------------------------------------------------------------- CAtaPowerConditionsLog::CAtaPowerConditionsLog() -: m_powerConditionLog(NULL) -, m_powerFlags(NULL) -, m_status(IN_PROGRESS) -, m_idleAPowerConditions(NULL), m_idleBPowerConditions(NULL), m_idleCPowerConditions(NULL) -, m_standbyYPowerConditions(NULL), m_standbyZPowerConditions(NULL) + : m_powerConditionLog(NULL) + , m_powerFlags(NULL) + , Buffer() + , m_status(IN_PROGRESS) + , m_myJSON() + , m_idleAPowerConditions(NULL), m_idleBPowerConditions(NULL), m_idleCPowerConditions(NULL) + , m_standbyYPowerConditions(NULL), m_standbyZPowerConditions(NULL) + , m_conditionFlags(NULL) + , conditionFlags() { } @@ -61,53 +65,56 @@ CAtaPowerConditionsLog::CAtaPowerConditionsLog() // //--------------------------------------------------------------------------- CAtaPowerConditionsLog::CAtaPowerConditionsLog(std::string filename) -: m_powerConditionLog(NULL) -, m_powerFlags(NULL) -, m_status(IN_PROGRESS) -, m_idleAPowerConditions(NULL), m_idleBPowerConditions(NULL), m_idleCPowerConditions(NULL) -, m_standbyYPowerConditions(NULL), m_standbyZPowerConditions(NULL) -, conditionFlags() + : m_powerConditionLog(NULL) + , m_powerFlags(NULL) + , Buffer() + , m_status(IN_PROGRESS) + , m_myJSON() + , m_idleAPowerConditions(NULL), m_idleBPowerConditions(NULL), m_idleCPowerConditions(NULL) + , m_standbyYPowerConditions(NULL), m_standbyZPowerConditions(NULL) + , m_conditionFlags(NULL) + , conditionFlags() { - CLog *cCLog; - cCLog = new CLog(filename); - if (cCLog->get_Log_Status() == SUCCESS) - { - if (cCLog->get_Buffer() != NULL) - { - size_t logSize = cCLog->get_Size(); - m_powerConditionLog = new uint8_t[logSize]; // new a buffer to the point -#ifndef _WIN64 - memcpy(m_powerConditionLog, cCLog->get_Buffer(), logSize); + CLog *cCLog; + cCLog = new CLog(filename); + if (cCLog->get_Log_Status() == SUCCESS) + { + if (cCLog->get_Buffer() != NULL) + { + size_t logSize = cCLog->get_Size(); + m_powerConditionLog = new uint8_t[logSize]; // new a buffer to the point +#ifndef __STDC_SECURE_LIB__ + memcpy(m_powerConditionLog, cCLog->get_Buffer(), logSize); #else - memcpy_s(m_powerConditionLog, logSize, cCLog->get_Buffer(), logSize);// copy the buffer data to the class member pBuf + memcpy_s(m_powerConditionLog, logSize, cCLog->get_Buffer(), logSize);// copy the buffer data to the class member pBuf #endif - sLogPageStruct *idCheck; - idCheck = (sLogPageStruct *)&m_powerConditionLog[0]; - byte_Swap_16(&idCheck->pageLength); - if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) - { - byte_Swap_16(&idCheck->pageLength); // now that we know it's not scsi we need to flip the bytes back - m_conditionFlags = &conditionFlags; - get_Power_Condition_Log(); - m_status = IN_PROGRESS; - } - else - { - m_status = BAD_PARAMETER; - } - } - else - { - - m_status = FAILURE; - } - } - else - { - m_status = cCLog->get_Log_Status(); - } - delete (cCLog); + sLogPageStruct *idCheck; + idCheck = reinterpret_cast(&m_powerConditionLog[0]); + byte_Swap_16(&idCheck->pageLength); + if (IsScsiLogPage(idCheck->pageLength, idCheck->pageCode) == false) + { + byte_Swap_16(&idCheck->pageLength); // now that we know it's not scsi we need to flip the bytes back + m_conditionFlags = &conditionFlags; + get_Power_Condition_Log(); + m_status = IN_PROGRESS; + } + else + { + m_status = BAD_PARAMETER; + } + } + else + { + + m_status = FAILURE; + } + } + else + { + m_status = cCLog->get_Log_Status(); + } + delete (cCLog); } //----------------------------------------------------------------------------- @@ -124,20 +131,23 @@ CAtaPowerConditionsLog::CAtaPowerConditionsLog(std::string filename) // //--------------------------------------------------------------------------- CAtaPowerConditionsLog::CAtaPowerConditionsLog(tDataPtr pData, JSONNODE *masterData) - : m_powerConditionLog(NULL) - , m_powerFlags(NULL) - , m_status(IN_PROGRESS) - , m_idleAPowerConditions(NULL), m_idleBPowerConditions(NULL), m_idleCPowerConditions(NULL) - , m_standbyYPowerConditions(NULL), m_standbyZPowerConditions(NULL) - , conditionFlags() + : m_powerConditionLog(NULL) + , m_powerFlags(NULL) + , Buffer() + , m_status(IN_PROGRESS) + , m_myJSON(masterData) + , m_idleAPowerConditions(NULL), m_idleBPowerConditions(NULL), m_idleCPowerConditions(NULL) + , m_standbyYPowerConditions(NULL), m_standbyZPowerConditions(NULL) + , m_conditionFlags(NULL) + , conditionFlags() { m_powerConditionLog = new uint8_t[pData.DataLen]; // new a buffer to the point -#ifndef _WIN64 - memcpy(m_powerConditionLog, (uint8_t*)pData.pData, pData.DataLen); +#ifndef __STDC_SECURE_LIB__ + memcpy(m_powerConditionLog, static_cast(pData.pData), pData.DataLen); #else - memcpy_s(m_powerConditionLog, pData.DataLen, (uint8_t*)pData.pData, pData.DataLen);// copy the buffer data to the class member pBuf + memcpy_s(m_powerConditionLog, pData.DataLen, static_cast(pData.pData), pData.DataLen);// copy the buffer data to the class member pBuf #endif - + if (m_powerConditionLog != NULL) { m_conditionFlags = &conditionFlags; @@ -168,7 +178,7 @@ CAtaPowerConditionsLog::~CAtaPowerConditionsLog() { if (m_powerConditionLog != NULL) { - delete [] m_powerConditionLog; + delete[] m_powerConditionLog; } } @@ -190,22 +200,22 @@ CAtaPowerConditionsLog::~CAtaPowerConditionsLog() eReturnValues CAtaPowerConditionsLog::get_Power_Condition_Log() { - //get the idle_a power condition descriptor - m_idleAPowerConditions = (sPowerLogDescriptor*)&m_powerConditionLog[OFFSET_IDLE_A]; + //get the idle_a power condition descriptor + m_idleAPowerConditions = reinterpret_cast(&m_powerConditionLog[OFFSET_IDLE_A]); - //get the idle_b power condition descriptor - m_idleBPowerConditions = (sPowerLogDescriptor*)&m_powerConditionLog[OFFSET_IDLE_B]; + //get the idle_b power condition descriptor + m_idleBPowerConditions = reinterpret_cast(&m_powerConditionLog[OFFSET_IDLE_B]); - //get the idle_c power condition descriptor - m_idleCPowerConditions = (sPowerLogDescriptor*)&m_powerConditionLog[OFFSET_IDLE_C]; + //get the idle_c power condition descriptor + m_idleCPowerConditions = reinterpret_cast(&m_powerConditionLog[OFFSET_IDLE_C]); - //get the standby_y power condition descriptor - m_standbyYPowerConditions = (sPowerLogDescriptor*)&m_powerConditionLog[OFFSET_STANDBY_Y]; + //get the standby_y power condition descriptor + m_standbyYPowerConditions = reinterpret_cast(&m_powerConditionLog[OFFSET_STANDBY_Y]); - //get the standby_z power condition descriptor - m_standbyZPowerConditions = (sPowerLogDescriptor*)&m_powerConditionLog[OFFSET_STANDBY_Z]; + //get the standby_z power condition descriptor + m_standbyZPowerConditions = reinterpret_cast(&m_powerConditionLog[OFFSET_STANDBY_Z]); - return SUCCESS; + return SUCCESS; } //----------------------------------------------------------------------------- @@ -225,57 +235,57 @@ eReturnValues CAtaPowerConditionsLog::get_Power_Condition_Log() //--------------------------------------------------------------------------- eReturnValues CAtaPowerConditionsLog::get_Power_Condition_Flags(uint8_t readFlags) { - eReturnValues ret = NOT_SUPPORTED; - m_conditionFlags->powerSupportBit = false; - m_conditionFlags->powerSaveableBit = false; - m_conditionFlags->powerChangeableBit = false; - m_conditionFlags->defaultTimerBit = false; - m_conditionFlags->savedTimmerBit = false; - m_conditionFlags->currentTimmerBit = false; - m_conditionFlags->holdPowerConditionBit = false; - m_conditionFlags->reserved = false; - - if (readFlags & BIT7) - { - m_conditionFlags->powerSupportBit = true; + eReturnValues ret = NOT_SUPPORTED; + m_conditionFlags->powerSupportBit = false; + m_conditionFlags->powerSaveableBit = false; + m_conditionFlags->powerChangeableBit = false; + m_conditionFlags->defaultTimerBit = false; + m_conditionFlags->savedTimmerBit = false; + m_conditionFlags->currentTimmerBit = false; + m_conditionFlags->holdPowerConditionBit = false; + m_conditionFlags->reserved = false; + + if (readFlags & BIT7) + { + m_conditionFlags->powerSupportBit = true; ret = SUCCESS; - } - if (readFlags & BIT6) - { - m_conditionFlags->powerSaveableBit = true; + } + if (readFlags & BIT6) + { + m_conditionFlags->powerSaveableBit = true; ret = SUCCESS; - } - if (readFlags & BIT5) - { - m_conditionFlags->powerChangeableBit = true; + } + if (readFlags & BIT5) + { + m_conditionFlags->powerChangeableBit = true; ret = SUCCESS; - } - if (readFlags & BIT4) - { - m_conditionFlags->defaultTimerBit = true; + } + if (readFlags & BIT4) + { + m_conditionFlags->defaultTimerBit = true; ret = SUCCESS; - } - if (readFlags & BIT3) - { - m_conditionFlags->savedTimmerBit = true; + } + if (readFlags & BIT3) + { + m_conditionFlags->savedTimmerBit = true; ret = SUCCESS; - } - if (readFlags & BIT2) - { - m_conditionFlags->currentTimmerBit = true; + } + if (readFlags & BIT2) + { + m_conditionFlags->currentTimmerBit = true; ret = SUCCESS; - } - if (readFlags & BIT1) - { - m_conditionFlags->holdPowerConditionBit = true; + } + if (readFlags & BIT1) + { + m_conditionFlags->holdPowerConditionBit = true; ret = SUCCESS; - } - if (readFlags & BIT0) - { - m_conditionFlags->reserved = true; - } + } + if (readFlags & BIT0) + { + m_conditionFlags->reserved = true; + } - return ret; + return ret; } //----------------------------------------------------------------------------- // @@ -293,39 +303,36 @@ eReturnValues CAtaPowerConditionsLog::get_Power_Condition_Flags(uint8_t readFlag //--------------------------------------------------------------------------- eReturnValues CAtaPowerConditionsLog::printPowerConditionLog(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); - - m_myJSON = json_new(JSON_NODE); - - JSONNODE *idleAConditionInfo = json_new(JSON_NODE); - json_set_name(m_myJSON, "SATA Power Condition Log"); - json_set_name(idleAConditionInfo, "Idle_a Power Condition Log"); - printPowerLogDescriptor(idleAConditionInfo, m_idleAPowerConditions); - json_push_back(m_myJSON, idleAConditionInfo); - - JSONNODE *idleBConditionInfo = json_new(JSON_NODE); - json_set_name(idleBConditionInfo, "Idle_b Power Condition Log"); - printPowerLogDescriptor(idleBConditionInfo, m_idleBPowerConditions); - json_push_back(m_myJSON, idleBConditionInfo); - - JSONNODE *idleCConditionInfo = json_new(JSON_NODE); - json_set_name(idleCConditionInfo, "Idle_c Power Condition Log"); - printPowerLogDescriptor(idleCConditionInfo, m_idleCPowerConditions); - json_push_back(m_myJSON, idleCConditionInfo); - - JSONNODE *standByYConditionInfo = json_new(JSON_NODE); - json_set_name(standByYConditionInfo, "Standby_y Power Condition Log"); - printPowerLogDescriptor(standByYConditionInfo, m_standbyYPowerConditions); - json_push_back(m_myJSON, standByYConditionInfo); - - JSONNODE *standByZConditionInfo = json_new(JSON_NODE); - json_set_name(standByZConditionInfo, "Standby_z Power Condition Log"); - printPowerLogDescriptor(standByZConditionInfo, m_standbyZPowerConditions); - json_push_back(m_myJSON, standByZConditionInfo); - json_push_back(masterData, m_myJSON); - - return SUCCESS; + m_myJSON = json_new(JSON_NODE); + + JSONNODE *idleAConditionInfo = json_new(JSON_NODE); + json_set_name(m_myJSON, "SATA Power Condition Log"); + json_set_name(idleAConditionInfo, "Idle_a Power Condition Log"); + printPowerLogDescriptor(idleAConditionInfo, m_idleAPowerConditions); + json_push_back(m_myJSON, idleAConditionInfo); + + JSONNODE *idleBConditionInfo = json_new(JSON_NODE); + json_set_name(idleBConditionInfo, "Idle_b Power Condition Log"); + printPowerLogDescriptor(idleBConditionInfo, m_idleBPowerConditions); + json_push_back(m_myJSON, idleBConditionInfo); + + JSONNODE *idleCConditionInfo = json_new(JSON_NODE); + json_set_name(idleCConditionInfo, "Idle_c Power Condition Log"); + printPowerLogDescriptor(idleCConditionInfo, m_idleCPowerConditions); + json_push_back(m_myJSON, idleCConditionInfo); + + JSONNODE *standByYConditionInfo = json_new(JSON_NODE); + json_set_name(standByYConditionInfo, "Standby_y Power Condition Log"); + printPowerLogDescriptor(standByYConditionInfo, m_standbyYPowerConditions); + json_push_back(m_myJSON, standByYConditionInfo); + + JSONNODE *standByZConditionInfo = json_new(JSON_NODE); + json_set_name(standByZConditionInfo, "Standby_z Power Condition Log"); + printPowerLogDescriptor(standByZConditionInfo, m_standbyZPowerConditions); + json_push_back(m_myJSON, standByZConditionInfo); + json_push_back(masterData, m_myJSON); + + return SUCCESS; } //----------------------------------------------------------------------------- @@ -345,48 +352,44 @@ eReturnValues CAtaPowerConditionsLog::printPowerConditionLog(JSONNODE *masterDat //--------------------------------------------------------------------------- eReturnValues CAtaPowerConditionsLog::printPowerLogDescriptor(JSONNODE *masterData, sPowerLogDescriptor *logDescriptor) { - std::string myStr = ""; - myStr.resize( BASIC ); - get_Power_Condition_Flags(logDescriptor->bitFlags); - if (logDescriptor != NULL) - { + get_Power_Condition_Flags(logDescriptor->bitFlags); + if (logDescriptor != NULL) + { #if defined _DEBUG - printf("\nReserved \n"); - printf("Power Condition Flags\n"); - printf(" Power Condition Supported : %" PRIu8" \n", m_conditionFlags->powerSupportBit); - printf(" Power Condition Saveable : %" PRIu8" \n", m_conditionFlags->powerSaveableBit); - printf(" Power Condition Changeable : %" PRIu8" \n", m_conditionFlags->powerChangeableBit); - printf(" Default Timer Enable : %" PRIu8" \n", m_conditionFlags->defaultTimerBit); - printf(" Saved Timer Enable : %" PRIu8" \n", m_conditionFlags->savedTimmerBit); - printf(" Current Timer Enable : %" PRIu8" \n", m_conditionFlags->currentTimmerBit); - printf(" Hold Power Condition NOT Supported : %" PRIu8" \n", m_conditionFlags->holdPowerConditionBit); - printf(" Reseved : %" PRIu8" \n", m_conditionFlags->reserved); - printf("Reserved \n"); - printf("Default Timer Setting Field : %" PRIu32" \n", logDescriptor->defaultTimerSetting); - printf("Saved Timer Setting Field : %" PRIu32" \n", logDescriptor->savedTimerSetting); - printf("Current Timer Setting Field : %" PRIu32" \n", logDescriptor->currentTimerSetting); - printf("Norminal Recovery Timer to PM0 : Active Filed : %" PRIu32" \n", logDescriptor->normalRecoveryTime); - printf("Minimum Timer Setting Field : %" PRIu32" \n", logDescriptor->minimumTimerSetting); - printf("Maximum Timer Setting Field : %" PRIu32" \n", logDescriptor->maximumTimerSetting); - printf("Reserved\n"); + printf("\nReserved \n"); + printf("Power Condition Flags\n"); + printf(" Power Condition Supported : %" PRIu8" \n", m_conditionFlags->powerSupportBit); + printf(" Power Condition Saveable : %" PRIu8" \n", m_conditionFlags->powerSaveableBit); + printf(" Power Condition Changeable : %" PRIu8" \n", m_conditionFlags->powerChangeableBit); + printf(" Default Timer Enable : %" PRIu8" \n", m_conditionFlags->defaultTimerBit); + printf(" Saved Timer Enable : %" PRIu8" \n", m_conditionFlags->savedTimmerBit); + printf(" Current Timer Enable : %" PRIu8" \n", m_conditionFlags->currentTimmerBit); + printf(" Hold Power Condition NOT Supported : %" PRIu8" \n", m_conditionFlags->holdPowerConditionBit); + printf(" Reseved : %" PRIu8" \n", m_conditionFlags->reserved); + printf("Reserved \n"); + printf("Default Timer Setting Field : %" PRIu32" \n", logDescriptor->defaultTimerSetting); + printf("Saved Timer Setting Field : %" PRIu32" \n", logDescriptor->savedTimerSetting); + printf("Current Timer Setting Field : %" PRIu32" \n", logDescriptor->currentTimerSetting); + printf("Norminal Recovery Timer to PM0 : Active Filed : %" PRIu32" \n", logDescriptor->normalRecoveryTime); + printf("Minimum Timer Setting Field : %" PRIu32" \n", logDescriptor->minimumTimerSetting); + printf("Maximum Timer Setting Field : %" PRIu32" \n", logDescriptor->maximumTimerSetting); + printf("Reserved\n"); #endif - //snprintf((char*)myStr.c_str(), BASIC, "Reserved"); - //json_push_back(masterData, json_new_a("Reserved :", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%x", logDescriptor->bitFlags); - json_push_back(masterData, json_new_a("Power Condition Flags", (char*)myStr.c_str())); + //json_push_back(masterData, json_new_a("Reserved :", "Reserved")); + std::ostringstream temp; + temp << std::hex << logDescriptor->bitFlags; + json_push_back(masterData, json_new_a("Power Condition Flags", temp.str().c_str())); printPowerConditionFlag(masterData); - //snprintf((char*)myStr.c_str(), BASIC, "Reserved"); - //json_push_back(masterData, json_new_a("Reserved :", (char*)myStr.c_str())); + //json_push_back(masterData, json_new_a("Reserved :", "Reserved")); json_push_back(masterData, json_new_i("Default Timer Setting Field", logDescriptor->defaultTimerSetting)); json_push_back(masterData, json_new_i("Saved Timer Setting Field", logDescriptor->savedTimerSetting)); json_push_back(masterData, json_new_i("Current Timer Setting Field", logDescriptor->currentTimerSetting)); json_push_back(masterData, json_new_i("Norminal Recovery Timer to PM0 Active Filed", logDescriptor->normalRecoveryTime)); json_push_back(masterData, json_new_i("Minimum Timer Setting Field", logDescriptor->minimumTimerSetting)); json_push_back(masterData, json_new_i("Maximum Timer Setting Field", logDescriptor->maximumTimerSetting)); - snprintf((char*)myStr.c_str(), BASIC, "Reserved"); - json_push_back(masterData, json_new_a("Reserved :", (char*)myStr.c_str())); + json_push_back(masterData, json_new_a("Reserved :", "Reserved")); } else { @@ -413,29 +416,29 @@ eReturnValues CAtaPowerConditionsLog::printPowerLogDescriptor(JSONNODE *masterDa void CAtaPowerConditionsLog::printPowerConditionFlag(JSONNODE *masterData) { - if (m_conditionFlags != NULL) - { + if (m_conditionFlags != NULL) + { #if defined _DEBUG - printf("Power Condition Supported = %d \n", m_conditionFlags->powerSupportBit); - printf("Power Condition Saveable = %d \n", m_conditionFlags->powerSaveableBit); - printf("Power Condition Changeable = %d \n", m_conditionFlags->powerChangeableBit); - printf("Default Timer Enable = %d \n", m_conditionFlags->defaultTimerBit); - printf("Saved Timer Enable = %d \n", m_conditionFlags->savedTimmerBit); - printf("Current Timer Enable = %d \n", m_conditionFlags->currentTimmerBit); - printf("Hold Power Condition NOT Supported = %d \n", m_conditionFlags->holdPowerConditionBit); - printf("Hold Power Condition NOT Supported = %d \n", m_conditionFlags->reserved); + printf("Power Condition Supported = %d \n", m_conditionFlags->powerSupportBit); + printf("Power Condition Saveable = %d \n", m_conditionFlags->powerSaveableBit); + printf("Power Condition Changeable = %d \n", m_conditionFlags->powerChangeableBit); + printf("Default Timer Enable = %d \n", m_conditionFlags->defaultTimerBit); + printf("Saved Timer Enable = %d \n", m_conditionFlags->savedTimmerBit); + printf("Current Timer Enable = %d \n", m_conditionFlags->currentTimmerBit); + printf("Hold Power Condition NOT Supported = %d \n", m_conditionFlags->holdPowerConditionBit); + printf("Hold Power Condition NOT Supported = %d \n", m_conditionFlags->reserved); #endif - json_push_back(masterData, json_new_b("Power Condition Supported ", m_conditionFlags->powerSupportBit)); - json_push_back(masterData, json_new_b("Power Condition Saveable ", m_conditionFlags->powerSaveableBit)); - json_push_back(masterData, json_new_b("Power Condition Changeable ", m_conditionFlags->powerChangeableBit)); - json_push_back(masterData, json_new_b("Default Timer Enable ", m_conditionFlags->defaultTimerBit)); - json_push_back(masterData, json_new_b("Saved Timer Enable ", m_conditionFlags->savedTimmerBit)); - json_push_back(masterData, json_new_b("Current Timer Enable ", m_conditionFlags->currentTimmerBit)); - json_push_back(masterData, json_new_b("Hold Power Condition NOT Supported ", m_conditionFlags->holdPowerConditionBit)); - json_push_back(masterData, json_new_b("Reserve ", m_conditionFlags->reserved)); - } + json_push_back(masterData, json_new_b("Power Condition Supported ", m_conditionFlags->powerSupportBit)); + json_push_back(masterData, json_new_b("Power Condition Saveable ", m_conditionFlags->powerSaveableBit)); + json_push_back(masterData, json_new_b("Power Condition Changeable ", m_conditionFlags->powerChangeableBit)); + json_push_back(masterData, json_new_b("Default Timer Enable ", m_conditionFlags->defaultTimerBit)); + json_push_back(masterData, json_new_b("Saved Timer Enable ", m_conditionFlags->savedTimmerBit)); + json_push_back(masterData, json_new_b("Current Timer Enable ", m_conditionFlags->currentTimmerBit)); + json_push_back(masterData, json_new_b("Hold Power Condition NOT Supported ", m_conditionFlags->holdPowerConditionBit)); + json_push_back(masterData, json_new_b("Reserve ", m_conditionFlags->reserved)); + } -} \ No newline at end of file +} diff --git a/src/CAta_SMART_Log_Dir.cpp b/src/CAta_SMART_Log_Dir.cpp index 317bd62..a7bcdb0 100644 --- a/src/CAta_SMART_Log_Dir.cpp +++ b/src/CAta_SMART_Log_Dir.cpp @@ -3,7 +3,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -69,7 +69,7 @@ CAta_SMART_Log_Dir::CAta_SMART_Log_Dir(const std::string &fileName) { size_t bufferSize = cCLog->get_Size(); pData = new uint8_t[cCLog->get_Size()]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, cCLog->get_Buffer(), bufferSize); #else memcpy_s(pData, bufferSize, cCLog->get_Buffer(), bufferSize);// copy the buffer data to the class member pBuf @@ -171,7 +171,7 @@ eReturnValues CAta_SMART_Log_Dir::parse_SMART_Log_Dir() { sLogDetailStructure logDetails; logDetails.numberOfPages = logSize; - logDetails.logAddress = offset / 2; + logDetails.logAddress = static_cast(offset / UINT16_C(2)); if (!m_hasHostSpecific && is_Host_Specific_Log(logDetails.logAddress)) { @@ -217,11 +217,6 @@ bool CAta_SMART_Log_Dir::is_Vendor_Specific_Log(uint8_t logAddress) //--------------------------------------------------------------------------- eReturnValues CAta_SMART_Log_Dir::print_SMART_Log_Dir(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); - std::string printStr; - printStr.resize(BASIC); - JSONNODE *dirInfo = json_new(JSON_NODE); json_set_name(dirInfo, "SMART Log Directory"); @@ -241,18 +236,19 @@ eReturnValues CAta_SMART_Log_Dir::print_SMART_Log_Dir(JSONNODE *masterData) } std::vector::iterator logItr = m_logDetailList.begin(); - for (; logItr != m_logDetailList.end(); logItr++) + for (; logItr != m_logDetailList.end(); ++logItr) { sLogDetailStructure logDetail = *logItr; - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", logDetail.logAddress); - snprintf((char*)printStr.c_str(), BASIC, "%" PRIu16"", logDetail.numberOfPages); + std::ostringstream temp, temp2; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(logDetail.logAddress); + temp2 << std::dec << logDetail.numberOfPages; if (is_Host_Specific_Log(logDetail.logAddress) && hostInfo != NULL) - json_push_back(hostInfo, json_new_a((char*)myStr.c_str(), (char*)printStr.c_str())); + json_push_back(hostInfo, json_new_a(temp.str().c_str(), temp2.str().c_str())); else if (is_Vendor_Specific_Log(logDetail.logAddress) && vendorInfo != NULL) - json_push_back(vendorInfo, json_new_a((char*)myStr.c_str(), (char*)printStr.c_str())); + json_push_back(vendorInfo, json_new_a(temp.str().c_str(), temp2.str().c_str())); else - json_push_back(dirInfo, json_new_a((char*)myStr.c_str(), (char*)printStr.c_str())); + json_push_back(dirInfo, json_new_a(temp.str().c_str(), temp2.str().c_str())); } if (hostInfo != NULL) diff --git a/src/CLog.cpp b/src/CLog.cpp index ee0a68d..5de8270 100644 --- a/src/CLog.cpp +++ b/src/CLog.cpp @@ -1,6 +1,6 @@ // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -56,7 +56,7 @@ CLog::CLog(const std::string &fileName) , m_bufferData() , m_logStatus(IN_PROGRESS) { - get_CLog(fileName); + get_CLog(); } CLog::CLog(const uint8_t * pBuf, uint32_t logSize) @@ -103,14 +103,14 @@ CLog::~CLog() //! \return eReturnValues // //--------------------------------------------------------------------------- -void CLog::get_CLog(const std::string & fileName) +void CLog::get_CLog() { m_logStatus = IN_PROGRESS; std::ifstream fb(m_fileName.c_str(), std::ios::in | std::ios::binary); if (fb.is_open()) { fb.seekg(0, std::ios::end); - m_size = (size_t)fb.tellg(); + m_size = static_cast(fb.tellg()); fb.seekg(0, std::ios::beg); //set back to beginning of the file now that we know the size fb.close(); } @@ -118,7 +118,7 @@ void CLog::get_CLog(const std::string & fileName) { m_logStatus = FILE_OPEN_ERROR; } - m_bufferData = (char *)calloc(m_size, sizeof(char)); + m_bufferData = static_cast(calloc(m_size, sizeof(char))); if (m_size != 0 && m_logStatus != FILE_OPEN_ERROR) { @@ -145,10 +145,10 @@ void CLog::get_CLog(const uint8_t * pBuf, uint32_t logSize) if (pBuf != NULL) { - m_bufferData = (char *)calloc(logSize, sizeof(char)); + m_bufferData = static_cast(calloc(logSize, sizeof(char))); if (m_bufferData) { -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(m_bufferData, pBuf, logSize); #else memcpy_s(m_bufferData, logSize, pBuf, logSize); @@ -197,5 +197,56 @@ eReturnValues CLog::read_In_Buffer() return SUCCESS; } +//----------------------------------------------------------------------------- +// +//! \fn read_In_Log() +// +//! \brief +//! Description: it will open the file and reads in the log not as a binary file +// +// Entry: +// +// Exit: +//! \return eReturnValues +// +//--------------------------------------------------------------------------- +void CLog::read_In_Log() +{ + m_logStatus = IN_PROGRESS; + + //open the file and see what the size is first + std::ifstream fb(m_fileName.c_str(), std::ios::in); + if (fb.is_open()) + { + fb.seekg(0, std::ios::end); + m_size = static_cast(fb.tellg()); + fb.seekg(0, std::ios::beg); //set back to beginning of the file now that we know the size + fb.close(); + } + else + { + m_logStatus = FILE_OPEN_ERROR; + } + //set the size of the buffer + m_bufferData = static_cast(calloc(m_size, sizeof(char))); + // now we need to read in the buffer + if (m_size != 0 && m_logStatus != FILE_OPEN_ERROR) + { + char* pData = &m_bufferData[0]; + std::fstream logFile(m_fileName.c_str(), std::ios::in ); + if (logFile.is_open()) + { + logFile.read(pData, m_size); + logFile.close(); + m_logStatus = SUCCESS; + } + else + { + m_logStatus = FILE_OPEN_ERROR; + //return FILE_OPEN_ERROR; + } + } + //return SUCCESS; +} diff --git a/src/CScsi_Application_Client_Log.cpp b/src/CScsi_Application_Client_Log.cpp index ad1bee5..0dbe6da 100644 --- a/src/CScsi_Application_Client_Log.cpp +++ b/src/CScsi_Application_Client_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Application_Client_Log.cpp Definition of Application Client Log where clients store information // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,6 +13,8 @@ // \file CScsi_Application_Client_Log.cpp Definition of Application Client Log where clients store information // #include "CScsi_Application_Client_Log.h" +#include +#include using namespace opensea_parser; //----------------------------------------------------------------------------- @@ -115,56 +117,56 @@ CScsiApplicationLog::~CScsiApplicationLog() //--------------------------------------------------------------------------- void CScsiApplicationLog::process_Client_Data(JSONNODE *appData) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Application Client Description \n"); #endif byte_Swap_16(&m_App->paramCode); //get_Cache_Parameter_Code_Description(&myStr); - snprintf((char*)myStr.c_str(), BASIC, "Application Client Log 0x%04" PRIx16"", m_App->paramCode); + std::ostringstream temp; + temp << "Application Client Log 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_App->paramCode; JSONNODE *appInfo = json_new(JSON_NODE); - json_set_name(appInfo, (char*)myStr.c_str()); + json_set_name(appInfo, temp.str().c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_App->paramCode); - json_push_back(appInfo, json_new_a("Application Client Parameter Code", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_App->paramCode; + json_push_back(appInfo, json_new_a("Application Client Parameter Code", temp.str().c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_App->paramControlByte); - json_push_back(appInfo, json_new_a("Application Client Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_App->paramLength); - json_push_back(appInfo, json_new_a("Application Client Length ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_App->paramControlByte); + json_push_back(appInfo, json_new_a("Application Client Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_App->paramLength); + json_push_back(appInfo, json_new_a("Application Client Length ", temp.str().c_str())); // format to show the buffer data. if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { uint32_t lineNumber = 0; - char *innerMsg = (char*)calloc(128, sizeof(char)); - char* innerStr = (char*)calloc(60, sizeof(char)); uint32_t offset = 0; for (uint32_t outer = 0; outer < APP_CLIENT_DATA_LEN - 1; ) { - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIX32 "", lineNumber); - sprintf(innerMsg, "%02" PRIX8 "", m_App->data[offset]); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << lineNumber; + + std::ostringstream innerMsg; + innerMsg << std::hex << std::setfill('0') << std::setw(2) << static_cast(m_App->data[offset]); // inner loop for creating a single ling of the buffer data for (uint32_t inner = 1; inner < 16 && offset < APP_CLIENT_DATA_LEN - 1; inner++) { - sprintf(innerStr, "%02" PRIX8"", m_App->data[offset]); + innerMsg << std::hex << std::setfill('0') << std::setw(2) << static_cast(m_App->data[offset]); if (inner % 4 == 0) { - strncat(innerMsg, " ", 1); + innerMsg << " "; } - strncat(innerMsg, innerStr, 2); offset++; } // push the line to the json node - json_push_back(appInfo, json_new_a((char*)myStr.c_str(), innerMsg)); + json_push_back(appInfo, json_new_a(temp.str().c_str(), innerMsg.str().c_str())); outer = offset; lineNumber = outer; } - safe_Free(innerMsg); //free the string - safe_Free(innerStr); // free the string } json_push_back(appData, appInfo); } @@ -191,7 +193,7 @@ eReturnValues CScsiApplicationLog::get_Client_Data(JSONNODE *masterData) json_set_name(pageInfo, "Application Client Log - Fh"); uint16_t l_NumberOfPartitions = 0; - for (size_t offset = 0; ((offset < m_PageLength) && (l_NumberOfPartitions <= MAX_PARTITION));) + for (uint32_t offset = 0; ((offset < m_PageLength) && (l_NumberOfPartitions <= MAX_PARTITION));) { if (offset+sizeof(sApplicationParams) < m_bufferLength && offset < UINT16_MAX) { @@ -217,4 +219,4 @@ eReturnValues CScsiApplicationLog::get_Client_Data(JSONNODE *masterData) retStatus = MEMORY_FAILURE; } return retStatus; -} \ No newline at end of file +} diff --git a/src/CScsi_Background_Operation_Log.cpp b/src/CScsi_Background_Operation_Log.cpp index 12aee97..8c2ae3f 100644 --- a/src/CScsi_Background_Operation_Log.cpp +++ b/src/CScsi_Background_Operation_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Background_Operation_Log.cpp Definition of Background Operation log page reports parameters that are specific to background operations. // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -70,7 +70,7 @@ CScsiOperationLog::CScsiOperationLog(uint8_t * buffer, size_t bufferSize, uint16 printf("%s \n", m_OperationName.c_str()); } pData = new uint8_t[pageLength]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, buffer, pageLength); #else memcpy_s(pData, pageLength, buffer, pageLength);// copy the buffer data to the class member pBuf @@ -128,27 +128,27 @@ void CScsiOperationLog::get_Background_Operations_status(std::string *status) { case 0x00: { - snprintf((char*)status->c_str(), BASIC, "No indication"); + status->assign("No indication"); break; } case 0x01: { - snprintf((char*)status->c_str(), BASIC, "No advanced background operation being performed"); + status->assign("No advanced background operation being performed"); break; } case 0x02: { - snprintf((char*)status->c_str(), BASIC, "Host initiated advanced background operation being performed"); + status->assign("Host initiated advanced background operation being performed"); break; } case 0x03: { - snprintf((char*)status->c_str(), BASIC, "Device initiated advanced background operation being performed"); + status->assign("Device initiated advanced background operation being performed"); break; } default: { - snprintf((char*)status->c_str(), BASIC, "reserved"); + status->assign("reserved"); break; } } @@ -167,28 +167,29 @@ void CScsiOperationLog::get_Background_Operations_status(std::string *status) //! \return none // //--------------------------------------------------------------------------- -void CScsiOperationLog::process_Background_Operations_Data(JSONNODE *operationData) +void CScsiOperationLog::process_Background_Operations_Data(JSONNODE *operationData, M_ATTR_UNUSED uint32_t offset) { std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Cache Event Description \n"); #endif byte_Swap_16(&m_Operation->paramCode); - snprintf((char*)myStr.c_str(), BASIC, "Background Operation Description %" PRId16"", m_Operation->paramCode); + std::ostringstream temp; + temp << "Background Operation Description " << std::dec << m_Operation->paramCode; JSONNODE *operationInfo = json_new(JSON_NODE); - json_set_name(operationInfo, (char*)myStr.c_str()); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_Operation->paramCode); - json_push_back(operationInfo, json_new_a("Background Operation Parameter Code", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Operation->paramControlByte); - json_push_back(operationInfo, json_new_a("Background Operation Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Operation->paramLength); - json_push_back(operationInfo, json_new_a("Background Operation Length ", (char*)myStr.c_str())); + json_set_name(operationInfo, temp.str().c_str()); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_Operation->paramCode; + json_push_back(operationInfo, json_new_a("Background Operation Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Operation->paramControlByte); + json_push_back(operationInfo, json_new_a("Background Operation Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Operation->paramLength); + json_push_back(operationInfo, json_new_a("Background Operation Length ", temp.str().c_str())); get_Background_Operations_status(&myStr); - json_push_back(operationInfo, json_new_i((char*)myStr.c_str(), static_cast(m_Operation->bo_Status))); + json_push_back(operationInfo, json_new_i(myStr.c_str(), static_cast(m_Operation->bo_Status))); json_push_back(operationData, operationInfo); } @@ -214,13 +215,13 @@ eReturnValues CScsiOperationLog::get_Background_Operations_Data(JSONNODE *master JSONNODE *pageInfo = json_new(JSON_NODE); json_set_name(pageInfo, "Background Operation Log - 15h"); - for (size_t offset = 0; offset < m_PageLength; ) + for (uint32_t offset = 0; offset < m_PageLength; ) { if (offset < m_bufferLength && offset < UINT16_MAX) { - m_Operation = (sOperationParams *)&pData[offset]; + m_Operation = reinterpret_cast(&pData[offset]); + process_Background_Operations_Data(pageInfo,offset); offset += sizeof(sOperationParams); - process_Background_Operations_Data(pageInfo); } else { diff --git a/src/CScsi_Background_Scan_Log.cpp b/src/CScsi_Background_Scan_Log.cpp index 326156e..b2593c7 100644 --- a/src/CScsi_Background_Scan_Log.cpp +++ b/src/CScsi_Background_Scan_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Background_Scan_Log.cpp Definition of Background Scan Log Page // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -74,7 +74,7 @@ CScsiScanLog::CScsiScanLog(uint8_t * buffer, size_t bufferSize, uint16_t pageLen printf("%s \n", m_ScanName.c_str()); } pData = new uint8_t[pageLength]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, buffer, pageLength); #else memcpy_s(pData, bufferSize, buffer, pageLength);// copy the buffer data to the class member pBuf @@ -132,52 +132,52 @@ void CScsiScanLog::get_Scan_Status_Description(std::string *scan) { case 0x00: { - snprintf((char*)scan->c_str(), BASIC, "No background scans active"); + scan->assign("No background scans active"); break; } case 0x01: { - snprintf((char*)scan->c_str(), BASIC, "Background medium scan is active"); + scan->assign("Background medium scan is active"); break; } case 0x02: { - snprintf((char*)scan->c_str(), BASIC, "Background prescan is active"); + scan->assign("Background prescan is active"); break; } case 0x03: { - snprintf((char*)scan->c_str(), BASIC, "Background medium scan halted due to fatal error"); + scan->assign("Background medium scan halted due to fatal error"); break; } case 0x04: { - snprintf((char*)scan->c_str(), BASIC, "Background medium scan halted due to a vendor specific pattern of errors"); + scan->assign("Background medium scan halted due to a vendor specific pattern of errors"); break; } case 0x05: { - snprintf((char*)scan->c_str(), BASIC, "Background medium scan halted due to medium formatted without Plist"); + scan->assign("Background medium scan halted due to medium formatted without Plist"); break; } case 0x06: { - snprintf((char*)scan->c_str(), BASIC, "Background medium scan halted - vendor specific cause"); + scan->assign("Background medium scan halted - vendor specific cause"); break; } case 0x07: { - snprintf((char*)scan->c_str(), BASIC, "Background medium scan halted due to temperature out of allowed range"); + scan->assign("Background medium scan halted due to temperature out of allowed range"); break; } case 0x08: { - snprintf((char*)scan->c_str(), BASIC, "Background medium scan halted, waiting for Background Medium Interval timer expiration"); + scan->assign("Background medium scan halted, waiting for Background Medium Interval timer expiration"); break; } default: { - snprintf((char*)scan->c_str(), BASIC, "Reserved"); + scan->assign("Reserved"); break; } } @@ -197,27 +197,28 @@ void CScsiScanLog::get_Scan_Status_Description(std::string *scan) //--------------------------------------------------------------------------- void CScsiScanLog::process_Scan_Status_Data(JSONNODE *scanData) { - std::string myStr = ""; - myStr.resize(BASIC); + std::string myStr; #if defined _DEBUG printf("Background Scan Status Description \n"); #endif byte_Swap_16(&m_ScanParam->paramCode); - snprintf((char*)myStr.c_str(), BASIC, "Background Scan Status"); JSONNODE *statusInfo = json_new(JSON_NODE); - json_set_name(statusInfo, (char*)myStr.c_str()); + json_set_name(statusInfo, "Background Scan Status"); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_ScanParam->paramCode); - json_push_back(statusInfo, json_new_a("Background Scan Status Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_ScanParam->paramControlByte); - json_push_back(statusInfo, json_new_a("Background Scan Status Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_ScanParam->paramLength); - json_push_back(statusInfo, json_new_a("Background Scan Status Length ", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_ScanParam->paramCode; + json_push_back(statusInfo, json_new_a("Background Scan Status Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_ScanParam->paramControlByte); + json_push_back(statusInfo, json_new_a("Background Scan Status Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_ScanParam->paramLength); + json_push_back(statusInfo, json_new_a("Background Scan Status Length ", temp.str().c_str())); byte_Swap_32(&m_ScanParam->timeStamp); json_push_back(statusInfo, json_new_i("SMART Time Stamp", static_cast(m_ScanParam->timeStamp))); get_Scan_Status_Description(&myStr); - json_push_back(statusInfo, json_new_i((char*)myStr.c_str(), static_cast(m_ScanParam->status))); + json_push_back(statusInfo, json_new_i(myStr.c_str(), static_cast(m_ScanParam->status))); byte_Swap_16(&m_ScanParam->scansPerformed); json_push_back(statusInfo, json_new_i("Number of Background Scans Performed", static_cast(m_ScanParam->scansPerformed))); byte_Swap_16(&m_ScanParam->mediumProgress); @@ -248,47 +249,47 @@ void CScsiScanLog::get_Scan_Defect_Status_Description(std::string *defect) { case 0x01: { - snprintf((char*)defect->c_str(), BASIC, "The LBA has not yet been reassigned"); + defect->assign("The LBA has not yet been reassigned"); break; } case 0x02: { - snprintf((char*)defect->c_str(), BASIC, "Performed Automatic Read Reassignment for the LBA"); + defect->assign("Performed Automatic Read Reassignment for the LBA"); break; } case 0x03: { - snprintf((char*)defect->c_str(), BASIC, "Reserved"); + defect->assign("Reserved"); break; } case 0x04: { - snprintf((char*)defect->c_str(), BASIC, "Attempt to Perform Automatic Read Reassignment Failed"); + defect->assign("Attempt to Perform Automatic Read Reassignment Failed"); break; } case 0x05: { - snprintf((char*)defect->c_str(), BASIC, "Error Corrected, Device rewriting the LBA without Performing Reassign Operation."); + defect->assign("Error Corrected, Device rewriting the LBA without Performing Reassign Operation."); break; } case 0x06: { - snprintf((char*)defect->c_str(), BASIC, "Application Client caused automatic write reassignment for the LBA or LBPRZ"); + defect->assign("Application Client caused automatic write reassignment for the LBA or LBPRZ"); break; } case 0x07: { - snprintf((char*)defect->c_str(), BASIC, "Application Client, Reassign by Command - Invalid Data"); + defect->assign("Application Client, Reassign by Command - Invalid Data"); break; } case 0x08: { - snprintf((char*)defect->c_str(), BASIC, "Application Client, Reassign Command Failed"); + defect->assign("Application Client, Reassign Command Failed"); break; } default: { - snprintf((char*)defect->c_str(), BASIC, "Reserved"); + defect->assign("Reserved"); break; } } @@ -308,55 +309,64 @@ void CScsiScanLog::get_Scan_Defect_Status_Description(std::string *defect) //--------------------------------------------------------------------------- void CScsiScanLog::process_Defect_Data(JSONNODE *defectData) { - std::string myStr = ""; - myStr.resize(BASIC); std::string headerStr = ""; - headerStr.resize(BASIC); + std::ostringstream temp; #if defined _DEBUG printf("Background Scan Defect Description \n"); #endif byte_Swap_16(&m_defect->paramCode); - snprintf((char*)myStr.c_str(), BASIC, "Background Scan Defect Location 0x%" PRIX16"", m_defect->paramCode);; + temp << "Background Scan Defect Location 0x" << std::hex << m_defect->paramCode; JSONNODE *defectInfo = json_new(JSON_NODE); - json_set_name(defectInfo, (char*)myStr.c_str()); + json_set_name(defectInfo, temp.str().c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_defect->paramCode); - json_push_back(defectInfo, json_new_a("Background Scan Defect Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_defect->paramControlByte); - json_push_back(defectInfo, json_new_a("Background Scan Defect Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_defect->paramLength); - json_push_back(defectInfo, json_new_a("Background Scan Defect Length ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_defect->paramCode; + json_push_back(defectInfo, json_new_a("Background Scan Defect Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_defect->paramControlByte); + json_push_back(defectInfo, json_new_a("Background Scan Defect Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_defect->paramLength); + json_push_back(defectInfo, json_new_a("Background Scan Defect Length ", temp.str().c_str())); byte_Swap_32(&m_defect->powerOnMinutes); json_push_back(defectInfo, json_new_i("Power On Minutes", static_cast(m_defect->powerOnMinutes))); //Nayana: Need not print the Scan status here as already printed in process_Scan_Status_Data //get_Scan_Status_Description(&myStr); - //json_push_back(defectInfo, json_new_i((char*)myStr.c_str(), static_cast(m_ScanParam->status))); + //json_push_back(defectInfo, json_new_i(myStr.c_str(), static_cast(m_ScanParam->status))); get_Scan_Defect_Status_Description(&headerStr); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", (uint8_t)M_GETBITRANGE(m_defect->status,7, 4)); - json_push_back(defectInfo, json_new_a((char*)headerStr.c_str(), (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", (uint8_t)M_GETBITRANGE(m_defect->status,3, 0)); - json_push_back(defectInfo, json_new_a("Sense Key", (char*)myStr.c_str())); + temp.str("");temp.clear(); + + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(M_GETBITRANGE(m_defect->status,7, 4)); + json_push_back(defectInfo, json_new_a(headerStr.c_str(), temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(M_GETBITRANGE(m_defect->status,3, 0)); + json_push_back(defectInfo, json_new_a("Sense Key", temp.str().c_str())); //json_push_back(defectInfo, json_new_i("Additional Sense Code", static_cast(m_defect->senseCode))); //json_push_back(defectInfo, json_new_i("Additional Sense Code Qualifier", static_cast(m_defect->codeQualifier))); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_defect->senseCode); - json_push_back(defectInfo, json_new_a("Additional Sense Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_defect->codeQualifier); - json_push_back(defectInfo, json_new_a("Additional Sense Code Qualifier", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_defect->vendorSpecific); - json_push_back(defectInfo, json_new_a("Vendor Specific", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_defect->vendorSpecific1); - json_push_back(defectInfo, json_new_a("Vendor Specific 1", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_defect->vendorSpecific2); - json_push_back(defectInfo, json_new_a("Vendor Specific 2", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_defect->senseCode); + json_push_back(defectInfo, json_new_a("Additional Sense Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_defect->codeQualifier); + json_push_back(defectInfo, json_new_a("Additional Sense Code Qualifier", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_defect->vendorSpecific; + json_push_back(defectInfo, json_new_a("Vendor Specific", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_defect->vendorSpecific1; + json_push_back(defectInfo, json_new_a("Vendor Specific 1", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_defect->vendorSpecific2); + json_push_back(defectInfo, json_new_a("Vendor Specific 2", temp.str().c_str())); byte_Swap_64(&m_defect->LBA); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu64"", m_defect->LBA); - json_push_back(defectInfo, json_new_a("Logical Block Address", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::dec << m_defect->LBA; + json_push_back(defectInfo, json_new_a("Logical Block Address", temp.str().c_str())); json_push_back(defectData, defectInfo); } @@ -376,24 +386,23 @@ void CScsiScanLog::process_Defect_Data(JSONNODE *defectData) //--------------------------------------------------------------------------- void CScsiScanLog::process_other_param_data(JSONNODE *scanData, size_t offset) { - std::string myStr = ""; - myStr.resize(BASIC); - std::string headerStr = ""; - headerStr.resize(BASIC); #if defined _DEBUG printf("Background Scan Defect Description \n"); #endif byte_Swap_16(&m_ParamHeader->paramCode); - snprintf((char*)myStr.c_str(), BASIC, "Background Scan Defect Location 0x%04" PRIX16"", m_ParamHeader->paramCode); + std::ostringstream temp; + temp << "Background Scan Defect Location 0x" << std::hex << std::uppercase << std::setfill('0') << m_ParamHeader->paramCode; JSONNODE *defectInfo = json_new(JSON_NODE); - json_set_name(defectInfo, (char*)myStr.c_str()); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_ParamHeader->paramCode); - json_push_back(defectInfo, json_new_a("Background Scan Defect Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_ParamHeader->paramControlByte); - json_push_back(defectInfo, json_new_a("Background Scan Defect Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_ParamHeader->paramLength); - json_push_back(defectInfo, json_new_a("Background Scan Defect Length ", (char*)myStr.c_str())); + json_set_name(defectInfo, temp.str().c_str()); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_ParamHeader->paramCode; + json_push_back(defectInfo, json_new_a("Background Scan Defect Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_ParamHeader->paramControlByte); + json_push_back(defectInfo, json_new_a("Background Scan Defect Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_ParamHeader->paramLength); + json_push_back(defectInfo, json_new_a("Background Scan Defect Length ", temp.str().c_str())); JSONNODE *myArray = json_new(JSON_ARRAY); json_set_name(myArray, ("Background Data")); // add the size of the param header @@ -427,35 +436,38 @@ eReturnValues CScsiScanLog::get_Scan_Data(JSONNODE *masterData) { JSONNODE *pageInfo = json_new(JSON_NODE); json_set_name(pageInfo, "Background Scan Log - 15h"); - m_ScanParam = (sScanStatusParams *)&pData[0]; + m_ScanParam = reinterpret_cast(&pData[0]); process_Scan_Status_Data(pageInfo); - for (size_t offset = ((size_t)m_ScanParam->paramLength + 4); offset < (((size_t)m_PageLength) - sizeof(sScanFindingsParams)); ) - { - if (offset < m_bufferLength && offset < UINT16_MAX) - { - uint16_t paramCode = *(reinterpret_cast(&pData[offset])); - byte_Swap_16(¶mCode); - if (paramCode >= 0x0001 && paramCode <= 0x0800) + if ((m_ScanParam->paramLength + 4) < m_PageLength) + { + for (size_t offset = (static_cast(m_ScanParam->paramLength) + PARAMSIZE); offset < ((static_cast(m_PageLength)) - sizeof(sScanFindingsParams)); ) + { + if (offset < m_bufferLength && offset < UINT16_MAX) { - m_defect = (sScanFindingsParams *)&pData[offset]; - process_Defect_Data(pageInfo); - //offset += sizeof(sScanFindingsParams); - offset += m_defect->paramLength + 4; + uint16_t paramCode = *(reinterpret_cast(&pData[offset])); + byte_Swap_16(¶mCode); + if (paramCode >= 0x0001 && paramCode <= 0x0800) + { + m_defect = reinterpret_cast(&pData[offset]); + process_Defect_Data(pageInfo); + //offset += sizeof(sScanFindingsParams); + offset += m_defect->paramLength + PARAMSIZE; + } + else //if (paramCode >= 0x8000) //TODO: Nayana to check with Tim how to skip ssd part here + { + m_ParamHeader = reinterpret_cast(&pData[offset]); + process_other_param_data(pageInfo, offset); + offset += m_ParamHeader->paramLength + PARAMSIZE; + } } - else //if (paramCode >= 0x8000) //TODO: Nayana to check with Tim how to skip ssd part here + else { - m_ParamHeader = (sBackgroundScanParamHeader*)&pData[offset]; - process_other_param_data(pageInfo,offset); - offset += m_ParamHeader->paramLength + 4; - } - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } - } + } + } json_push_back(masterData, pageInfo); retStatus = SUCCESS; @@ -465,4 +477,4 @@ eReturnValues CScsiScanLog::get_Scan_Data(JSONNODE *masterData) retStatus = MEMORY_FAILURE; } return retStatus; -} \ No newline at end of file +} diff --git a/src/CScsi_Cache_Statistics_Log.cpp b/src/CScsi_Cache_Statistics_Log.cpp index cba3be0..a98960c 100644 --- a/src/CScsi_Cache_Statistics_Log.cpp +++ b/src/CScsi_Cache_Statistics_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Cache_Statistics_Log.cpp Definition of Cache Statistics page for SAS // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -30,18 +30,18 @@ using namespace opensea_parser; // //--------------------------------------------------------------------------- CScsiCacheLog::CScsiCacheLog() - : pData() - , m_CacheName("Cache Statistics Log") - , m_CacheStatus(IN_PROGRESS) - , m_PageLength(0) - , m_bufferLength() - , m_Value(0) - , m_cache() + : pData() + , m_CacheName("Cache Statistics Log") + , m_CacheStatus(IN_PROGRESS) + , m_PageLength(0) + , m_bufferLength() + , m_Value(0) + , m_cache() { - if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) - { - printf("%s \n", m_CacheName.c_str()); - } + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_CacheName.c_str()); + } } //----------------------------------------------------------------------------- // @@ -59,26 +59,26 @@ CScsiCacheLog::CScsiCacheLog() // //--------------------------------------------------------------------------- CScsiCacheLog::CScsiCacheLog(uint8_t * buffer, size_t bufferSize, uint16_t pageLength) - : pData(buffer) - , m_CacheName("Cache Statistics Log") - , m_CacheStatus(IN_PROGRESS) - , m_PageLength(pageLength) - , m_bufferLength(bufferSize) - , m_Value(0) - , m_cache() + : pData(buffer) + , m_CacheName("Cache Statistics Log") + , m_CacheStatus(IN_PROGRESS) + , m_PageLength(pageLength) + , m_bufferLength(bufferSize) + , m_Value(0) + , m_cache() { - if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) - { - printf("%s \n", m_CacheName.c_str()); - } - if (buffer != NULL) - { - m_CacheStatus = IN_PROGRESS; - } - else - { - m_CacheStatus = FAILURE; - } + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_CacheName.c_str()); + } + if (buffer != NULL) + { + m_CacheStatus = IN_PROGRESS; + } + else + { + m_CacheStatus = FAILURE; + } } @@ -117,44 +117,46 @@ CScsiCacheLog::~CScsiCacheLog() bool CScsiCacheLog::get_Cache_Parameter_Code_Description(std::string *cache) { bool descriptionFound = false; - switch (m_cache->paramCode) - { - case 0x0000: - { - snprintf((char*)cache->c_str(), BASIC, "Number of logical blocks that have been Sent"); + switch (m_cache->paramCode) + { + case 0x0000: + { + *cache = "Number of logical blocks that have been Sent"; descriptionFound = true; - break; - } - case 0x0001: - { - snprintf((char*)cache->c_str(), BASIC, "Number of logical blocks that have been Received"); + break; + } + case 0x0001: + { + *cache = "Number of logical blocks that have been Received"; descriptionFound = true; - break; - } - case 0x0002: - { - snprintf((char*)cache->c_str(), BASIC, "Number of logical blocks READ from the Cache Memory"); + break; + } + case 0x0002: + { + *cache = "Number of logical blocks READ from the Cache Memory"; descriptionFound = true; - break; - } - case 0x0003: - { - snprintf((char*)cache->c_str(), BASIC, "Number of READ and WRITE Commands lengths equal or less than the current segment size"); + break; + } + case 0x0003: + { + *cache = "# of R and W Commands lengths equal or less than the current segment size"; descriptionFound = true; - break; - } - case 0x0004: - { - snprintf((char*)cache->c_str(), BASIC, "Number of READ and WRITE Commands lengths greater than the current segment size"); + break; + } + case 0x0004: + { + *cache = "# of READ and WRITE Commands lengths greater than the current segment size"; descriptionFound = true; - break; - } - default: - { - snprintf((char*)cache->c_str(), BASIC, "Vendor specific 0x%04" PRIx16"", m_cache->paramCode); - break; - } - } + break; + } + default: + { + std::ostringstream temp; + temp << "Vendor specific 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_cache->paramCode; + cache->assign(temp.str()); + break; + } + } return descriptionFound; } //----------------------------------------------------------------------------- @@ -173,31 +175,29 @@ bool CScsiCacheLog::get_Cache_Parameter_Code_Description(std::string *cache) //--------------------------------------------------------------------------- void CScsiCacheLog::process_Cache_Event_Data(JSONNODE *cacheData) { - bool discriptionIsFound = false; - std::string myStr = ""; - myStr.resize(BASIC); + std::string myStr; #if defined _DEBUG - printf("Cache Event Description \n"); + printf("Cache Event Description \n"); #endif if (m_Value != 0) { byte_Swap_16(&m_cache->paramCode); - discriptionIsFound = get_Cache_Parameter_Code_Description(&myStr); - //snprintf((char*)myStr.c_str(), BASIC, "Cache Statistics Description %" PRId16"", m_cache->paramCode); + bool discriptionIsFound = get_Cache_Parameter_Code_Description(&myStr); JSONNODE *cacheInfo = json_new(JSON_NODE); - json_set_name(cacheInfo, (char*)myStr.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_cache->paramCode); - json_push_back(cacheInfo, json_new_a("Cache Statistics Parameter Code", (char*)myStr.c_str())); + json_set_name(cacheInfo, myStr.c_str()); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_cache->paramCode; + json_push_back(cacheInfo, json_new_a("Cache Statistics Parameter Code", temp.str().c_str())); if (!discriptionIsFound) { - + temp.str("");temp.clear(); - //json_push_back(cacheInfo, json_new_a("Cache Statistics Description", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_cache->paramControlByte); - json_push_back(cacheInfo, json_new_a("Cache Statistics Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_cache->paramLength); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_cache->paramControlByte); + json_push_back(cacheInfo, json_new_a("Cache Statistics Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_cache->paramLength); - json_push_back(cacheInfo, json_new_a("Cache Statistics Length ", (char*)myStr.c_str())); + json_push_back(cacheInfo, json_new_a("Cache Statistics Length ", temp.str().c_str())); } set_json_64bit(cacheInfo, "Cache Statistics Value", m_Value, false); @@ -220,99 +220,98 @@ void CScsiCacheLog::process_Cache_Event_Data(JSONNODE *cacheData) //--------------------------------------------------------------------------- eReturnValues CScsiCacheLog::get_Cache_Data(JSONNODE *masterData) { - eReturnValues retStatus = IN_PROGRESS; - if (pData != NULL) - { - JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, "Cache Statistics Log - 37h"); + eReturnValues retStatus = IN_PROGRESS; + if (pData != NULL) + { + JSONNODE *pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, "Cache Statistics Log - 37h"); + + for (size_t offset = 0; offset < m_PageLength; ) + { + if (offset < m_bufferLength && offset < UINT16_MAX) + { + m_cache = reinterpret_cast(&pData[offset]); + offset += sizeof(sCacheParams); + switch (m_cache->paramLength) + { + case 1: + { + if ((offset + m_cache->paramLength) < m_bufferLength) + { + m_Value = pData[offset]; + offset += m_cache->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 2: + { + if ((offset + m_cache->paramLength) < m_bufferLength) + { + m_Value = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); + offset += m_cache->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 4: + { + if ((offset + m_cache->paramLength) < m_bufferLength) + { + m_Value = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); + offset += m_cache->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 8: + { + if ((offset + m_cache->paramLength) < m_bufferLength) + { + m_Value = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); + offset += m_cache->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + default: + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + } + process_Cache_Event_Data(pageInfo); + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } - for (size_t offset = 0; offset < m_PageLength; ) - { - if (offset < m_bufferLength && offset < UINT16_MAX) - { - m_cache = (sCacheParams *)&pData[offset]; - offset += sizeof(sCacheParams); - switch (m_cache->paramLength) - { - case 1: - { - if ((offset + m_cache->paramLength) < m_bufferLength) - { - m_Value = pData[offset]; - offset += m_cache->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 2: - { - if ((offset + m_cache->paramLength) < m_bufferLength) - { - m_Value = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); - offset += m_cache->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 4: - { - if ((offset + m_cache->paramLength) < m_bufferLength) - { - m_Value = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); - offset += m_cache->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 8: - { - if ((offset + m_cache->paramLength) < m_bufferLength) - { - m_Value = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); - offset += m_cache->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - default: - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - break; - } - } - process_Cache_Event_Data(pageInfo); - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - - } + } - json_push_back(masterData, pageInfo); - retStatus = SUCCESS; - } - else - { - retStatus = MEMORY_FAILURE; - } - return retStatus; + json_push_back(masterData, pageInfo); + retStatus = SUCCESS; + } + else + { + retStatus = MEMORY_FAILURE; + } + return retStatus; } \ No newline at end of file diff --git a/src/CScsi_Environmental_Logs.cpp b/src/CScsi_Environmental_Logs.cpp index e375b13..8af8597 100644 --- a/src/CScsi_Environmental_Logs.cpp +++ b/src/CScsi_Environmental_Logs.cpp @@ -2,7 +2,7 @@ // CScsi_Environmental_Logs.cpp Implementation of CScsi Environmental Log class // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -33,6 +33,8 @@ CScsiEnvironmentLog::CScsiEnvironmentLog() : CScsiTemperatureLog() , m_EvnName("Environmnetal Log") , m_EnvStatus(IN_PROGRESS) + , m_PageLength(0) + , m_SubPage(0) { if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { @@ -58,6 +60,7 @@ CScsiEnvironmentLog::CScsiEnvironmentLog(uint8_t *bufferData, size_t bufferSize, :CScsiTemperatureLog(&bufferData[4], bufferSize) , m_EvnName("Environmnetal Log") , m_EnvStatus(IN_PROGRESS) + , m_PageLength(0) , m_SubPage(subPage) { if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) @@ -67,9 +70,9 @@ CScsiEnvironmentLog::CScsiEnvironmentLog(uint8_t *bufferData, size_t bufferSize, if (bufferData != NULL) { pData = bufferData; - m_Page = (sLogPageStruct *)bufferData; // set a buffer to the point to the log page info + m_Page = reinterpret_cast(bufferData); // set a buffer to the point to the log page info m_PageLength = m_Page->pageLength; - byte_Swap_16(&m_PageLength); // get the length of the page and byte swap it + //byte_Swap_16(&m_PageLength); // get the length of the page and byte swap it m_EnvStatus = figureout_What_Log_To_Parsed(masterData); // init the data for getting the log } else diff --git a/src/CScsi_Error_Counter_Log.cpp b/src/CScsi_Error_Counter_Log.cpp index 79237ad..fe49c7d 100644 --- a/src/CScsi_Error_Counter_Log.cpp +++ b/src/CScsi_Error_Counter_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Error_Counter_Log.cpp Definition of Error Counter for READ WRITE VERIFY ERRORS // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -30,19 +30,19 @@ using namespace opensea_parser; // //--------------------------------------------------------------------------- CScsiErrorCounterLog::CScsiErrorCounterLog() - : pData() - , m_ErrorName("Error Counter Log") - , m_ErrorStatus(IN_PROGRESS) - , m_PageLength(0) - , m_bufferLength(0) - , m_ErrorValue(0) - , m_Error() - , m_pageType(WRITE) + : pData() + , m_ErrorName("Error Counter Log") + , m_ErrorStatus(IN_PROGRESS) + , m_PageLength(0) + , m_bufferLength(0) + , m_ErrorValue(0) + , m_Error() + , m_pageType(WRITE) { - if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) - { - printf("%s \n", m_ErrorName.c_str()); - } + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_ErrorName.c_str()); + } } //----------------------------------------------------------------------------- // @@ -61,34 +61,34 @@ CScsiErrorCounterLog::CScsiErrorCounterLog() // //--------------------------------------------------------------------------- CScsiErrorCounterLog::CScsiErrorCounterLog(uint8_t * buffer, size_t bufferSize, uint16_t pageLength, uint8_t type) - : pData(buffer) - , m_ErrorName("Error Counter Log") - , m_ErrorStatus(IN_PROGRESS) - , m_PageLength(pageLength) - , m_bufferLength(bufferSize) - , m_ErrorValue(0) - , m_Error() - , m_pageType(type) + : pData(buffer) + , m_ErrorName("Error Counter Log") + , m_ErrorStatus(IN_PROGRESS) + , m_PageLength(pageLength) + , m_bufferLength(bufferSize) + , m_ErrorValue(0) + , m_Error() + , m_pageType(type) { - if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) - { - printf("%s \n", m_ErrorName.c_str()); - } - if (buffer != NULL) - { - if (m_pageType == WRITE || m_pageType == READ || m_pageType == VERIFY) - { - m_ErrorStatus = IN_PROGRESS; - } - else - { - m_ErrorStatus = BAD_PARAMETER; - } - } - else - { - m_ErrorStatus = FAILURE; - } + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_ErrorName.c_str()); + } + if (buffer != NULL) + { + if (m_pageType == WRITE || m_pageType == READ || m_pageType == VERIFY) + { + m_ErrorStatus = IN_PROGRESS; + } + else + { + m_ErrorStatus = BAD_PARAMETER; + } + } + else + { + m_ErrorStatus = FAILURE; + } } @@ -127,27 +127,29 @@ CScsiErrorCounterLog::~CScsiErrorCounterLog() //--------------------------------------------------------------------------- void CScsiErrorCounterLog::append_Error_Log_Page_Number(std::string *typeStr, std::string main) { + std::ostringstream temp; switch (m_pageType) { case 0x02: { - snprintf((char*)typeStr->c_str(), BASIC, "%s - %s", (char*)main.c_str(), "02h");// WRITE + temp << main << "02h";// WRITE break; } case 0x03: { - snprintf((char*)typeStr->c_str(), BASIC, "%s - %s", (char*)main.c_str(), "03h"); // READ + temp << main << "03h"; // READ break; } case 0x05: { - snprintf((char*)typeStr->c_str(), BASIC, "%s - %s", (char*)main.c_str(), "05h"); // VERIFY + temp << main << "05h"; // VERIFY break; } default: - snprintf((char*)typeStr->c_str(), BASIC, "%s - %s", (char*)main.c_str(), "03h"); ///READ + temp << main << "03h"; //READ break; } + typeStr->assign(temp.str()); } //----------------------------------------------------------------------------- // @@ -166,27 +168,29 @@ void CScsiErrorCounterLog::append_Error_Log_Page_Number(std::string *typeStr, st //--------------------------------------------------------------------------- void CScsiErrorCounterLog::set_Master_String(std::string *typeStr, std::string main) { - switch (m_pageType) - { - case 0x02: - { - snprintf((char*)typeStr->c_str(), BASIC, "%s %s", "WRITE", (char*)main.c_str()); - break; - } - case 0x03: - { - snprintf((char*)typeStr->c_str(), BASIC, "%s %s", "READ", (char*)main.c_str()); - break; - } - case 0x05: - { - snprintf((char*)typeStr->c_str(), BASIC, "%s %s", "VERIFY", (char*)main.c_str()); - break; - } - default: - snprintf((char*)typeStr->c_str(), BASIC, "%s %s", "READ", (char*)main.c_str()); - break; - } + std::ostringstream temp; + switch (m_pageType) + { + case 0x02: + { + temp << "WRITE" << main; + break; + } + case 0x03: + { + temp << "READ" << main; + break; + } + case 0x05: + { + temp << "VERIFY" << main; + break; + } + default: + temp << "READ" << main; + break; + } + typeStr->assign(temp.str()); } //----------------------------------------------------------------------------- // @@ -205,56 +209,58 @@ void CScsiErrorCounterLog::set_Master_String(std::string *typeStr, std::string m bool CScsiErrorCounterLog::get_Error_Parameter_Code_Description(std::string *error) { bool descriptionFound = false; - switch (m_Error->paramCode) - { - case 0x0000: - { - snprintf((char*)error->c_str(), BASIC, "Corrected Without Substantial Delay"); - descriptionFound = true; - break; - } - case 0x0001: - { - snprintf((char*)error->c_str(), BASIC, "Corrected With Possible Delay"); - descriptionFound = true; - break; - } - case 0x0002: - { - snprintf((char*)error->c_str(), BASIC, "Number of Errors that are Corrected by Applying Retries"); - descriptionFound = true; - break; - } - case 0x0003: - { - snprintf((char*)error->c_str(), BASIC, "Total Number of Errors Corrected"); - descriptionFound = true; - break; - } - case 0x0004: - { - snprintf((char*)error->c_str(), BASIC, "Total Times Correction Algorithm Processed"); - descriptionFound = true; - break; - } - case 0x0005: - { - snprintf((char*)error->c_str(), BASIC, "Total Bytes Processed"); - descriptionFound = true; - break; - } - case 0x0006: - { - snprintf((char*)error->c_str(), BASIC, "Total Uncorrected Errors"); - descriptionFound = true; - break; - } - default: - { - snprintf((char*)error->c_str(), BASIC, "Vendor Specific 0x%04" PRIx16"", m_Error->paramCode); - break; - } - } + switch (m_Error->paramCode) + { + case 0x0000: + { + error->assign("Corrected Without Substantial Delay"); + descriptionFound = true; + break; + } + case 0x0001: + { + error->assign("Corrected With Possible Delay"); + descriptionFound = true; + break; + } + case 0x0002: + { + error->assign("Number of Errors that are Corrected by Applying Retries"); + descriptionFound = true; + break; + } + case 0x0003: + { + error->assign("Total Number of Errors Corrected"); + descriptionFound = true; + break; + } + case 0x0004: + { + error->assign("Total Times Correction Algorithm Processed"); + descriptionFound = true; + break; + } + case 0x0005: + { + error->assign("Total Bytes Processed"); + descriptionFound = true; + break; + } + case 0x0006: + { + error->assign("Total Uncorrected Errors"); + descriptionFound = true; + break; + } + default: + { + std::ostringstream temp; + temp << "Vendor Specific 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw << m_Error->paramCode; + error->assign(temp.str()); + break; + } + } return descriptionFound; } //----------------------------------------------------------------------------- @@ -274,46 +280,45 @@ bool CScsiErrorCounterLog::get_Error_Parameter_Code_Description(std::string *err void CScsiErrorCounterLog::process_Error_Data(JSONNODE *errorData) { bool descriptionFound = false; - std::string myStr = ""; - myStr.resize(BASIC); - std::string myHeader = ""; - myHeader.resize(BASIC); + std::string myStr = ""; + std::string myHeader = ""; #if defined _DEBUG - printf("Error Counter Log \n"); + printf("Error Counter Log \n"); #endif - byte_Swap_16(&m_Error->paramCode); + byte_Swap_16(&m_Error->paramCode); descriptionFound = get_Error_Parameter_Code_Description(&myHeader); if (m_ErrorValue != 0) { set_Master_String(&myStr, myHeader); JSONNODE *errorInfo = json_new(JSON_NODE); - json_set_name(errorInfo, (char*)myStr.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_Error->paramCode); - json_push_back(errorInfo, json_new_a("Error Counter Code", (char*)myStr.c_str())); + json_set_name(errorInfo, myStr.c_str()); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_Error->paramCode; + json_push_back(errorInfo, json_new_a("Error Counter Code", temp.str().c_str())); if (!descriptionFound) { - - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Error->paramControlByte); - json_push_back(errorInfo, json_new_a("Error Counter Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Error->paramLength); - json_push_back(errorInfo, json_new_a("Error Counter Length ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Error->paramControlByte); + json_push_back(errorInfo, json_new_a("Error Counter Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Error->paramLength); + json_push_back(errorInfo, json_new_a("Error Counter Length ", temp.str().c_str())); } if (m_Error->paramLength == 8 || m_ErrorValue > UINT32_MAX) { set_json_64bit(errorInfo, "Error Count", m_ErrorValue, false); } else - { + { if (M_GETBITRANGE(m_ErrorValue, 33, 15) == 0) { json_push_back(errorInfo, json_new_i("Error Count", static_cast(m_ErrorValue))); } - else { - std::string printStr; - snprintf((char*)printStr.c_str(), BASIC, "%" PRIu32"", static_cast(m_ErrorValue)); - json_push_back(errorInfo, json_new_a((char *)myStr.c_str(), (char*)printStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(m_ErrorValue); + json_push_back(errorInfo, json_new_a(myStr.c_str(), temp.str().c_str())); } } @@ -336,105 +341,102 @@ void CScsiErrorCounterLog::process_Error_Data(JSONNODE *errorData) //--------------------------------------------------------------------------- eReturnValues CScsiErrorCounterLog::get_Error_Counter_Data(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); + std::string myStr = ""; std::string headerStr = ""; - headerStr.resize(BASIC); - eReturnValues retStatus = IN_PROGRESS; - if (pData != NULL) - { - set_Master_String(&headerStr, "Error Counter Log"); + eReturnValues retStatus = IN_PROGRESS; + if (pData != NULL) + { + set_Master_String(&headerStr, "Error Counter Log"); append_Error_Log_Page_Number(&myStr, headerStr); - JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, (char*)myStr.c_str()); + JSONNODE *pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, myStr.c_str()); - for (size_t offset = 0; offset < m_PageLength; ) - { - if (offset < m_bufferLength && offset < UINT16_MAX) - { - m_Error = (sErrorParams *)&pData[offset]; - offset += sizeof(sErrorParams); - switch (m_Error->paramLength) - { - case 1: - { - if ((offset + m_Error->paramLength) < m_bufferLength) - { - m_ErrorValue = pData[offset]; - offset += m_Error->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 2: - { - if ((offset + m_Error->paramLength) < m_bufferLength) - { - m_ErrorValue = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); - offset += m_Error->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 4: - { - if ((offset + m_Error->paramLength) < m_bufferLength) - { - m_ErrorValue = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); - offset += m_Error->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 8: - { - if ((offset + m_Error->paramLength) < m_bufferLength) - { - m_ErrorValue = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); - offset += m_Error->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - default: - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - break; - } - } - process_Error_Data(pageInfo); - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } + for (size_t offset = 0; offset < m_PageLength; ) + { + if (offset < m_bufferLength && offset < UINT16_MAX) + { + m_Error = reinterpret_cast(&pData[offset]); + offset += sizeof(sErrorParams); + switch (m_Error->paramLength) + { + case 1: + { + if ((offset + m_Error->paramLength) < m_bufferLength) + { + m_ErrorValue = pData[offset]; + offset += m_Error->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 2: + { + if ((offset + m_Error->paramLength) < m_bufferLength) + { + m_ErrorValue = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); + offset += m_Error->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 4: + { + if ((offset + m_Error->paramLength) < m_bufferLength) + { + m_ErrorValue = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); + offset += m_Error->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 8: + { + if ((offset + m_Error->paramLength) < m_bufferLength) + { + m_ErrorValue = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); + offset += m_Error->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + default: + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + } + process_Error_Data(pageInfo); + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } - } + } - json_push_back(masterData, pageInfo); - retStatus = SUCCESS; - } - else - { - retStatus = MEMORY_FAILURE; - } - return retStatus; + json_push_back(masterData, pageInfo); + retStatus = SUCCESS; + } + else + { + retStatus = MEMORY_FAILURE; + } + return retStatus; } \ No newline at end of file diff --git a/src/CScsi_Factory_Log.cpp b/src/CScsi_Factory_Log.cpp index ad39654..6f43907 100644 --- a/src/CScsi_Factory_Log.cpp +++ b/src/CScsi_Factory_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Factory_Log.cpp Definition of Factory Log page for SAS // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -30,18 +30,18 @@ using namespace opensea_parser; // //--------------------------------------------------------------------------- CScsiFactoryLog::CScsiFactoryLog() - : pData() - , m_FactoryName("Cache Statistics Log") - , m_FactoryStatus(IN_PROGRESS) - , m_PageLength(0) - , m_bufferLength() - , m_Value(0) - , m_factory() + : pData() + , m_FactoryName("Factory Log Page") + , m_FactoryStatus(IN_PROGRESS) + , m_PageLength(0) + , m_bufferLength() + , m_Value(0) + , m_factory() { - if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) - { - printf("%s \n", m_FactoryName.c_str()); - } + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_FactoryName.c_str()); + } } //----------------------------------------------------------------------------- // @@ -59,26 +59,26 @@ CScsiFactoryLog::CScsiFactoryLog() // //--------------------------------------------------------------------------- CScsiFactoryLog::CScsiFactoryLog(uint8_t * buffer, size_t bufferSize, uint16_t pageLength) - : pData(buffer) - , m_FactoryName("Cache Statistics Log") - , m_FactoryStatus(IN_PROGRESS) - , m_PageLength(pageLength) - , m_bufferLength(bufferSize) - , m_Value(0) - , m_factory() + : pData(buffer) + , m_FactoryName("Factory Log Page") + , m_FactoryStatus(IN_PROGRESS) + , m_PageLength(pageLength) + , m_bufferLength(bufferSize) + , m_Value(0) + , m_factory() { - if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) - { - printf("%s \n", m_FactoryName.c_str()); - } - if (buffer != NULL) - { - m_FactoryStatus = IN_PROGRESS; - } - else - { - m_FactoryStatus = FAILURE; - } + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_FactoryName.c_str()); + } + if (buffer != NULL) + { + m_FactoryStatus = IN_PROGRESS; + } + else + { + m_FactoryStatus = FAILURE; + } } @@ -116,25 +116,28 @@ CScsiFactoryLog::~CScsiFactoryLog() //--------------------------------------------------------------------------- void CScsiFactoryLog::process_Factorty_Data(JSONNODE *factoryData) { - std::string myStr = ""; - myStr.resize(BASIC); + std::string myStr = ""; if (m_Value != 0) { #if defined _DEBUG printf("Factory Description \n"); #endif byte_Swap_16(&m_factory->paramCode); - snprintf((char*)myStr.c_str(), BASIC, "Factory Description %" PRIu16"", m_factory->paramCode); + std::ostringstream temp; + temp << "Factory Description " << std::dec << m_factory->paramCode; JSONNODE *factoryInfo = json_new(JSON_NODE); - json_set_name(factoryInfo, (char*)myStr.c_str()); + json_set_name(factoryInfo, temp.str().c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_factory->paramCode); - json_push_back(factoryInfo, json_new_a("Factory Parameter Code", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_factory->paramCode; + json_push_back(factoryInfo, json_new_a("Factory Parameter Code", temp.str().c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_factory->paramControlByte); - json_push_back(factoryInfo, json_new_a("Factory Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_factory->paramLength); - json_push_back(factoryInfo, json_new_a("FactoryLength ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_factory->paramControlByte); + json_push_back(factoryInfo, json_new_a("Factory Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_factory->paramLength); + json_push_back(factoryInfo, json_new_a("FactoryLength ", temp.str().c_str())); if (m_factory->paramLength == 8 || m_Value > UINT32_MAX) { set_json_64bit(factoryInfo, "Factory value", m_Value, false); @@ -163,99 +166,98 @@ void CScsiFactoryLog::process_Factorty_Data(JSONNODE *factoryData) //--------------------------------------------------------------------------- eReturnValues CScsiFactoryLog::get_Factory_Data(JSONNODE *masterData) { - eReturnValues retStatus = IN_PROGRESS; - if (pData != NULL) - { - JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, "Factory Log - 3Eh"); + eReturnValues retStatus = IN_PROGRESS; + if (pData != NULL) + { + JSONNODE *pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, "Factory Log - 3Eh"); - for (size_t offset = 0; offset < m_PageLength; ) - { - if (offset < m_bufferLength && offset < UINT16_MAX) - { - m_factory = (sFactoryParams *)&pData[offset]; - offset += sizeof(sFactoryParams); - switch (m_factory->paramLength) - { - case 1: - { - if ((offset + m_factory->paramLength) < m_bufferLength) - { - m_Value = pData[offset]; - offset += m_factory->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 2: - { - if ((offset + m_factory->paramLength) < m_bufferLength) - { - m_Value = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); - offset += m_factory->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 4: - { - if ((offset + m_factory->paramLength) < m_bufferLength) - { - m_Value = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); - offset += m_factory->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - case 8: - { - if ((offset + m_factory->paramLength) < m_bufferLength) - { - m_Value = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); - offset += m_factory->paramLength; - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } - break; - } - default: - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - break; - } - } - process_Factorty_Data(pageInfo); - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } + for (size_t offset = 0; offset < m_PageLength; ) + { + if (offset < m_bufferLength && offset < UINT16_MAX) + { + m_factory = reinterpret_cast(&pData[offset]); + offset += LOGPAGESIZE; + switch (m_factory->paramLength) + { + case 1: + { + if ((offset + m_factory->paramLength) <= m_bufferLength) + { + m_Value = pData[offset]; + offset += m_factory->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 2: + { + if ((offset + m_factory->paramLength) <= m_bufferLength) + { + m_Value = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); + offset += m_factory->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 4: + { + if ((offset + m_factory->paramLength) <= m_bufferLength) + { + m_Value = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); + offset += m_factory->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + case 8: + { + if ((offset + m_factory->paramLength) <= m_bufferLength) + { + m_Value = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); + offset += m_factory->paramLength; + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + break; + } + default: + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + } + process_Factorty_Data(pageInfo); + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } - } + } - json_push_back(masterData, pageInfo); - retStatus = SUCCESS; - } - else - { - retStatus = MEMORY_FAILURE; - } - return retStatus; + json_push_back(masterData, pageInfo); + retStatus = SUCCESS; + } + else + { + retStatus = MEMORY_FAILURE; + } + return retStatus; } \ No newline at end of file diff --git a/src/CScsi_Format_Status_Log.cpp b/src/CScsi_Format_Status_Log.cpp index ee923da..2faee9e 100644 --- a/src/CScsi_Format_Status_Log.cpp +++ b/src/CScsi_Format_Status_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Format_Status_Log.cpp Format Status log page reports information about the most recent successful format operation // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -37,6 +37,7 @@ CScsiFormatStatusLog::CScsiFormatStatusLog() , m_bufferLength() , m_Value(0) , m_Format() + , m_FormatDataOutParamValue() { if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { @@ -66,6 +67,7 @@ CScsiFormatStatusLog::CScsiFormatStatusLog(uint8_t * buffer, size_t bufferSize, , m_bufferLength(bufferSize) , m_Value(0) , m_Format() + , m_FormatDataOutParamValue() { if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { @@ -120,32 +122,34 @@ void CScsiFormatStatusLog::get_Format_Parameter_Code_Description(std::string *va { case 0x0000: { - snprintf((char*)valueData->c_str(), BASIC, "Format Data Out count"); + valueData->assign("Format Data Out count"); break; } case 0x0001: { - snprintf((char*)valueData->c_str(), BASIC, "Grown Defects During Certification count"); + valueData->assign("Grown Defects During Certification count"); break; } case 0x0002: { - snprintf((char*)valueData->c_str(), BASIC, "Total Blocks Reassigned During Format count"); + valueData->assign("Total Blocks Reassigned During Format count"); break; } case 0x0003: { - snprintf((char*)valueData->c_str(), BASIC, "Total New Blocks Reassigned count"); + valueData->assign("Total New Blocks Reassigned count"); break; } case 0x0004: { - snprintf((char*)valueData->c_str(), BASIC, "Power On Minutes Since Format count"); + valueData->assign("Power On Minutes Since Format count"); break; } default: { - snprintf((char*)valueData->c_str(), BASIC, "Vendor Specific 0x%04" PRIx16"", m_Format->paramCode); + std::ostringstream temp; + temp << "Vendor Specific 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_Format->paramCode; + valueData->assign(temp.str()); break; } } @@ -166,10 +170,7 @@ void CScsiFormatStatusLog::get_Format_Parameter_Code_Description(std::string *va //--------------------------------------------------------------------------- void CScsiFormatStatusLog::process_Format_Status_Data(JSONNODE *formatData) { - std::string myStr = ""; - myStr.resize(BASIC); - std::string myHeader = ""; - myHeader.resize(BASIC); + std::string myHeader; #if defined _DEBUG printf("Format Status Log\n"); @@ -177,14 +178,17 @@ void CScsiFormatStatusLog::process_Format_Status_Data(JSONNODE *formatData) get_Format_Parameter_Code_Description(&myHeader); JSONNODE *formatInfo = json_new(JSON_NODE); - json_set_name(formatInfo, (char*)myHeader.c_str()); + json_set_name(formatInfo, myHeader.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_Format->paramCode); - json_push_back(formatInfo, json_new_a("Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Format->paramControlByte); - json_push_back(formatInfo, json_new_a("Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Format->paramLength); - json_push_back(formatInfo, json_new_a("Length ", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_Format->paramCode; + json_push_back(formatInfo, json_new_a("Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Format->paramControlByte); + json_push_back(formatInfo, json_new_a("Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Format->paramLength); + json_push_back(formatInfo, json_new_a("Length ", temp.str().c_str())); if (m_Format->paramLength == 8 || m_Value > UINT32_MAX) { set_json_64bit(formatInfo, "Value", m_Value, true); @@ -197,9 +201,9 @@ void CScsiFormatStatusLog::process_Format_Status_Data(JSONNODE *formatData) } else { - std::string printStr; - snprintf((char*)printStr.c_str(), BASIC, "0x%08" PRIx64"", m_Value); - json_push_back(formatInfo, json_new_a("Value", (char*)printStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << m_Value; + json_push_back(formatInfo, json_new_a("Value", temp.str().c_str())); } } json_push_back(formatData, formatInfo); @@ -220,53 +224,49 @@ void CScsiFormatStatusLog::process_Format_Status_Data(JSONNODE *formatData) //--------------------------------------------------------------------------- void CScsiFormatStatusLog::process_Format_Status_Data_Variable_Length(JSONNODE * formatData) { - std::string myStr = ""; - myStr.resize(BASIC); - std::string myHeader = ""; - myHeader.resize(BASIC); + std::string myHeader; #if defined _DEBUG printf("Format Status Log \n"); #endif get_Format_Parameter_Code_Description(&myHeader); JSONNODE *formatInfo = json_new(JSON_NODE); - json_set_name(formatInfo, (char*)myHeader.c_str()); + json_set_name(formatInfo, myHeader.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_Format->paramCode); - json_push_back(formatInfo, json_new_a("Format Status Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Format->paramControlByte); - json_push_back(formatInfo, json_new_a("Format Status Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Format->paramLength); - json_push_back(formatInfo, json_new_a("Format Status Length ", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_Format->paramCode; + json_push_back(formatInfo, json_new_a("Format Status Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Format->paramControlByte); + json_push_back(formatInfo, json_new_a("Format Status Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Format->paramLength); + json_push_back(formatInfo, json_new_a("Format Status Length ", temp.str().c_str())); uint8_t lineNumber = 0; - char *innerMsg = (char*)calloc(128, sizeof(char)); - char* innerStr = (char*)calloc(60, sizeof(char)); uint8_t offset = 0; - for (uint8_t outer = 0; outer < m_Format->paramLength - 1; ) { - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIX32 "", lineNumber); - sprintf(innerMsg, "%02" PRIX8 "", m_FormatDataOutParamValue[offset++]); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(lineNumber); + + std::ostringstream innerMsg; + innerMsg << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_FormatDataOutParamValue[offset++]); // inner loop for creating a single ling of the buffer data for (uint8_t inner = 1; inner < 16 && offset < m_Format->paramLength - 1; inner++) { - sprintf(innerStr, "%02" PRIX8"", m_FormatDataOutParamValue[offset]); + innerMsg << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_FormatDataOutParamValue[offset]); if (inner % 4 == 0) { - strncat(innerMsg, " ", 1); + innerMsg << " "; } - strncat(innerMsg, innerStr, 2); offset++; } // push the line to the json node - json_push_back(formatInfo, json_new_a((char*)myStr.c_str(), innerMsg)); + json_push_back(formatInfo, json_new_a(temp.str().c_str(), innerMsg.str().c_str())); outer = offset; lineNumber = outer; } - safe_Free(innerMsg); //free the string - safe_Free(innerStr); // free the string - json_push_back(formatData, formatInfo); } //----------------------------------------------------------------------------- @@ -285,24 +285,21 @@ void CScsiFormatStatusLog::process_Format_Status_Data_Variable_Length(JSONNODE * //--------------------------------------------------------------------------- eReturnValues CScsiFormatStatusLog::get_Format_Status_Data(JSONNODE *masterData) { - std::string headerStr = ""; - headerStr.resize(BASIC); eReturnValues retStatus = IN_PROGRESS; if (pData != NULL) { - snprintf((char*)headerStr.c_str(), BASIC, "Format Status Log 08h"); JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, (char*)headerStr.c_str()); + json_set_name(pageInfo, "Format Status Log 08h"); for (size_t offset = 0; offset < m_PageLength; ) { if (offset < m_bufferLength && offset < UINT16_MAX) { - m_Format = (sFormatParams *)&pData[offset]; + m_Format = reinterpret_cast(&pData[offset]); offset += sizeof(sFormatParams); byte_Swap_16(&m_Format->paramCode); - if (m_Format->paramCode == 0x0000 && (m_Format->paramLength > 8)) + if (m_Format->paramCode == UINT8_C(0x0000) && (m_Format->paramLength > 8)) { if ((offset + m_Format->paramLength) < m_bufferLength) { @@ -380,7 +377,6 @@ eReturnValues CScsiFormatStatusLog::get_Format_Status_Data(JSONNODE *masterData) { //json_push_back(masterData, pageInfo); return BAD_PARAMETER; - break; } } process_Format_Status_Data(pageInfo); diff --git a/src/CScsi_Informational_Exeptions_Log.cpp b/src/CScsi_Informational_Exeptions_Log.cpp index 02f3f4f..393b2bb 100644 --- a/src/CScsi_Informational_Exeptions_Log.cpp +++ b/src/CScsi_Informational_Exeptions_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Informational_Exeptions_Log.cpp Definition of the Informational Exceptions Log page provides a place for reporting detail about exceptions. // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -70,7 +70,7 @@ CScsiInformationalExeptionsLog::CScsiInformationalExeptionsLog(uint8_t * buffer, printf("%s \n", m_infoName.c_str()); } pData = new uint8_t[bufferSize]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, buffer, bufferSize); #else memcpy_s(pData, bufferSize, buffer, bufferSize);// copy the buffer data to the class member pBuf @@ -122,34 +122,100 @@ CScsiInformationalExeptionsLog::~CScsiInformationalExeptionsLog() //! \return none // //--------------------------------------------------------------------------- -void CScsiInformationalExeptionsLog::process_Informational_Exceptions_Data(JSONNODE *exeptionData, uint16_t count) +void CScsiInformationalExeptionsLog::process_Informational_Exceptions_Data(JSONNODE *exeptionData, uint16_t count, uint16_t offset) { - std::string myStr = ""; - myStr.resize(BASIC); + std::ostringstream temp; #if defined _DEBUG printf("Informational Exceptions Log \n"); #endif - snprintf((char*)myStr.c_str(), BASIC, "Informational Exception %" PRId16"", count); - JSONNODE *exeptionInfo = json_new(JSON_NODE); - json_set_name(exeptionInfo, (char*)myStr.c_str()); - byte_Swap_16(&m_Exeptions->paramCode); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_Exeptions->paramCode); - json_push_back(exeptionInfo, json_new_a("Informational Exception Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Exeptions->paramControlByte); - json_push_back(exeptionInfo, json_new_a("Informational Exception Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Exeptions->paramLength); - json_push_back(exeptionInfo, json_new_a("Informational Exception Length ", (char*)myStr.c_str())); - json_push_back(exeptionInfo, json_new_i("Informational Exception Additional Sense Code", static_cast(m_Exeptions->senseCode))); - json_push_back(exeptionInfo, json_new_i("Informational Exception Additional Sense Code Qualifier", static_cast(m_Exeptions->senseCodeQualifier))); - json_push_back(exeptionInfo, json_new_i("Most Recent Temperature Reading", static_cast(m_Exeptions->temp))); - json_push_back(exeptionInfo, json_new_i("Vendor Hda Temperature Trip Point", static_cast(m_Exeptions->tempLimit))); - json_push_back(exeptionInfo, json_new_i("Maximum Temperature", static_cast(m_Exeptions->maxTemp))); - json_push_back(exeptionInfo, json_new_i("Vendor specific First", static_cast(m_Exeptions->vendor1))); - json_push_back(exeptionInfo, json_new_i("Vendor specific Second", static_cast(m_Exeptions->vendor2))); - json_push_back(exeptionInfo, json_new_i("Vendor specific Third", static_cast(m_Exeptions->vendor3))); + if (g_dataformat == PREPYTHON_DATA) + { + JSONNODE* data = json_new(JSON_NODE); + json_push_back(data, json_new_a("name", "environment_temperature")); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << std::setfill('0') << INFORMATIONAL_EXCEPTIONS << "," << 0 << ":0x" << std::hex << std::nouppercase << m_Exeptions->paramCode << ":" << std::dec << offset; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::nouppercase << std::setfill('0') << std::setw(2) << static_cast(m_Exeptions->senseCode); + json_push_back(label, json_new_a("scsi_asc", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::nouppercase << std::setfill('0') << std::setw(2) << static_cast(m_Exeptions->senseCodeQualifier); + json_push_back(label, json_new_a("scsi_ascq", temp.str().c_str())); + json_push_back(label, json_new_a("stat_type", "most recent temperature")); + json_push_back(label, json_new_a("units", "celsius")); + json_push_back(data, label); + json_push_back(data, json_new_f("value", static_cast(m_Exeptions->temp))); + json_push_back(exeptionData, data); + + JSONNODE* trip = json_new(JSON_NODE); + json_push_back(trip, json_new_a("name", "environment_temperature")); + JSONNODE* label1 = json_new(JSON_NODE); + json_set_name(label1, "labels"); + temp.str("");temp.clear(); + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << std::setfill('0') << INFORMATIONAL_EXCEPTIONS << "," << 0 << ":0x" << std::hex << std::nouppercase << m_Exeptions->paramCode << ":" << std::dec << offset; + json_push_back(label1, json_new_a("metric_source", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::nouppercase << std::setfill('0') << std::setw(2) << static_cast(m_Exeptions->senseCode); + json_push_back(label1, json_new_a("scsi_asc", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::nouppercase << std::setfill('0') << std::setw(2) << static_cast(m_Exeptions->senseCodeQualifier); + json_push_back(label1, json_new_a("scsi_ascq", temp.str().c_str())); + json_push_back(label1, json_new_a("stat_type", "trip point temperature")); + json_push_back(label1, json_new_a("units", "celsius")); + json_push_back(trip, label1); + json_push_back(trip, json_new_f("value", static_cast(m_Exeptions->tempLimit))); + json_push_back(exeptionData, trip); + + JSONNODE* max = json_new(JSON_NODE); + json_push_back(max, json_new_a("name", "environment_temperature")); + JSONNODE* label2 = json_new(JSON_NODE); + json_set_name(label2, "labels"); + temp.str("");temp.clear(); + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << std::setfill('0') << INFORMATIONAL_EXCEPTIONS << "," << 0 << ":0x" << std::hex << std::nouppercase << m_Exeptions->paramCode << ":" << std::dec << offset; + json_push_back(label2, json_new_a("metric_source", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::nouppercase << std::setfill('0') << std::setw(2) << static_cast(m_Exeptions->senseCode); + json_push_back(label2, json_new_a("scsi_asc", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::nouppercase << std::setfill('0') << std::setw(2) << static_cast(m_Exeptions->senseCodeQualifier); + json_push_back(label2, json_new_a("scsi_ascq", temp.str().c_str())); + json_push_back(label2, json_new_a("stat_type", "maximum temperature")); + json_push_back(label2, json_new_a("units", "celsius")); + json_push_back(max, label2); + json_push_back(max, json_new_f("value", static_cast(m_Exeptions->maxTemp))); + json_push_back(exeptionData, max); - json_push_back(exeptionData, exeptionInfo); + } + else + { + temp.str("");temp.clear(); + temp << "Informational Exception " << std::dec << count; + JSONNODE* exeptionInfo = json_new(JSON_NODE); + json_set_name(exeptionInfo, temp.str().c_str()); + byte_Swap_16(&m_Exeptions->paramCode); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_Exeptions->paramCode; + json_push_back(exeptionInfo, json_new_a("Informational Exception Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Exeptions->paramControlByte); + json_push_back(exeptionInfo, json_new_a("Informational Exception Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Exeptions->paramLength); + json_push_back(exeptionInfo, json_new_a("Informational Exception Length ", temp.str().c_str())); + + json_push_back(exeptionInfo, json_new_i("Informational Exception Additional Sense Code", static_cast(m_Exeptions->senseCode))); + json_push_back(exeptionInfo, json_new_i("Informational Exception Additional Sense Code Qualifier", static_cast(m_Exeptions->senseCodeQualifier))); + json_push_back(exeptionInfo, json_new_i("Most Recent Temperature Reading", static_cast(m_Exeptions->temp))); + json_push_back(exeptionInfo, json_new_i("Vendor Hda Temperature Trip Point", static_cast(m_Exeptions->tempLimit))); + json_push_back(exeptionInfo, json_new_i("Maximum Temperature", static_cast(m_Exeptions->maxTemp))); + json_push_back(exeptionInfo, json_new_i("Vendor specific First", static_cast(m_Exeptions->vendor1))); + json_push_back(exeptionInfo, json_new_i("Vendor specific Second", static_cast(m_Exeptions->vendor2))); + json_push_back(exeptionInfo, json_new_i("Vendor specific Third", static_cast(m_Exeptions->vendor3))); + + json_push_back(exeptionData, exeptionInfo); + } } //----------------------------------------------------------------------------- // @@ -170,27 +236,40 @@ eReturnValues CScsiInformationalExeptionsLog::get_Informational_Exceptions_Data( eReturnValues retStatus = IN_PROGRESS; if (pData != NULL) { - JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, "Informational Exceptions Log - 2fh length 0x0f"); + JSONNODE* pageInfo; + if (g_dataformat == PREPYTHON_DATA) + { + pageInfo = masterData; + } + else + { + pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, "Informational Exceptions Log - 2fh length 0x0f"); + } uint16_t number = 0; - for (size_t offset = 0; offset < m_PageLength; ) + for (uint16_t offset = 0; offset < m_PageLength; ) { if (offset < m_bufferLength && offset < UINT16_MAX) { number++; - m_Exeptions = (sExeptionsParams *)&pData[offset]; + m_Exeptions = reinterpret_cast(&pData[offset]); + process_Informational_Exceptions_Data(pageInfo, number, offset); offset += sizeof(sExeptionsParams); - process_Informational_Exceptions_Data(pageInfo, number); } else { - json_push_back(masterData, pageInfo); + if (g_dataformat != PREPYTHON_DATA) + { + json_push_back(masterData, pageInfo); + } return BAD_PARAMETER; } } - - json_push_back(masterData, pageInfo); + if (g_dataformat != PREPYTHON_DATA) + { + json_push_back(masterData, pageInfo); + } retStatus = SUCCESS; } else @@ -198,4 +277,4 @@ eReturnValues CScsiInformationalExeptionsLog::get_Informational_Exceptions_Data( retStatus = MEMORY_FAILURE; } return retStatus; -} \ No newline at end of file +} diff --git a/src/CScsi_Log.cpp b/src/CScsi_Log.cpp index 76cbe8b..1e2ae70 100644 --- a/src/CScsi_Log.cpp +++ b/src/CScsi_Log.cpp @@ -2,7 +2,7 @@ // CScsiLog.cpp Implementation of Base class CScsiLog // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -50,13 +50,13 @@ using namespace opensea_parser; // //--------------------------------------------------------------------------- CScsiLog::CScsiLog() - : bufferData(NULL) - , m_LogSize(0) - , m_name("SCSI Log") - , m_ScsiStatus(IN_PROGRESS) - , m_Page() -{ - + : bufferData(NULL) + , m_LogSize(0) + , m_name("SCSI Log") + , m_ScsiStatus(IN_PROGRESS) + , m_Page() +{ + } //----------------------------------------------------------------------------- // @@ -72,38 +72,39 @@ CScsiLog::CScsiLog() // //--------------------------------------------------------------------------- CScsiLog::CScsiLog(const std::string fileName, JSONNODE *masterData) - : bufferData(NULL) - , m_LogSize(0) - , m_name("SCSI Log") - , m_ScsiStatus(IN_PROGRESS) + : bufferData(NULL) + , m_LogSize(0) + , m_name("SCSI Log") + , m_ScsiStatus(IN_PROGRESS) + , m_Page() { - CLog *cCLog; - cCLog = new CLog(fileName); - if (cCLog->get_Log_Status() == SUCCESS) - { - if (cCLog->get_Buffer() != NULL) - { - m_LogSize = cCLog->get_Size(); - bufferData = new uint8_t[m_LogSize]; // new a buffer to the point -#ifndef _WIN64 - memcpy(bufferData, cCLog->get_Buffer(), m_LogSize); + CLog *cCLog; + cCLog = new CLog(fileName); + if (cCLog->get_Log_Status() == SUCCESS) + { + if (cCLog->get_Buffer() != NULL) + { + m_LogSize = cCLog->get_Size(); + bufferData = new uint8_t[m_LogSize]; // new a buffer to the point +#ifndef __STDC_SECURE_LIB__ + memcpy(bufferData, cCLog->get_Buffer(), m_LogSize); #else - memcpy_s(bufferData, m_LogSize, cCLog->get_Buffer(), m_LogSize);// copy the buffer data to the class member pBuf + memcpy_s(bufferData, m_LogSize, cCLog->get_Buffer(), m_LogSize);// copy the buffer data to the class member pBuf #endif - m_ScsiStatus = get_Log_Parsed(masterData); // init the data for getting the log - } - else - { + m_ScsiStatus = get_Log_Parsed(masterData); // init the data for getting the log + } + else + { - m_ScsiStatus = FAILURE; - } - } - else - { - m_ScsiStatus = cCLog->get_Log_Status(); - } - delete (cCLog); + m_ScsiStatus = FAILURE; + } + } + else + { + m_ScsiStatus = cCLog->get_Log_Status(); + } + delete (cCLog); } //----------------------------------------------------------------------------- @@ -124,7 +125,7 @@ CScsiLog::~CScsiLog() { if (bufferData != NULL) { - delete [] bufferData; + delete[] bufferData; } } //----------------------------------------------------------------------------- @@ -147,13 +148,13 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) if (bufferData != NULL) { sLogPageStruct myStr; - sLogPageStruct* m_Page = &myStr; + sLogPageStruct* lpStruct = &myStr; - m_Page = (sLogPageStruct *)bufferData; // set a buffer to the point to the log page info - byte_Swap_16(&m_Page->pageLength); - if (IsScsiLogPage(m_Page->pageLength , M_GETBITRANGE(m_Page->pageCode, 5, 0)) == true) + lpStruct = reinterpret_cast(bufferData); // set a buffer to the point to the log page info + byte_Swap_16(&lpStruct->pageLength); + if (IsScsiLogPage(lpStruct->pageLength , M_GETBITRANGE(lpStruct->pageCode, 5, 0)) == true) { - switch (M_GETBITRANGE(m_Page->pageCode, 5, 0)) + switch (M_GETBITRANGE(lpStruct->pageCode, 5, 0)) { case SUPPORTED_LOG_PAGES: { @@ -162,15 +163,35 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Supported Log Pages Found" << std::endl; } CScsiSupportedLog *cSupport; - if (m_Page->subPage == 00) + if (lpStruct->subPage == 00) { - cSupport = new CScsiSupportedLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength, false); + cSupport = new CScsiSupportedLog(&bufferData[4], m_LogSize, lpStruct->pageLength, false); } else { - cSupport = new CScsiSupportedLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength, true); + cSupport = new CScsiSupportedLog(&bufferData[4], m_LogSize, lpStruct->pageLength, true); + } + retStatus = cSupport->get_Log_Status(); + if (retStatus == IN_PROGRESS) + { + try + { + retStatus = cSupport->parse_Supported_Log_Pages_Log(masterData); + } + catch (...) + { + retStatus = cSupport->get_Log_Status(); + delete(cSupport); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } - retStatus = cSupport->parse_Supported_Log_Pages_Log(masterData); delete(cSupport); } break; @@ -181,11 +202,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Write Error Counter Log Pages Found" << std::endl; } CScsiErrorCounterLog *cWriteError; - cWriteError = new CScsiErrorCounterLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength, m_Page->pageCode); + cWriteError = new CScsiErrorCounterLog(&bufferData[4], m_LogSize, lpStruct->pageLength, lpStruct->pageCode); retStatus = cWriteError->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cWriteError->parse_Error_Counter_Log(masterData); + try + { + retStatus = cWriteError->parse_Error_Counter_Log(masterData); + } + catch (...) + { + retStatus = cWriteError->get_Log_Status(); + delete(cWriteError); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cWriteError); } @@ -197,11 +234,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Read Error Counter Log Pages Found" << std::endl; } CScsiErrorCounterLog *cReadError; - cReadError = new CScsiErrorCounterLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength, m_Page->pageCode); + cReadError = new CScsiErrorCounterLog(&bufferData[4], m_LogSize, lpStruct->pageLength, lpStruct->pageCode); retStatus = cReadError->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cReadError->parse_Error_Counter_Log(masterData); + try + { + retStatus = cReadError->parse_Error_Counter_Log(masterData); + } + catch (...) + { + retStatus = cReadError->get_Log_Status(); + delete(cReadError); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cReadError); } @@ -213,11 +266,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Verify Error Counter Log Pages Found" << std::endl; } CScsiErrorCounterLog *cVerifyError; - cVerifyError = new CScsiErrorCounterLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength, m_Page->pageCode); + cVerifyError = new CScsiErrorCounterLog(&bufferData[4], m_LogSize, lpStruct->pageLength, lpStruct->pageCode); retStatus = cVerifyError->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cVerifyError->parse_Error_Counter_Log(masterData); + try + { + retStatus = cVerifyError->parse_Error_Counter_Log(masterData); + } + catch (...) + { + retStatus = cVerifyError->get_Log_Status(); + delete(cVerifyError); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cVerifyError); } @@ -229,11 +298,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Non-Medium Error Log Pages Found" << std::endl; } CScsiNonMediumErrorCountLog *cNonMedium; - cNonMedium = new CScsiNonMediumErrorCountLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cNonMedium = new CScsiNonMediumErrorCountLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cNonMedium->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cNonMedium->parse_Non_Medium_Error_Count_Log(masterData); + try + { + retStatus = cNonMedium->parse_Non_Medium_Error_Count_Log(masterData); + } + catch (...) + { + retStatus = cNonMedium->get_Log_Status(); + delete(cNonMedium); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cNonMedium); } @@ -246,11 +331,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) } CScsiFormatStatusLog *cFormat; - cFormat = new CScsiFormatStatusLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cFormat = new CScsiFormatStatusLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cFormat->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cFormat->parse_Format_Status_Log(masterData); + try + { + retStatus = cFormat->parse_Format_Status_Log(masterData); + } + catch (...) + { + retStatus = cFormat->get_Log_Status(); + delete(cFormat); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cFormat); } @@ -262,11 +363,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Logical Block Provisioning Log Pages Found" << std::endl; } CScsiLBAProvisionLog *cLBA; - cLBA = new CScsiLBAProvisionLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cLBA = new CScsiLBAProvisionLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cLBA->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cLBA->parse_LBA_Provision_Log(masterData); + try + { + retStatus = cLBA->parse_LBA_Provision_Log(masterData); + } + catch (...) + { + retStatus = cLBA->get_Log_Status(); + delete(cLBA); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cLBA); } @@ -278,7 +395,7 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Environmental Log Found" << std::endl; } CScsiEnvironmentLog *cEPA; - cEPA = new CScsiEnvironmentLog((uint8_t *)bufferData, m_LogSize, m_Page->subPage, masterData); + cEPA = new CScsiEnvironmentLog(bufferData, m_LogSize, lpStruct->subPage, masterData); retStatus = cEPA->get_Log_Status(); delete (cEPA); } @@ -290,7 +407,7 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Start Stop Cycle Log Found" << std::endl; } CScsiStartStop *cSS; - cSS = new CScsiStartStop((uint8_t *)&bufferData[4], m_LogSize, masterData); + cSS = new CScsiStartStop(&bufferData[4], lpStruct->pageLength, masterData); retStatus = cSS->get_Log_Status(); delete(cSS); } @@ -302,11 +419,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Application Client Log Pages Found" << std::endl; } CScsiApplicationLog *cApplicationClient; - cApplicationClient = new CScsiApplicationLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cApplicationClient = new CScsiApplicationLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cApplicationClient->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cApplicationClient->parse_Application_Client_Log(masterData); + try + { + retStatus = cApplicationClient->parse_Application_Client_Log(masterData); + } + catch (...) + { + retStatus = cApplicationClient->get_Log_Status(); + delete(cApplicationClient); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cApplicationClient); } @@ -318,7 +451,7 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Self Test Log Found" << std::endl; } CScsi_DST_Results *cSelfTest; - cSelfTest = new CScsi_DST_Results((uint8_t *)&bufferData[4], m_LogSize, masterData); + cSelfTest = new CScsi_DST_Results(&bufferData[4], m_LogSize, masterData); retStatus = cSelfTest->get_Log_Status(); delete(cSelfTest); } @@ -330,11 +463,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Solid State Drive Log Pages Found" << std::endl; } CScsiSolidStateDriveLog *cSSD; - cSSD = new CScsiSolidStateDriveLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cSSD = new CScsiSolidStateDriveLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cSSD->get_Solid_State_Drive_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cSSD->parse_Solid_State_Drive_Log(masterData); + try + { + retStatus = cSSD->parse_Solid_State_Drive_Log(masterData); + } + catch (...) + { + retStatus = cSSD->get_Solid_State_Drive_Log_Status(); + delete(cSSD); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cSSD); } @@ -346,47 +495,111 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Zoned Device Statistics Log Pages Found" << std::endl; } CScsiZonedDeviceStatisticsLog *cZDS; - cZDS = new CScsiZonedDeviceStatisticsLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cZDS = new CScsiZonedDeviceStatisticsLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cZDS->get_Zoned_Device_Statistics_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cZDS->parse_Zoned_Device_Statistics_Log(masterData); + try + { + retStatus = cZDS->parse_Zoned_Device_Statistics_Log(masterData); + } + catch (...) + { + retStatus = cZDS->get_Zoned_Device_Statistics_Log_Status(); + delete(cZDS); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cZDS); } break; case BACKGROUND_SCAN: { - if (m_Page->subPage == 0x00) // Background Scan + if (lpStruct->subPage == 0x00) // Background Scan { CScsiScanLog *cScan; - cScan = new CScsiScanLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cScan = new CScsiScanLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cScan->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cScan->parse_Background_Scan_Log(masterData); + try + { + retStatus = cScan->parse_Background_Scan_Log(masterData); + } + catch (...) + { + retStatus = cScan->get_Log_Status(); + delete(cScan); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cScan); } - else if (m_Page->subPage == 0x01) // Pending Defects log + else if (lpStruct->subPage == 0x01) // Pending Defects log { CScsiPendingDefectsLog *cPlist; - cPlist = new CScsiPendingDefectsLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cPlist = new CScsiPendingDefectsLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cPlist->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cPlist->parse_Supported_Log_Pages_Log(masterData); + try + { + retStatus = cPlist->parse_Plist_Log(masterData); + } + catch (...) + { + retStatus = cPlist->get_Log_Status(); + delete(cPlist); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cPlist); } - else if (m_Page->subPage == 0x02) // Background Operation + else if (lpStruct->subPage == 0x02) // Background Operation { CScsiOperationLog *cOperation; - cOperation = new CScsiOperationLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cOperation = new CScsiOperationLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cOperation->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cOperation->parse_Background_Operationss_Log(masterData); + try + { + retStatus = cOperation->parse_Background_Operationss_Log(masterData); + } + catch (...) + { + retStatus = cOperation->get_Log_Status(); + delete(cOperation); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cOperation); } @@ -400,9 +613,30 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Protocol Specific Port Log Pages Found" << std::endl; } CScsiProtocolPortLog * cPSP; - cPSP = new CScsiProtocolPortLog((uint8_t *)&bufferData[4], m_LogSize); - cPSP->set_PSP_Page_Length(m_Page->pageLength); - retStatus = cPSP->parse_Protocol_Port_Log(masterData); + cPSP = new CScsiProtocolPortLog(&bufferData[4], m_LogSize); + //uint16_t l_pageLength = *(reinterpret_cast(&bufferData[2])); + retStatus = cPSP->get_Log_Status(); + if (retStatus == IN_PROGRESS) + { + try + { + cPSP->set_PSP_Page_Length_NoSwap(lpStruct->pageLength); //TODO: noswap vs swap + retStatus = cPSP->parse_Protocol_Port_Log(masterData); + } + catch (...) + { + retStatus = cPSP->get_Log_Status(); + delete(cPSP); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } + } delete (cPSP); } break; @@ -413,8 +647,28 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Power Condition Transitions Log Pages Found" << std::endl; } CScsiPowerConditiontLog *cPower; - cPower = new CScsiPowerConditiontLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); - retStatus = cPower->parse_Power_Condition_Transitions_Log(masterData); + cPower = new CScsiPowerConditiontLog(&bufferData[4], m_LogSize, lpStruct->pageLength); + retStatus = cPower->get_Log_Status(); + if (retStatus == IN_PROGRESS) + { + try + { + retStatus = cPower->parse_Power_Condition_Transitions_Log(masterData); + } + catch (...) + { + retStatus = cPower->get_Log_Status(); + delete(cPower); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } + } delete(cPower); } break; @@ -425,11 +679,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Informational Exceptions Log Pages Found" << std::endl; } CScsiInformationalExeptionsLog *cInfo; - cInfo = new CScsiInformationalExeptionsLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cInfo = new CScsiInformationalExeptionsLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cInfo->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cInfo->get_Informational_Exceptions(masterData); + try + { + retStatus = cInfo->get_Informational_Exceptions(masterData); + } + catch (...) + { + retStatus = cInfo->get_Log_Status(); + delete(cInfo); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cInfo); } @@ -441,24 +711,117 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Cache Statistics Log Pages Found" << std::endl; } CScsiCacheLog *cCache; - cCache = new CScsiCacheLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); - retStatus = cCache->parse_Cache_Statistics_Log(masterData); + cCache = new CScsiCacheLog(&bufferData[4], m_LogSize, lpStruct->pageLength); + if (cCache->get_Log_Status() == SUCCESS) + { + try + { + retStatus = cCache->parse_Cache_Statistics_Log(masterData); + } + catch (...) + { + retStatus = cCache->get_Log_Status(); + delete(cCache); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } + } delete (cCache); } break; case SEAGATE_SPECIFIC_LOG: { - CSCSI_Farm_Log *pCFarm; - pCFarm = new CSCSI_Farm_Log((uint8_t *)bufferData, m_LogSize, false); - if (pCFarm->get_Log_Status() == SUCCESS) + if (lpStruct->subPage == FARM_LOG_PAGE) // Farm Log { - retStatus = pCFarm->parse_Farm_Log(); - if (retStatus == SUCCESS) + CSCSI_Farm_Log* pCFarm; + pCFarm = new CSCSI_Farm_Log(bufferData, lpStruct->pageLength + 4, lpStruct->subPage,false); + if (pCFarm->get_Log_Status() == SUCCESS) { - pCFarm->print_All_Pages(masterData); + try + { + pCFarm->print_Page_One_Node(masterData); + retStatus = pCFarm->get_Log_Status(); + } + catch (...) + { + retStatus = pCFarm->get_Log_Status(); + delete(pCFarm); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } + delete(pCFarm); + } + else if (lpStruct->subPage == FARM_FACTORY_LOG_PAGE) // Farm Log + { + CSCSI_Farm_Log* pCFarm; + pCFarm = new CSCSI_Farm_Log(bufferData, lpStruct->pageLength + 4, lpStruct->subPage,false); + if (pCFarm->get_Log_Status() == SUCCESS) + { + try + { + pCFarm->print_Page_One_Node(masterData); + retStatus = pCFarm->get_Log_Status(); + } + catch (...) + { + retStatus = pCFarm->get_Log_Status(); + delete(pCFarm); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } + } + delete(pCFarm); + } + else if (lpStruct->subPage >= FARM_TIME_SERIES_0 && lpStruct->subPage <= FARM_TEMP_TRIGGER_LOG_PAGE) // FARM log when Temperature exceeds 70 c + { + CSCSI_Farm_Log* pCFarm; + pCFarm = new CSCSI_Farm_Log(bufferData, lpStruct->pageLength + 4, lpStruct->subPage,false); // issue with the log bufer size + if (pCFarm->get_Log_Status() == SUCCESS) + { + retStatus = pCFarm->get_Log_Status(); + if (retStatus == SUCCESS) + { + try + { + pCFarm->print_Page_One_Node(masterData); + retStatus = pCFarm->get_Log_Status(); + } + catch (...) + { + retStatus = pCFarm->get_Log_Status(); + delete(pCFarm); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } + } + } + delete(pCFarm); // SAS Log Page 0x3D subpage 0x10 - 0xC7 } - delete(pCFarm); } break; case FACTORY_LOG: @@ -468,11 +831,27 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Factory Log Pages Found" << std::endl; } CScsiFactoryLog *cFactory; - cFactory = new CScsiFactoryLog((uint8_t *)&bufferData[4], m_LogSize, m_Page->pageLength); + cFactory = new CScsiFactoryLog(&bufferData[4], m_LogSize, lpStruct->pageLength); retStatus = cFactory->get_Log_Status(); if (retStatus == IN_PROGRESS) { - retStatus = cFactory->parse_Factory_Log(masterData); + try + { + retStatus = cFactory->parse_Factory_Log(masterData); + } + catch (...) + { + retStatus = cFactory->get_Log_Status(); + delete(cFactory); + if (retStatus == SUCCESS || retStatus == IN_PROGRESS) + { + return PARSE_FAILURE; + } + else + { + return retStatus; + } + } } delete(cFactory); } @@ -484,7 +863,7 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) std::cout << "Not Found" << std::endl; } std::cout << "not supported" << std::endl; - retStatus = SUCCESS; + retStatus = static_cast(NOT_SUPPORTED); } break; } @@ -493,10 +872,10 @@ eReturnValues CScsiLog::get_Log_Parsed(JSONNODE *masterData) { if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { - std::cout << "Invalid Length" << std::endl; + std::cout << "Not Found" << std::endl; } - std::cout << "Invalid Length check --LogType" << std::endl; - retStatus = static_cast(INVALID_LENGTH); + std::cout << "not supported check --logType" << std::endl; + retStatus = static_cast(NOT_SUPPORTED); } } else diff --git a/src/CScsi_Logical_Block_Provisioning_Log.cpp b/src/CScsi_Logical_Block_Provisioning_Log.cpp index dea3c5d..092fd8b 100644 --- a/src/CScsi_Logical_Block_Provisioning_Log.cpp +++ b/src/CScsi_Logical_Block_Provisioning_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Logical_Block_Provisioning_Logg.cpp Definition of Logical Block Provisioning Log page // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -31,17 +31,17 @@ using namespace opensea_parser; // //--------------------------------------------------------------------------- CScsiLBAProvisionLog::CScsiLBAProvisionLog() - : pData() - , m_LBAName("Logical Block Provisioning Log") - , m_LBAStatus(IN_PROGRESS) - , m_PageLength(0) - , m_bufferLength() - , m_Provision() + : pData() + , m_LBAName("Logical Block Provisioning Log") + , m_LBAStatus(IN_PROGRESS) + , m_PageLength(0) + , m_bufferLength() + , m_Provision() { - if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) - { - printf("%s \n", m_LBAName.c_str()); - } + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_LBAName.c_str()); + } } //----------------------------------------------------------------------------- // @@ -59,25 +59,25 @@ CScsiLBAProvisionLog::CScsiLBAProvisionLog() // //--------------------------------------------------------------------------- CScsiLBAProvisionLog::CScsiLBAProvisionLog(uint8_t * buffer, size_t bufferSize, uint16_t pageLength) - : pData(buffer) - , m_LBAName("Logical Block Provisioning Log") - , m_LBAStatus(IN_PROGRESS) - , m_PageLength(pageLength) - , m_bufferLength(bufferSize) - , m_Provision() + : pData(buffer) + , m_LBAName("Logical Block Provisioning Log") + , m_LBAStatus(IN_PROGRESS) + , m_PageLength(pageLength) + , m_bufferLength(bufferSize) + , m_Provision() { - if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) - { - printf("%s \n", m_LBAName.c_str()); - } - if (buffer != NULL) - { - m_LBAStatus = IN_PROGRESS; - } - else - { - m_LBAStatus = FAILURE; - } + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_LBAName.c_str()); + } + if (buffer != NULL) + { + m_LBAStatus = IN_PROGRESS; + } + else + { + m_LBAStatus = FAILURE; + } } @@ -115,15 +115,16 @@ CScsiLBAProvisionLog::~CScsiLBAProvisionLog() //--------------------------------------------------------------------------- void CScsiLBAProvisionLog::get_Resource_Percentage(std::string *percentStr) { - uint16_t percent = static_cast(m_Provision->resourceCount); - if (percent < 100) - { - snprintf((char*)percentStr->c_str(), BASIC, "%" PRId16" Percent", percent); - } - else - { - snprintf((char*)percentStr->c_str(), BASIC, "Invalid Percentage"); - } + if (m_Provision->resourceCount < 100) + { + std::ostringstream temp; + temp << std::dec << m_Provision->resourceCount << " Percent"; + percentStr->assign(temp.str()); + } + else + { + percentStr->assign("Invalid Percentage"); + } } //----------------------------------------------------------------------------- // @@ -141,49 +142,43 @@ void CScsiLBAProvisionLog::get_Resource_Percentage(std::string *percentStr) //--------------------------------------------------------------------------- void CScsiLBAProvisionLog::get_LBA_Provision_Parameter_Description(std::string *lbaStr) { - switch (m_Provision->paramCode) - { - case 0x0000: - { - snprintf((char*)lbaStr->c_str(), BASIC, "Reserved"); - break; - } - case 0x0001: - { - snprintf((char*)lbaStr->c_str(), BASIC, "Available LBA Mapping Resource Count"); - break; - } - case 0x0002: - { - snprintf((char*)lbaStr->c_str(), BASIC, "Used LBA Mapping Resource Count"); - break; - } - case 0x0003: - { - snprintf((char*)lbaStr->c_str(), BASIC, "Available Provisioning Resource Percentage"); - break; - } - case 0x0100: - { - snprintf((char*)lbaStr->c_str(), BASIC, "De-duplicated LBA Resource Count"); - break; - } - case 0x0101: - { - snprintf((char*)lbaStr->c_str(), BASIC, "Compressed LBA Resource Count"); - break; - } - case 0x0102: - { - snprintf((char*)lbaStr->c_str(), BASIC, "Total Efficiency LBA Resource Count"); - break; - } - default: - { - snprintf((char*)lbaStr->c_str(), BASIC, "Reserved %" PRId16"", m_Provision->paramCode); - break; - } - } + if (m_Provision->paramCode == 0x0000 + || (m_Provision->paramCode >= 0x0004 && m_Provision->paramCode <= 0x00FF) + || (m_Provision->paramCode >= 0x0103 && m_Provision->paramCode <= 0xFFEF)) + { + lbaStr->assign("Reserved"); + } + else + { + switch (m_Provision->paramCode) + { + case 0x0001: + lbaStr->assign("available lba mapping resource count"); + break; + case 0x0002: + lbaStr->assign("used lba mapping resource count"); + break; + case 0x0003: + lbaStr->assign("available provisioning resource percentage"); + break; + case 0x0100: + lbaStr->assign("de-duplicated lba resource count"); + break; + case 0x0101: + lbaStr->assign("compressed LBA resource count"); + break; + case 0x0102: + lbaStr->assign("total efficiency LBA resource count"); + break; + default: + { + std::ostringstream temp; + temp << "vendor specific " << std::dec << m_Provision->paramCode; + lbaStr->assign(temp.str()); + break; + } + } + } } //----------------------------------------------------------------------------- // @@ -201,34 +196,35 @@ void CScsiLBAProvisionLog::get_LBA_Provision_Parameter_Description(std::string * //--------------------------------------------------------------------------- void CScsiLBAProvisionLog::process_LBA_Provision_Data(JSONNODE *lbaData) { - std::string myStr = ""; - myStr.resize(BASIC); + std::string myStr = ""; #if defined _DEBUG - printf("Logical Block Provisioning Log \n"); + printf("Logical Block Provisioning Log \n"); #endif - byte_Swap_16(&m_Provision->paramCode); - get_LBA_Provision_Parameter_Description(&myStr); - JSONNODE *lbaInfo = json_new(JSON_NODE); - json_set_name(lbaInfo, (char*)myStr.c_str()); + byte_Swap_16(&m_Provision->paramCode); + get_LBA_Provision_Parameter_Description(&myStr); + JSONNODE *lbaInfo = json_new(JSON_NODE); + json_set_name(lbaInfo, myStr.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_Provision->paramCode); - json_push_back(lbaInfo, json_new_a("Logical Block Provisioning Parameter Code", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_Provision->paramCode; + json_push_back(lbaInfo, json_new_a("Logical Block Provisioning Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Provision->paramControlByte); + json_push_back(lbaInfo, json_new_a("Logical Block Provisioning Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Provision->paramLength); + json_push_back(lbaInfo, json_new_a("Logical Block Provisioning Length ", temp.str().c_str())); + if (m_Provision->paramCode == 0x0003) + { + get_Resource_Percentage(&myStr); + json_push_back(lbaInfo, json_new_a("Percentage of Resources Available", myStr.c_str())); + } + else + { + json_push_back(lbaInfo, json_new_i("Logical Block Provisioning Resource Count", m_Provision->resourceCount)); + } - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Provision->paramControlByte); - json_push_back(lbaInfo, json_new_a("Logical Block Provisioning Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Provision->paramLength); - json_push_back(lbaInfo, json_new_a("Logical Block Provisioning Length ", (char*)myStr.c_str())); - if (m_Provision->paramCode == 0x0003) - { - get_Resource_Percentage(&myStr); - json_push_back(lbaInfo, json_new_a( "Percentage of Resources Available", (char*)myStr.c_str())); - } - else - { - json_push_back(lbaInfo, json_new_i("Logical Block Provisioning Resource Count", m_Provision->resourceCount)); - } - - json_push_back(lbaData, lbaInfo); + json_push_back(lbaData, lbaInfo); } //----------------------------------------------------------------------------- // @@ -246,34 +242,34 @@ void CScsiLBAProvisionLog::process_LBA_Provision_Data(JSONNODE *lbaData) //--------------------------------------------------------------------------- eReturnValues CScsiLBAProvisionLog::get_LBA_Data(JSONNODE *masterData) { - eReturnValues retStatus = IN_PROGRESS; - if (pData != NULL) - { - JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, "Logical Block Provisioning Log - Ch"); + eReturnValues retStatus = IN_PROGRESS; + if (pData != NULL) + { + JSONNODE *pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, "Logical Block Provisioning Log - 0Ch"); - for (size_t offset = 0; offset < (size_t)m_PageLength; ) - { - if (offset < m_bufferLength && offset < UINT16_MAX) - { - m_Provision = (sLBA *)&pData[offset]; - process_LBA_Provision_Data(pageInfo); - offset += sizeof(sLBA); - } - else - { - json_push_back(masterData, pageInfo); - return BAD_PARAMETER; - } + for (size_t offset = 0; offset < static_cast(m_PageLength); ) + { + if (offset < m_bufferLength && offset < UINT16_MAX) + { + m_Provision = reinterpret_cast(&pData[offset]); + process_LBA_Provision_Data(pageInfo); + offset += sizeof(sLBA); + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } - } + } - json_push_back(masterData, pageInfo); - retStatus = SUCCESS; - } - else - { - retStatus = MEMORY_FAILURE; - } - return retStatus; + json_push_back(masterData, pageInfo); + retStatus = SUCCESS; + } + else + { + retStatus = MEMORY_FAILURE; + } + return retStatus; } \ No newline at end of file diff --git a/src/CScsi_Non_Medium_Error_Count_Log.cpp b/src/CScsi_Non_Medium_Error_Count_Log.cpp index 4978721..9b9e69e 100644 --- a/src/CScsi_Non_Medium_Error_Count_Log.cpp +++ b/src/CScsi_Non_Medium_Error_Count_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Non_Medium_Error_Count_Log.cpp Definition of the Non-Medium Error Count Log // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -101,7 +101,6 @@ CScsiNonMediumErrorCountLog::~CScsiNonMediumErrorCountLog() { } - //----------------------------------------------------------------------------- // //! \fn process_Non_Medium_Error_Count_Data @@ -116,39 +115,36 @@ CScsiNonMediumErrorCountLog::~CScsiNonMediumErrorCountLog() //! \return none // //--------------------------------------------------------------------------- -void CScsiNonMediumErrorCountLog::process_Non_Medium_Error_Count_Data(JSONNODE *countData) +void CScsiNonMediumErrorCountLog::process_Non_Medium_Error_Count_Data(JSONNODE* countData) { - std::string myStr = ""; - myStr.resize(BASIC); - if (m_Value != 0) - { #if defined _DEBUG - printf("Non-Medium Error Count Log Parameters\n"); + printf("Non-Medium Error Count Log Parameters\n"); #endif - byte_Swap_16(&m_CountErrors->paramCode); - - snprintf((char*)myStr.c_str(), BASIC, "Non-Medium Error Count Log Parameters 0x%04" PRIx16"", m_CountErrors->paramCode); - JSONNODE *cacheInfo = json_new(JSON_NODE); - json_set_name(cacheInfo, (char*)myStr.c_str()); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_CountErrors->paramCode); - json_push_back(cacheInfo, json_new_a("Non-Medium Error Count Parameter Code", (char*)myStr.c_str())); + byte_Swap_16(&m_CountErrors->paramCode); + std::ostringstream temp; + temp << "Non-Medium Error Count Log Parameters 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_CountErrors->paramCode; + JSONNODE* cacheInfo = json_new(JSON_NODE); + json_set_name(cacheInfo, temp.str().c_str()); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_CountErrors->paramCode; + json_push_back(cacheInfo, json_new_a("Non-Medium Error Count Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_CountErrors->paramControlByte); + json_push_back(cacheInfo, json_new_a("Non-Medium Error Count Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_CountErrors->paramLength); + json_push_back(cacheInfo, json_new_a("Non-Medium Error CountLength ", temp.str().c_str())); + if (m_CountErrors->paramLength == 8 || m_Value > UINT32_MAX) + { + set_json_64bit(cacheInfo, "Non-Medium Error Count", m_Value, false); + } + else + { + json_push_back(cacheInfo, json_new_i("Non-Medium Error Count", m_Value)); + } - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_CountErrors->paramControlByte); - json_push_back(cacheInfo, json_new_a("Non-Medium Error Count Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_CountErrors->paramLength); - json_push_back(cacheInfo, json_new_a("Non-Medium Error CountLength ", (char*)myStr.c_str())); - if (m_CountErrors->paramLength == 8 || m_Value > UINT32_MAX) - { - set_json_64bit(cacheInfo, "Non-Medium Error Count", m_Value, false); - } - else - { - json_push_back(cacheInfo, json_new_i("Non-Medium Error Count", static_cast(m_Value))); - } + json_push_back(countData, cacheInfo); - json_push_back(countData, cacheInfo); - } } //----------------------------------------------------------------------------- // @@ -171,17 +167,17 @@ eReturnValues CScsiNonMediumErrorCountLog::get_Non_Medium_Error_Count_Data(JSONN { JSONNODE *pageInfo = json_new(JSON_NODE); json_set_name(pageInfo, "Non-Medium Error Count Log - 6h"); - for (size_t offset = 0; offset < m_PageLength; ) + for (uint32_t offset = 0; offset < m_PageLength; ) { if (offset < m_bufferLength && offset < UINT16_MAX) { - m_CountErrors = (sNonMediumErrorCount *)&pData[offset]; - offset += sizeof(sNonMediumErrorCount); + m_CountErrors = reinterpret_cast(&pData[offset]); + offset += PARAMSIZE; switch (m_CountErrors->paramLength) { case 1: { - if ((offset + m_CountErrors->paramLength) < m_bufferLength) + if ((offset + m_CountErrors->paramLength) <= static_cast(m_bufferLength)) { m_Value = pData[offset]; offset += m_CountErrors->paramLength; @@ -195,7 +191,7 @@ eReturnValues CScsiNonMediumErrorCountLog::get_Non_Medium_Error_Count_Data(JSONN } case 2: { - if ((offset + m_CountErrors->paramLength) < m_bufferLength) + if ((offset + m_CountErrors->paramLength) <= static_cast(m_bufferLength)) { m_Value = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); offset += m_CountErrors->paramLength; @@ -209,7 +205,7 @@ eReturnValues CScsiNonMediumErrorCountLog::get_Non_Medium_Error_Count_Data(JSONN } case 4: { - if ((offset + m_CountErrors->paramLength) < m_bufferLength) + if ((offset + m_CountErrors->paramLength) <= static_cast(m_bufferLength)) { m_Value = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); offset += m_CountErrors->paramLength; @@ -223,7 +219,7 @@ eReturnValues CScsiNonMediumErrorCountLog::get_Non_Medium_Error_Count_Data(JSONN } case 8: { - if ((offset + m_CountErrors->paramLength) < m_bufferLength) + if ((offset + m_CountErrors->paramLength) <= static_cast(m_bufferLength)) { m_Value = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); offset += m_CountErrors->paramLength; @@ -239,7 +235,6 @@ eReturnValues CScsiNonMediumErrorCountLog::get_Non_Medium_Error_Count_Data(JSONN { json_push_back(masterData, pageInfo); return BAD_PARAMETER; - break; } } process_Non_Medium_Error_Count_Data(pageInfo); @@ -258,4 +253,4 @@ eReturnValues CScsiNonMediumErrorCountLog::get_Non_Medium_Error_Count_Data(JSONN retStatus = MEMORY_FAILURE; } return retStatus; -} \ No newline at end of file +} diff --git a/src/CScsi_Page_19h_Cache_Memory_Statistics_Log.cpp b/src/CScsi_Page_19h_Cache_Memory_Statistics_Log.cpp new file mode 100644 index 0000000..aaab8ac --- /dev/null +++ b/src/CScsi_Page_19h_Cache_Memory_Statistics_Log.cpp @@ -0,0 +1,310 @@ +// +// CScsi_Page_19h_Cache_Memory_Statistics_Log.cpp Definition of SCSI cache memory statistics log +// Do NOT modify or remove this copyright and license +// +// Copyright (c) 2015 - 2021 Seagate Technology LLC and/or its Affiliates +// +// This software is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +// ****************************************************************************************** + +// \file CScsi_Page_19h_Cache_Memory_Statistics_Log.cpp Definition of SCSI cache memory Statistics Page +// +#include "CScsi_Page_19h_Cache_Memory_Statistics_Log.h" + +using namespace opensea_parser; +//----------------------------------------------------------------------------- +// +//! \fn CScsiCacheMemStatLog() +// +//! \brief +//! Description: Default Class constructor +// +// Entry: +// \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +CScsiCacheMemStatLog::CScsiCacheMemStatLog() + : pData() + , m_CacheMemName("Cache Memory Statistics Log") + , m_LogStatus(IN_PROGRESS) + , m_PageLength(0) + , m_bufferLength(0) + , m_CacheMemLog() + , m_TimeIntervalDescriptorParam(NULL) + , m_Value(0) +{ + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_CacheMemName.c_str()); + } +} +//----------------------------------------------------------------------------- +// +//! \fn CScsiCacheMemStatLog() +// +//! \brief +//! Description: Class constructor for VOLTAGE MONITORING LOG +// +// Entry: +//! \param buffer = holds the buffer information +//! \param bufferSize - Full size of the buffer +//! \param pageLength - the size of the page for the parameter header +// +// Exit: +// +//--------------------------------------------------------------------------- +CScsiCacheMemStatLog::CScsiCacheMemStatLog(uint8_t * buffer, size_t bufferSize, uint16_t pageLength) + : pData(buffer) + , m_CacheMemName("Cache Memory Statistics Log") + , m_LogStatus(IN_PROGRESS) + , m_PageLength(pageLength) + , m_bufferLength(bufferSize) + , m_CacheMemLog() + , m_TimeIntervalDescriptorParam(NULL) + , m_Value(0) +{ + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_CacheMemName.c_str()); + } + if (buffer != NULL) + { + m_LogStatus = IN_PROGRESS; + } + else + { + m_LogStatus = FAILURE; + } +} +//----------------------------------------------------------------------------- +// +//! \fn CScsiCacheMemStatLog +// +//! \brief +//! Description: Class deconstructor +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +CScsiCacheMemStatLog::~CScsiCacheMemStatLog() +{ + +} +//----------------------------------------------------------------------------- +// +//! \fn get_Parameter_Code_Description +// +//! \brief +//! Description: parser out the data for Cache Memory Parameter Information +// +// Entry: +//! \param description - string to give the Cache Memory Parameter depending on what the code is +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void CScsiCacheMemStatLog::get_Parameter_Code_Description(uint16_t paramCode, std::string *cacheStatistics) +{ + std::ostringstream temp; + switch (paramCode) + { + case 0x0001: + *cacheStatistics = "read cache memory hits"; + break; + case 0x0002: + *cacheStatistics = "reads to cache memory"; + break; + case 0x0003: + *cacheStatistics = "writes cache memory hits"; + break; + case 0x0004: + *cacheStatistics = "writes from cache memory"; + break; + case 0x0005: + *cacheStatistics = "time from last hard reset"; + break; + case 0x0006: + *cacheStatistics = "time interval"; + break; + default: + temp << "vendor specific 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << paramCode; + *cacheStatistics = temp.str(); + break; + } +} +//----------------------------------------------------------------------------- +// +//! \fn get_Parameter_Code_Description +// +//! \brief +//! Description: parser out the data for Cache Memory Parameter Information +// +// Entry: +//! \param description - string to give the Cache Memory Parameter depending on what the code is +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void opensea_parser::CScsiCacheMemStatLog::process_Cache_Memory_Statistics_interval_Data(JSONNODE * cacheData) +{ + std::string myStr = ""; + +#if defined_DEBUG + printf("Cache Memory Statistics Log Description\n"); +#endif + + byte_Swap_16(&m_TimeIntervalDescriptorParam->paramCode); + get_Parameter_Code_Description(m_TimeIntervalDescriptorParam->paramCode, &myStr); + + byte_Swap_Int32(&m_TimeIntervalDescriptorParam->intervalExponent); + byte_Swap_32(&m_TimeIntervalDescriptorParam->intervalInteger); + + JSONNODE* cacheStatisticsInfo = json_new(JSON_NODE); + json_set_name(cacheStatisticsInfo, myStr.c_str()); + + json_push_back(cacheStatisticsInfo, json_new_i("Time Interval Descriptor-Exponent", m_TimeIntervalDescriptorParam->intervalExponent)); + json_push_back(cacheStatisticsInfo, json_new_i("Time Interval Descriptor-Integer", m_TimeIntervalDescriptorParam->intervalExponent)); + + json_push_back(cacheData, cacheStatisticsInfo); +} + +//----------------------------------------------------------------------------- +// +//! \fn process_Generic_Data +// +//! \brief +//! Description: parser out the data for Cache Memory Parameter Information +// +// Entry: +//! \param description - string to give the Cache Memory Parameter depending on what the code is +//! \param offset - the offset to where params came from +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void CScsiCacheMemStatLog::process_Generic_Data(JSONNODE *genData) +{ + std::string myStr; + std::string myHeader; + +#if defined_DEBUG + printf("Cache Memory Statistics Log Description\n"); +#endif + byte_Swap_16(&m_CacheMemLog->paramCode); + get_Parameter_Code_Description(m_CacheMemLog->paramCode, &myHeader); + + std::ostringstream temp; + temp << std::dec << m_Value; + json_push_back(genData, json_new_a(myHeader.c_str(), temp.str().c_str())); +} +//----------------------------------------------------------------------------- +// +//! \fn populate_Generic_Param_Value +// +//! \brief +//! Description: parser out the data for Cache Memory Parameter Information +// +// Entry: +//! \param paramLength - string to give the Cache Memory Parameter depending on what the code +//! \param offset - the offset to get the value +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void CScsiCacheMemStatLog::populate_Generic_Param_Value(uint8_t paramLength, uint32_t offset) +{ + switch (paramLength) + { + case ONE_INT_SIZE: + m_Value = pData[offset]; + break; + case TWO_INT_SIZE: + m_Value = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); + break; + case FOUR_INT_SIZE: + m_Value = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); + break; + case EIGHT_INT_SIZE: + m_Value = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); + break; + default: + m_Value = 0; + break; + } +} +//----------------------------------------------------------------------------- +// +//! \fn get_Cache_Memory_Statistics_Data +// +//! \brief +//! Description: parser out the data for the error counter log +// +// Entry: +//! \param masterData - Json node that holds all the data +// +// Exit: +//! \return eReturnValues +// +//--------------------------------------------------------------------------- +eReturnValues CScsiCacheMemStatLog::get_Cache_Memory_Statistics_Data(JSONNODE *masterData) +{ + + std::string myStr; + std::string headerStr; + eReturnValues retStatus = IN_PROGRESS; + if (pData != NULL) + { + headerStr = "Cache Memory Statistics Log - 19h"; + JSONNODE* pageInfo = json_new(JSON_NODE); + + json_set_name(pageInfo, headerStr.c_str()); + + for (uint32_t offset = 0; offset < m_PageLength; ) + { + if (offset < m_bufferLength && offset < UINT16_MAX) + { + uint16_t paramCode = *(reinterpret_cast(&pData[offset])); + byte_Swap_16(¶mCode); + if (paramCode == 0x0005) + { + m_TimeIntervalDescriptorParam = reinterpret_cast(&pData[offset]); + process_Cache_Memory_Statistics_interval_Data(pageInfo); + offset += m_TimeIntervalDescriptorParam->paramLength + LOGPAGESIZE; + } + else + { + m_CacheMemLog = reinterpret_cast(&pData[offset]); + populate_Generic_Param_Value(m_CacheMemLog->paramLength,offset + LOGPAGESIZE); + process_Generic_Data(pageInfo); + offset += (m_CacheMemLog->paramLength + LOGPAGESIZE); + } + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + } + json_push_back(masterData, pageInfo); + retStatus = SUCCESS; + } + else + { + retStatus = MEMORY_FAILURE; + } + return retStatus; +} diff --git a/src/CScsi_Page_19h_Command_Duration_Limits_Log.cpp b/src/CScsi_Page_19h_Command_Duration_Limits_Log.cpp new file mode 100644 index 0000000..3bf7560 --- /dev/null +++ b/src/CScsi_Page_19h_Command_Duration_Limits_Log.cpp @@ -0,0 +1,329 @@ +// +// CScsi_Page_19h_Command_Duration_Limits_Log.cpp +// Do NOT modify or remove this copyright and license +// +// Copyright (c) 2015 - 2021 Seagate Technology LLC and/or its Affiliates +// +// This software is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +// ****************************************************************************************** + +// \file CScsi_Page_19h_Command_Duration_Limits_Log.cpp Definition of SCSI Command Duration Limits Log +// +#include "CScsi_Page_19h_Command_Duration_Limits_Log.h" + +using namespace opensea_parser; +//----------------------------------------------------------------------------- +// +//! \fn CScsiCmdDurationLimitsLog() +// +//! \brief +//! Description: Default Class constructor +// +// Entry: +// \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +CScsiCmdDurationLimitsLog::CScsiCmdDurationLimitsLog() + : pData() + , m_CMDLimitsName("Command Duration Limits Log") + , m_LogStatus(IN_PROGRESS) + , m_PageLength(0) + , m_bufferLength(0) + , m_commandLog(NULL) + , m_limitsLog(NULL) + , m_Value(0) +{ + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_CMDLimitsName.c_str()); + } +} +//----------------------------------------------------------------------------- +// +//! \fn CScsiPerformanceStatisticsLog() +// +//! \brief +//! Description: Class constructor for VOLTAGE MONITORING LOG +// +// Entry: +//! \param buffer = holds the buffer information +//! \param bufferSize - Full size of the buffer +//! \param pageLength - the size of the page for the parameter header +// +// Exit: +// +//--------------------------------------------------------------------------- +CScsiCmdDurationLimitsLog::CScsiCmdDurationLimitsLog(uint8_t * buffer, size_t bufferSize, uint16_t pageLength) + : pData(buffer) + , m_CMDLimitsName("Command Duration Limits Log") + , m_LogStatus(IN_PROGRESS) + , m_PageLength(pageLength) + , m_bufferLength(bufferSize) + , m_commandLog(NULL) + , m_limitsLog(NULL) + , m_Value(0) +{ + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("%s \n", m_CMDLimitsName.c_str()); + } + if (buffer != NULL) + { + m_LogStatus = IN_PROGRESS; + } + else + { + m_LogStatus = FAILURE; + } +} +//----------------------------------------------------------------------------- +// +//! \fn CScsiCmdDurationLimitsLog +// +//! \brief +//! Description: Class deconstructor +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +CScsiCmdDurationLimitsLog::~CScsiCmdDurationLimitsLog() +{ + +} +//----------------------------------------------------------------------------- +// +//! \fn get_Parameter_Code_Description +// +//! \brief +//! Description: parser out the data for Error Parameter Information +// +// Entry: +//! \param description - string to give the Error Parameter depending on what the code is +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void CScsiCmdDurationLimitsLog::get_Parameter_Code_Description(uint16_t paramCode, std::string* generalStr) +{ + if (paramCode >= 0x0011 && paramCode <= 0x0017) + { + *generalStr = "Command Duration Limit T2A"; + } + else if (paramCode >= 0x0021 && paramCode <= 0x0027) + { + *generalStr = "Command Duration Limit T2B"; + } + else + { + std::ostringstream temp; + temp <<"vendor specific 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << paramCode; + generalStr->assign(temp.str()); + } +} +//----------------------------------------------------------------------------- +// +//! \fn process_Generic_Data() +// +//! \brief +//! Description: function for parsing out the Generic information +// +// Entry: +//! \param fuaData - the Json node olding all the FUA data +//! \param paramCode - passed in param code +// +// Exit: +// +//--------------------------------------------------------------------------- +void CScsiCmdDurationLimitsLog::process_Generic_Data(JSONNODE* genericData) +{ + std::string myHeader; + +#if defined_DEBUG + printf("Genaric Log Description\n"); +#endif + byte_Swap_16(&m_commandLog->paramCode); + get_Parameter_Code_Description(m_commandLog->paramCode, &myHeader); + std::ostringstream temp; + temp << std::dec << m_Value; + json_push_back(genericData, json_new_a(myHeader.c_str(), temp.str().c_str())); +} +//----------------------------------------------------------------------------- +// +//! \fn process_Achievable_Data() +// +//! \brief +//! Description: function for parsing out the achivable Latency target information +// +// Entry: +//! \param fuaData - the Json node olding all the FUA data +//! \param paramCode - passed in param code +// +// Exit: +// +//--------------------------------------------------------------------------- +void CScsiCmdDurationLimitsLog::process_Achievable_Data(JSONNODE * achievableData) +{ + std::string myHeader; + +#if defined_DEBUG + printf("Achievable Latency Target Log Description\n"); +#endif + byte_Swap_16(&m_commandLog->paramCode); + + myHeader = "Achievable Latency Target"; + std::ostringstream temp; + temp << std::dec << m_Value; + json_push_back(achievableData, json_new_a(myHeader.c_str(), temp.str().c_str())); + +} +//----------------------------------------------------------------------------- +// +//! \fn process_Duration_Limits_Data() +// +//! \brief +//! Description: function for parsing out the fua data for 0x0004 param +// +// Entry: +//! \param fuaData - the Json node olding all the FUA data +// +// Exit: +// +//--------------------------------------------------------------------------- +void CScsiCmdDurationLimitsLog::process_Duration_Limits_Data(JSONNODE* limitData) +{ + std::string myStr; + +#if defined_DEBUG + printf("Command DurationLimits Log Description\n"); +#endif + byte_Swap_16(&m_limitsLog->paramCode); + get_Parameter_Code_Description(m_limitsLog->paramCode, &myStr); + + byte_Swap_32(&m_limitsLog->activeMiss); + byte_Swap_32(&m_limitsLog->inactiveMiss); + byte_Swap_32(&m_limitsLog->latencyMiss); + byte_Swap_32(&m_limitsLog->latencyMissesDeferredErrors); + byte_Swap_32(&m_limitsLog->latencyMissesDoToError); + byte_Swap_32(&m_limitsLog->missedDoToBackgroundOperations); + byte_Swap_32(&m_limitsLog->nonconformingMiss); + byte_Swap_32(&m_limitsLog->predictiveLatencyMiss); + + JSONNODE* limitInfo = json_new(JSON_NODE); + json_set_name(limitInfo, myStr.c_str()); + + set_json_64bit(limitInfo, "Number of Inactive Target Miss Commands", m_limitsLog->inactiveMiss, false); + set_json_64bit(limitInfo, "Number of Write FUA commands", m_limitsLog->activeMiss, false); + set_json_64bit(limitInfo, "Number of read FUA_NV commands", m_limitsLog->latencyMiss, false); + set_json_64bit(limitInfo, "Number of write FUA_NV commands", m_limitsLog->nonconformingMiss, false); + set_json_64bit(limitInfo, "Read FUA Commands Processing Itervals", m_limitsLog->predictiveLatencyMiss, false); + set_json_64bit(limitInfo, "Write FUA Commands Processing Itervals", m_limitsLog->latencyMissesDoToError, false); + set_json_64bit(limitInfo, "Read FUA_NV Commands Processing Itervals", m_limitsLog->latencyMissesDeferredErrors, false); + set_json_64bit(limitInfo, "Read FUA_NV Commands Processing Itervals", m_limitsLog->missedDoToBackgroundOperations, false); + + json_push_back(limitData, limitInfo); + +} + +void CScsiCmdDurationLimitsLog::populate_Generic_Param_Value(uint8_t paramLength, uint32_t offset) +{ + switch (paramLength) + { + case ONE_INT_SIZE: + m_Value = pData[offset]; + break; + case TWO_INT_SIZE: + m_Value = M_BytesTo2ByteValue(pData[offset], pData[offset + 1]); + break; + case FOUR_INT_SIZE: + m_Value = M_BytesTo4ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3]); + break; + case EIGHT_INT_SIZE: + m_Value = M_BytesTo8ByteValue(pData[offset], pData[offset + 1], pData[offset + 2], pData[offset + 3], pData[offset + 4], pData[offset + 5], pData[offset + 6], pData[offset + 7]); + break; + default: + m_Value = 0; + break; + } +} +//----------------------------------------------------------------------------- +// +//! \fn get_Limits_Data +// +//! \brief +//! Description: parser out the data for the command duration limit +// +// Entry: +//! \param masterData - Json node that holds all the data +// +// Exit: +//! \return eReturnValues +// +//--------------------------------------------------------------------------- +eReturnValues CScsiCmdDurationLimitsLog::get_Limits_Data(JSONNODE *masterData) +{ + + eReturnValues retStatus = IN_PROGRESS; + if (pData != NULL) + { + JSONNODE* pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, "Command Duration Limits Log - 19h, 21h"); + for (uint32_t offset = 0; offset < m_PageLength; ) + { + if (offset < m_bufferLength && offset < UINT16_MAX) + { + uint16_t paramCode = *(reinterpret_cast(&pData[offset])); + byte_Swap_16(¶mCode); + if (paramCode == 0x0001) + { + m_commandLog = reinterpret_cast(&pData[offset]); + process_Achievable_Data(pageInfo); + offset += m_commandLog->paramLength + LOGPAGESIZE; + } + else if (paramCode >= 0x0011 && paramCode <= 0x0017) + { + + m_limitsLog = reinterpret_cast(&pData[offset]); + process_Duration_Limits_Data(pageInfo); + offset += m_limitsLog->paramLength + LOGPAGESIZE; + } + else if (paramCode >= 0x0021 && paramCode <= 0x0027) + { + + m_limitsLog = reinterpret_cast(&pData[offset]); + process_Duration_Limits_Data(pageInfo); + offset += m_limitsLog->paramLength + LOGPAGESIZE; + } + else + { + m_commandLog = reinterpret_cast(&pData[offset]); + populate_Generic_Param_Value(m_commandLog->paramLength,offset + LOGPAGESIZE); + process_Generic_Data(pageInfo); + offset += (m_commandLog->paramLength + LOGPAGESIZE); + } + } + else + { + json_push_back(masterData, pageInfo); + return BAD_PARAMETER; + } + } + json_push_back(masterData, pageInfo); + retStatus = SUCCESS; + } + else + { + retStatus = MEMORY_FAILURE; + } + return retStatus; +} diff --git a/src/CScsi_Pending_Defects_Log.cpp b/src/CScsi_Pending_Defects_Log.cpp index 8b26269..b62e2f6 100644 --- a/src/CScsi_Pending_Defects_Log.cpp +++ b/src/CScsi_Pending_Defects_Log.cpp @@ -1,7 +1,7 @@ // CScsi_Pending_Defects_Log..cpp Definition for parsing the pending defecs // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -37,6 +37,7 @@ CScsiPendingDefectsLog::CScsiPendingDefectsLog() , m_bufferLength(0) , m_PListCountParam() , m_PlistDefect() + , m_count(0) { if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { @@ -66,13 +67,14 @@ CScsiPendingDefectsLog::CScsiPendingDefectsLog(uint8_t * buffer, size_t bufferSi , m_bufferLength(bufferSize) , m_PListCountParam() , m_PlistDefect() + , m_count(0) { if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { printf("%s \n", m_PlistName.c_str()); } pData = new uint8_t[pageLength]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, buffer, pageLength); #else memcpy_s(pData, pageLength, buffer, pageLength);// copy the buffer data to the class member pBuf @@ -126,28 +128,34 @@ CScsiPendingDefectsLog::~CScsiPendingDefectsLog() //--------------------------------------------------------------------------- void CScsiPendingDefectsLog::process_PList_Data(JSONNODE *pendingData) { - std::string myStr = ""; - myStr.resize(BASIC); + byte_Swap_16(&m_PlistDefect->paramCode); + byte_Swap_32(&m_PlistDefect->defectPOH); + byte_Swap_64(&m_PlistDefect->defectLBA); + #if defined _DEBUG printf("Pending Defect Log \n"); #endif - byte_Swap_16(&m_PlistDefect->paramCode); - snprintf((char*)myStr.c_str(), BASIC, "Pending Defect number %" PRIi16"", m_PlistDefect->paramCode); - JSONNODE *pListInfo = json_new(JSON_NODE); - json_set_name(pListInfo, (char*)myStr.c_str()); + std::ostringstream temp; + temp << "Pending Defect number " << std::dec << m_PlistDefect->paramCode; + JSONNODE* pListInfo = json_new(JSON_NODE); + json_set_name(pListInfo, temp.str().c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_PlistDefect->paramCode); - json_push_back(pListInfo, json_new_a("Pending Defect Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_PlistDefect->paramControlByte); - json_push_back(pListInfo, json_new_a("Pending DefectControl Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_PlistDefect->paramLength); - json_push_back(pListInfo, json_new_a("Pending Defect Length ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_PlistDefect->paramCode; + json_push_back(pListInfo, json_new_a("Pending Defect Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_PlistDefect->paramControlByte); + json_push_back(pListInfo, json_new_a("Pending DefectControl Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_PlistDefect->paramLength); + json_push_back(pListInfo, json_new_a("Pending Defect Length ", temp.str().c_str())); json_push_back(pListInfo, json_new_i("Pending Defect Power On Hours", static_cast(m_PlistDefect->defectPOH))); set_json_64bit(pListInfo, "Pending Defect LBA", m_PlistDefect->defectLBA, true); json_push_back(pendingData, pListInfo); + } //----------------------------------------------------------------------------- // @@ -165,25 +173,27 @@ void CScsiPendingDefectsLog::process_PList_Data(JSONNODE *pendingData) //--------------------------------------------------------------------------- void CScsiPendingDefectsLog::process_PList_Count(JSONNODE *pendingCount) { - std::string myStr = ""; - myStr.resize(BASIC); + byte_Swap_16(&m_PListCountParam->paramCode); + byte_Swap_32(&m_PListCountParam->totalPlistCount); + #if defined _DEBUG printf("Pending Defect Count \n"); #endif - byte_Swap_16(&m_PListCountParam->paramCode); - JSONNODE *countInfo = json_new(JSON_NODE); + JSONNODE* countInfo = json_new(JSON_NODE); json_set_name(countInfo, "Pending Defect count"); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_PListCountParam->paramCode); - json_push_back(countInfo, json_new_a("Pending Defect Counter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_PListCountParam->paramControlByte); - json_push_back(countInfo, json_new_a("Pending Defect Counter Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_PListCountParam->paramLength); - json_push_back(countInfo, json_new_a("Pending Defect Counter Length ", (char*)myStr.c_str())); - byte_Swap_32(&m_PListCountParam->totalPlistCount); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_PListCountParam->paramCode; + json_push_back(countInfo, json_new_a("Pending Defect Counter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_PListCountParam->paramControlByte); + json_push_back(countInfo, json_new_a("Pending Defect Counter Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_PListCountParam->paramLength); + json_push_back(countInfo, json_new_a("Pending Defect Counter Length ", temp.str().c_str())); json_push_back(countInfo, json_new_i("Pending Defect Count", static_cast(m_PListCountParam->totalPlistCount))); json_push_back(pendingCount, countInfo); + } //----------------------------------------------------------------------------- // @@ -201,24 +211,22 @@ void CScsiPendingDefectsLog::process_PList_Count(JSONNODE *pendingCount) //--------------------------------------------------------------------------- eReturnValues CScsiPendingDefectsLog::get_Plist_Data(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); eReturnValues retStatus = IN_PROGRESS; if (pData != NULL) { - myStr = "Pending Defect Log - 15h"; JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, (char*)myStr.c_str()); - m_PListCountParam = (sPendindDefectCount *)pData; + json_set_name(pageInfo, "Pending Defect Log - 15h"); + m_PListCountParam = reinterpret_cast(pData); process_PList_Count(pageInfo); - if ((size_t)m_PageLength > sizeof(sPendindDefectCount)) // for when there is zero count defects + if (static_cast(m_PageLength) > sizeof(sPendindDefectCount)) // for when there is zero count defects { - for (size_t offset = sizeof(sPendindDefectCount); offset < (size_t)m_PageLength; ) + for (uint32_t offset = sizeof(sPendindDefectCount); offset < static_cast(m_PageLength); ) { if (offset < (m_bufferLength - sizeof(sLogPageStruct))) { - m_PlistDefect = (sDefect *)&pData[offset]; + m_PlistDefect = reinterpret_cast(&pData[offset]); offset += sizeof(sDefect); + m_count++; // defect found add one to the count process_PList_Data(pageInfo); } else @@ -236,4 +244,4 @@ eReturnValues CScsiPendingDefectsLog::get_Plist_Data(JSONNODE *masterData) retStatus = MEMORY_FAILURE; } return retStatus; -} \ No newline at end of file +} diff --git a/src/CScsi_Power_Condition_Transitions_Log.cpp b/src/CScsi_Power_Condition_Transitions_Log.cpp index 1cf2f2a..378e349 100644 --- a/src/CScsi_Power_Condition_Transitions_Log.cpp +++ b/src/CScsi_Power_Condition_Transitions_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Power_Condition_Transitions_Log.h Definition of Power Condition Transistions Log Page for SAS // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -69,7 +69,7 @@ CScsiPowerConditiontLog::CScsiPowerConditiontLog(uint8_t * buffer, size_t buffer printf("%s \n", m_PowerName.c_str()); } pData = new uint8_t[pageLength]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, buffer, pageLength); #else memcpy_s(pData, pageLength, buffer, pageLength);// copy the buffer data to the class member pBuf @@ -129,43 +129,43 @@ bool CScsiPowerConditiontLog::get_Power_Mode_Type(std::string *power, uint16_t c { case ACTIVE: { - snprintf((char*)power->c_str(), BASIC, "Accumulated transitions to active"); + power->assign("Accumulated transitions to active"); typeFound = true; break; } case IDLE_A: { - snprintf((char*)power->c_str(), BASIC, "Accumulated transitions to idle_a"); + power->assign("Accumulated transitions to idle_a"); typeFound = true; break; } case IDLE_B: { - snprintf((char*)power->c_str(), BASIC, "Accumulated transitions to idle_b"); + power->assign("Accumulated transitions to idle_b"); typeFound = true; break; } case IDLE_C: { - snprintf((char*)power->c_str(), BASIC, "Accumulated transitions to idle_c"); + power->assign("Accumulated transitions to idle_c"); typeFound = true; break; } case STANDZ: { - snprintf((char*)power->c_str(), BASIC, "Accumulated transitions to standby_z"); + power->assign("Accumulated transitions to standby_z"); typeFound = true; break; } case STANDY: { - snprintf((char*)power->c_str(), BASIC, "Accumulated transitions to standby_y"); + power->assign("Accumulated transitions to standby_y"); typeFound = true; break; } default: { - snprintf((char*)power->c_str(), BASIC, "Vendor Specific Power Mode Transition Type"); + power->assign("Vendor Specific Power Mode Transition Type"); break; } } @@ -189,7 +189,6 @@ void CScsiPowerConditiontLog::process_List_Information(JSONNODE *powerData) { bool typeFound = false; std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Power Condition Transitions Log Page\n"); #endif @@ -200,15 +199,18 @@ void CScsiPowerConditiontLog::process_List_Information(JSONNODE *powerData) if (m_PowerParam->paramValue != 0) { JSONNODE *powerInfo = json_new(JSON_NODE); - json_set_name(powerInfo, (char*)myStr.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_PowerParam->paramCode); - json_push_back(powerInfo, json_new_a("Power Condition Type", (char*)myStr.c_str())); + json_set_name(powerInfo, myStr.c_str()); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_PowerParam->paramCode; + json_push_back(powerInfo, json_new_a("Power Condition Type", temp.str().c_str())); if (!typeFound) { - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_PowerParam->paramControlByte); - json_push_back(powerInfo, json_new_a("Control Byte", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_PowerParam->paramLength); - json_push_back(powerInfo, json_new_a("Length", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_PowerParam->paramControlByte); + json_push_back(powerInfo, json_new_a("Control Byte", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_PowerParam->paramLength); + json_push_back(powerInfo, json_new_a("Length", temp.str().c_str())); } json_push_back(powerInfo, json_new_i("Power Value", m_PowerParam->paramValue)); json_push_back(powerData, powerInfo); @@ -240,7 +242,7 @@ eReturnValues CScsiPowerConditiontLog::get_Data(JSONNODE *masterData) { if (offset < m_bufferLength && offset < UINT16_MAX) { - m_PowerParam = (sPowerParams *)&pData[offset]; + m_PowerParam = reinterpret_cast(&pData[offset]); // process the power information process_List_Information(pageInfo); } @@ -259,4 +261,4 @@ eReturnValues CScsiPowerConditiontLog::get_Data(JSONNODE *masterData) retStatus = MEMORY_FAILURE; } return retStatus; -} \ No newline at end of file +} diff --git a/src/CScsi_Protocol_Specific_Port_Log.cpp b/src/CScsi_Protocol_Specific_Port_Log.cpp index 6a4de57..9937cde 100644 --- a/src/CScsi_Protocol_Specific_Port_Log.cpp +++ b/src/CScsi_Protocol_Specific_Port_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Protocol_Specific_Port_Log.h Definition of Protocol-Specific Port log page for SAS // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -60,13 +60,16 @@ CScsiProtocolPortLog::CScsiProtocolPortLog(uint8_t *buffer, size_t bufferSize) , m_PSPStatus(IN_PROGRESS) , m_PageLength(0) , m_bufferLength(bufferSize) + , m_List(NULL) + , m_Descriptor(NULL) + , m_Event(NULL) { if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { printf("%s \n", m_PSPName.c_str()); } pData = new uint8_t[bufferSize]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, buffer, bufferSize); #else memcpy_s(pData, bufferSize, buffer, bufferSize); // copy the buffer data to the class member pBuf @@ -120,24 +123,26 @@ CScsiProtocolPortLog::~CScsiProtocolPortLog() //--------------------------------------------------------------------------- void CScsiProtocolPortLog::process_Events_Data(JSONNODE *eventData) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Phy Event Description \n"); #endif - snprintf((char*)myStr.c_str(), BASIC, "Phy Event Description %" PRId8"",m_Event->eventSource); + std::ostringstream temp; + temp << "Phy Event Description " << std::dec << static_cast(m_Event->eventSource); JSONNODE *eventInfo = json_new(JSON_NODE); - json_set_name(eventInfo, (char*)myStr.c_str()); + json_set_name(eventInfo, temp.str().c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Event->eventSource); - json_push_back(eventInfo, json_new_a("Phy Event Source", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Event->eventSource); + json_push_back(eventInfo, json_new_a("Phy Event Source", temp.str().c_str())); byte_Swap_32(&m_Event->event); // need to byte swap on SAS byte_Swap_32(&m_Event->threshold); // need to byte swap on SAS - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", m_Event->event); - json_push_back(eventInfo, json_new_a("Phy Event", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", m_Event->threshold); - json_push_back(eventInfo, json_new_a("Peak Value Detector Threshold", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << m_Event->event; + json_push_back(eventInfo, json_new_a("Phy Event", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << m_Event->threshold; + json_push_back(eventInfo, json_new_a("Peak Value Detector Threshold", temp.str().c_str())); json_push_back(eventData, eventInfo); } @@ -162,22 +167,22 @@ void CScsiProtocolPortLog::get_Device_Type_Field(std::string *description, uint8 { case 0x01: { - snprintf((char*)description->c_str(), BASIC, "1 = End device"); + description->assign("1 = End device"); break; } case 0x02: { - snprintf((char*)description->c_str(), BASIC, "2 = Expander device"); + description->assign("2 = Expander device"); break; } case 0x03: { - snprintf((char*)description->c_str(), BASIC, "3 = Expander device compliant with a previous version of the SAS standard"); + description->assign("3 = Expander device compliant with a previous version of the SAS standard"); break; } default: { - snprintf((char*)description->c_str(), BASIC, "Reserved"); + description->assign("Reserved"); break; } @@ -204,52 +209,52 @@ void CScsiProtocolPortLog::get_Reason_Field(std::string *reason, uint8_t code) { case 0x01: { - snprintf((char*)reason->c_str(), BASIC, "Unknown reason"); + reason->assign("Unknown reason"); break; } case 0x02: { - snprintf((char*)reason->c_str(), BASIC, "Power on"); + reason->assign("Power on"); break; } case 0x03: { - snprintf((char*)reason->c_str(), BASIC, "Hard reset"); + reason->assign("Hard reset"); break; } case 0x04: { - snprintf((char*)reason->c_str(), BASIC, "SMP PHY CONTROL function LINK RESET phy operation"); + reason->assign("SMP PHY CONTROL function LINK RESET phy operation"); break; } case 0x05: { - snprintf((char*)reason->c_str(), BASIC, "After the multiplexing sequence complete"); + reason->assign("After the multiplexing sequence complete"); break; } case 0x06: { - snprintf((char*)reason->c_str(), BASIC, "I_T nexus loss timer"); + reason->assign("I_T nexus loss timer"); break; } case 0x07: { - snprintf((char*)reason->c_str(), BASIC, "Break Timeout Timer expired"); + reason->assign("Break Timeout Timer expired"); break; } case 0x08: { - snprintf((char*)reason->c_str(), BASIC, "Phy test function stopped"); + reason->assign("Phy test function stopped"); break; } case 0x09: { - snprintf((char*)reason->c_str(), BASIC, "Expander device reduced functionality"); + reason->assign("Expander device reduced functionality"); break; } default: { - snprintf((char*)reason->c_str(), BASIC, "Reserved"); + reason->assign("Reserved"); break; } @@ -257,6 +262,317 @@ void CScsiProtocolPortLog::get_Reason_Field(std::string *reason, uint8_t code) } //----------------------------------------------------------------------------- // +//! \fn process_Event_Description +// +//! \brief +//! Description: parser out the data for phy event source +// +// Entry: +//! \param source - string to give the event a name +//! \param event - code holds event description +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void CScsiProtocolPortLog::process_Event_Description(std::string* source, uint8_t event) +{ + switch (event) + { + case 0x00: + { + *source = "no event"; + break; + } + case 0x01: + { + *source = "invalid dwords"; + break; + } + case 0x02: + { + *source = "running disparity errors"; + break; + } + case 0x03: + { + *source = "loss of dword sync"; + break; + } + case 0x04: + { + *source = "phy reset problems"; + break; + } + case 0x05: + { + *source = "elasticity buffer overflows"; + break; + } + case 0x06: + { + *source = "received errors"; + break; + } + case 0x07: + *source = "invalid SPL packets"; + break; + case 0x08: + *source = "loss of SPL packet sync"; + break; + case 0x09: + case 0x0a: + case 0x0b: + case 0x0c: + case 0x0d: + case 0x0e: + case 0x0f: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1a: + case 0x1b: + case 0x1c: + case 0x1d: + case 0x1e: + case 0x1f: + { + *source = "reserved for phy layer-based phy events"; + break; + } + case 0x20: + { + *source = "received address frame errors"; + break; + } + case 0x21: + { + *source = "transmitted abandon-class open_rejects"; + break; + } + case 0x22: + { + *source = "received abandon-class open_rejects"; + break; + } + case 0x23: + { + *source = "transmitted retry-class open_rejects"; + break; + } + case 0x24: + { + *source = "received retry-class open_rejects"; + break; + } + case 0x25: + { + *source = "received (waiting on partial) apis"; + break; + } + case 0x26: + { + *source = "received (waiting on connection) apis"; + break; + } + case 0x27: + { + *source = "transmitted breaks"; + break; + } + case 0x28: + { + *source = "received breaks"; + break; + } + case 0x29: + { + *source = "break timeouts"; + break; + } + case 0x2a: + { + *source = "connections"; + break; + } + case 0x2b: + { + *source = "peak transmitted pathway blocks"; + break; + } + case 0x2c: + { + *source = "peak transmitted arbitration wait time"; + break; + } + case 0x2d: + { + *source = "peak arbitration time"; + break; + } + case 0x2e: + { + if (g_dataformat == PREPYTHON_DATA) + { + *source = "peak connection time"; + } + else + { + *source = "peak connection time pvd the peak duration, in microseconds, of any connection in which the phy was involved"; + } + break; + } + case 0x2f: + *source = "persistent connections"; + break; + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3a: + case 0x3b: + case 0x3c: + case 0x3d: + case 0x3e: + case 0x3f: + { + *source = "reserved for sas arbitration-related phy information"; + break; + } + case 0x40: + { + *source = "transmitted ssp frames"; + break; + } + case 0x41: + { + *source = "received ssp frames"; + break; + } + case 0x42: + { + *source = "transmitted ssp frame errors"; + break; + } + case 0x43: + { + *source = "received ssp frame errors"; + break; + } + case 0x44: + { + *source = "transmitted credit_blockeds"; + break; + } + case 0x45: + { + *source = "received credit_blockeds"; + break; + } + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4a: + case 0x4b: + case 0x4c: + case 0x4d: + case 0x4e: + case 0x4f: + { + *source = "reserved for ssp-related phy events"; + break; + } + case 0x50: + { + *source = "transmitted sata frames"; + break; + } + case 0x51: + { + *source = "received sata frames"; + break; + } + case 0x52: + { + *source = "sata flow control buffer overflows"; + break; + } + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5a: + case 0x5b: + case 0x5c: + case 0x5d: + case 0x5e: + case 0x5f: + { + *source = "reserved for stp and sata-related phy events"; + break; + } + case 0x60: + { + *source = "transmitted smp frames"; + break; + } + case 0x61: + { + *source = "received smp frames"; + break; + } + case 0x62: + { + *source = "reserved for smp-related phy events"; + break; + } + case 0x63: + { + *source = "received smp frame errors"; + break; + } + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6a: + case 0x6b: + case 0x6c: + case 0x6d: + case 0x6e: + case 0x6f: + { + *source = "reserved for smp-related phy events"; + break; + } + default: + { + *source = "vendor specific"; + break; + } + } +} +//----------------------------------------------------------------------------- +// //! \fn get_Negotiated_Logical_Link_Rate // //! \brief @@ -276,22 +592,27 @@ void CScsiProtocolPortLog::get_Negotiated_Logical_Link_Rate(std::string *rate, u { case 0x09: { - snprintf((char*)rate->c_str(), BASIC, "1.5 GBs"); + rate->assign("1.5 GBs"); break; } case 0x0a: { - snprintf((char*)rate->c_str(), BASIC, "3.5 to 6 GBs"); + rate->assign("3.5 to 6 GBs"); break; } case 0x0b: { - snprintf((char*)rate->c_str(), BASIC, "6 - 12 GBs"); + rate->assign("6 - 12 GBs"); + break; + } + case 0x0c: + { + rate->assign("22.5 GBs"); break; } default: { - snprintf((char*)rate->c_str(), BASIC, "Same as the NEGOTIATED LOGICAL LINK RATE field"); + rate->assign("Same as the NEGOTIATED LOGICAL LINK RATE field"); break; } } @@ -312,60 +633,70 @@ void CScsiProtocolPortLog::get_Negotiated_Logical_Link_Rate(std::string *rate, u //--------------------------------------------------------------------------- void CScsiProtocolPortLog::process_Descriptor_Information(JSONNODE *descData) { - std::string myStr = ""; - myStr.resize(BASIC); + std::string myStr; #if defined _DEBUG printf("Descriptor Information \n"); #endif - - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->phyIdent); - json_push_back(descData, json_new_a("PHY Identifier", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->phyLength); - json_push_back(descData, json_new_a("SAS Phy Descriptor Length", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->attached); - json_push_back(descData, json_new_a("Attached Device Type and Reason", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->phyIdent); + json_push_back(descData, json_new_a("PHY Identifier", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->phyLength); + json_push_back(descData, json_new_a("SAS Phy Descriptor Length", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->attached); + json_push_back(descData, json_new_a("Attached Device Type and Reason", temp.str().c_str())); + temp.str("");temp.clear(); get_Device_Type_Field(&myStr,M_GETBITRANGE(m_Descriptor->attached, 6, 4)); - json_push_back(descData, json_new_a("Attached Device Type Meaning", (char*)myStr.c_str())); + json_push_back(descData, json_new_a("Attached Device Type Meaning", myStr.c_str())); get_Reason_Field(&myStr, M_GETBITRANGE(m_Descriptor->attached, 3, 0)); - json_push_back(descData, json_new_a("Attached Reason Meaning", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->reason); - json_push_back(descData, json_new_a("Attached Rate", (char*)myStr.c_str())); + json_push_back(descData, json_new_a("Attached Reason Meaning", myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->reason); + json_push_back(descData, json_new_a("Attached Rate", temp.str().c_str())); get_Negotiated_Logical_Link_Rate(&myStr, M_GETBITRANGE(m_Descriptor->reason, 3, 0)); - json_push_back(descData, json_new_a("Attached Rate Meaning", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->initiatorPort); - json_push_back(descData, json_new_a("Attached Initiator Port", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->targetPort); - json_push_back(descData, json_new_a("Attached Target Port", (char*)myStr.c_str())); + json_push_back(descData, json_new_a("Attached Rate Meaning", myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->initiatorPort); + json_push_back(descData, json_new_a("Attached Initiator Port", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->targetPort); + json_push_back(descData, json_new_a("Attached Target Port", temp.str().c_str())); byte_Swap_64(&m_Descriptor->address); // need to byte swap on SAS 64 bit byte_Swap_64(&m_Descriptor->attachedAddress); // need to byte swap on SAS 64 bit - snprintf((char*)myStr.c_str(), BASIC, "0x%014" PRIx64"", m_Descriptor->address); - json_push_back(descData, json_new_a("World Wide Name", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%014" PRIx64"", m_Descriptor->attachedAddress); - json_push_back(descData, json_new_a("Attached Address", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->attachedPhyIdent); - json_push_back(descData, json_new_a("Attached Phy Identifier", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(14) << m_Descriptor->address; + json_push_back(descData, json_new_a("World Wide Name", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(14) << m_Descriptor->attachedAddress; + json_push_back(descData, json_new_a("Attached Address", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->attachedPhyIdent); + json_push_back(descData, json_new_a("Attached Phy Identifier", temp.str().c_str())); byte_Swap_32(&m_Descriptor->invalidDwordCount); // need to byte swap on SAS byte_Swap_32(&m_Descriptor->disparityErrorCount); // need to byte swap on SAS byte_Swap_32(&m_Descriptor->synchronization); // need to byte swap on SAS byte_Swap_32(&m_Descriptor->phyResetProblem); // need to byte swap on SAS - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", m_Descriptor->invalidDwordCount); - json_push_back(descData, json_new_a("Invalid Dword Count", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", m_Descriptor->disparityErrorCount); - json_push_back(descData, json_new_a("Running Dispariity Error Count", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", m_Descriptor->synchronization); - json_push_back(descData, json_new_a("Loss Of DWORD Synchronization", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", m_Descriptor->phyResetProblem); - json_push_back(descData, json_new_a("Phy Reset Problem", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->phyEventLength); - json_push_back(descData, json_new_a("Phy Event Descriptor Length", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Descriptor->numberOfEvents); - json_push_back(descData, json_new_a("Number of Pyh Events", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << m_Descriptor->invalidDwordCount; + json_push_back(descData, json_new_a("Invalid Dword Count", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << m_Descriptor->disparityErrorCount; + json_push_back(descData, json_new_a("Running Dispariity Error Count", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << m_Descriptor->synchronization; + json_push_back(descData, json_new_a("Loss Of DWORD Synchronization", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << m_Descriptor->phyResetProblem; + json_push_back(descData, json_new_a("Phy Reset Problem", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->phyEventLength); + json_push_back(descData, json_new_a("Phy Event Descriptor Length", temp.str().c_str())); + temp.str(""); temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Descriptor->numberOfEvents); + json_push_back(descData, json_new_a("Number of Pyh Events", temp.str().c_str())); } //----------------------------------------------------------------------------- @@ -384,22 +715,24 @@ void CScsiProtocolPortLog::process_Descriptor_Information(JSONNODE *descData) //--------------------------------------------------------------------------- void CScsiProtocolPortLog::process_List_Information(JSONNODE *listData) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("List Information \n"); #endif - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_List->paramCode); - json_push_back(listData, json_new_a("Relative Target Port Identifier", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_List->paramControlByte); - json_push_back(listData, json_new_a("Relative Target Port Control Byte", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_List->paramLength); - json_push_back(listData, json_new_a("Relative Target Port Length", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_List->ident); - json_push_back(listData, json_new_a("Port Identifier", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_List->genCode); - json_push_back(listData, json_new_a("Generation Code", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_List->paramCode; + json_push_back(listData, json_new_a("Relative Target Port Identifier", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_List->paramControlByte); + json_push_back(listData, json_new_a("Relative Target Port Control Byte", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_List->paramLength); + json_push_back(listData, json_new_a("Relative Target Port Length", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_List->ident); + json_push_back(listData, json_new_a("Port Identifier", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_List->genCode); + json_push_back(listData, json_new_a("Generation Code", temp.str().c_str())); json_push_back(listData, json_new_i("Number of Phys", m_List->numberOfPhys)); } //----------------------------------------------------------------------------- @@ -418,8 +751,6 @@ void CScsiProtocolPortLog::process_List_Information(JSONNODE *listData) //--------------------------------------------------------------------------- eReturnValues CScsiProtocolPortLog::get_Data(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); eReturnValues retStatus = IN_PROGRESS; if (pData != NULL) @@ -429,23 +760,25 @@ eReturnValues CScsiProtocolPortLog::get_Data(JSONNODE *masterData) for (size_t offset = 0; (offset < m_PageLength && offset < UINT16_MAX);) { - m_List = (sRelativeTargetPort *)&pData[offset]; + m_List = reinterpret_cast(&pData[offset]); // process the List header information byte_Swap_16(&m_List->paramCode); - snprintf((char*)myStr.c_str(), BASIC, "Relative Target Port Information %" PRId16"", m_List->paramCode); + std::ostringstream temp; + temp << "Relative Target Port Information " << std::dec << m_List->paramCode; JSONNODE *listInfo = json_new(JSON_NODE); - json_set_name(listInfo, (char*)myStr.c_str()); + json_set_name(listInfo, temp.str().c_str()); process_List_Information(listInfo); offset += sizeof(sRelativeTargetPort); - m_Descriptor = (sSASPHYLogDescriptorList *)&pData[offset]; + m_Descriptor = reinterpret_cast(&pData[offset]); if((offset + m_Descriptor->phyLength) <= m_bufferLength) { offset += sizeof(sSASPHYLogDescriptorList); // process the descriptor information - snprintf((char*)myStr.c_str(), BASIC, "Descriptor Information %" PRId8"", m_Descriptor->phyIdent); + temp.str("");temp.clear(); + temp << "Descriptor Information " << std::dec << static_cast(m_Descriptor->phyIdent); JSONNODE *descInfo = json_new(JSON_NODE); - json_set_name(descInfo, (char*)myStr.c_str()); + json_set_name(descInfo, temp.str().c_str()); process_Descriptor_Information(descInfo); for (uint32_t events = 1; events <= m_Descriptor->numberOfEvents; events++) @@ -453,7 +786,7 @@ eReturnValues CScsiProtocolPortLog::get_Data(JSONNODE *masterData) // check the length to the end of the buffer if ((offset + m_Descriptor->phyEventLength) <= m_bufferLength) { - m_Event = (sPhyEventDescriptor *)&pData[offset]; + m_Event = reinterpret_cast(&pData[offset]); offset += m_Descriptor->phyEventLength; //process events process_Events_Data(descInfo); diff --git a/src/CScsi_Self_Test_Results_Log.cpp b/src/CScsi_Self_Test_Results_Log.cpp index 4237282..6d3b64c 100644 --- a/src/CScsi_Self_Test_Results_Log.cpp +++ b/src/CScsi_Self_Test_Results_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Self_Test_Results_Log.cpp Implementation of DST Results log // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -97,7 +97,7 @@ CScsi_DST_Results::~CScsi_DST_Results() } //----------------------------------------------------------------------------- // -//! \fn parse_Self_Test_Log() +//! \fn get_Self_Test_Log() // //! \brief //! Description: parse the ext self test dst log @@ -110,18 +110,13 @@ CScsi_DST_Results::~CScsi_DST_Results() //! \return eReturnValues success // //--------------------------------------------------------------------------- -eReturnValues CScsi_DST_Results::parse_Self_Test_Log(uint8_t *buffer, size_t bufferSize, JSONNODE *masterJson) +eReturnValues CScsi_DST_Results::get_Self_Test_Log(uint8_t *buffer, size_t bufferSize, JSONNODE *masterJson) { eReturnValues retStatus = IN_PROGRESS; - std::string myStr = ""; - myStr.resize(BASIC); JSONNODE *DstJson = json_new(JSON_NODE); - - json_set_name(DstJson, "Self Test Results Log - 10h"); - - m_DST = (sSelfTest *)buffer; - for (int i = 1; i <= 20; i++) + m_DST = reinterpret_cast(buffer); + for (uint16_t i = 1; i <= 20; i++) { byte_Swap_Self_Test(); if (m_DST->paramCode == i && m_DST->paramLength == 0x10) @@ -133,7 +128,7 @@ eReturnValues CScsi_DST_Results::parse_Self_Test_Log(uint8_t *buffer, size_t buf } else { - if ( (((size_t)i+1) * sizeof(sSelfTest) ) < bufferSize ) + if ( ((static_cast(i)+1) * sizeof(sSelfTest) ) <= bufferSize ) { m_DST++; retStatus = IN_PROGRESS; @@ -174,44 +169,56 @@ eReturnValues CScsi_DST_Results::parse_Self_Test_Log(uint8_t *buffer, size_t buf //--------------------------------------------------------------------------- void CScsi_DST_Results::print_Self_Test_Log(JSONNODE *dstNode, uint16_t run) { - std::string myStr = ""; - myStr.resize(BASIC); - JSONNODE *runInfo = json_new(JSON_NODE); - snprintf((char*)myStr.c_str(), BASIC, "Entry %3d ", run); // changed the run# to Entry per Paul - json_set_name(runInfo, (char*)myStr.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_DST->paramCode); - json_push_back(runInfo, json_new_a("Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIx8"", m_DST->paramLength); - json_push_back(runInfo, json_new_a("Parameter Length", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_DST->paramControlByte); - json_push_back(runInfo, json_new_a("Control Byte", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"",(uint8_t) M_GETBITRANGE(m_DST->stCode, 7, 5)); - json_push_back(runInfo, json_new_a("Self Test Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", (uint8_t)M_GETBITRANGE( m_DST->stCode,3,0)); - json_push_back(runInfo, json_new_a("Self Test Results", (char*)myStr.c_str())); + JSONNODE* runInfo = json_new(JSON_NODE); + std::ostringstream temp; + temp << "Entry " << std::setw(3) << run; // changed the run# to Entry per Paul + json_set_name(runInfo, temp.str().c_str()); + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_DST->paramCode; + json_push_back(runInfo, json_new_a("Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_DST->paramLength); + json_push_back(runInfo, json_new_a("Parameter Length", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_DST->paramControlByte; + json_push_back(runInfo, json_new_a("Control Byte", temp.str().c_str())); + } + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(M_GETBITRANGE(m_DST->stCode, 7, 5)); + json_push_back(runInfo, json_new_a("Self Test Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(M_GETBITRANGE(m_DST->stCode, 3, 0)); + json_push_back(runInfo, json_new_a("Self Test Results", temp.str().c_str())); if (M_GETBITRANGE(m_DST->stCode, 7, 5) == DST_NOT_RUN) { json_push_back(runInfo, json_new_a("Self Test Results Meaning", "Self Test Not Ran")); } else { + std::string myStr; get_Self_Test_Results_String(myStr, M_GETBITRANGE(m_DST->stCode, 3, 0)); - json_push_back(runInfo, json_new_a("Self Test Results Meaning", (char*)myStr.c_str())); + json_push_back(runInfo, json_new_a("Self Test Results Meaning", myStr.c_str())); } json_push_back(runInfo, json_new_i("Self Test Number", static_cast(m_DST->stNumber))); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", m_DST->accPOH); - json_push_back(runInfo, json_new_a("Accumulated Power On Hours", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_DST->accPOH; + json_push_back(runInfo, json_new_a("Accumulated Power On Hours", temp.str().c_str())); set_json_64bit(runInfo, "Address of First Failure", m_DST->address, true); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", m_DST->senseKey); - json_push_back(runInfo, json_new_a("Sense Key", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", m_DST->addSenseCode); - json_push_back(runInfo, json_new_a("Additional Sense Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", m_DST->addSenseCodeQualifier); - json_push_back(runInfo, json_new_a("Additional Sense Code Qualifier", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(m_DST->senseKey); + json_push_back(runInfo, json_new_a("Sense Key", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(m_DST->addSenseCode); + json_push_back(runInfo, json_new_a("Additional Sense Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(m_DST->addSenseCodeQualifier); + json_push_back(runInfo, json_new_a("Additional Sense Code Qualifier", temp.str().c_str())); json_push_back(dstNode, runInfo); + } //----------------------------------------------------------------------------- // @@ -230,67 +237,44 @@ void CScsi_DST_Results::print_Self_Test_Log(JSONNODE *dstNode, uint16_t run) //--------------------------------------------------------------------------- void CScsi_DST_Results::get_Self_Test_Results_String( std::string & meaning, uint8_t result) { - meaning.resize(BASIC); switch (result) { case DST_COMPLETED_WITHOUT_ERROR: - { meaning = "Self Test completed without error"; break; - } case DST_BACKGROUND_ABORTED: - { meaning = "Was Aborted by the host"; break; - } case DST_ABORTED: - { - meaning = "Was interepted by the host with a hard reset of a soft reset"; + meaning = "Was interepted by the host with a hard reset or a soft reset"; break; - } case DST_UNKNOWN_ERROR: - { meaning = "unknown error and Self Test was unable to complete"; break; - } case DST_FAILURE_UNKNOWN_SEGMENT: - { - meaning = "Completed and has faild and the element is unknown"; + meaning = "Completed and has failed and the element is unknown"; break; - } case DST_FAILURE_FIRST_SEGMENT: - { meaning = "Completed With an electrical element failing"; break; - } case DST_FAILURE_SECOND_SEGMENT: - { meaning = "Completed having a servo element failure"; break; - } case DST_FAILURE_CHECK_NUMBER_FOR_SEGMENT: - { meaning = "Completed having a read element failure"; break; - } case DST_FAILURE_HANDLING_DAMAGE: - { meaning = "Completed having handling damage"; - } + break; case DST_FAILURE_SUSPECTED_HANDLING_DAMAGE: - { meaning = "Completed having suspected handling damage"; - } + break; case DST_IN_PROGRESS: - { meaning = "Self Test is in progress"; break; - } default: - { meaning = "Reserved."; break; - } } } //----------------------------------------------------------------------------- @@ -312,4 +296,4 @@ void CScsi_DST_Results::byte_Swap_Self_Test() byte_Swap_16(&m_DST->paramCode); byte_Swap_16(&m_DST->accPOH); byte_Swap_64(&m_DST->address); -} \ No newline at end of file +} diff --git a/src/CScsi_Solid_State_Drive_Log.cpp b/src/CScsi_Solid_State_Drive_Log.cpp index 210cd56..9dccc84 100644 --- a/src/CScsi_Solid_State_Drive_Log.cpp +++ b/src/CScsi_Solid_State_Drive_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Solid_State_Drive_Log.cpp Definition of Solid State Drive Log // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -119,13 +119,15 @@ bool CScsiSolidStateDriveLog::get_SSD_Parameter_Code_Description(std::string *ss { case 0x0001: { - snprintf((char*)ssdString->c_str(), BASIC, "Percentage Used Indicator"); + ssdString->assign("Percentage Used Indicator"); descriptionFound = true; break; } default: { - snprintf((char*)ssdString->c_str(), BASIC, "Vendor Specific 0x%04" PRIx16"", m_SSDParam->paramCode); + std::ostringstream temp; + temp << "Vendor Specific 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_SSDParam->paramCode; + ssdString->assign(temp.str()); break; } } @@ -148,10 +150,7 @@ bool CScsiSolidStateDriveLog::get_SSD_Parameter_Code_Description(std::string *ss void CScsiSolidStateDriveLog::process_Solid_State_Drive_Data(JSONNODE *ssdData) { bool descriptionFound = false; - std::string myStr = ""; - myStr.resize(BASIC); - std::string myHeader = ""; - myHeader.resize(BASIC); + std::string myHeader; #if defined _DEBUG printf("Solid State Drive Log \n"); @@ -160,17 +159,19 @@ void CScsiSolidStateDriveLog::process_Solid_State_Drive_Data(JSONNODE *ssdData) descriptionFound = get_SSD_Parameter_Code_Description(&myHeader); JSONNODE *ssdInfo = json_new(JSON_NODE); - json_set_name(ssdInfo, (char*)myHeader.c_str()); - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_SSDParam->paramCode); - json_push_back(ssdInfo, json_new_a("Solid State Drive Param Code", (char*)myStr.c_str())); + json_set_name(ssdInfo, myHeader.c_str()); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_SSDParam->paramCode; + json_push_back(ssdInfo, json_new_a("Solid State Drive Param Code", temp.str().c_str())); if (!descriptionFound) { - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_SSDParam->paramControlByte); - json_push_back(ssdInfo, json_new_a("Solid State Drive Param Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_SSDParam->paramLength); - json_push_back(ssdInfo, json_new_a("Solid State Drive Param Length ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_SSDParam->paramControlByte); + json_push_back(ssdInfo, json_new_a("Solid State Drive Param Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_SSDParam->paramLength); + json_push_back(ssdInfo, json_new_a("Solid State Drive Param Length ", temp.str().c_str())); } if (m_SSDParam->paramLength == 8 || m_SSDValue > UINT32_MAX) @@ -185,8 +186,9 @@ void CScsiSolidStateDriveLog::process_Solid_State_Drive_Data(JSONNODE *ssdData) } else { - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", static_cast(m_SSDValue)); - json_push_back(ssdInfo, json_new_a("Solid State Drive Param Value", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_SSDValue; + json_push_back(ssdInfo, json_new_a("Solid State Drive Param Value", temp.str().c_str())); } } @@ -208,10 +210,6 @@ void CScsiSolidStateDriveLog::process_Solid_State_Drive_Data(JSONNODE *ssdData) //--------------------------------------------------------------------------- eReturnValues CScsiSolidStateDriveLog::get_Solid_State_Drive_Data(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); - std::string headerStr = ""; - headerStr.resize(BASIC); eReturnValues retStatus = IN_PROGRESS; if (pData != NULL) { @@ -222,8 +220,8 @@ eReturnValues CScsiSolidStateDriveLog::get_Solid_State_Drive_Data(JSONNODE *mast { if (offset < m_bufferLength && offset < UINT16_MAX) { - m_SSDParam = (sSSDParams *)&pData[offset]; - offset += sizeof(sSSDParams); + m_SSDParam = reinterpret_cast(&pData[offset]); + offset += sizeof(sLogParams); switch (m_SSDParam->paramLength) { case 1: @@ -286,7 +284,6 @@ eReturnValues CScsiSolidStateDriveLog::get_Solid_State_Drive_Data(JSONNODE *mast { json_push_back(masterData, pageInfo); return BAD_PARAMETER; - break; } } process_Solid_State_Drive_Data(pageInfo); @@ -306,4 +303,4 @@ eReturnValues CScsiSolidStateDriveLog::get_Solid_State_Drive_Data(JSONNODE *mast retStatus = MEMORY_FAILURE; } return retStatus; -} \ No newline at end of file +} diff --git a/src/CScsi_Start_Stop_Cycle_Counter_Log.cpp b/src/CScsi_Start_Stop_Cycle_Counter_Log.cpp index 2a833d8..8bdb302 100644 --- a/src/CScsi_Start_Stop_Cycle_Counter_Log.cpp +++ b/src/CScsi_Start_Stop_Cycle_Counter_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Start_Stop_Counter_Log.cpp Implementation of CScsi start stop cycle counter Log class // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,6 +13,8 @@ // \file CScsi_Start_Stop_Counter_Log.cpp Implementation of CScsi start stop cycle counter Log class // #include "CScsi_Start_Stop_Cycle_Counter_Log.h" +#include +#include using namespace opensea_parser; //----------------------------------------------------------------------------- @@ -30,12 +32,12 @@ using namespace opensea_parser; // //--------------------------------------------------------------------------- CScsiStartStop::CScsiStartStop() - : pData(NULL) + : pData(NULL) , m_SSName("Start Stop Log") - , m_StartStatus(IN_PROGRESS) - , m_PageLength(0) + , m_StartStatus(IN_PROGRESS) + , m_PageLength(0) , m_SubPage(0) - , m_Page(0) + , m_Page(0) { } @@ -54,26 +56,26 @@ CScsiStartStop::CScsiStartStop() // //--------------------------------------------------------------------------- CScsiStartStop::CScsiStartStop(uint8_t * buffer, size_t bufferSize, JSONNODE *masterData) - : pData(NULL) + : pData(NULL) , m_SSName("Start Stop Log") - , m_StartStatus(IN_PROGRESS) - , m_PageLength(0) + , m_StartStatus(IN_PROGRESS) + , m_PageLength(0) , m_SubPage(0) - , m_Page(0) + , m_Page(0) { - if (buffer != NULL) - { + if (buffer != NULL) + { pData = new uint8_t[bufferSize]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(pData, buffer, bufferSize); #else memcpy_s(pData, bufferSize, buffer, bufferSize);// copy the buffer data to the class member pBuf #endif if (pData != NULL) { - if (bufferSize >= (sizeof(sStartStopStruct) + sizeof(sLogPageStruct))) // check for invaid log size < need to add in the size of the log page header + if (bufferSize >= sizeof(sStartStopStruct)) // check for invaid log size < need to add in the size of the log page header { - m_Page = (sStartStopStruct *)pData; // set a buffer to the point to the log page info + m_Page = reinterpret_cast(pData); // set a buffer to the point to the log page info m_StartStatus = parse_Start_Stop_Log(masterData); } else @@ -85,11 +87,11 @@ CScsiStartStop::CScsiStartStop(uint8_t * buffer, size_t bufferSize, JSONNODE *ma { m_StartStatus = MEMORY_FAILURE; } - } - else - { - m_StartStatus = FAILURE; - } + } + else + { + m_StartStatus = FAILURE; + } } @@ -131,77 +133,91 @@ CScsiStartStop::~CScsiStartStop() //--------------------------------------------------------------------------- eReturnValues CScsiStartStop::parse_Start_Stop_Log(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); - eReturnValues status = IN_PROGRESS; - eReturnValues retStatus = IN_PROGRESS; - JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, "Scsi Start Stop Cycle Counter Log - Eh"); - byte_Swap_16(&m_Page->manufatureParamCode); - if (manufactureDate == m_Page->manufatureParamCode) - { - retStatus = week_Year_Print(pageInfo, m_Page->manufatureParamCode, m_Page->paramLength1, m_Page->paramControlByte1, m_Page->year, m_Page->week, "Date of Manufacture", "Year of Manufacture", "Week of Manufacture"); - } - else - { - retStatus = BAD_PARAMETER; - } - byte_Swap_16(&m_Page->accountParamCode); - if (accountingDate == m_Page->accountParamCode) - { - retStatus = week_Year_Print(pageInfo, m_Page->accountParamCode, m_Page->paramLength2, m_Page->paramControlByte2, m_Page->accYear, m_Page->accWeek, "Accounting Data","Accounting Year", "Accounting Week"); - } - else - { - retStatus = BAD_PARAMETER; - } - byte_Swap_16(&m_Page->specCycleParamCode); - if (specLifetime == m_Page->specCycleParamCode) - { - retStatus = get_Count(pageInfo, m_Page->specCycleParamCode, m_Page->paramLength3, m_Page->paramControlByte3, m_Page->specLifeTime,"Specified Cycle Count", "Specified Cycle Count Over Device Lifetime"); - } - else - { - retStatus = BAD_PARAMETER; - } - byte_Swap_16(&m_Page->AccumulatedParamCode); - if (accumulated == m_Page->AccumulatedParamCode) - { - retStatus = get_Count(pageInfo, m_Page->AccumulatedParamCode, m_Page->paramLength4, m_Page->paramControlByte4, m_Page->accumulatedCycles, "Accumulated Start-Stop Count", "Accumulated Start-Stop Over Device Lifetime"); - } - else - { - retStatus = BAD_PARAMETER; - } - byte_Swap_16(&m_Page->loadUnloadParamCode); - if (loadUnload == m_Page->loadUnloadParamCode) - { - retStatus = get_Count(pageInfo, m_Page->loadUnloadParamCode, m_Page->paramLength5, m_Page->paramControlByte5, m_Page->loadUnloadCount, "Load - Unload Count", "Specified Load-Unload Count Over Device Lifetime"); - } - else - { - retStatus = BAD_PARAMETER; - } - byte_Swap_16(&m_Page->accLoadUnloadParamCode); - if (accumulatedLU == m_Page->accLoadUnloadParamCode) - { - retStatus = get_Count(pageInfo, m_Page->accLoadUnloadParamCode, m_Page->paramLength6, m_Page->paramControlByte6, m_Page->accloadUnloadCount, "Accumulated Load - Unload Count", "Specified Load-Unload Count Over Device Lifetime"); - } - else - { - retStatus = BAD_PARAMETER; - } - json_push_back(masterData, pageInfo); + eReturnValues status = IN_PROGRESS; + eReturnValues retStatus = IN_PROGRESS; + JSONNODE *pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, "Scsi Start Stop Cycle Counter Log - Eh"); + byte_Swap_16(&m_Page->manufatureParamCode); + if (manufactureDate == m_Page->manufatureParamCode) + { + retStatus = week_Year_Print(pageInfo, m_Page->manufatureParamCode, m_Page->paramLength1, m_Page->paramControlByte1, m_Page->year, m_Page->week, "Date of Manufacture", "Year of Manufacture", "Week of Manufacture"); + } + else + { + retStatus = BAD_PARAMETER; + } - if (retStatus == BAD_PARAMETER || retStatus == IN_PROGRESS) - { - status = BAD_PARAMETER; - } - else - { - status = SUCCESS; - } - return status; + if (retStatus == SUCCESS) + { + byte_Swap_16(&m_Page->accountParamCode); + if (accountingDate == m_Page->accountParamCode) + { + retStatus = week_Year_Print(pageInfo, m_Page->accountParamCode, m_Page->paramLength2, m_Page->paramControlByte2, m_Page->accYear, m_Page->accWeek, "Accounting Date", "Accounting Year", "Accounting Week"); + } + else + { + retStatus = BAD_PARAMETER; + } + if (retStatus == SUCCESS) + { + byte_Swap_16(&m_Page->specCycleParamCode); + if (specLifetime == m_Page->specCycleParamCode) + { + retStatus = get_Count(pageInfo, m_Page->specCycleParamCode, m_Page->paramLength3, m_Page->paramControlByte3, m_Page->specLifeTime, "Specified Cycle Count", "Specified Cycle Count Over Device Lifetime"); + } + else + { + retStatus = BAD_PARAMETER; + } + if (retStatus == SUCCESS) + { + byte_Swap_16(&m_Page->AccumulatedParamCode); + if (accumulated == m_Page->AccumulatedParamCode) + { + retStatus = get_Count(pageInfo, m_Page->AccumulatedParamCode, m_Page->paramLength4, m_Page->paramControlByte4, m_Page->accumulatedCycles, "Accumulated Start-Stop Count", "Accumulated Start-Stop Over Device Lifetime"); + } + else + { + retStatus = BAD_PARAMETER; + } + if (retStatus == SUCCESS) + { + byte_Swap_16(&m_Page->loadUnloadParamCode); + if (loadUnload == m_Page->loadUnloadParamCode) + { + retStatus = get_Count(pageInfo, m_Page->loadUnloadParamCode, m_Page->paramLength5, m_Page->paramControlByte5, m_Page->loadUnloadCount, "Load - Unload Count", "Specified Load-Unload Count Over Device Lifetime"); + } + else + { + retStatus = BAD_PARAMETER; + } + if (retStatus == SUCCESS) + { + byte_Swap_16(&m_Page->accLoadUnloadParamCode); + if (accumulatedLU == m_Page->accLoadUnloadParamCode) + { + retStatus = get_Count(pageInfo, m_Page->accLoadUnloadParamCode, m_Page->paramLength6, m_Page->paramControlByte6, m_Page->accloadUnloadCount, "Accumulated Load - Unload Count", "Specified Load-Unload Count Over Device Lifetime"); + } + else + { + retStatus = BAD_PARAMETER; + } + } + } + } + } + } + json_push_back(masterData, pageInfo); + + if (retStatus == BAD_PARAMETER || retStatus == IN_PROGRESS) + { + status = BAD_PARAMETER; + } + else + { + status = SUCCESS; + } + return status; } //----------------------------------------------------------------------------- @@ -226,49 +242,90 @@ eReturnValues CScsiStartStop::parse_Start_Stop_Log(JSONNODE *masterData) //! \return eReturnParserValues // //--------------------------------------------------------------------------- -eReturnValues CScsiStartStop::week_Year_Print(JSONNODE *data,uint16_t param, uint8_t paramlength, uint8_t paramConByte, uint32_t year, uint16_t week,const std::string strHeader, const std::string strYear, const std::string strWeek) +eReturnValues CScsiStartStop::week_Year_Print(JSONNODE *data, uint16_t param, uint8_t paramlength, uint8_t paramConByte, uint32_t year, uint16_t week, const std::string strHeader, const std::string strYear, const std::string strWeek) { #define YEARSIZE 4 #define WEEKSIZE 2 - std::string myStr = ""; - myStr.resize(BASIC); + std::string myStr; JSONNODE *dateInfo = json_new(JSON_NODE); - json_set_name(dateInfo, (char *)strHeader.c_str()); + json_set_name(dateInfo, strHeader.c_str()); if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", param); - json_push_back(dateInfo, json_new_a("Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", paramlength); - json_push_back(dateInfo, json_new_a("Parameter Length", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", paramConByte); - json_push_back(dateInfo, json_new_a("Control Byte", (char*)myStr.c_str())); + std::ostringstream temp; + + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << param; + json_push_back(dateInfo, json_new_a("Parameter Code", temp.str().c_str())); + + temp.str("");temp.clear(); + temp << std::dec << static_cast(paramlength); //cast is because streams interpret char/unsigned char as a character, but 16 bits wide will be ok to cast to to get around this. -TJE + json_push_back(dateInfo, json_new_a("Parameter Length", temp.str().c_str())); + + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') <(paramConByte); //cast is because streams interpret char/unsigned char as a character, but 16 bits wide will be ok to cast to to get around this. -TJE + json_push_back(dateInfo, json_new_a("Control Byte", temp.str().c_str())); } - myStr.resize(YEARSIZE); - memset((char*)myStr.c_str(), 0, YEARSIZE); - if (year != 0x20202020) + + if (year != UINT32_C(0x20202020)) { - strncpy((char *)myStr.c_str(), (char*)&year, YEARSIZE); + bool validASCII = true; + char charYear[YEARSIZE + 1] = { 0 }; + memcpy(&charYear[0], &year, YEARSIZE); + //Check if all ascii characters or not + for (uint8_t i = 0; i < YEARSIZE; ++i) + { + if (!is_ASCII(charYear[i]) || !isdigit(charYear[i])) + { + validASCII = false; + break; + } + } + if (validASCII) + { + myStr.assign(reinterpret_cast(&year), sizeof(year)); + } + else + { + myStr = "0000"; + } } else { myStr = "0000"; } - json_push_back(dateInfo, json_new_a((char *)strYear.c_str(), (char*)myStr.c_str())); - myStr.resize(WEEKSIZE); - if (week != 0x2020) + json_push_back(dateInfo, json_new_a(strYear.c_str(), myStr.c_str())); + if (week != UINT16_C(0x2020)) { - strncpy((char *)myStr.c_str(), (char*)&week, WEEKSIZE); + bool validASCII = true; + char charWeek[WEEKSIZE + 1] = { 0 }; + memcpy(&charWeek[0], &week, WEEKSIZE); + //Check if all ascii characters or not + for (uint8_t i = 0; i < WEEKSIZE; ++i) + { + if (!is_ASCII(charWeek[i]) || !isdigit(charWeek[i])) + { + validASCII = false; + break; + } + } + if (validASCII) + { + myStr.assign(reinterpret_cast(&week), sizeof(week)); + } + else + { + myStr = "00"; + } } else { myStr = "00"; } - json_push_back(dateInfo, json_new_a((char *)strWeek.c_str(), (char*)myStr.c_str())); + json_push_back(dateInfo, json_new_a(strWeek.c_str(), myStr.c_str())); - json_push_back(data, dateInfo); - return SUCCESS; + json_push_back(data, dateInfo); + return SUCCESS; } //----------------------------------------------------------------------------- // @@ -286,24 +343,24 @@ eReturnValues CScsiStartStop::week_Year_Print(JSONNODE *data,uint16_t param, uin //--------------------------------------------------------------------------- eReturnValues CScsiStartStop::get_Count(JSONNODE *countData, uint16_t param, uint8_t paramlength, uint8_t paramConByte, uint32_t count, const std::string strHeader, const std::string strCount) { - std::string myStr = ""; - myStr.resize(BASIC); - JSONNODE *countInfo = json_new(JSON_NODE); - json_set_name(countInfo, (char *)strHeader.c_str()); + json_set_name(countInfo, strHeader.c_str()); if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) { - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", param); - json_push_back(countInfo, json_new_a("Parameter Code", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", paramlength); - json_push_back(countInfo, json_new_a("Parameter Length", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", paramConByte); - json_push_back(countInfo, json_new_a("Control Byte", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << param; + json_push_back(countInfo, json_new_a("Parameter Code", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(paramlength); + json_push_back(countInfo, json_new_a("Parameter Length", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(paramConByte); + json_push_back(countInfo, json_new_a("Control Byte", temp.str().c_str())); } byte_Swap_32(&count); - json_push_back(countInfo, json_new_i((char *)strCount.c_str(), count )); + json_push_back(countInfo, json_new_i(strCount.c_str(), count )); json_push_back(countData, countInfo); return SUCCESS; -} \ No newline at end of file +} diff --git a/src/CScsi_Supported_LogPages_Log.cpp b/src/CScsi_Supported_LogPages_Log.cpp index 33b99b1..8c08a23 100644 --- a/src/CScsi_Supported_LogPages_Log.cpp +++ b/src/CScsi_Supported_LogPages_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Supported_LogPages_Log.cpp Definition for parsing the supported log pages // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -129,11 +129,11 @@ void CScsiSupportedLog::get_Supported_And_Subpage_Description(std::string *descr { if (m_ShowSubPage && m_SubPage == 0xFF) { - snprintf((char*)description->c_str(), BASIC, "Supported Log Pages and Subpages"); + description->assign("Supported Log Pages and Subpages"); } else { - snprintf((char*)description->c_str(), BASIC, "Supported Log Pages"); + description->assign("Supported Log Pages"); } m_ShowSupportedPagesOnce = false; } @@ -141,119 +141,121 @@ void CScsiSupportedLog::get_Supported_And_Subpage_Description(std::string *descr } case WRITE_ERROR_COUNTER: { - snprintf((char*)description->c_str(), BASIC, "Write Error Counter"); + description->assign("Write Error Counter"); break; } case READ_ERROR_COUNTER: { - snprintf((char*)description->c_str(), BASIC, "Read Error Counter"); + description->assign("Read Error Counter"); break; } case VERIFY_ERROR_COUNTER: { - snprintf((char*)description->c_str(), BASIC, "Verify Error Counter"); + description->assign("Verify Error Counter"); break; } case NON_MEDIUM_ERROR: { - snprintf((char*)description->c_str(), BASIC, "Non-Medium Error"); + description->assign("Non-Medium Error"); break; } case FORMAT_STATUS: { - snprintf((char*)description->c_str(), BASIC, "Format Status"); + description->assign("Format Status"); break; } case LOGICAL_BLOCK_PROVISIONING: { - snprintf((char*)description->c_str(), BASIC, "Logical Block Provisioning"); + description->assign("Logical Block Provisioning"); break; } case ENVIRONMENTAL: { if (m_ShowSubPage && m_SubPage == 0x00) { - snprintf((char*)description->c_str(), BASIC, "Temperature"); + description->assign("Temperature"); } else if (m_ShowSubPage && m_SubPage == 0x01) { - snprintf((char*)description->c_str(), BASIC, "Environmental Reporting"); + description->assign("Environmental Reporting"); } else if (m_ShowSubPage && m_SubPage == 0x02) { - snprintf((char*)description->c_str(), BASIC, "Environmental Limits"); + description->assign("Environmental Limits"); } else { - snprintf((char*)description->c_str(), BASIC, "Environmental"); + description->assign("Environmental"); } break; } case START_STOP_CYCLE_COUNTER: { - snprintf((char*)description->c_str(), BASIC, "Start-Stop Cycle Counter"); + description->assign("Start-Stop Cycle Counter"); break; } case APPLICATION_CLIENT: { - snprintf((char*)description->c_str(), BASIC, "Application Client"); + description->assign("Application Client"); break; } case SELF_TEST_RESULTS: { - snprintf((char*)description->c_str(), BASIC, "Self-Test Results"); + description->assign("Self-Test Results"); break; } case SOLID_STATE_MEDIA: { - snprintf((char*)description->c_str(), BASIC, "Solid State Media"); + description->assign("Solid State Media"); break; } case ZONED_DEVICE_STATISTICS: { - snprintf((char*)description->c_str(), BASIC, "Zoned Device Statistics"); + description->assign("Zoned Device Statistics"); break; } case BACKGROUND_SCAN: { if (m_ShowSubPage && m_SubPage == 0x02) { - snprintf((char*)description->c_str(), BASIC, "Background Operation"); + description->assign("Background Operation"); } else { - snprintf((char*)description->c_str(), BASIC, "Background Scan"); + description->assign("Background Scan"); } break; } case PROTOCOL_SPECIFIC_PORT: { - snprintf((char*)description->c_str(), BASIC, "SAS Protocol Log Page"); + description->assign("SAS Protocol Log Page"); break; } case POWER_CONDITION_TRANSITIONS: { - snprintf((char*)description->c_str(), BASIC, "Protocol Specific Port"); + description->assign("Protocol Specific Port"); break; } case INFORMATIONAL_EXCEPTIONS: { - snprintf((char*)description->c_str(), BASIC, "Informational Exceptions"); + description->assign("Informational Exceptions"); break; } case CACHE_STATISTICS: { - snprintf((char*)description->c_str(), BASIC, "Cache Statistics"); + description->assign("Cache Statistics"); break; } case FACTORY_LOG: { - snprintf((char*)description->c_str(), BASIC, "Factory Log"); + description->assign("Factory Log"); break; } default: { - snprintf((char*)description->c_str(), BASIC, "Unknown 0x%02" PRIx8"", m_Page); + std::ostringstream temp; + temp << "Unknown 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Page); + description->assign(temp.str()); break; } } @@ -274,24 +276,18 @@ void CScsiSupportedLog::get_Supported_And_Subpage_Description(std::string *descr //--------------------------------------------------------------------------- void CScsiSupportedLog::process_Supported_Data(JSONNODE *SupportData) { - std::string myStr = ""; - myStr.resize(BASIC); - std::string myHeader = ""; - myHeader.resize(BASIC); + std::string myStr; #if defined _DEBUG printf("Supported Log Pages \n"); #endif - + std::ostringstream temp; + temp << "Page 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Page); if (m_ShowSubPage) { - snprintf((char*)myHeader.c_str(), BASIC, "Page 0x%02" PRIx8" SubPage 0x%02" PRIx8"", m_Page, m_SubPage); - } - else - { - snprintf((char*)myHeader.c_str(), BASIC, "Page 0x%02" PRIx8"", m_Page); + temp << " SubPage 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_SubPage); } get_Supported_And_Subpage_Description(&myStr); - json_push_back(SupportData, json_new_a((char*)myHeader.c_str(), (char*)myStr.c_str())); + json_push_back(SupportData, json_new_a(temp.str().c_str(), myStr.c_str())); } //----------------------------------------------------------------------------- // @@ -309,24 +305,21 @@ void CScsiSupportedLog::process_Supported_Data(JSONNODE *SupportData) //--------------------------------------------------------------------------- eReturnValues CScsiSupportedLog::get_Supported_Log_Data(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); eReturnValues retStatus = IN_PROGRESS; if (pData != NULL) { - myStr = "Supported Logs"; JSONNODE *pageInfo = json_new(JSON_NODE); - json_set_name(pageInfo, (char*)myStr.c_str()); + json_set_name(pageInfo, "Supported Logs"); - for (size_t offset = 0; offset < (size_t) m_PageLength; ) + for (size_t offset = 0; offset < static_cast(m_PageLength); ) { if (offset < m_bufferLength ) { - m_Page = (uint8_t)pData[offset]; + m_Page = static_cast(pData[offset]); offset++; if (m_ShowSubPage && (offset +1 ) < m_bufferLength) { - m_SubPage = (uint8_t)pData[offset]; + m_SubPage = static_cast(pData[offset]); offset++; } if ((m_Page != 0 || m_SubPage != 0) ) diff --git a/src/CScsi_Temperature_Log.cpp b/src/CScsi_Temperature_Log.cpp index 9abc5ea..6c22202 100644 --- a/src/CScsi_Temperature_Log.cpp +++ b/src/CScsi_Temperature_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Temperature_Log.cpp Implementation of CScsi Temperature Log class // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -70,7 +70,7 @@ CScsiTemperatureLog::CScsiTemperatureLog(uint8_t * buffer, size_t bufferSize) if (buffer != NULL) { pData = buffer; - m_Page = (sTempLogPageStruct *)buffer; // set a buffer to the point to the log page info + m_Page = reinterpret_cast(buffer); // set a buffer to the point to the log page info m_TempStatus = SUCCESS; } else @@ -114,22 +114,24 @@ CScsiTemperatureLog::~CScsiTemperatureLog() //--------------------------------------------------------------------------- void CScsiTemperatureLog::get_Temp(JSONNODE *tempData) { - std::string myStr = ""; - myStr.resize(BASIC); #if defined _DEBUG printf("Temperature Log Page \n"); printf("\tParameter Code = 0x%04" PRIx16" \n", m_Page->paramCode); #endif - snprintf((char*)myStr.c_str(), BASIC, "Parameter Code 0x%04" PRIx16"", m_Page->paramCode); + std::ostringstream temp; + temp << "Parameter Code 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_Page->paramCode; JSONNODE *paramInfo = json_new(JSON_NODE); - json_set_name(paramInfo, (char*)myStr.c_str()); + json_set_name(paramInfo, temp.str().c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Page->paramLength); - json_push_back(paramInfo, json_new_a("Parameter Length", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_Page->paramControlByte); - json_push_back(paramInfo, json_new_a("Control Byte", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu8"", m_Page->temp); - json_push_back(paramInfo, json_new_a("Temperature", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Page->paramLength); + json_push_back(paramInfo, json_new_a("Parameter Length", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_Page->paramControlByte); + json_push_back(paramInfo, json_new_a("Control Byte", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << static_cast(m_Page->temp); + json_push_back(paramInfo, json_new_a("Temperature", temp.str().c_str())); json_push_back(tempData, paramInfo); } @@ -161,7 +163,7 @@ eReturnValues CScsiTemperatureLog::get_Data(JSONNODE *masterData) byte_Swap_16(&m_Page->paramCode); get_Temp(pageInfo); // Check to make sure we still have engough data to increment the m_Page - if ((param + (2* tempSize) + sizeof(sLogPageStruct)) > m_pDataSize && param + tempSize < m_PageLength || param > UINT32_MAX) + if (((param + (2* tempSize) + sizeof(sLogPageStruct)) > m_pDataSize && param + tempSize < m_PageLength) || param > UINT32_MAX) { json_push_back(masterData, pageInfo); return BAD_PARAMETER; diff --git a/src/CScsi_Zoned_Device_Statistics_Log.cpp b/src/CScsi_Zoned_Device_Statistics_Log.cpp index 7220bde..e742c7b 100644 --- a/src/CScsi_Zoned_Device_Statistics_Log.cpp +++ b/src/CScsi_Zoned_Device_Statistics_Log.cpp @@ -1,8 +1,8 @@ // -// CScsi_Zoned_Device_Statistics_Log.cpp Definition of Error Counter for READ WRITE VERIFY ERRORS +// CScsi_Zoned_Device_Statistics_Log.cpp // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -113,80 +113,82 @@ CScsiZonedDeviceStatisticsLog::~CScsiZonedDeviceStatisticsLog() //! \return void // //--------------------------------------------------------------------------- -bool CScsiZonedDeviceStatisticsLog::get_ZDS_Parameter_Code_Description(uint16_t paramCode, std::string *zdsString) +bool CScsiZonedDeviceStatisticsLog::get_ZDS_Parameter_Code_Description(std::string *zdsString) { bool descriptionFound = false; switch (m_ZDSParam->paramCode) { case 0x0000: { - snprintf((char*)zdsString->c_str(), BASIC, "Maximum Open Zones"); + zdsString->assign("maximum open zones"); descriptionFound = true; break; } case 0x0001: { - snprintf((char*)zdsString->c_str(), BASIC, "Maximum Explicitly Open Zones"); + zdsString->assign("maximum explicitly open zones"); descriptionFound = true; break; } case 0x0002: { - snprintf((char*)zdsString->c_str(), BASIC, "Maximum Implicitly Open Zones"); + zdsString->assign("maximum implicitly open zones"); descriptionFound = true; break; } case 0x0003: { - snprintf((char*)zdsString->c_str(), BASIC, "Minimum Empty Zones"); + zdsString->assign("minimum empty zones"); descriptionFound = true; break; } case 0x0004: { - snprintf((char*)zdsString->c_str(), BASIC, "Maximum Non-sequential Zones"); + zdsString->assign("maximum non-sequential zones"); descriptionFound = true; break; } case 0x0005: { - snprintf((char*)zdsString->c_str(), BASIC, "Zones Emptied"); + zdsString->assign("zones emptied"); descriptionFound = true; break; } case 0x0006: { - snprintf((char*)zdsString->c_str(), BASIC, "Suboptimal Write Commands"); + zdsString->assign("suboptimal write commands"); descriptionFound = true; break; } case 0x0007: { - snprintf((char*)zdsString->c_str(), BASIC, "Commands Exceeding Optimal Limit"); + zdsString->assign("commands exceeding optimal limit"); descriptionFound = true; break; } case 0x0008: { - snprintf((char*)zdsString->c_str(), BASIC, "Failed Explicit Opens"); + zdsString->assign("failed explicit opens"); descriptionFound = true; break; } case 0x0009: { - snprintf((char*)zdsString->c_str(), BASIC, "Read Rule Violations"); + zdsString->assign("read rule violations"); descriptionFound = true; break; } case 0x000A: { - snprintf((char*)zdsString->c_str(), BASIC, "Write Rule Violations"); + zdsString->assign("write rule violations"); descriptionFound = true; break; } default: { - snprintf((char*)zdsString->c_str(), BASIC, "Vendor Specific 0x%04" PRIx16"", m_ZDSParam->paramCode); + std::ostringstream temp; + temp << "Vendor Specific 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_ZDSParam->paramCode; + zdsString->assign(temp.str()); break; } } @@ -208,32 +210,30 @@ bool CScsiZonedDeviceStatisticsLog::get_ZDS_Parameter_Code_Description(uint16_t //--------------------------------------------------------------------------- void CScsiZonedDeviceStatisticsLog::process_Zoned_Device_Statistics_Data(JSONNODE *zdsData) { - bool descriptionFound = false; - std::string myStr = ""; - myStr.resize(BASIC); - std::string myHeader = ""; - myHeader.resize(BASIC); - + std::string myHeader; if (m_ZDSValue != 0) { #if defined _DEBUG printf("Zoned Device Statistics Log \n"); #endif byte_Swap_16(&m_ZDSParam->paramCode); - descriptionFound = get_ZDS_Parameter_Code_Description(m_ZDSParam->paramCode, &myHeader); + bool descriptionFound = get_ZDS_Parameter_Code_Description( &myHeader); JSONNODE *zdsInfo = json_new(JSON_NODE); - json_set_name(zdsInfo, (char*)myHeader.c_str()); + json_set_name(zdsInfo, myHeader.c_str()); - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", m_ZDSParam->paramCode); - json_push_back(zdsInfo, json_new_a("Zoned Device Statistics Param Code", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << m_ZDSParam->paramCode; + json_push_back(zdsInfo, json_new_a("Zoned Device Statistics Param Code", temp.str().c_str())); if (!descriptionFound) { - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_ZDSParam->paramControlByte); - json_push_back(zdsInfo, json_new_a("Zoned Device Statistics Param Control Byte ", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%02" PRIx8"", m_ZDSParam->paramLength); - json_push_back(zdsInfo, json_new_a("Zoned Device Statistics Param Length ", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_ZDSParam->paramControlByte); + json_push_back(zdsInfo, json_new_a("Zoned Device Statistics Param Control Byte ", temp.str().c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << static_cast(m_ZDSParam->paramLength); + json_push_back(zdsInfo, json_new_a("Zoned Device Statistics Param Length ", temp.str().c_str())); } if (m_ZDSParam->paramLength == 8 || m_ZDSValue > UINT32_MAX) @@ -248,8 +248,9 @@ void CScsiZonedDeviceStatisticsLog::process_Zoned_Device_Statistics_Data(JSONNOD } else { - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu32"", static_cast(m_ZDSValue)); - json_push_back(zdsInfo, json_new_a("Zoned Device Statistics Param Value", (char*)myStr.c_str())); + temp.str("");temp.clear(); + temp << std::dec << m_ZDSValue; + json_push_back(zdsInfo, json_new_a("Zoned Device Statistics Param Value", temp.str().c_str())); } } @@ -272,10 +273,6 @@ void CScsiZonedDeviceStatisticsLog::process_Zoned_Device_Statistics_Data(JSONNOD //--------------------------------------------------------------------------- eReturnValues CScsiZonedDeviceStatisticsLog::get_Zoned_Device_Statistics_Data(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); - std::string headerStr = ""; - headerStr.resize(BASIC); eReturnValues retStatus = IN_PROGRESS; if (pData != NULL) { @@ -286,7 +283,7 @@ eReturnValues CScsiZonedDeviceStatisticsLog::get_Zoned_Device_Statistics_Data(JS { if (offset < m_bufferLength && offset < UINT16_MAX) { - m_ZDSParam = (sZDSParams *)&pData[offset]; + m_ZDSParam = reinterpret_cast(&pData[offset]); offset += sizeof(sZDSParams); switch (m_ZDSParam->paramLength) { @@ -350,7 +347,6 @@ eReturnValues CScsiZonedDeviceStatisticsLog::get_Zoned_Device_Statistics_Data(JS { json_push_back(masterData, pageInfo); return BAD_PARAMETER; - break; } } process_Zoned_Device_Statistics_Data(pageInfo); @@ -370,4 +366,4 @@ eReturnValues CScsiZonedDeviceStatisticsLog::get_Zoned_Device_Statistics_Data(JS retStatus = MEMORY_FAILURE; } return retStatus; -} \ No newline at end of file +} diff --git a/src/Opensea_Parser_Helper.cpp b/src/Opensea_Parser_Helper.cpp index 56c9328..58d38c7 100644 --- a/src/Opensea_Parser_Helper.cpp +++ b/src/Opensea_Parser_Helper.cpp @@ -1,7 +1,7 @@ // Opensea_Parser_Helper.cpp Definition of SeaParser specific functions, structures // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,10 +12,12 @@ // \file Opensea_Parser_Helper.cpp Definition of SeaParser specific functions, structures #include "Opensea_Parser_Helper.h" -eVerbosityLevels g_verbosity = VERBOSITY_DEFAULT; -time_t g_currentTime; -char g_currentTimeString[64]; -char *g_currentTimeStringPtr = g_currentTimeString; +eVerbosityLevels g_verbosity = VERBOSITY_DEFAULT; +eDataFormat g_dataformat = JSON_DATA; +bool g_parseUnknown = true; +time_t g_currentTime; +char g_currentTimeString[64]; +char *g_currentTimeStringPtr = g_currentTimeString; //----------------------------------------------------------------------------- @@ -50,7 +52,7 @@ void opensea_parser::get_SMART_Save_Flages(JSONNODE *headerNode, uint8_t flag) json_push_back(headerNode, json_new_a("SMART Save Flag", "03 XX Error")); break; case SMART_FRAME_FLAG_SAVED_DUE_TO_04_XX_ERROR: - json_push_back(headerNode, json_new_a("SMART Save Flag", "04 XX Errror")); + json_push_back(headerNode, json_new_a("SMART Save Flag", "04 XX Error")); break; case SMART_FRAME_FLAG_SAVED_DUE_TO_1_5D_ERROR_FOR_PREDICTIVE_FAILURE: json_push_back(headerNode, json_new_a("SMART Save Flag", "5D Error for Predictive Failure")); @@ -116,7 +118,7 @@ void opensea_parser::get_SMART_Save_Flages(JSONNODE *headerNode, uint8_t flag) json_push_back(headerNode, json_new_a("SMART Save Flag", "Write Protect Invocation")); break; case SMART_FRAME_FLAG_SAVED_DUE_TO_FACTORY_COMMAND_TO_INVOCATE_A_FRAME_THAT_CAN_BE_INTERRUPTABLE: - json_push_back(headerNode, json_new_a("SMART Save Flag", "Invocate a frame that can be interruptable")); + json_push_back(headerNode, json_new_a("SMART Save Flag", "Invocate a frame that can be interruptible")); break; case SMART_FRAME_FLAG_SAVED_DUE_TO_SMART_SCT_COMMAND: json_push_back(headerNode, json_new_a("SMART Save Flag", "SCT Command")); @@ -161,4 +163,269 @@ void opensea_parser::get_SMART_Save_Flages(JSONNODE *headerNode, uint8_t flag) json_push_back(headerNode, json_new_a("SMART Save Flag", "Did not match any value")); break; } -} \ No newline at end of file +} +//----------------------------------------------------------------------------- +// +//! \fn get_SMART_Save_Flages() +// +//! \brief +//! Description: gets the command timeout values from the raw data +// +// Entry: +//! \param headerNode - the json node that we will be adding the data to +//! \param flag - the uint8 value from the buffer +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void opensea_parser::get_SMART_Save_Flages_String(std::string& reason, uint8_t flag) +{ + switch (flag) + { + case SMART_FRAME_FLAG_SAVED_AT_MSI_PERIOD: + reason = "MSI PERIOD"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_COLD_START: + reason = "Cold Start"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_SCSI_REZERO_COMMAND: + reason = "SCSI Rezero Command"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_03_XX_ERROR: + reason = "03 XX Error"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_04_XX_ERROR: + reason = "04 XX Errror"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_1_5D_ERROR_FOR_PREDICTIVE_FAILURE: + reason = "5D Error for Predictive Failure"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_FACTORY_COMMAND: + reason = "Factory Command"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_SEND_DIAGNOSTIC_COMMAND_WITH_SELFTEST_BIT_SET: + reason = "Diag Command with Selftest bit set"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_SCSI_0B_08_ERROR: + reason = "SCSI 0B 08 Error"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_SCSI_09_XX_ERROR: + reason = "SCSI 09 XX Error"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_SCSI_REZERO_COMMAND_WITH_HARD_RESET: + reason = "SCSI Rezero Command with hard reset"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_0B_01_WARNING: + reason = "0B 01 Warning"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_POWER_DOWN: + reason = "Power Down"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_BEGINNING_OF_SCSI_FORMAT_OPERATION: + reason = "SCSI Format Operation"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_RESET_FLASH_LED_ERROR: + reason = "Reset Flash Led Error"; + break; + case SMART_FRAME_FLAG_RESERVED: + reason = "Reserved"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_SCSI_DOWNLOAD_COMMAND: + reason = "SCSI Download Command"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_SCSI_TRIP_ALGORITHM: + reason = "SCSI Trip Algorithm"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_NHT_HEALTH_TRIP: + reason = "NHT Health Trip"; + break; + case SMART_FRAME_FLAG_DUE_TO_ISSRA_WARNING: + reason = "ISSRA Warning"; + break; + case SMART_FRAME_FLAG_DUE_TO_FACTORY_COMMAND_SAVE: + reason = "Factory Command Save"; + break; + case SMART_FRAME_FLAG_DUE_TO_EXIT_REMANUFACTURING: + reason = "Exit Remanufacturing"; + break; + case SMART_FRAME_FLAG_DUE_TO_HITACHI_ORM_OR_HD_TEST: + reason = "Hitachi ORM or HD test"; + break; + case SMART_FRAME_FLAG_STOP_UNIT_FRAME: + reason = "Unit Frame"; + break; + case SMART_FRAME_FLAG_INTERIM_FRAME_10MIN_IDLE_TIME: + reason = "10 minute IDLE Time"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_WRITE_PROTECT_INVOCATION: + reason = "Write Protect Invocation"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_FACTORY_COMMAND_TO_INVOCATE_A_FRAME_THAT_CAN_BE_INTERRUPTABLE: + reason = "Invocate a frame that can be interruptable"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_SMART_SCT_COMMAND: + reason = "SCT Command"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_HEAD_UNLOADING: + reason = "Head Unloading"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_START_OF_SANITIZE_COMMAND: + reason = "Start of Sanitize Command"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_END_OF_SANITIZE_COMMAND: + reason = "End of Sanitize Command"; + break; + case SMART_FRAME_FLAG_SAVED_DUE_TO_FORMAT_COMPLETION: + reason = "Format Completion"; + break; + case SMART_FRAME_FLAG_UNRECOVERED_WRITE_NVC_RESET_FRAME: + reason = "Unrecovered write NVC Reset Frame"; + break; + case SMART_FRAME_FLAG_QUICK_FORMAT_FINISH: + reason = "Quick Format Finish (SAS)"; + break; + case SMART_FRAME_FLAG_SATA_DEVICE_FAULT: + reason = "Sata Device Fault"; + break; + case SMART_FRAME_FLAG_SATA_UNCORRECTABLE_ERROR: + reason = "Uncorrectable Error"; + break; + case SMART_FRAME_FLAG_SATA_ERC_UNCORRETABLE_ERROR: + reason = "ERC Uncorrectable Error"; + break; + case SMART_FRAME_FLAG_DRIVE_SELF_TEST_COMPLETE_WITH_FAILURE: + reason = "DST Test Completed with Failure"; + break; + case SMART_FRAME_FLAG_DEFECT_LIST_COMMAND: + reason = "Defect List Command"; + break; + case SMART_FRAME_FLAG_F7_CDB_TRIGGER: + reason = "F7 CDB Trigger"; + break; + default: + reason = "Did not match any value"; + break; + } +} + +//----------------------------------------------------------------------------- +// +//! \fn prePython_uknown_params() +// +//! \brief +//! Description: process prepython unknow or vendor spcific information +// +// Entry: +//! \param value - the 64 bit value +//! \param logPage - the log page number of the data +//! \param subPage - the sub page number of the data +//! \param paramCode for the data +//! \param offset - offset with in the buffer where the data is coming from +//! \param parseUnknowns - do we need to show the data or just skip it all +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +void opensea_parser::prePython_unknown_params(JSONNODE* masterData, uint64_t value, uint16_t logPage, uint8_t subPage, uint16_t paramCode, uint32_t offset) +{ + if (g_parseUnknown) + { + std::string myStr = ""; + JSONNODE* data = json_new(JSON_NODE); + json_push_back(data, json_new_a("name", "unknown_parameter")); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + //json_push_back(label, json_new_a("units", "unknown")); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << logPage << "," << std::hex << std::nouppercase << static_cast(subPage) << ":0x" << std::hex << std::nouppercase << paramCode << ":" << std::dec << offset; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(data, label); + + JSONNODE* valueRaw = json_new(JSON_ARRAY); + json_set_name(valueRaw, "value_raw"); + //uint8_t vraw = 0; + byte_Swap_64(&value); + for (size_t i = 0; i < sizeof(uint64_t); i++) // loop for the zones + { + uint8_t vraw = static_cast((value >> (i *8))& UINT64_C(0x00000000000000FF)); + json_push_back(valueRaw, json_new_i("value_raw", vraw)); + } + json_push_back(label, valueRaw); + + + json_push_back(data, json_new_i("value", -1)); + json_push_back(masterData, data); + } + +} +//----------------------------------------------------------------------------- +// +//! \fn prePython_int() +// +//! \brief +//! Description: format the data for the prepython data int type +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +void opensea_parser::prePython_int(JSONNODE* masterData, const char* name, const char* statType, const char* unit, uint64_t value, uint16_t logPage, uint8_t subPage, uint16_t paramCode, uint32_t offset) +{ + std::string myStr = ""; + JSONNODE* data = json_new(JSON_NODE); + json_push_back(data, json_new_a("name", name)); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + if (statType != NULL) + { + json_push_back(label, json_new_a("stat_type", statType)); + } + json_push_back(label, json_new_a("units", unit)); + + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << logPage << "," << std::hex << std::nouppercase << static_cast(subPage) << ":0x" << std::hex << std::nouppercase << paramCode << ":" << std::dec << offset; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(data, label); + json_push_back(data, json_new_i("value", value)); + + json_push_back(masterData, data); +} +//----------------------------------------------------------------------------- +// +//! \fn prePython_float() +// +//! \brief +//! Description: format the data for the prepython data float type +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +void opensea_parser::prePython_float(JSONNODE* masterData, const char* name, const char* statType, const char* unit, double value, uint16_t logPage,uint8_t subPage, uint16_t paramCode, uint32_t offset) +{ + std::string myStr = ""; + JSONNODE* data = json_new(JSON_NODE); + json_push_back(data, json_new_a("name", name)); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + if (statType != NULL) + { + json_push_back(label, json_new_a("stat_type", statType)); + } + json_push_back(label, json_new_a("units", unit)); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << logPage << "," << std::hex << std::nouppercase << static_cast(subPage) << ":0x" << std::hex << std::nouppercase << paramCode << ":" << std::dec << offset; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(data, label); + json_push_back(data, json_new_f("value", value)); + + json_push_back(masterData, data); +} diff --git a/src/Seagate/CAta_Farm_Log.cpp b/src/Seagate/CAta_Farm_Log.cpp index fd8679c..a7e07ff 100644 --- a/src/Seagate/CAta_Farm_Log.cpp +++ b/src/Seagate/CAta_Farm_Log.cpp @@ -1,7 +1,7 @@ // // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -73,8 +73,8 @@ CATA_Farm_Log::CATA_Farm_Log(uint8_t *bufferData, size_t bufferSize, bool showSt , m_MajorRev(0) , m_MinorRev(0) { - pBuf = new uint8_t[bufferSize]; // new a buffer to the point -#ifndef _WIN64 + pBuf = new uint8_t[bufferSize]; // new a buffer to the point +#ifndef __STDC_SECURE_LIB__ memcpy(pBuf, bufferData, bufferSize); #else memcpy_s(pBuf, bufferSize, bufferData, bufferSize);// copy the buffer data to the class member pBuf @@ -89,12 +89,12 @@ CATA_Farm_Log::CATA_Farm_Log(uint8_t *bufferData, size_t bufferSize, bool showSt else { m_pHeader = reinterpret_cast(&pBuf[0]); - m_totalPages = m_pHeader->pagesSupported & 0x00FFFFFFFFFFFFFFLL; - m_logSize = m_pHeader->logSize & 0x00FFFFFFFFFFFFFFLL; - m_pageSize = m_pHeader->pageSize & 0x00FFFFFFFFFFFFFFLL; - m_heads = m_pHeader->headsSupported & 0x00FFFFFFFFFFFFFFLL; - m_MaxHeads = m_pHeader->headsSupported & 0x00FFFFFFFFFFFFFFLL; - m_copies = m_pHeader->copies & 0x00FFFFFFFFFFFFFFLL; + m_totalPages = m_pHeader->pagesSupported & UINT64_C(0x00FFFFFFFFFFFFFF); + m_logSize = m_pHeader->logSize & UINT64_C(0x00FFFFFFFFFFFFFF); + m_pageSize = m_pHeader->pageSize & UINT64_C(0x00FFFFFFFFFFFFFF); + m_heads = m_pHeader->headsSupported & UINT64_C(0x00FFFFFFFFFFFFFF); + m_MaxHeads = m_pHeader->headsSupported & UINT64_C(0x00FFFFFFFFFFFFFF); + m_copies = m_pHeader->copies & UINT64_C(0x00FFFFFFFFFFFFFF); m_status = IN_PROGRESS; m_MajorRev = M_DoubleWord0(m_pHeader->majorRev); m_MinorRev = M_DoubleWord0(m_pHeader->minorRev); @@ -155,43 +155,45 @@ eReturnValues CATA_Farm_Log::parse_Farm_Log() return retStatus; } sFarmFrame *pFarmFrame = new sFarmFrame(); // create the pointer to the union - if ((m_pHeader->signature & 0x00FFFFFFFFFFFFFFLL) == FARMSIGNATURE) // check the head to see if it has the farm signature else fail + uint64_t signature = m_pHeader->signature & UINT64_C(0x00FFFFFFFFFFFFFF); + // TODO: Add in a check for time series that has all FFFF's even for the signature - show as empty + if (signature == FARMSIGNATURE || signature == FACTORYCOPY) // check the head to see if it has the farm signature else fail { for (uint32_t index = 0; index <= m_copies; ++index) // loop for the number of copies. I don't think it's zero base as of now { - sDriveInfo *idInfo = (sDriveInfo *)&pBuf[offset]; // get the id drive information at the time. + sDriveInfo *idInfo = reinterpret_cast(&pBuf[offset]); // get the id drive information at the time. pFarmFrame->driveInfo = *idInfo; sStringIdentifyData strIdInfo; - create_Serial_Number(pFarmFrame->identStringInfo.serialNumber, idInfo); - create_World_Wide_Name(pFarmFrame->identStringInfo.worldWideName, idInfo); - create_Firmware_String(pFarmFrame->identStringInfo.firmwareRev, idInfo); - create_Device_Interface_String(pFarmFrame->identStringInfo.deviceInterface, idInfo); + create_Serial_Number(pFarmFrame->identStringInfo.serialNumber, M_DoubleWord0(idInfo->serialNumber), M_DoubleWord0(idInfo->serialNumber2), m_MajorRev, false); + create_World_Wide_Name(pFarmFrame->identStringInfo.worldWideName, idInfo->worldWideName2, idInfo->worldWideName,false); + create_Firmware_String(pFarmFrame->identStringInfo.firmwareRev, M_DoubleWord0(idInfo->firmware), M_DoubleWord0(idInfo->firmwareRev),false); + create_Device_Interface_String(pFarmFrame->identStringInfo.deviceInterface, M_DoubleWord0(idInfo->deviceInterface),false); if (m_MajorRev >= MAJORVERSION3) // must be higher then version 3.0 for the model number { - create_Model_Number_String(pFarmFrame->identStringInfo.modelNumber, idInfo); + create_Model_Number_String(pFarmFrame->identStringInfo.modelNumber, idInfo->modelNumber,false); } else { pFarmFrame->identStringInfo.modelNumber = "ST12345678"; } - + offset += m_pageSize; - sWorkLoadStat *pworkLoad = (sWorkLoadStat *)&pBuf[offset]; // get the work load information + sWorkLoadStat *pworkLoad = reinterpret_cast(&pBuf[offset]); // get the work load information memcpy(&pFarmFrame->workLoadPage, pworkLoad, sizeof(sWorkLoadStat)); offset += m_pageSize; - sErrorStat *pError = (sErrorStat *)&pBuf[offset]; // get the error status + sErrorStat *pError = reinterpret_cast(&pBuf[offset]); // get the error status memcpy(&pFarmFrame->errorPage, pError, sizeof(sErrorStat)); offset += m_pageSize; - sEnvironementStat *pEnvironment = (sEnvironementStat *)&pBuf[offset]; // get the envirmonent information + sEnvironementStat *pEnvironment = reinterpret_cast(&pBuf[offset]); // get the envirmonent information memcpy(&pFarmFrame->environmentPage, pEnvironment, sizeof(sEnvironementStat)); offset += m_pageSize; - sAtaReliabilityStat *pReli = (sAtaReliabilityStat *)&pBuf[offset]; // get the Reliabliity stat + sAtaReliabilityStat *pReli = reinterpret_cast(&pBuf[offset]); // get the Reliabliity stat memcpy(&pFarmFrame->reliPage, pReli, sizeof(sAtaReliabilityStat)); offset += m_pageSize; // add another page size. I think there is only on header vFarmFrame.push_back(*pFarmFrame); // push the data to the vector @@ -218,28 +220,26 @@ eReturnValues CATA_Farm_Log::parse_Farm_Log() //--------------------------------------------------------------------------- eReturnValues CATA_Farm_Log::print_Header(JSONNODE *masterData) { - std::string myStr = ""; - myStr.resize(BASIC); JSONNODE *pageInfo = json_new(JSON_NODE); - sFarmHeader *header = (sFarmHeader *)&pBuf[0]; // pointer to the header to get the signature + sFarmHeader *header = reinterpret_cast(&pBuf[0]); // pointer to the header to get the signature #if defined _DEBUG printf("\n\n \tFARM Log Header \n"); - printf("\tLog Signature (debug): 0x%" PRIX64" \n", header->signature & 0x00FFFFFFFFFFFFFFLL); //!< Log Signature = 0x00004641524D4552 - printf("\tMajor Revision (debug): %" PRIu64" \n", header->majorRev & 0x00FFFFFFFFFFFFFFLL); //!< Log Major rev - printf("\tMinor Revision (debug): %" PRIu64" \n", header->minorRev & 0x00FFFFFFFFFFFFFFLL); //!< minor rev - printf("\tPages Supported (debug): %" PRIu64" \n", header->pagesSupported & 0x00FFFFFFFFFFFFFFLL); //!< number of pages supported - printf("\tLog Size (debug): %" PRIu64" \n", header->logSize & 0x00FFFFFFFFFFFFFFLL); //!< log size in bytes - printf("\tPage Size (debug): %" PRIu64" \n", header->pageSize & 0x00FFFFFFFFFFFFFFLL); //!< page size in bytes - printf("\tHeads Supported (debug): %" PRIu64" \n", header->headsSupported & 0x00FFFFFFFFFFFFFFLL); //!< Maximum Drive Heads Supported - printf("\tNumber of Copies (debug): %" PRIu64" \n", header->copies & 0x00FFFFFFFFFFFFF); //!< Number of Historical Copies - printf("\tReason for Frame Capture(debug): %" PRIu64" \n", header->reasonForFrameCpature & 0x00FFFFFFFFFFFFF); //!< Reason for Frame Capture + printf("\tLog Signature (debug): 0x%" PRIX64" \n", header->signature & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Log Signature = 0x00004641524D4552 + printf("\tMajor Revision (debug): %" PRIu64" \n", header->majorRev & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Log Major rev + printf("\tMinor Revision (debug): %" PRIu64" \n", header->minorRev & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< minor rev + printf("\tPages Supported (debug): %" PRIu64" \n", header->pagesSupported & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< number of pages supported + printf("\tLog Size (debug): %" PRIu64" \n", header->logSize & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< log size in bytes + printf("\tPage Size (debug): %" PRIu64" \n", header->pageSize & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< page size in bytes + printf("\tHeads Supported (debug): %" PRIu64" \n", header->headsSupported & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Maximum Drive Heads Supported + printf("\tNumber of Copies (debug): %" PRIu64" \n", header->copies & UINT64_C(0x00FFFFFFFFFFFFF)); //!< Number of Historical Copies + printf("\tReason for Frame Capture(debug): %" PRIu64" \n", header->reasonForFrameCapture & UINT64_C(0x00FFFFFFFFFFFFF)); //!< Reason for Frame Capture #endif json_set_name(pageInfo, "FARM Log Header"); - - snprintf((char*)myStr.c_str(), BASIC, "0x%" PRIX64"", check_Status_Strip_Status(header->signature)); - json_push_back(pageInfo, json_new_a("Log Signature", (char*)myStr.c_str())); + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << std::uppercase << check_Status_Strip_Status(header->signature); + json_push_back(pageInfo, json_new_a("Log Signature", temp.str().c_str())); json_push_back(pageInfo, json_new_i("Major Revision", static_cast(check_Status_Strip_Status(header->majorRev)))); json_push_back(pageInfo, json_new_i("Minor Revision", static_cast(check_Status_Strip_Status(header->minorRev)))); json_push_back(pageInfo, json_new_i("Pages Supported", static_cast(check_Status_Strip_Status(header->pagesSupported)))); @@ -247,8 +247,11 @@ eReturnValues CATA_Farm_Log::print_Header(JSONNODE *masterData) json_push_back(pageInfo, json_new_i("Page Size", static_cast(check_Status_Strip_Status(header->pageSize)))); json_push_back(pageInfo, json_new_i("Heads Supported", static_cast(check_Status_Strip_Status(header->headsSupported)))); json_push_back(pageInfo, json_new_i("Number of Copies", static_cast(check_Status_Strip_Status(header->copies)))); - json_push_back(pageInfo, json_new_i("Reason for Frame Capture", static_cast(check_Status_Strip_Status(header->reasonForFrameCpature)))); - get_SMART_Save_Flages(pageInfo, M_Byte0(header->reasonForFrameCpature)); + json_push_back(pageInfo, json_new_i("Reason for Frame Capture", static_cast(check_Status_Strip_Status(header->reasonForFrameCapture)))); + std::string reason; + Get_FARM_Reason_For_Capture(&reason, M_Byte0(header->reasonForFrameCapture)); + json_push_back(pageInfo, json_new_a("Reason Meaning", reason.c_str())); + json_push_back(masterData, pageInfo); @@ -272,8 +275,7 @@ eReturnValues CATA_Farm_Log::print_Header(JSONNODE *masterData) //--------------------------------------------------------------------------- eReturnValues CATA_Farm_Log::print_Drive_Information(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); + std::ostringstream myStr; JSONNODE *pageInfo = json_new(JSON_NODE); #if defined _DEBUG @@ -290,127 +292,138 @@ eReturnValues CATA_Farm_Log::print_Drive_Information(JSONNODE *masterData, uint3 printf("\tfirmware Rev(debug): %s \n", vFarmFrame[page].identStringInfo.firmwareRev.c_str()); //!< Firmware Revision [0:3] printf("\nDrive Information From Farm Log copy %d(debug): \n", page); printf("\tDevice Interface(debug): %s \n", vFarmFrame[page].identStringInfo.deviceInterface.c_str()); - printf("\tDevice Capacity in sectors(debug): %" PRId64" \n", vFarmFrame[page].driveInfo.deviceCapacity & 0x00FFFFFFFFFFFFFFLL); - printf("\tPhysical Sector size(debug): %" PRIX64" \n", vFarmFrame[page].driveInfo.psecSize & 0x00FFFFFFFFFFFFFFLL); //!< Physical Sector Size in Bytes - printf("\tLogical Sector Size(debug): %" PRIX64" \n", vFarmFrame[page].driveInfo.lsecSize & 0x00FFFFFFFFFFFFFFLL); //!< Logical Sector Size in Bytes - printf("\tDevice Buffer Size(debug): %" PRIX64" \n", vFarmFrame[page].driveInfo.deviceBufferSize & 0x00FFFFFFFFFFFFFFLL); //!< Device Buffer Size in Bytes - printf("\tNumber of heads(debug): %" PRId64" \n", vFarmFrame[page].driveInfo.heads & 0x00FFFFFFFFFFFFFFLL); //!< Number of Heads - printf("\tDevice form factor(debug): %" PRIX64" \n", vFarmFrame[page].driveInfo.factor & 0x00FFFFFFFFFFFFFFLL); //!< Device Form Factor (ID Word 168) - printf("\tRotation Rate(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.rotationRate & 0x00FFFFFFFFFFFFFFLL); //!< Rotational Rate of Device (ID Word 217) - printf("\tATA Features Supported (ID Word 78)(debug): 0x%04" PRIX64" \n", vFarmFrame[page].driveInfo.featuresSupported & 0x00FFFFFFFFFFFFFFLL); //!< ATA Features Supported (ID Word 78) - printf("\tATA Features Enabled (ID Word 79)(debug): 0x%04" PRIX64" \n", vFarmFrame[page].driveInfo.featuresEnabled & 0x00FFFFFFFFFFFFFFLL); //!< ATA Features Enabled (ID Word 79) - printf("\tATA Security State (ID Word 128)(debug): 0x%04" PRIX64" \n", vFarmFrame[page].driveInfo.security & 0x00FFFFFFFFFFFFFFLL); //!< ATA Security State (ID Word 128) - printf("\tPower on Hours(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.poh & 0x00FFFFFFFFFFFFFFLL); //!< Power-on Hour - printf("\tSpindle Power on hours(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.spoh & 0x00FFFFFFFFFFFFFFLL); //!< Spindle Power-on Hours - printf("\tHead Flight Hours(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.headFlightHours & 0x00FFFFFFFFFFFFFFLL); //!< Head Flight Hours - printf("\tHead Load Events(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.headLoadEvents & 0x00FFFFFFFFFFFFFFLL); //!< Head Load Events - printf("\tPower Cycle count(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.powerCycleCount & 0x00FFFFFFFFFFFFFFLL); //!< Power Cycle Count - printf("\tHardware Reset count(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.resetCount & 0x00FFFFFFFFFFFFFFLL); //!< Hardware Reset Count - printf("\tSpin-up Time(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.spinUpTime & 0x00FFFFFFFFFFFFFFLL); //!< SMART Spin-Up time in milliseconds - printf("\tNVC Status @ power on(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.NVC_StatusATPowerOn & 0x00FFFFFFFFFFFFFFLL); //!< NVC Status on Power-on - printf("\tTime Available to save(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.timeAvailable & 0x00FFFFFFFFFFFFFFLL); //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) - printf("\tTime of latest frame(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.timeStamp1 & 0x00FFFFFFFFFFFFFFLL); //!< Timestamp of latest SMART Summary Frame in Power-On Hours microseconds (spec is wrong) - printf("\tTime of latest frame (milliseconds)(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.timeStamp2 & 0x00FFFFFFFFFFFFFFLL); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds1 - printf("\tTime to ready of the last power cycle(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.timeToReady & 0x00FFFFFFFFFFFFFFLL); //!< time to ready of the last power cycle - printf("\tTime drive is held in staggered spin(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.timeHeld & 0x00FFFFFFFFFFFFFFLL); //!< time drive is held in staffered spin during the last power on sequence - printf("\tDepopulation Head Mask(debug): %" PRIu64" \n", vFarmFrame[page].driveInfo.depopulationHeadMask & 0x00FFFFFFFFFFFFFFLL); + printf("\tDevice Capacity in sectors(debug): %" PRId64" \n", (vFarmFrame[page].driveInfo.deviceCapacity & UINT64_C(0x00FFFFFFFFFFFFFF))); + printf("\tPhysical Sector size(debug): %" PRIX64" \n", (vFarmFrame[page].driveInfo.psecSize & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Physical Sector Size in Bytes + printf("\tLogical Sector Size(debug): %" PRIX64" \n", (vFarmFrame[page].driveInfo.lsecSize & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Logical Sector Size in Bytes + printf("\tDevice Buffer Size(debug): %" PRIX64" \n", (vFarmFrame[page].driveInfo.deviceBufferSize & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Device Buffer Size in Bytes + printf("\tNumber of heads(debug): %" PRId64" \n", (vFarmFrame[page].driveInfo.heads & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Number of Heads + printf("\tDevice form factor(debug): %" PRIX64" \n", (vFarmFrame[page].driveInfo.factor & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Device Form Factor (ID Word 168) + printf("\tRotation Rate(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.rotationRate & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Rotational Rate of Device (ID Word 217) + printf("\tATA Features Supported (ID Word 78)(debug): 0x%04" PRIX64" \n", (vFarmFrame[page].driveInfo.featuresSupported & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< ATA Features Supported (ID Word 78) + printf("\tATA Features Enabled (ID Word 79)(debug): 0x%04" PRIX64" \n", (vFarmFrame[page].driveInfo.featuresEnabled & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< ATA Features Enabled (ID Word 79) + printf("\tATA Security State (ID Word 128)(debug): 0x%04" PRIX64" \n", (vFarmFrame[page].driveInfo.security & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< ATA Security State (ID Word 128) + printf("\tPower on Hours(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.poh & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Power-on Hour + printf("\tSpindle Power on hours(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.spoh & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Spindle Power-on Hours + printf("\tHead Flight Hours(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.headFlightHours & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Head Flight Hours + printf("\tHead Load Events(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.headLoadEvents & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Head Load Events + printf("\tPower Cycle count(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.powerCycleCount & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Power Cycle Count + printf("\tHardware Reset count(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.resetCount & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Hardware Reset Count + printf("\tSpin-up Time(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.spinUpTime & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< SMART Spin-Up time in milliseconds + printf("\tNVC Status @ power on(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.NVC_StatusATPowerOn & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< NVC Status on Power-on + printf("\tTime Available to save(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.timeAvailable & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) + printf("\tTime of latest frame(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.timeStamp1 & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Timestamp of latest SMART Summary Frame in Power-On Hours microseconds (spec is wrong) + printf("\tTime of latest frame (milliseconds)(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.timeStamp2 & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds1 + printf("\tTime to ready of the last power cycle(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.timeToReady & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< time to ready of the last power cycle + printf("\tTime drive is held in staggered spin(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.timeHeld & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< time drive is held in staffered spin during the last power on sequence + printf("\tDepopulation Head Mask(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.depopulationHeadMask & UINT64_C(0x00FFFFFFFFFFFFFF))); + printf("\tHead Flight Hours, Actuator 1(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.headFlightHoursAct1 & UINT64_C(0x00FFFFFFFFFFFFFF))); + + printf("\tHead Load Events, Actuator 1(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.headLoadEventsAct1 & UINT64_C(0x00FFFFFFFFFFFFFF))); + printf("\tDrive Recording Type(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.driveRecordingType & UINT64_C(0x00FFFFFFFFFFFFFF))); + printf("\tdepopped(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.depopped & UINT64_C(0x00FFFFFFFFFFFFFF))); + printf("\tMax number of sectors for reasssingment(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.maxNumberForReasign & UINT64_C(0x00FFFFFFFFFFFFFF))); + printf("\tDate of Assembly(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.dateOfAssembly & UINT64_C(0x00FFFFFFFFFFFFFF))); + printf("\tHAMR Data Protect Status(debug): %" PRIu64" \n", (vFarmFrame[page].driveInfo.HAMRProtectStatus & UINT64_C(0x00FFFFFFFFFFFFFF))); #endif + std::ostringstream temp; + // check the level of print form the eToolVerbosityLevels if (vFarmFrame[page].driveInfo.copyNumber == FACTORYCOPY) { - snprintf((char*)myStr.c_str(), BASIC, "Drive Information From Farm Log copy FACTORY"); + temp << "Drive Information From Farm Log copy FACTORY"; } else { - snprintf((char*)myStr.c_str(), BASIC, "Drive Information From Farm Log copy %" PRIu32"", page); + temp << "Drive Information From Farm Log copy " << std::dec << page; } - json_set_name(pageInfo, (char*)myStr.c_str()); - - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.serialNumber.c_str()); //!< serial number of the device - json_push_back(pageInfo, json_new_a("Serial Number", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.modelNumber.c_str()); //!< model Number only on 3.0 and higher - json_push_back(pageInfo, json_new_a("Model Number", (char*)myStr.c_str())); + json_set_name(pageInfo, temp.str().c_str()); + + json_push_back(pageInfo, json_new_a("Serial Number", vFarmFrame[page].identStringInfo.serialNumber.c_str())); //!< serial number of the device + json_push_back(pageInfo, json_new_a("Model Number", vFarmFrame[page].identStringInfo.modelNumber.c_str())); //!< model Number only on 3.0 and higher - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.worldWideName.c_str()); - json_push_back(pageInfo, json_new_a("World Wide Name", (char*)myStr.c_str())); //!< world wide Name - //!< Firmware Revision [0:3] - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.deviceInterface.c_str());//!< Rotational Rate of Device (ID Word 217) - json_push_back(pageInfo, json_new_a("Device Interface", (char*)myStr.c_str())); //!< Device Interface - set_json_64_bit_With_Status(pageInfo, "Power on Hour", vFarmFrame[page].driveInfo.poh, false, m_showStatusBits); //!< Power-on Hour + json_push_back(pageInfo, json_new_a("World Wide Name", vFarmFrame[page].identStringInfo.worldWideName.c_str())); //!< world wide Name + + + json_push_back(pageInfo, json_new_a("Device Interface", vFarmFrame[page].identStringInfo.deviceInterface.c_str())); //!< Device Interface + set_json_64_bit_With_Status(pageInfo, "Power on Hour", vFarmFrame[page].driveInfo.poh, false, m_showStatusBits); //!< Power-on Hour set_json_64_bit_With_Status(pageInfo, "Device Capacity in Sectors", vFarmFrame[page].driveInfo.deviceCapacity, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Physical Sector size", vFarmFrame[page].driveInfo.psecSize, false, m_showStatusBits); //!< Physical Sector Size in Bytes - set_json_64_bit_With_Status(pageInfo, "Logical Sector Size", vFarmFrame[page].driveInfo.lsecSize, false, m_showStatusBits); //!< Logical Sector Size in Bytes - set_json_64_bit_With_Status(pageInfo, "Device Buffer Size", vFarmFrame[page].driveInfo.deviceBufferSize, false, m_showStatusBits); //!< Device Buffer Size in Bytes - set_json_64_bit_With_Status(pageInfo, "Number of heads", vFarmFrame[page].driveInfo.heads, false, m_showStatusBits); //!< Number of Heads + set_json_64_bit_With_Status(pageInfo, "Physical Sector size", vFarmFrame[page].driveInfo.psecSize, false, m_showStatusBits); //!< Physical Sector Size in Bytes + set_json_64_bit_With_Status(pageInfo, "Logical Sector Size", vFarmFrame[page].driveInfo.lsecSize, false, m_showStatusBits); //!< Logical Sector Size in Bytes + set_json_64_bit_With_Status(pageInfo, "Device Buffer Size", vFarmFrame[page].driveInfo.deviceBufferSize, false, m_showStatusBits); //!< Device Buffer Size in Bytes + set_json_64_bit_With_Status(pageInfo, "Number of heads", vFarmFrame[page].driveInfo.heads, false, m_showStatusBits); //!< Number of Heads if (check_Status_Strip_Status(vFarmFrame[page].driveInfo.heads) != 0) { m_heads = check_Status_Strip_Status(vFarmFrame[page].driveInfo.heads); } - set_json_64_bit_With_Status(pageInfo, "Device form factor", vFarmFrame[page].driveInfo.factor, false, m_showStatusBits); //!< Device Form Factor (ID Word 168) + set_json_64_bit_With_Status(pageInfo, "Device form factor", vFarmFrame[page].driveInfo.factor, false, m_showStatusBits); //!< Device Form Factor (ID Word 168) set_json_64_bit_With_Status(pageInfo, "Rotation Rate", vFarmFrame[page].driveInfo.rotationRate, false, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.firmwareRev.c_str()); - json_push_back(pageInfo, json_new_a("Firmware Rev", (char*)myStr.c_str())); - - - set_json_64_bit_With_Status(pageInfo, "ATA Security State (ID Word 128)", vFarmFrame[page].driveInfo.security, true, m_showStatusBits); //!< ATA Security State (ID Word 128) - set_json_64_bit_With_Status(pageInfo, "ATA Features Supported (ID Word 78)", vFarmFrame[page].driveInfo.featuresSupported, true, m_showStatusBits); //!< ATA Features Supported (ID Word 78) - set_json_64_bit_With_Status(pageInfo, "ATA Features Enabled (ID Word 79)", vFarmFrame[page].driveInfo.featuresEnabled, true, m_showStatusBits); //!< ATA Features Enabled (ID Word 79) - - set_json_64_bit_With_Status(pageInfo, "Spindle Power on hours", vFarmFrame[page].driveInfo.spoh, false, m_showStatusBits); //!< Spindle Power-on Hours - set_json_64_bit_With_Status(pageInfo, "Head Flight Hours", vFarmFrame[page].driveInfo.headFlightHours, false, m_showStatusBits); //!< Head Flight Hours - set_json_64_bit_With_Status(pageInfo, "Head Load Events", vFarmFrame[page].driveInfo.headLoadEvents, false, m_showStatusBits); //!< Head Load Events - set_json_64_bit_With_Status(pageInfo, "Power Cycle count", vFarmFrame[page].driveInfo.powerCycleCount, false, m_showStatusBits); //!< Power Cycle Count - set_json_64_bit_With_Status(pageInfo, "Hardware Reset count", vFarmFrame[page].driveInfo.resetCount, false, m_showStatusBits); //!< Hardware Reset Count - set_json_64_bit_With_Status(pageInfo, "Spin-up Time", vFarmFrame[page].driveInfo.spinUpTime, false, m_showStatusBits); //!< SMART Spin-Up time in milliseconds - - set_json_64_bit_With_Status(pageInfo, "NVC Status @ power on", vFarmFrame[page].driveInfo.NVC_StatusATPowerOn, false, m_showStatusBits); //!< NVC Status on Power-on - set_json_64_bit_With_Status(pageInfo, "NVC Time Available to save (in 100us)", vFarmFrame[page].driveInfo.timeAvailable, false, m_showStatusBits); //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) - snprintf((char*)myStr.c_str(), BASIC, "%llu", vFarmFrame[page].driveInfo.timeStamp1 & 0x00FFFFFFFFFFFFFFLL); - set_json_string_With_Status(pageInfo, "Timestamp of First SMART Summary Frame (ms)", (char*)myStr.c_str(), vFarmFrame[page].driveInfo.timeStamp1, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%llu", vFarmFrame[page].driveInfo.timeStamp2 & 0x00FFFFFFFFFFFFFFLL); - set_json_string_With_Status(pageInfo, "TimeStamp of Last SMART Summary Frame (ms)", (char*)myStr.c_str(), vFarmFrame[page].driveInfo.timeStamp2, m_showStatusBits); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds1 - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_Word0(vFarmFrame[page].driveInfo.timeToReady)) / 1000); - set_json_string_With_Status(pageInfo, "Time to ready of the last power cycle", (char*)myStr.c_str(), vFarmFrame[page].driveInfo.timeToReady, m_showStatusBits); //!< time to ready of the last power cycle - set_json_64_bit_With_Status(pageInfo, "Time drive is held in staggered spin", vFarmFrame[page].driveInfo.timeHeld, false, m_showStatusBits); //!< time drive is held in staggered spin during the last power on sequence - - myStr = "Drive Recording Type"; + json_push_back(pageInfo, json_new_a("Firmware Rev", vFarmFrame[page].identStringInfo.firmwareRev.c_str())); //!< Firmware Revision [0:3] + + + set_json_64_bit_With_Status(pageInfo, "ATA Security State (ID Word 128)", vFarmFrame[page].driveInfo.security, true, m_showStatusBits); //!< ATA Security State (ID Word 128) + set_json_64_bit_With_Status(pageInfo, "ATA Features Supported (ID Word 78)", vFarmFrame[page].driveInfo.featuresSupported, true, m_showStatusBits); //!< ATA Features Supported (ID Word 78) + set_json_64_bit_With_Status(pageInfo, "ATA Features Enabled (ID Word 79)", vFarmFrame[page].driveInfo.featuresEnabled, true, m_showStatusBits); //!< ATA Features Enabled (ID Word 79) + + set_json_64_bit_With_Status(pageInfo, "Spindle Power on hours", vFarmFrame[page].driveInfo.spoh, false, m_showStatusBits); //!< Spindle Power-on Hours + set_json_64_bit_With_Status(pageInfo, "Head Flight Hours", vFarmFrame[page].driveInfo.headFlightHours, false, m_showStatusBits); //!< Head Flight Hours + set_json_64_bit_With_Status(pageInfo, "Head Load Events", vFarmFrame[page].driveInfo.headLoadEvents, false, m_showStatusBits); //!< Head Load Events + set_json_64_bit_With_Status(pageInfo, "Power Cycle count", vFarmFrame[page].driveInfo.powerCycleCount, false, m_showStatusBits); //!< Power Cycle Count + set_json_64_bit_With_Status(pageInfo, "Hardware Reset count", vFarmFrame[page].driveInfo.resetCount, false, m_showStatusBits); //!< Hardware Reset Count + set_json_64_bit_With_Status(pageInfo, "Spin-up Time", vFarmFrame[page].driveInfo.spinUpTime, false, m_showStatusBits); //!< SMART Spin-Up time in milliseconds + + set_json_64_bit_With_Status(pageInfo, "NVC Status @ power on", vFarmFrame[page].driveInfo.NVC_StatusATPowerOn, false, m_showStatusBits); //!< NVC Status on Power-on + Get_NVC_Status(pageInfo, vFarmFrame[page].driveInfo.NVC_StatusATPowerOn); + set_json_64_bit_With_Status(pageInfo, "NVC Time Available to save (in 100us)", vFarmFrame[page].driveInfo.timeAvailable, false, m_showStatusBits); //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) + + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.timeStamp1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + set_json_string_With_Status(pageInfo, "Timestamp of First SMART Summary Frame (ms)", temp.str(), vFarmFrame[page].driveInfo.timeStamp1, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.timeStamp2 & UINT64_C(0x00FFFFFFFFFFFFFF)); + set_json_string_With_Status(pageInfo, "TimeStamp of Last SMART Summary Frame (ms)", temp.str(), vFarmFrame[page].driveInfo.timeStamp2, m_showStatusBits); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds1 + + temp.str("");temp.clear(); + temp << std::setfill('0') << std::setprecision(6) << static_cast(M_Word0(vFarmFrame[page].driveInfo.timeToReady)) / 1000; + set_json_string_With_Status(pageInfo, "Time to ready of the last power cycle (sec)", temp.str().c_str(), vFarmFrame[page].driveInfo.timeToReady, m_showStatusBits); //!< time to ready of the last power cycle in milliseconds + temp.str("");temp.clear(); + temp << std::setfill('0') << std::setprecision(3) << static_cast(M_Word0(vFarmFrame[page].driveInfo.timeHeld)) / 1000; + set_json_64_bit_With_Status(pageInfo, "Time drive is held in staggered spin (sec)", vFarmFrame[page].driveInfo.timeHeld, false, m_showStatusBits); //!< time drive is held in staggered spin during the last power on sequence in milliseconds + + myStr << "Drive Recording Type"; std::string type = "CMR"; if (vFarmFrame[page].driveInfo.driveRecordingType & BIT0) { type = "SMR"; } - set_json_string_With_Status(pageInfo, myStr, type, vFarmFrame[page].driveInfo.driveRecordingType, m_showStatusBits); - - myStr = "Has Drive been Depopped"; + set_json_string_With_Status(pageInfo, myStr.str().c_str(), type, vFarmFrame[page].driveInfo.driveRecordingType, m_showStatusBits); + myStr.str(""); myStr.clear(); + myStr<< "Has Drive been Depopped"; if (check_Status_Strip_Status(vFarmFrame[page].driveInfo.depopped) != 0) { - set_Json_Bool(pageInfo, myStr, true); + set_Json_Bool(pageInfo, myStr.str().c_str(), true); } else { - set_Json_Bool(pageInfo, myStr, false); + set_Json_Bool(pageInfo, myStr.str().c_str(), false); } set_json_64_bit_With_Status(pageInfo, "Max Number of Available Sectors for Reassignment", vFarmFrame[page].driveInfo.maxNumberForReasign, false, m_showStatusBits); //!< Max Number of Available Sectors for Reassignment � Value in disc sectors(started in 3.3 ) - + //!< Date of Assembly in ASCII if (check_For_Active_Status(&vFarmFrame[page].driveInfo.dateOfAssembly)) { - myStr.resize(DATE_YEAR_DATE_SIZE); - memset((char*)myStr.c_str(), 0, DATE_YEAR_DATE_SIZE); - uint16_t year = M_Word1(vFarmFrame[page].driveInfo.dateOfAssembly); - uint16_t week = M_Word0(vFarmFrame[page].driveInfo.dateOfAssembly); - - _common.create_Year_Assembled_String(myStr, year, false); - json_push_back(pageInfo, json_new_a("Year of Assembled", (char*)myStr.c_str())); - - _common.create_Year_Assembled_String(myStr, week, false); - json_push_back(pageInfo, json_new_a("Week of Assembled", (char*)myStr.c_str())); + uint16_t week = M_Word1(vFarmFrame[page].driveInfo.dateOfAssembly); + uint16_t year = M_Word0(vFarmFrame[page].driveInfo.dateOfAssembly); + std::string dataAndTime; + create_Year_Assembled_String(dataAndTime, year, false); + json_push_back(pageInfo, json_new_a("Year of Assembled", dataAndTime.c_str())); + dataAndTime.clear(); + create_Year_Assembled_String(dataAndTime, week, false); + json_push_back(pageInfo, json_new_a("Week of Assembled", dataAndTime.c_str())); } else { @@ -418,6 +431,24 @@ eReturnValues CATA_Farm_Log::print_Drive_Information(JSONNODE *masterData, uint3 json_push_back(pageInfo, json_new_a("Week of Assembled", "00")); } set_json_64_bit_With_Status(pageInfo, "Depopulation Head Mask", vFarmFrame[page].driveInfo.depopulationHeadMask, false, m_showStatusBits); //!< Depopulation Head Mask + + //version 4.21 + if (m_MajorRev >= 4 && m_MinorRev > 20) + { + set_json_64_bit_With_Status(pageInfo, "Head Flight Hours, Actuator 1", vFarmFrame[page].driveInfo.headFlightHoursAct1, false, m_showStatusBits); //!< Head Flight Hours, Actuator 1 + set_json_64_bit_With_Status(pageInfo, "Head Load Events, Actuator 1", vFarmFrame[page].driveInfo.headLoadEventsAct1, false, m_showStatusBits); //!< Head Load Events, Actuator 1 + } + myStr.str(""); myStr.clear(); + myStr << "HAMR Data Protect Status"; + if (check_Status_Strip_Status(vFarmFrame[page].driveInfo.depopped) != 0) + { + set_Json_Bool(pageInfo, myStr.str().c_str(), true); + } + else + { + set_Json_Bool(pageInfo, myStr.str().c_str(), false); + } + json_push_back(masterData, pageInfo); return SUCCESS; @@ -440,75 +471,124 @@ eReturnValues CATA_Farm_Log::print_Drive_Information(JSONNODE *masterData, uint3 //--------------------------------------------------------------------------- eReturnValues CATA_Farm_Log::print_Work_Load(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); JSONNODE *pageInfo = json_new(JSON_NODE); #if defined _DEBUG if (vFarmFrame[page].workLoadPage.copyNumber == FACTORYCOPY) { - printf("\nWork Load From Farm Log copy FACTORY \n"); + printf("\nWorkload From Farm Log copy FACTORY \n"); } else { - printf("\nWork Load From Farm Log copy %d \n", page); - } - printf("\tRated Workload Percentaged(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.workloadPercentage & 0x00FFFFFFFFFFFFFFLL); //!< rated Workload Percentage - printf("\tTotal Number of Other Commands(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalNumberofOtherCMDS & 0x00FFFFFFFFFFFFFFLL); //!< Total Number Of Other Commands - printf("\tTotal Number of Write Commands(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalWriteCommands & 0x00FFFFFFFFFFFFFFLL); //!< Total Number of Write Commands - printf("\tTotal Number of Read Commands(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalReadCommands & 0x00FFFFFFFFFFFFFFLL); //!< Total Number of Read Commands - printf("\tLogical Sectors Written(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.logicalSecWritten & 0x00FFFFFFFFFFFFFFLL); //!< Logical Sectors Written - printf("\tLogical Sectors Read(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.logicalSecRead & 0x00FFFFFFFFFFFFFFLL); //!< Logical Sectors Read - printf("\tTotal Number of Random Read Cmds(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalRandomReads & 0x00FFFFFFFFFFFFFFLL); //!< Total Number of Random Read Commands - printf("\tTotal Number of Random Write Cmds(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalRandomWrites & 0x00FFFFFFFFFFFFFFLL); //!< Total Number of Random Write Commands - printf("\tLogical Sectors Written(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.logicalSecWritten & 0x00FFFFFFFFFFFFFFLL); //!< Logical Sectors Written - printf("\tLogical Sectors Read(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.logicalSecRead & 0x00FFFFFFFFFFFFFFLL); //!< Logical Sectors Read - printf("\tDither events during current power cycle(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.dither & 0x00FFFFFFFFFFFFFFLL); //!< Number of dither events during current power cycle (added 3.4) - printf("\tDither was held off during random(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.ditherRandom & 0x00FFFFFFFFFFFFFFLL); //!< Number of times dither was held off during random workloads during current power cycle(added 3.4) - printf("\tDither was held off during sequential(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.ditherSequential & 0x00FFFFFFFFFFFFFFLL); //!< Number of times dither was held off during sequential workloads during current power cycle(added 3.4) - printf("\tRead cmds from 0-3.125%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfReadCmds1 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames(added 4.4) - printf("\tRead cmds from 3.125-25%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfReadCmds2 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames(added 4.4) - printf("\tRead cmds from 25-50%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfReadCmds3 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames(added 4.4) - printf("\tRead cmds from 50-100%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfReadCmds4 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames(added 4.4) - printf("\tWrite cmds from 0-3.125%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfWriteCmds1 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames(added 4.4) - printf("\tWrite cmds from 3.125-25%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfWriteCmds2 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames(added 4.4) - printf("\tWrite cmds from 25-50%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfWriteCmds3 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames(added 4.4) - printf("\tWrite cmds from 50-100%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfWriteCmds4 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames(added 4.4) + printf("\nWorkload From Farm Log copy %d \n", page); + } + printf("\tRated Workload Percentage(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.workloadPercentage & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< rated Workload Percentage + printf("\tTotal Number of Other Commands(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalNumberofOtherCMDS & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number Of Other Commands + printf("\tTotal Number of Write Commands(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalWriteCommands & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number of Write Commands + printf("\tTotal Number of Read Commands(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalReadCommands & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number of Read Commands + printf("\tLogical Sectors Written(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.logicalSecWritten & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Logical Sectors Written + printf("\tLogical Sectors Read(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.logicalSecRead & UINT64_C(0x00FFFFFFFFFFFFF)); //!< Logical Sectors Read + printf("\tTotal Number of Random Read Cmds(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalRandomReads & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number of Random Read Commands + printf("\tTotal Number of Random Write Cmds(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.totalRandomWrites & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number of Random Write Commands + printf("\tLogical Sectors Written(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.logicalSecWritten & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Logical Sectors Written + printf("\tLogical Sectors Read(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.logicalSecRead & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Logical Sectors Read + printf("\tDither events during current power cycle(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.dither & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of dither events during current power cycle (added 3.4) + printf("\tDither was held off during random(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.ditherRandom & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of times dither was held off during random workloads during current power cycle(added 3.4) + printf("\tDither was held off during sequential(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.ditherSequential & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of times dither was held off during sequential workloads during current power cycle(added 3.4) + printf("\tRead cmds from 0-3.125%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfReadCmds1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames(added 4.4) + printf("\tRead cmds from 3.125-25%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfReadCmds2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames(added 4.4) + printf("\tRead cmds from 25-50%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfReadCmds3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames(added 4.4) + printf("\tRead cmds from 50-100%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfReadCmds4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames(added 4.4) + printf("\tWrite cmds from 0-3.125%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfWriteCmds1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames(added 4.4) + printf("\tWrite cmds from 3.125-25%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfWriteCmds2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames(added 4.4) + printf("\tWrite cmds from 25-50%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfWriteCmds3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames(added 4.4) + printf("\tWrite cmds from 50-100%% of LBA space(debug): %" PRIu64" \n", vFarmFrame[page].workLoadPage.numberOfWriteCmds4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames(added 4.4) + //4.21 + if (m_MajorRev >= 4 && m_MinorRev > 20) + { + printf("\tNumber of Read Commands of transfer length <=16KB for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.numReadTransferSmallATA & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of Read Commands of transfer length (16KB - 512KB] for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.numReadTransferMid1ATA & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of Read Commands of transfer length (512KB - 2MB] for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.numReadTransferMid2ATA & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of Read Commands of transfer length > 2MB for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.numReadTransferLargeATA & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of Write Commands of transfer length <=16KB for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.numWriteTransferSmallATA & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of Write Commands of transfer length (16KB - 512KB] for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.numWriteTransferMid1ATA & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of Write Commands of transfer length (512KB - 2MB] for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.numWriteTransferMid2ATA & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of Write Commands of transfer length > 2MB for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.numWriteTransferLargeATA & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth =1 at 30s intervals for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.cntQueueDepth1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth =2 at 30s intervals for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.cntQueueDepth2 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth =3-4 at 30s intervals for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.cntQueueDepth3to4 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth =5-8 at 30s intervals for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.cntQueueDepth5to8 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth =9-16 at 30s intervals for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.cntQueueDepth9to16 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth =17-32 at 30s intervals for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.cntQueueDepth17to32 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth =33-64 at 30s intervals for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.cntQueueDepth33to64 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth >64 at 30s intervals for last 3 SMART Summary Frames %llu \n", vFarmFrame[page].workLoadPage.cntQueueDepthmorethan64 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of dither events during current power cycle, Actuator 1 %llu \n", vFarmFrame[page].workLoadPage.numDithEvtAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of times dither was held off during random workloads during current power cycle, Actuator 1 %llu \n", vFarmFrame[page].workLoadPage.numRandWLDitherHoldOffAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tNumber of times dither was held off during sequential workloads during current power cycle, Actuator 1 %llu \n", vFarmFrame[page].workLoadPage.numSequentialWLDitherHoldOffAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + } + + + #endif + std::ostringstream temp; if (vFarmFrame[page].workLoadPage.copyNumber == FACTORYCOPY) { - snprintf((char*)myStr.c_str(), BASIC, "Work Load From Farm Log copy FACTORY"); + temp << "Workload From Farm Log copy FACTORY"; } else { - snprintf((char*)myStr.c_str(), BASIC, "Work Load From Farm Log copy %" PRIu32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - - set_json_64_bit_With_Status(pageInfo, "Rated Workload Percentaged", vFarmFrame[page].workLoadPage.workloadPercentage, false, m_showStatusBits); //!< rated Workload Percentage - set_json_64_bit_With_Status(pageInfo, "Total Number of Read Commands", vFarmFrame[page].workLoadPage.totalReadCommands, false, m_showStatusBits); //!< Total Number of Read Commands - set_json_64_bit_With_Status(pageInfo, "Total Number of Write Commands", vFarmFrame[page].workLoadPage.totalWriteCommands, false, m_showStatusBits); //!< Total Number of Write Commands - set_json_64_bit_With_Status(pageInfo, "Total Number of Random Read Cmds", vFarmFrame[page].workLoadPage.totalRandomReads, false, m_showStatusBits); //!< Total Number of Random Read Commands - set_json_64_bit_With_Status(pageInfo, "Total Number of Random Write Cmds", vFarmFrame[page].workLoadPage.totalRandomWrites, false, m_showStatusBits); //!< Total Number of Random Write Commands - set_json_64_bit_With_Status(pageInfo, "Total Number of Other Commands", vFarmFrame[page].workLoadPage.totalNumberofOtherCMDS, false, m_showStatusBits); //!< Total Number Of Other Commands - snprintf((char*)myStr.c_str(), BASIC, "%llu", vFarmFrame[page].workLoadPage.logicalSecWritten & 0x00FFFFFFFFFFFFFFLL); - set_json_string_With_Status(pageInfo, "Logical Sectors Written", (char*)myStr.c_str(), vFarmFrame[page].workLoadPage.logicalSecWritten, m_showStatusBits); //!< Logical Sectors Written - snprintf((char*)myStr.c_str(), BASIC, "%llu", vFarmFrame[page].workLoadPage.logicalSecRead & 0x00FFFFFFFFFFFFFFLL); - set_json_string_With_Status(pageInfo, "Logical Sectors Read", (char*)myStr.c_str(), vFarmFrame[page].workLoadPage.logicalSecRead, m_showStatusBits); //!< Logical Sectors Read - set_json_64_bit_With_Status(pageInfo, "Number of dither events during current power cycle", vFarmFrame[page].workLoadPage.dither, false, m_showStatusBits); //!< Number of dither events during current power cycle (added 3.4) - set_json_64_bit_With_Status(pageInfo, "Number of times dither was held off during random workloads", vFarmFrame[page].workLoadPage.ditherRandom, false, m_showStatusBits); //!< Number of times dither was held off during random workloads during current power cycle(added 3.4) - set_json_64_bit_With_Status(pageInfo, "Number of times dither was held off during sequential workloads", vFarmFrame[page].workLoadPage.ditherSequential, false, m_showStatusBits); //!< Number of times dither was held off during sequential workloads during current power cycle(added 3.4) - - set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames", vFarmFrame[page].workLoadPage.numberOfReadCmds1, false, m_showStatusBits); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames(added 4.4) - set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames", vFarmFrame[page].workLoadPage.numberOfReadCmds2, false, m_showStatusBits); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames(added 4.4) - set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames", vFarmFrame[page].workLoadPage.numberOfReadCmds3, false, m_showStatusBits); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames(added 4.4) - set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames", vFarmFrame[page].workLoadPage.numberOfReadCmds4, false, m_showStatusBits); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames(added 4.4) - set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames", vFarmFrame[page].workLoadPage.numberOfWriteCmds1, false, m_showStatusBits); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames(added 4.4) - set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames", vFarmFrame[page].workLoadPage.numberOfWriteCmds2, false, m_showStatusBits); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames(added 4.4) - set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames", vFarmFrame[page].workLoadPage.numberOfWriteCmds3, false, m_showStatusBits); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames(added 4.4) - set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames", vFarmFrame[page].workLoadPage.numberOfWriteCmds4, false, m_showStatusBits); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames(added 4.4) - + temp << "Workload From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); + + set_json_64_bit_With_Status(pageInfo, "Rated Workload Percentage", vFarmFrame[page].workLoadPage.workloadPercentage, false, m_showStatusBits); //!< rated Workload Percentage + set_json_64_bit_With_Status(pageInfo, "Total Read Commands", vFarmFrame[page].workLoadPage.totalReadCommands, false, m_showStatusBits); //!< Total Number of Read Commands + set_json_64_bit_With_Status(pageInfo, "Total Write Commands", vFarmFrame[page].workLoadPage.totalWriteCommands, false, m_showStatusBits); //!< Total Number of Write Commands + set_json_64_bit_With_Status(pageInfo, "Total Random Read Cmds", vFarmFrame[page].workLoadPage.totalRandomReads, false, m_showStatusBits); //!< Total Number of Random Read Commands + set_json_64_bit_With_Status(pageInfo, "Total Random Write Cmds", vFarmFrame[page].workLoadPage.totalRandomWrites, false, m_showStatusBits); //!< Total Number of Random Write Commands + set_json_64_bit_With_Status(pageInfo, "Total Other Commands", vFarmFrame[page].workLoadPage.totalNumberofOtherCMDS, false, m_showStatusBits); //!< Total Number Of Other Commands + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].workLoadPage.logicalSecWritten & UINT64_C(0x00FFFFFFFFFFFFFF)); + set_json_string_With_Status(pageInfo, "Logical Sectors Written", temp.str().c_str(), vFarmFrame[page].workLoadPage.logicalSecWritten, m_showStatusBits); //!< Logical Sectors Written + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].workLoadPage.logicalSecRead & UINT64_C(0x00FFFFFFFFFFFFFF)); + set_json_string_With_Status(pageInfo, "Logical Sectors Read", temp.str().c_str(), vFarmFrame[page].workLoadPage.logicalSecRead, m_showStatusBits); //!< Logical Sectors Read + temp.str("");temp.clear(); + set_json_64_bit_With_Status(pageInfo, "dither events Actuator 0", vFarmFrame[page].workLoadPage.dither, false, m_showStatusBits); //!< Number of dither events during current power cycle (added 3.4) + set_json_64_bit_With_Status(pageInfo, "dither held off during random workloads, Actuator 0", vFarmFrame[page].workLoadPage.ditherRandom, false, m_showStatusBits); //!< Number of times dither was held off during random workloads during current power cycle(added 3.4) + set_json_64_bit_With_Status(pageInfo, "dither was held off during sequential workloads, Actuator 0", vFarmFrame[page].workLoadPage.ditherSequential, false, m_showStatusBits); //!< Number of times dither was held off during sequential workloads during current power cycle(added 3.4) + + set_json_64_bit_With_Status(pageInfo, "Read commands from 0-3.125% of LBA space", vFarmFrame[page].workLoadPage.numberOfReadCmds1, false, m_showStatusBits); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames(added 4.4) + set_json_64_bit_With_Status(pageInfo, "Read commands from 3.125-25% of LBA space", vFarmFrame[page].workLoadPage.numberOfReadCmds2, false, m_showStatusBits); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames(added 4.4) + set_json_64_bit_With_Status(pageInfo, "Read commands from 25-50% of LBA space", vFarmFrame[page].workLoadPage.numberOfReadCmds3, false, m_showStatusBits); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames(added 4.4) + set_json_64_bit_With_Status(pageInfo, "Read commands from 50-100% of LBA space", vFarmFrame[page].workLoadPage.numberOfReadCmds4, false, m_showStatusBits); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames(added 4.4) + set_json_64_bit_With_Status(pageInfo, "Write commands from 0-3.125% of LBA space", vFarmFrame[page].workLoadPage.numberOfWriteCmds1, false, m_showStatusBits); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames(added 4.4) + set_json_64_bit_With_Status(pageInfo, "Write commands from 3.125-25% of LBA space", vFarmFrame[page].workLoadPage.numberOfWriteCmds2, false, m_showStatusBits); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames(added 4.4) + set_json_64_bit_With_Status(pageInfo, "Write commands from 25-50% of LBA space", vFarmFrame[page].workLoadPage.numberOfWriteCmds3, false, m_showStatusBits); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames(added 4.4) + set_json_64_bit_With_Status(pageInfo, "Write commands from 50-100% of LBA space", vFarmFrame[page].workLoadPage.numberOfWriteCmds4, false, m_showStatusBits); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames(added 4.4) + //4.21 + + set_json_64_bit_With_Status(pageInfo, "Read Commands of transfer length <=16KB", vFarmFrame[page].workLoadPage.numReadTransferSmallATA, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Read Commands of transfer length (16KB - 512KB]", vFarmFrame[page].workLoadPage.numReadTransferMid1ATA, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Read Commands of transfer length (512KB - 2MB]", vFarmFrame[page].workLoadPage.numReadTransferMid2ATA, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Read Commands of transfer length > 2MB", vFarmFrame[page].workLoadPage.numReadTransferLargeATA, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Write Commands of transfer length <=16KB", vFarmFrame[page].workLoadPage.numWriteTransferSmallATA, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Write Commands of transfer length (16KB - 512KB]", vFarmFrame[page].workLoadPage.numWriteTransferMid1ATA, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Write Commands of transfer length (512KB - 2MB]", vFarmFrame[page].workLoadPage.numWriteTransferMid2ATA, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Write Commands of transfer length > 2MB", vFarmFrame[page].workLoadPage.numWriteTransferLargeATA, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Queue Depth bin = 1", vFarmFrame[page].workLoadPage.cntQueueDepth1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Queue Depth bin = 2", vFarmFrame[page].workLoadPage.cntQueueDepth2, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Queue Depth bin = 3-4", vFarmFrame[page].workLoadPage.cntQueueDepth3to4, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Queue Depth bin = 5-8", vFarmFrame[page].workLoadPage.cntQueueDepth5to8, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Queue Depth bin = 9-16", vFarmFrame[page].workLoadPage.cntQueueDepth9to16, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Queue Depth bin = 17-32", vFarmFrame[page].workLoadPage.cntQueueDepth17to32, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Queue Depth bin = 33-64", vFarmFrame[page].workLoadPage.cntQueueDepth33to64, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Queue Depth bin > 64", vFarmFrame[page].workLoadPage.cntQueueDepthmorethan64, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "dither events, Actuator 1", vFarmFrame[page].workLoadPage.numDithEvtAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "dither was held off during random workloads, Actuator 1", vFarmFrame[page].workLoadPage.numRandWLDitherHoldOffAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "dither was held off during sequential workloads, Actuator 1", vFarmFrame[page].workLoadPage.numSequentialWLDitherHoldOffAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Hot Write Statistics", vFarmFrame[page].workLoadPage.hotWriteStatistics, false, m_showStatusBits); json_push_back(masterData, pageInfo); return SUCCESS; @@ -531,12 +611,9 @@ eReturnValues CATA_Farm_Log::print_Work_Load(JSONNODE *masterData, uint32_t page //--------------------------------------------------------------------------- eReturnValues CATA_Farm_Log::print_Error_Information(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - std::string timeStr = " "; - myStr.resize(BASIC); - timeStr.resize(BASIC); + std::string myStr; + std::string timeStr; uint32_t loopCount = 0; - myStr.resize(BASIC); JSONNODE *pageInfo = json_new(JSON_NODE); #if defined _DEBUG @@ -548,121 +625,154 @@ eReturnValues CATA_Farm_Log::print_Error_Information(JSONNODE *masterData, uint3 { printf("\nError Information Log From Farm Log copy %d: \n", page); } - printf("\tUnrecoverable Read Errors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalReadECC & 0x00FFFFFFFFFFFFFFLL); //!< Number of Unrecoverable Read Errors - printf("\tUnrecoverable Write Errors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalWriteECC & 0x00FFFFFFFFFFFFFFLL); //!< Number of Unrecoverable Write Errors - printf("\tNumber of Reallocated Sectors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalReallocations & 0x00FFFFFFFFFFFFFFLL); //!< Number of Reallocated Sectors - printf("\tNumber of Read Recovery Attempt(debug)s: %" PRId64" \n", vFarmFrame[page].errorPage.totalReadRecoveryAttepts & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read Recovery Attempts - printf("\tNumber of Mechanical Start Failures(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalMechanicalFails & 0x00FFFFFFFFFFFFFFLL); //!< Number of Mechanical Start Failures - printf("\tNumber of Reallocated Candidate Sectors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalReallocatedCanidates & 0x00FFFFFFFFFFFFFFLL); //!< Number of Reallocated Candidate Sectors - printf("\tNumber of ASR Events(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.totalASREvents & 0x00FFFFFFFFFFFFFFLL); //!< Number of ASR Events - printf("\tNumber of Interface CRC Errors(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.totalCRCErrors & 0x00FFFFFFFFFFFFFFLL); //!< Number of Interface CRC Errors - printf("\tSpin Retry Count(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.attrSpinRetryCount & 0x00FFFFFFFFFFFFFFLL); //!< Spin Retry Count (Most recent value from array at byte 401 of attribute sector) - printf("\tSpin Retry Count Normalized(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.normalSpinRetryCount & 0x00FFFFFFFFFFFFFFLL); //!< Spin Retry Count (SMART Attribute 10 Normalized) - printf("\tSpin Retry Count Worst(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.worstSpinRretryCount & 0x00FFFFFFFFFFFFFFLL); //!< Spin Retry Count (SMART Attribute 10 Worst Ever) - printf("\tNumber of IOEDC Errors (Raw)(debug): 0x%" PRIx64" \n", vFarmFrame[page].errorPage.attrIOEDCErrors & 0x00FFFFFFFFFFFFFFLL); //!< Number of IOEDC Errors (SMART Attribute 184 Raw) - printf("\tCTO Count Total(debug): %" PRId64" \n", vFarmFrame[page].errorPage.attrCTOCount & 0x00FFFFFFFFFFFFFFLL); //!< CTO Count Total (SMART Attribute 188 Raw[0..1]) - printf("\tCTO Count Over 5s(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.overfiveSecCTO & 0x00FFFFFFFFFFFFFFLL); //!< CTO Count Over 5s (SMART Attribute 188 Raw[2..3]) - printf("\tCTO Count Over 7.5s(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.oversevenSecCTO & 0x00FFFFFFFFFFFFFFLL); //!< CTO Count Over 7.5s (SMART Attribute - printf("\tTotal Flash LED (Assert) Events(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalFlashLED & 0x00FFFFFFFFFFFFFFLL); //!< Total Flash LED (Assert) Events - printf("\tIndex of the last Flash LED(debug): %" PRId64" \n", vFarmFrame[page].errorPage.indexFlashLED & 0x00FFFFFFFFFFFFFFLL); //!< index of the last Flash LED of the array - printf("\tUncorrectable errors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.uncorrectables & 0x00FFFFFFFFFFFFFFLL); //!< uncorrecatables errors (sata only) + printf("\tUnrecoverable Read Errors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalReadECC & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Unrecoverable Read Errors + printf("\tUnrecoverable Write Errors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalWriteECC & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Unrecoverable Write Errors + printf("\tNumber of Reallocated Sectors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalReallocations & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Reallocated Sectors + printf("\tNumber of Read Recovery Attempts(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalReadRecoveryAttepts & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read Recovery Attempts + printf("\tNumber of Mechanical Start Failures(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalMechanicalFails & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Mechanical Start Failures + printf("\tNumber of Reallocated Candidate Sectors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalReallocatedCanidates & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Reallocated Candidate Sectors + printf("\tNumber of ASR Events(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.totalASREvents & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of ASR Events + printf("\tNumber of Interface CRC Errors(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.totalCRCErrors & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Interface CRC Errors + printf("\tSpin Retry Count(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.attrSpinRetryCount & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Spin Retry Count (Most recent value from array at byte 401 of attribute sector) + printf("\tSpin Retry Count Normalized(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.normalSpinRetryCount & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Spin Retry Count (SMART Attribute 10 Normalized) + printf("\tSpin Retry Count Worst(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.worstSpinRretryCount & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Spin Retry Count (SMART Attribute 10 Worst Ever) + printf("\tNumber of IOEDC Errors (Raw)(debug): 0x%" PRIx64" \n", vFarmFrame[page].errorPage.attrIOEDCErrors & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of IOEDC Errors (SMART Attribute 184 Raw) + printf("\tCTO Count Total(debug): %" PRId64" \n", vFarmFrame[page].errorPage.attrCTOCount & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< CTO Count Total (SMART Attribute 188 Raw[0..1]) + printf("\tCTO Count Over 5s(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.overfiveSecCTO & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< CTO Count Over 5s (SMART Attribute 188 Raw[2..3]) + printf("\tCTO Count Over 7.5s(debug): %" PRIu64" \n", vFarmFrame[page].errorPage.oversevenSecCTO & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< CTO Count Over 7.5s (SMART Attribute + printf("\tTotal Flash LED (Assert) Events(debug): %" PRId64" \n", vFarmFrame[page].errorPage.totalFlashLED & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Flash LED (Assert) Events + printf("\tIndex of the last Flash LED(debug): %" PRId64" \n", vFarmFrame[page].errorPage.indexFlashLED & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< index of the last Flash LED of the array + printf("\tUncorrectable errors(debug): %" PRId64" \n", vFarmFrame[page].errorPage.uncorrectables & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< uncorrecatables errors (sata only) for (loopCount = 0; loopCount < FLASH_EVENTS; ++loopCount) { - printf("\tFlash LED event # %d: %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.flashLEDArray[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!= 4 && m_MinorRev > 20) + { + printf("\tReallocated Sectors, Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.reallocSectorsAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tReallocation Candidate Sectors , Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.reallocCandidatesAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tTotal Flash LED (Assert) Events, Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.totalFlashLEDEvents & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tIndex of last entry in FLED Info array below, in case the array wraps, Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.lastIDXFLEDInfoAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + for (loopCount = 0; loopCount < FLASH_EVENTS; ++loopCount) + { + printf("\tInfo on the last 8 Flash LED (assert) Events, wrapping array, Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.last8FLEDEventsAct1[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tInfo on the last 8 Read/Write Retry events, wrapping array, Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.last8ReadWriteRetryEvts[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); + } + for (loopCount = 0; loopCount < REALLOCATIONEVENTS; loopCount++) + { + printf("\tReallocated sectors by cause, Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.reallocSectorsByCauseAct1[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); + } + + for (loopCount = 0; loopCount < FLASH_EVENTS; ++loopCount) + { + printf("\tUniversal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array, Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.last8FLEDEvtsAct1[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tPower Cycle of the last 8 Flash LED (assert) Events, wrapping array, Actuator 1 %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].errorPage.last8FLEDEvtsPowerCycleAct1[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); + } } -#endif +#endif + std::ostringstream temp; if (vFarmFrame[page].errorPage.copyNumber == FACTORYCOPY) { - snprintf((char*)myStr.c_str(), BASIC, "Error Information From Farm Log copy FACTORYe"); + temp << "Error Information From Farm Log copy FACTORYe"; } else { - snprintf((char*)myStr.c_str(), BASIC, "Error Information Log From Farm Log copy %" PRIu32"", page); + temp << "Error Information Log From Farm Log copy " << std::dec << page; } - json_set_name(pageInfo, (char*)myStr.c_str()); + json_set_name(pageInfo, temp.str().c_str()); - set_json_64_bit_With_Status(pageInfo, "Unrecoverable Read Errors", vFarmFrame[page].errorPage.totalReadECC, false, m_showStatusBits); //!< Number of Unrecoverable Read Errors - set_json_64_bit_With_Status(pageInfo, "Unrecoverable Write Errors", vFarmFrame[page].errorPage.totalWriteECC, false, m_showStatusBits); //!< Number of Unrecoverable Write Errors - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors", vFarmFrame[page].errorPage.totalReallocations, false, m_showStatusBits); //!< Number of Reallocated Sectors - set_json_64_bit_With_Status(pageInfo, "Number of Read Recovery Attempts", vFarmFrame[page].errorPage.totalReadRecoveryAttepts, false, m_showStatusBits); //!< Number of Read Recovery Attempts - set_json_64_bit_With_Status(pageInfo, "Number of Mechanical Start Failures", vFarmFrame[page].errorPage.totalMechanicalFails, false, m_showStatusBits); //!< Number of Mechanical Start Failures + set_json_64_bit_With_Status(pageInfo, "Unrecoverable Read Errors", vFarmFrame[page].errorPage.totalReadECC, false, m_showStatusBits); //!< Number of Unrecoverable Read Errors + set_json_64_bit_With_Status(pageInfo, "Unrecoverable Write Errors", vFarmFrame[page].errorPage.totalWriteECC, false, m_showStatusBits); //!< Number of Unrecoverable Write Errors + set_json_64_bit_With_Status(pageInfo, "Reallocated Sectors", vFarmFrame[page].errorPage.totalReallocations, false, m_showStatusBits); //!< Number of Reallocated Sectors + set_json_64_bit_With_Status(pageInfo, "Read Recovery Attempts", vFarmFrame[page].errorPage.totalReadRecoveryAttepts, false, m_showStatusBits); //!< Number of Read Recovery Attempts + set_json_64_bit_With_Status(pageInfo, "Mechanical Start Failures", vFarmFrame[page].errorPage.totalMechanicalFails, false, m_showStatusBits); //!< Number of Mechanical Start Failures - set_json_int_With_Status(pageInfo, "Number of Reallocated Candidate Sectors", vFarmFrame[page].errorPage.totalReallocatedCanidates, m_showStatusBits); //!< Number of Reallocated Candidate Sectors - set_json_64_bit_With_Status(pageInfo, "Number of ASR Events", vFarmFrame[page].errorPage.totalASREvents, false, m_showStatusBits); //!< Number of ASR Events - set_json_64_bit_With_Status(pageInfo, "Number of Interface CRC Errors", vFarmFrame[page].errorPage.totalCRCErrors, false, m_showStatusBits); //!< Number of Interface CRC Errors - set_json_64_bit_With_Status(pageInfo, "Spin Retry Count", vFarmFrame[page].errorPage.attrSpinRetryCount, false, m_showStatusBits); //!< Spin Retry Count (Most recent value from array at byte 401 of attribute sector) - set_json_64_bit_With_Status(pageInfo, "Spin Retry Count Normalized", vFarmFrame[page].errorPage.normalSpinRetryCount, false, m_showStatusBits); //!< Spin Retry Count (SMART Attribute 10 Normalized) - set_json_64_bit_With_Status(pageInfo, "Spin Retry Count Worst", vFarmFrame[page].errorPage.worstSpinRretryCount, false, m_showStatusBits); //!< Spin Retry Count (SMART Attribute 10 Worst Ever) - set_json_64_bit_With_Status(pageInfo, "Number of IOEDC Errors (Raw)", vFarmFrame[page].errorPage.attrIOEDCErrors, false, m_showStatusBits); //!< Number of IOEDC Errors (SMART Attribute 184 Raw) - set_json_64_bit_With_Status(pageInfo, "CTO Count Total", vFarmFrame[page].errorPage.attrCTOCount, false, m_showStatusBits); //!< CTO Count Total (SMART Attribute 188 Raw[0..1]) - set_json_64_bit_With_Status(pageInfo, "CTO Count Over 5s", vFarmFrame[page].errorPage.overfiveSecCTO, false, m_showStatusBits); //!< CTO Count Over 5s (SMART Attribute 188 Raw[2..3]) - set_json_64_bit_With_Status(pageInfo, "CTO Count Over 7.5s", vFarmFrame[page].errorPage.oversevenSecCTO, false, m_showStatusBits); //!< CTO Count Over 7.5s (SMART Attribute - set_json_64_bit_With_Status(pageInfo, "Total Flash LED (Assert) Events", vFarmFrame[page].errorPage.totalFlashLED, false, m_showStatusBits); //!< Total Flash LED (Assert) Events + set_json_int_With_Status(pageInfo, "Reallocated Candidate Sectors", vFarmFrame[page].errorPage.totalReallocatedCanidates, m_showStatusBits); //!< Number of Reallocated Candidate Sectors + set_json_64_bit_With_Status(pageInfo, "ASR Events", vFarmFrame[page].errorPage.totalASREvents, false, m_showStatusBits); //!< Number of ASR Events + set_json_64_bit_With_Status(pageInfo, "Interface CRC Errors", vFarmFrame[page].errorPage.totalCRCErrors, false, m_showStatusBits); //!< Number of Interface CRC Errors + set_json_64_bit_With_Status(pageInfo, "Spin Retry Count", vFarmFrame[page].errorPage.attrSpinRetryCount, false, m_showStatusBits); //!< Spin Retry Count (Most recent value from array at byte 401 of attribute sector) + set_json_64_bit_With_Status(pageInfo, "Spin Retry Count Normalized", vFarmFrame[page].errorPage.normalSpinRetryCount, false, m_showStatusBits); //!< Spin Retry Count (SMART Attribute 10 Normalized) + set_json_64_bit_With_Status(pageInfo, "Spin Retry Count Worst", vFarmFrame[page].errorPage.worstSpinRretryCount, false, m_showStatusBits); //!< Spin Retry Count (SMART Attribute 10 Worst Ever) + set_json_64_bit_With_Status(pageInfo, "IOEDC Errors (Raw)", vFarmFrame[page].errorPage.attrIOEDCErrors, false, m_showStatusBits); //!< Number of IOEDC Errors (SMART Attribute 184 Raw) + set_json_64_bit_With_Status(pageInfo, "CTO Count Total", vFarmFrame[page].errorPage.attrCTOCount, false, m_showStatusBits); //!< CTO Count Total (SMART Attribute 188 Raw[0..1]) + set_json_64_bit_With_Status(pageInfo, "CTO Count Over 5s", vFarmFrame[page].errorPage.overfiveSecCTO, false, m_showStatusBits); //!< CTO Count Over 5s (SMART Attribute 188 Raw[2..3]) + set_json_64_bit_With_Status(pageInfo, "CTO Count Over 7.5s", vFarmFrame[page].errorPage.oversevenSecCTO, false, m_showStatusBits); //!< CTO Count Over 7.5s (SMART Attribute + set_json_64_bit_With_Status(pageInfo, "Total Flash LED (Assert) Events", vFarmFrame[page].errorPage.totalFlashLED, false, m_showStatusBits); //!< Total Flash LED (Assert) Events - set_json_int_With_Status(pageInfo, "Index of the last Flash LED", vFarmFrame[page].errorPage.indexFlashLED, m_showStatusBits); //!< index of the last Flash LED of the array - set_json_64_bit_With_Status(pageInfo, "Uncorrectable errors", vFarmFrame[page].errorPage.uncorrectables, false, m_showStatusBits); //!< uncorrecatables errors (sata only) + set_json_int_With_Status(pageInfo, "Index of the last Flash LED", vFarmFrame[page].errorPage.indexFlashLED, m_showStatusBits); //!< index of the last Flash LED of the array + set_json_64_bit_With_Status(pageInfo, "Uncorrectable errors", vFarmFrame[page].errorPage.uncorrectables, false, m_showStatusBits); //!< uncorrecatables errors (sata only) for (loopCount = 0; loopCount < FLASH_EVENTS; loopCount++) { + temp.str("");temp.clear(); JSONNODE *eventInfo = json_new(JSON_NODE); - snprintf((char*)myStr.c_str(), BASIC, "Flash LED Event %" PRIu16"", loopCount); - json_set_name(eventInfo, (char*)myStr.c_str()); - - set_json_64_bit_With_Status(eventInfo, "Event Information", vFarmFrame[page].errorPage.flashLEDArray[loopCount], true, m_showStatusBits); //!< Info on the last 8 Flash LED (assert) Events, wrapping array - - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.flashLEDArray[loopCount]))); - json_push_back(eventInfo, json_new_a("Flash LED Code", (char*)myStr.c_str())); - _common.get_Assert_Code_Meaning(timeStr, M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.flashLEDArray[loopCount]))); - json_push_back(eventInfo, json_new_a("Flash LED Code Meaning", (char*)timeStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].errorPage.flashLEDArray[loopCount]))); - json_push_back(eventInfo, json_new_a("Flash LED Address", (char*)myStr.c_str())); - - - snprintf((char*)myStr.c_str(), BASIC, "TimeStamp of Event(hours) %" PRIu16"", loopCount); - snprintf((char*)timeStr.c_str(), BASIC, "%0.03f", static_cast(M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].errorPage.timestampForLED[loopCount])) / 3600000) *.001); - set_json_string_With_Status(eventInfo, (char*)myStr.c_str(), (char*)timeStr.c_str(), vFarmFrame[page].errorPage.timestampForLED[loopCount], m_showStatusBits);//!< Universal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array - snprintf((char*)myStr.c_str(), BASIC, "Power Cycle Event %" PRIu16"", loopCount); - set_json_64_bit_With_Status(eventInfo, (char*)myStr.c_str(), vFarmFrame[page].errorPage.powerCycleOfLED[loopCount], false, m_showStatusBits); //!< Power Cycle of the last 8 Flash LED (assert) Events, wrapping array + temp << "Flash LED Event " << std::dec << loopCount; + json_set_name(eventInfo, temp.str().c_str()); + + set_json_64_bit_With_Status(eventInfo, "Event Information", vFarmFrame[page].errorPage.flashLEDArray[loopCount], true, m_showStatusBits); //!< Info on the last 8 Flash LED (assert) Events, wrapping array + + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.flashLEDArray[loopCount])); + json_push_back(eventInfo, json_new_a("Flash LED Code", temp.str().c_str())); + get_Assert_Code_Meaning(timeStr, M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.flashLEDArray[loopCount]))); + json_push_back(eventInfo, json_new_a("Flash LED Code Meaning", timeStr.c_str())); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].errorPage.flashLEDArray[loopCount])); + json_push_back(eventInfo, json_new_a("Flash LED Address", temp.str().c_str())); + + temp.str("");temp.clear(); + temp << "TimeStamp of Event(hours) " << std::dec << loopCount; + std::ostringstream temp1; + temp1 << std::setprecision(3) << std::setfill('0') << static_cast(M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].errorPage.timestampForLED[loopCount])) / 3600000) *.001; + set_json_string_With_Status(eventInfo, temp.str().c_str(), temp1.str().c_str(), vFarmFrame[page].errorPage.timestampForLED[loopCount], m_showStatusBits);//!< Universal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array + + temp.str("");temp.clear(); + temp << "Power Cycle Event " << std::dec << loopCount; + set_json_64_bit_With_Status(eventInfo, temp.str().c_str(), vFarmFrame[page].errorPage.powerCycleOfLED[loopCount], false, m_showStatusBits); //!< Power Cycle of the last 8 Flash LED (assert) Events, wrapping array + temp.str("");temp.clear(); json_push_back(pageInfo, eventInfo); } if (m_MajorRev >= MAJORVERSION3 && m_MinorRev >= 2 && m_MinorRev <= 4) { + // get read write retry events for (loopCount = 0; loopCount <= 7; ++loopCount) { JSONNODE *rwrInfo = json_new(JSON_NODE); - snprintf((char*)myStr.c_str(), BASIC, "Read Write Retry # %" PRIu16"", loopCount); - json_set_name(rwrInfo, (char*)myStr.c_str()); - - set_json_64_bit_With_Status(pageInfo, "Log Entry #", M_Byte5(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Error Type #", M_Byte6(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Zone Group #", M_Word1(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Head #", M_Nibble3(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Count #", M_Byte0(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - + temp.str("");temp.clear(); + temp << "Read Write Retry " << std::dec << loopCount; + json_set_name(rwrInfo, temp.str().c_str()); + + set_json_64_bit_With_Status(rwrInfo, "Error Type", M_Byte6(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Log Entry", M_Byte5(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Zone Group", M_Word1(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Head", M_Nibble3(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Count", M_Byte0(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + json_push_back(pageInfo, rwrInfo); } } @@ -671,14 +781,15 @@ eReturnValues CATA_Farm_Log::print_Error_Information(JSONNODE *masterData, uint3 for (loopCount = 0; loopCount <= 7; ++loopCount) { JSONNODE *rwrInfo = json_new(JSON_NODE); - snprintf((char*)myStr.c_str(), BASIC, "Read Write Retry # %" PRIu16"", loopCount); - json_set_name(rwrInfo, (char*)myStr.c_str()); + temp.str("");temp.clear(); + temp << "Read Write Retry " << std::dec << loopCount; + json_set_name(rwrInfo, temp.str().c_str()); - set_json_64_bit_With_Status(rwrInfo, "Log Entry #", M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - set_json_64_bit_With_Status(rwrInfo, "Error Type #", M_Byte6(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - set_json_64_bit_With_Status(rwrInfo, "Zone Group #", M_Word1(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - set_json_64_bit_With_Status(rwrInfo, "Head #", M_Byte1(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); - set_json_64_bit_With_Status(rwrInfo, "Count #", M_Byte0(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Error Type", M_Byte6(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Log Entry", M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Zone Group", M_Word1(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Head", M_Byte1(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Count", M_Byte0(check_Status_Strip_Status(vFarmFrame[page].errorPage.readWriteRetry[loopCount])), false, m_showStatusBits); json_push_back(pageInfo, rwrInfo); } @@ -687,22 +798,81 @@ eReturnValues CATA_Farm_Log::print_Error_Information(JSONNODE *masterData, uint3 for (loopCount = 0; loopCount < REALLOCATIONEVENTS; ++loopCount) { - _common.get_Reallocation_Cause_Meanings(myStr, loopCount); - set_json_64_bit_With_Status(pageInfo, (char*)myStr.c_str(), vFarmFrame[page].errorPage.reallocatedSectors[loopCount], false, m_showStatusBits); + get_Reallocation_Cause_Meanings(myStr, static_cast(loopCount)); + set_json_64_bit_With_Status(pageInfo, myStr, vFarmFrame[page].errorPage.reallocatedSectors[loopCount], false, m_showStatusBits); } set_json_64_bit_With_Status(pageInfo, "Cum Lifetime Unrecoverable Read errors due to ERC", vFarmFrame[page].errorPage.cumLifeTimeECCReadDueErrorRecovery, false, m_showStatusBits); for (loopCount = 0; loopCount < m_heads; ++loopCount) { JSONNODE *eventInfo = json_new(JSON_NODE); - snprintf((char*)myStr.c_str(), BASIC, "Cum Lifetime Unrecoverable by head %" PRIu16"", loopCount); - json_set_name(eventInfo, (char*)myStr.c_str()); - + temp.str("");temp.clear(); + temp << "Cum Lifetime Unrecoverable by Head " << std::dec << loopCount; + json_set_name(eventInfo, temp.str().c_str()); set_json_64_bit_With_Status(eventInfo, "Cum Lifetime Unrecoverable Read Repeating", vFarmFrame[page].errorPage.cumLifeUnRecoveralbeReadByhead[loopCount], false, m_showStatusBits); //!< Cumulative Lifetime Unrecoverable Read Repeating by head set_json_64_bit_With_Status(eventInfo, "Cum Lifetime Unrecoverable Read Unique", vFarmFrame[page].errorPage.cumLiveUnRecoveralbeReadUnique[loopCount], false, m_showStatusBits); //!< Cumulative Lifetime Unrecoverable Read Unique by head - json_push_back(pageInfo, eventInfo); } + if (m_MajorRev >= 4 && m_MinorRev > 20) + { + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors, Actuator 1", vFarmFrame[page].errorPage.reallocSectorsAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Candidate Sectors, Actuator 1", vFarmFrame[page].errorPage.reallocCandidatesAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Total Flash LED (Assert) Events, Actuator 1", vFarmFrame[page].errorPage.totalFlashLEDEvents, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Index of last entry in FLED Info array below, in case the array wraps, Actuator 1", vFarmFrame[page].errorPage.lastIDXFLEDInfoAct1, false, m_showStatusBits); + for (loopCount = 0; loopCount < FLASH_EVENTS; ++loopCount) + { + JSONNODE *eventInfoact1 = json_new(JSON_NODE); + temp.str("");temp.clear(); + temp << "Flash LED Event " << std::dec << loopCount << " Actuator 1"; + json_set_name(eventInfoact1, temp.str().c_str()); + + set_json_64_bit_With_Status(eventInfoact1, "Event Information", vFarmFrame[page].errorPage.last8FLEDEventsAct1[loopCount], true, m_showStatusBits); //!> Info on the last 8 Flash LED(assert) Events, wrapping array, Actuator 1 + + temp.str(""); temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8FLEDEventsAct1[loopCount])); + json_push_back(eventInfoact1, json_new_a("Flash LED Code Actuator 1", temp.str().c_str())); + get_Assert_Code_Meaning(timeStr, M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8FLEDEventsAct1[loopCount]))); + json_push_back(eventInfoact1, json_new_a("Flash LED Code Meaning", timeStr.c_str())); + temp.str(""); temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8FLEDEventsAct1[loopCount])); + json_push_back(eventInfoact1, json_new_a("Flash LED Address Actuator 1", temp.str().c_str())); + + temp.str(""); temp.clear(); + temp << "TimeStamp Actuator 1 Event(hours) " << std::dec << loopCount; + std::ostringstream temp1; + temp1 << std::setprecision(3) << std::setfill('0') << static_cast(M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8FLEDEvtsAct1[loopCount])) / 3600000) * .001; + set_json_string_With_Status(eventInfoact1, temp.str().c_str(), temp1.str().c_str(), vFarmFrame[page].errorPage.last8FLEDEvtsAct1[loopCount], m_showStatusBits); //!< Universal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array, Actuator 1 + + temp.str(""); temp.clear(); + temp << "Power Cycle Actuator 1 Event " << std::dec << loopCount; + set_json_64_bit_With_Status(eventInfoact1, temp.str().c_str(), vFarmFrame[page].errorPage.last8FLEDEvtsPowerCycleAct1[loopCount], false, m_showStatusBits); //!< Power Cycle of the last 8 Flash LED (assert) Events, wrapping array, Actuator 1 + temp.str(""); temp.clear(); + + json_push_back(pageInfo, eventInfoact1); + } + for (loopCount = 0; loopCount <= 7; ++loopCount) + { + JSONNODE* rwrInfo = json_new(JSON_NODE); + temp.str(""); temp.clear(); + temp << "Read Write Retry " << std::dec << loopCount << " Actuator 1"; + json_set_name(rwrInfo, temp.str().c_str()); + + set_json_64_bit_With_Status(rwrInfo, "Error Type Actuator 1", M_Byte6(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8ReadWriteRetryEvts[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Log Entry Actuator 1", M_Word2(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8ReadWriteRetryEvts[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Zone Group Actuator 1", M_Word1(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8ReadWriteRetryEvts[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Head Actuator 1", M_Byte1(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8ReadWriteRetryEvts[loopCount])), false, m_showStatusBits); + set_json_64_bit_With_Status(rwrInfo, "Count Actuator 1", M_Byte0(check_Status_Strip_Status(vFarmFrame[page].errorPage.last8ReadWriteRetryEvts[loopCount])), false, m_showStatusBits); + + json_push_back(pageInfo, rwrInfo); + } + for (loopCount = 0; loopCount < REALLOCATIONEVENTS; ++loopCount) + { + get_Reallocation_Cause_Meanings(myStr, static_cast(loopCount)); + myStr = "Actuator 1 " + myStr; + set_json_64_bit_With_Status(pageInfo, myStr, vFarmFrame[page].errorPage.reallocSectorsByCauseAct1[loopCount], false, m_showStatusBits); + } + + } json_push_back(masterData, pageInfo); @@ -726,8 +896,6 @@ eReturnValues CATA_Farm_Log::print_Error_Information(JSONNODE *masterData, uint3 //--------------------------------------------------------------------------- eReturnValues CATA_Farm_Log::print_Enviroment_Information(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); JSONNODE *pageInfo = json_new(JSON_NODE); #if defined _DEBUG @@ -740,147 +908,225 @@ eReturnValues CATA_Farm_Log::print_Enviroment_Information(JSONNODE *masterData, printf("\nEnvironment Information From Farm Log copy %d:", page); } - printf("\tCurrent Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.curentTemp & 0x00FFFFFFFFFFFFFFLL); //!< Current Temperature in Celsius - printf("\tHighest Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.highestTemp & 0x00FFFFFFFFFFFFFFLL); //!< Highest Temperature in Celsius - printf("\tLowest Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.lowestTemp & 0x00FFFFFFFFFFFFFFLL); //!< Lowest Temperature - printf("\tAverage Short Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.averageTemp & 0x00FFFFFFFFFFFFFFLL); //!< Average Short Term Temperature5 - printf("\tAverage Long Term Temperatures (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.averageLongTemp & 0x00FFFFFFFFFFFFFFLL); //!< Average Long Term Temperature5 - printf("\tHighest Average Short Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.highestShortTemp & 0x00FFFFFFFFFFFFFFLL); //!< Highest Average Short Term Temperature5 - printf("\tLowest Average Short Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.lowestShortTemp & 0x00FFFFFFFFFFFFFFLL); //!< Lowest Average Short Term Temperature5 - printf("\tHighest Average Long Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.highestLongTemp & 0x00FFFFFFFFFFFFFFLL); //!< Highest Average Long Term Temperature5 - printf("\tLowest Average Long Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.lowestLongTemp & 0x00FFFFFFFFFFFFFFLL); //!< Lowest Average Long Term Temperature5 - printf("\tTime In Over Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.overTempTime & 0x00FFFFFFFFFFFFFFLL); //!< Time In Over Temperature5 - printf("\tTime In Under Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.underTempTime & 0x00FFFFFFFFFFFFFFLL); //!< Time In Under Temperature5 - printf("\tSpecified Max Operating Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.maxTemp & 0x00FFFFFFFFFFFFFFLL); //!< Specified Max Operating Temperature - printf("\tSpecified Min Operating Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.minTemp & 0x00FFFFFFFFFFFFFFLL); //!< Specified Min Operating Temperature - printf("\tOver-Limit Shock Events Count(Raw) (debug): 0x%" PRIx64" \n", vFarmFrame[page].environmentPage.shockEvents & 0x00FFFFFFFFFFFFFFLL); //!< Over-Limit Shock Events Count(SMART Attribute 191 Raw) - printf("\tHigh Fly Write Count (Raw) (debug): 0x%" PRIx64" \n", vFarmFrame[page].environmentPage.hfWriteCounts & 0x00FFFFFFFFFFFFFFLL); //!< High Fly Write Count (SMART Attribute 189 Raw) - printf("\tCurrent Relative Humidity (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.humidity & 0x00FFFFFFFFFFFFFFLL); //!< Current Relative Humidity (in units of .1%) - printf("\tHumidity Mixed Ratio (debug): %" PRIu64" \n", ((vFarmFrame[page].environmentPage.humidityRatio & 0x00FFFFFFFFFFFFFFLL) / 8)); //!< Humidity Mixed Ratio multiplied by 8 (divide by 8 to get actual value) - printf("\tCurrent Motor Power (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.currentMotorPower & 0x00FFFFFFFFFFFFFFLL); //!< Current Motor Power, value from most recent SMART Summary Frame6 - printf("\tCurrent 12 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.current12v & 0x00FFFFFFFFFFFFFFLL, \ - (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current12v)) / 1000), (M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current12v)) % 1000) ); - - printf("\tMinimum 12 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.min12v & 0x00FFFFFFFFFFFFFFLL, \ + printf("\tCurrent Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.curentTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current Temperature in Celsius + printf("\tHighest Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.highestTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Highest Temperature in Celsius + printf("\tLowest Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.lowestTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Lowest Temperature + printf("\tAverage Short Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.averageTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Average Short Term Temperature5 + printf("\tAverage Long Term Temperatures (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.averageLongTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Average Long Term Temperature5 + printf("\tHighest Average Short Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.highestShortTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Highest Average Short Term Temperature5 + printf("\tLowest Average Short Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.lowestShortTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Lowest Average Short Term Temperature5 + printf("\tHighest Average Long Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.highestLongTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Highest Average Long Term Temperature5 + printf("\tLowest Average Long Term Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.lowestLongTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Lowest Average Long Term Temperature5 + printf("\tTime In Over Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.overTempTime & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Time In Over Temperature5 + printf("\tTime In Under Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.underTempTime & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Time In Under Temperature5 + printf("\tSpecified Max Operating Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.maxTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Specified Max Operating Temperature + printf("\tSpecified Min Operating Temperature (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.minTemp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Specified Min Operating Temperature + printf("\tOver-Limit Shock Events Count(Raw) (debug): 0x%" PRIx64" \n", vFarmFrame[page].environmentPage.shockEvents & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Over-Limit Shock Events Count(SMART Attribute 191 Raw) + printf("\tHigh Fly Write Count (Raw) (debug): 0x%" PRIx64" \n", vFarmFrame[page].environmentPage.hfWriteCounts & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< High Fly Write Count (SMART Attribute 189 Raw) + printf("\tCurrent Relative Humidity (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.humidity & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current Relative Humidity (in units of .1%) + printf("\tHumidity Mixed Ratio (debug): %" PRIu64" \n", ((vFarmFrame[page].environmentPage.humidityRatio & UINT64_C(0x00FFFFFFFFFFFFFF)) / 8)); //!< Humidity Mixed Ratio multiplied by 8 (divide by 8 to get actual value) + printf("\tCurrent Motor Power (debug): %" PRIu64" \n", vFarmFrame[page].environmentPage.currentMotorPower & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current Motor Power, value from most recent SMART Summary Frame6 + printf("\tCurrent 12 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.current12v & UINT64_C(0x00FFFFFFFFFFFFFF), \ + (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current12v)) / 1000), (M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current12v)) % 1000)); + + printf("\tMinimum 12 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.min12v & UINT64_C(0x00FFFFFFFFFFFFFF), \ (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) / 1000), (M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) % 1000)); - - printf("\tMaximum 12 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.max12v & 0x00FFFFFFFFFFFFFFLL, \ + + printf("\tMaximum 12 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.max12v & UINT64_C(0x00FFFFFFFFFFFFFF), \ (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) / 1000), (M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) % 1000)); - printf("\tCurrent 5 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.current5v & 0x00FFFFFFFFFFFFFFLL, \ + printf("\tCurrent 5 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.current5v & UINT64_C(0x00FFFFFFFFFFFFFF), \ (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current5v)) / 1000), (M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current5v)) % 1000)); - printf("\tMaximum 5 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.min5v & 0x00FFFFFFFFFFFFFFLL, \ + printf("\tMinimum 5 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.min5v & UINT64_C(0x00FFFFFFFFFFFFFF), \ (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) / 1000), (M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) % 1000)); - printf("\tMaximum 5 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.max5v & 0x00FFFFFFFFFFFFFFLL, \ + printf("\tMaximum 5 volts (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.max5v & UINT64_C(0x00FFFFFFFFFFFFFF), \ (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) / 1000), (M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) % 1000)); - printf("\t12V Power Average (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerAvg12v & 0x00FFFFFFFFFFFFFFLL, \ + printf("\t12V Power Average (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerAvg12v & UINT64_C(0x00FFFFFFFFFFFFFF), \ static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg12v)) / 1000), static_cast(vFarmFrame[page].environmentPage.powerAvg12v % 1000)); - printf("\t12V Power Minimum (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerMin12v & 0x00FFFFFFFFFFFFFFLL, \ + printf("\t12V Power Minimum (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerMin12v & UINT64_C(0x00FFFFFFFFFFFFFF), \ static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin12v)) / 1000), static_cast(vFarmFrame[page].environmentPage.powerMin12v % 1000)); - printf("\t12V Power Maximum (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerMax12v & 0x00FFFFFFFFFFFFFFLL, \ + printf("\t12V Power Maximum (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerMax12v & UINT64_C(0x00FFFFFFFFFFFFFF), \ static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax12v)) / 1000), static_cast(vFarmFrame[page].environmentPage.powerMax12v % 1000)); - printf("\t5V Power Average(debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerAvg5v & 0x00FFFFFFFFFFFFFFLL, \ + printf("\t5V Power Average(debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerAvg5v & UINT64_C(0x00FFFFFFFFFFFFFF), \ static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg5v)) / 1000), static_cast(vFarmFrame[page].environmentPage.powerAvg5v % 1000)); - - printf("\t5V Power Minimum (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerMin5v & 0x00FFFFFFFFFFFFFFLL, \ - static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin5v)) / 1000), static_cast(vFarmFrame[page].environmentPage.powerMin5v % 1000)); - - printf("\t5V Power Maximum (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerMax5v & 0x00FFFFFFFFFFFFFFLL, \ - static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax5v)) / 1000), static_cast(vFarmFrame[page].environmentPage.powerMax5v % 1000)); + printf("\t5V Power Minimum (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerMin5v & UINT64_C(0x00FFFFFFFFFFFFFF), \ + static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin5v)) / 1000), static_cast(vFarmFrame[page].environmentPage.powerMin5v % 1000)); + printf("\t5V Power Maximum (debug): 0x%" PRIx64" Translation %" PRIu16". % 03" PRId16" \n", vFarmFrame[page].environmentPage.powerMax5v & UINT64_C(0x00FFFFFFFFFFFFFF), \ + static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax5v)) / 1000), static_cast(vFarmFrame[page].environmentPage.powerMax5v % 1000)); + //version 4_21 + if (m_MajorRev >= 4 && m_MinorRev > 20) + { + printf("\tCurrent Low Frequency Vibe Score - Actuator 0: %" PRIu64" \n", vFarmFrame[page].environmentPage.currLFVibeAct0 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current Low Frequency Vibe Score - Actuator 0 + printf("\tCurrent Mid Frequency Vibe Score - Actuator 0: %" PRIu64" \n", vFarmFrame[page].environmentPage.currMFVibeAct0 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current Mid Frequency Vibe Score - Actuator 0 + printf("\tCurrent High Frequency Vibe Score - Actuator 0: %" PRIu64" \n", vFarmFrame[page].environmentPage.currHFVibeAct0 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current High Frequency Vibe Score - Actuator 0 + printf("\tWorst Low Frequency Vibe Score - Actuator 0 %" PRIu64" \n", vFarmFrame[page].environmentPage.worstLFVibeAct0 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Worst Low Frequency Vibe Score - Actuator 0 + printf("\tWorst Mid Frequency Vibe Score - Actuator 0: %" PRIu64" \n", vFarmFrame[page].environmentPage.worstMFVibeAct0 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Worst Mid Frequency Vibe Score - Actuator 0 + printf("\tWorst High Frequency Vibe Score - Actuator 0: %" PRIu64" \n", vFarmFrame[page].environmentPage.worstHFVibeAct0 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Worst High Frequency Vibe Score - Actuator 0 + printf("\tCurrent Low Frequency Vibe Score - Actuator 1: %" PRIu64" \n", vFarmFrame[page].environmentPage.currLFVibeAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current Low Frequency Vibe Score - Actuator 1 + printf("\tCurrent Mid Frequency Vibe Score - Actuator 1: %" PRIu64" \n", vFarmFrame[page].environmentPage.currMFVibeAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current Mid Frequency Vibe Score - Actuator 1 + printf("\tCurrent High Frequency Vibe Score - Actuator 1: %" PRIu64" \n", vFarmFrame[page].environmentPage.currHFVibeAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current High Frequency Vibe Score - Actuator 1 + printf("\tWorst Low Frequency Vibe Score - Actuator 1: %" PRIu64" \n", vFarmFrame[page].environmentPage.worstLFVibeAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Worst Low Frequency Vibe Score - Actuator 1 + printf("\tWorst Mid Frequency Vibe Score - Actuator 1: %" PRIu64" \n", vFarmFrame[page].environmentPage.worstMFVibeAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Worst mid Frequency Vibe Score - Actuator 1 + printf("\tWorst High Frequency Vibe Score - Actuator 1: %" PRIu64" \n", vFarmFrame[page].environmentPage.worstHFVibeAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Worst High Frequency Vibe Score - Actuator 1 + } #endif + std::ostringstream temp; if (vFarmFrame[page].environmentPage.copyNumber == FACTORYCOPY) { - snprintf((char*)myStr.c_str(), BASIC, "Environment Information From Farm Log copy FACTORY"); + temp << "Environment Information From Farm Log copy FACTORY"; } else { - snprintf((char*)myStr.c_str(), BASIC, "Environment Information From Farm Log copy %" PRIu32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.curentTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Current Temperature (Celsius)", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.curentTemp, m_showStatusBits); //!< Current Temperature in Celsius - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.highestTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Highest Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.highestTemp, m_showStatusBits); //!< Highest Temperature in Celsius - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.lowestTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Lowest Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.lowestTemp, m_showStatusBits); //!< Lowest Temperature - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.averageTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Average Short Term Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.averageTemp, m_showStatusBits); //!< Average Short Term Temperature - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.averageLongTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Average Long Term Temperatures", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.averageLongTemp, m_showStatusBits); //!< Average Long Term Temperature - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.highestShortTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Highest Average Short Term Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.highestShortTemp, m_showStatusBits); //!< Highest Average Short Term Temperature - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.lowestShortTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Lowest Average Short Term Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.lowestShortTemp, m_showStatusBits); //!< Lowest Average Short Term Temperature - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.highestLongTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Highest Average Long Term Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.highestLongTemp, m_showStatusBits); //!< Highest Average Long Term Temperature - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.lowestLongTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Lowest Average Long Term Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.lowestLongTemp, m_showStatusBits); //!< Lowest Average Long Term Temperature - - set_json_int_With_Status(pageInfo, "Time In Over Temperature", vFarmFrame[page].environmentPage.overTempTime, m_showStatusBits); //!< Time In Over Temperature - set_json_int_With_Status(pageInfo, "Time In Under Temperature", vFarmFrame[page].environmentPage.underTempTime, m_showStatusBits); //!< Time In Under Temperature - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.maxTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Specified Max Operating Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.maxTemp, m_showStatusBits); //!< Specified Max Operating Temperature - - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.minTemp)*1.00)); - set_json_string_With_Status(pageInfo, "Specified Min Operating Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.minTemp, m_showStatusBits); //!< Specified Min Operating Temperature - - set_json_int_With_Status(pageInfo, "Over-Limit Shock Events Count(Raw)", vFarmFrame[page].environmentPage.shockEvents, m_showStatusBits); //!< Over-Limit Shock Events Count - set_json_int_With_Status(pageInfo, "High Fly Write Count (Raw)", vFarmFrame[page].environmentPage.hfWriteCounts, m_showStatusBits); //!< High Fly Write Count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", (check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidity))*0.1); //!< Current Relative Humidity (in units of .1%) - set_json_string_With_Status(pageInfo, "Current Relative Humidity", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.humidity, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", (check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidityRatio) / 8.0)); //!< Humidity Mixed Ratio multiplied by 8 (divide by 8 to get actual value) - set_json_string_With_Status(pageInfo, "Humidity Mixed Ratio", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.humidityRatio, m_showStatusBits); - set_json_int_With_Status(pageInfo, "Current Motor Power", vFarmFrame[page].environmentPage.currentMotorPower, m_showStatusBits); //!< Current Motor Power, value from most recent SMART Summary Frame6 - - - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current12v)) / 1000), \ - (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current12v)) % 1000)); - set_json_string_With_Status(pageInfo, "Current 12 volts", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.current12v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) / 1000), \ - (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) % 1000)); - set_json_string_With_Status(pageInfo, "Minimum 12 volts", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.min12v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) / 1000), \ - (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) % 1000)); - set_json_string_With_Status(pageInfo, "Maximum 12 volts", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.max12v, m_showStatusBits); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current5v)) / 1000), \ - (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current5v)) % 1000)); - set_json_string_With_Status(pageInfo, "Current 5 volts", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.current5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) / 1000), \ - (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) % 1000)); - set_json_string_With_Status(pageInfo, "Maximum 5 volts", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.min5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) / 1000), \ - (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) % 1000)); - set_json_string_With_Status(pageInfo, "Maximum 5 volts", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.max5v, m_showStatusBits); - - + temp << "Environment Information From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); + + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.curentTemp)*1.00); + set_json_string_With_Status(pageInfo, "Current Temperature (Celsius)", temp.str().c_str(), vFarmFrame[page].environmentPage.curentTemp, m_showStatusBits); //!< Current Temperature in Celsius + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_Byte0(vFarmFrame[page].environmentPage.highestTemp)*1.00); + set_json_string_With_Status(pageInfo, "Highest Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.highestTemp, m_showStatusBits); //!< Highest Temperature in Celsius + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.lowestTemp)*1.00); + set_json_string_With_Status(pageInfo, "Lowest Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.lowestTemp, m_showStatusBits); //!< Lowest Temperature + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.averageTemp)*1.00); + set_json_string_With_Status(pageInfo, "Average Short Term Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.averageTemp, m_showStatusBits); //!< Average Short Term Temperature + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.averageLongTemp)*1.00); + set_json_string_With_Status(pageInfo, "Average Long Term Temperatures", temp.str().c_str(), vFarmFrame[page].environmentPage.averageLongTemp, m_showStatusBits); //!< Average Long Term Temperature + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.highestShortTemp)*1.00); + set_json_string_With_Status(pageInfo, "Highest Average Short Term Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.highestShortTemp, m_showStatusBits); //!< Highest Average Short Term Temperature + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.lowestShortTemp)*1.00); + set_json_string_With_Status(pageInfo, "Lowest Average Short Term Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.lowestShortTemp, m_showStatusBits); //!< Lowest Average Short Term Temperature + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.highestLongTemp)*1.00); + set_json_string_With_Status(pageInfo, "Highest Average Long Term Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.highestLongTemp, m_showStatusBits); //!< Highest Average Long Term Temperature + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.lowestLongTemp)*1.00); + set_json_string_With_Status(pageInfo, "Lowest Average Long Term Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.lowestLongTemp, m_showStatusBits); //!< Lowest Average Long Term Temperature + + set_json_int_With_Status(pageInfo, "Time In Over Temperature", vFarmFrame[page].environmentPage.overTempTime, m_showStatusBits); //!< Time In Over Temperature + set_json_int_With_Status(pageInfo, "Time In Under Temperature", vFarmFrame[page].environmentPage.underTempTime, m_showStatusBits); //!< Time In Under Temperature + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.maxTemp)*1.00); + set_json_string_With_Status(pageInfo, "Specified Max Operating Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.maxTemp, m_showStatusBits); //!< Specified Max Operating Temperature + + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.minTemp)*1.00); + set_json_string_With_Status(pageInfo, "Specified Min Operating Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.minTemp, m_showStatusBits); //!< Specified Min Operating Temperature + + set_json_int_With_Status(pageInfo, "Over-Limit Shock Events Count(Raw)", vFarmFrame[page].environmentPage.shockEvents, m_showStatusBits); //!< Over-Limit Shock Events Count + set_json_int_With_Status(pageInfo, "High Fly Write Count (Raw)", vFarmFrame[page].environmentPage.hfWriteCounts, m_showStatusBits); //!< High Fly Write Count + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << (check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidity))*0.1; //!< Current Relative Humidity (in units of .1%) + set_json_string_With_Status(pageInfo, "Current Relative Humidity", temp.str().c_str(), vFarmFrame[page].environmentPage.humidity, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << (check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidityRatio) / 8.0); //!< Humidity Mixed Ratio multiplied by 8 (divide by 8 to get actual value) + set_json_string_With_Status(pageInfo, "Humidity Mixed Ratio", temp.str().c_str(), vFarmFrame[page].environmentPage.humidityRatio, m_showStatusBits); + set_json_int_With_Status(pageInfo, "Current Motor Power", vFarmFrame[page].environmentPage.currentMotorPower, m_showStatusBits); //!< Current Motor Power, value from most recent SMART Summary Frame6 + + temp.str("");temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current12v)) % 1000; + set_json_string_With_Status(pageInfo, "Current 12 volts", temp.str().c_str(), vFarmFrame[page].environmentPage.current12v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) % 1000); + set_json_string_With_Status(pageInfo, "Minimum 12 volts", temp.str().c_str(), vFarmFrame[page].environmentPage.min12v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) % 1000); + set_json_string_With_Status(pageInfo, "Maximum 12 volts", temp.str().c_str(), vFarmFrame[page].environmentPage.max12v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.current5v)) % 1000); + set_json_string_With_Status(pageInfo, "Current 5 volts", temp.str().c_str(), vFarmFrame[page].environmentPage.current5v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) % 1000; + set_json_string_With_Status(pageInfo, "Minimum 5 volts", temp.str().c_str(), vFarmFrame[page].environmentPage.min5v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) % 1000); + set_json_string_With_Status(pageInfo, "Maximum 5 volts", temp.str().c_str(), vFarmFrame[page].environmentPage.max5v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg12v)) / 1000 << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg12v)) % 1000; + set_json_string_With_Status(pageInfo, "12V Power Average", temp.str().c_str(), vFarmFrame[page].environmentPage.powerAvg12v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin12v)) / 1000 << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin12v)) % 1000; + set_json_string_With_Status(pageInfo, "12V Power Minimum", temp.str().c_str(), vFarmFrame[page].environmentPage.powerMin12v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax12v)) / 1000 << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax12v)) % 1000; + set_json_string_With_Status(pageInfo, "12V Power Maximum", temp.str().c_str(), vFarmFrame[page].environmentPage.powerMax12v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg5v)) / 1000 << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg5v)) % 1000; + set_json_string_With_Status(pageInfo, "5V Power Average",temp.str().c_str(), vFarmFrame[page].environmentPage.powerAvg5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg12v)) / 1000, M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg12v)) % 1000); - set_json_string_With_Status(pageInfo, "12V Power Average", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.powerAvg12v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin12v)) / 1000, M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin12v)) % 1000); - set_json_string_With_Status(pageInfo, "12V Power Minimum", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.powerMin12v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax12v)) / 1000, M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax12v)) % 1000); - set_json_string_With_Status(pageInfo, "12V Power Maximum", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.powerMax12v, m_showStatusBits); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg5v)) / 1000, M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerAvg5v)) % 1000); - set_json_string_With_Status(pageInfo, "5V Power Average", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.powerAvg5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin5v)) / 1000, M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin5v)) % 1000); - set_json_string_With_Status(pageInfo, "5V Power Minimum", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.powerMin5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax5v)) / 1000, M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax5v)) % 1000); - set_json_string_With_Status(pageInfo, "5V Power Maximum", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.powerMax5v, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::dec << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin5v)) / 1000 << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMin5v)) % 1000; + set_json_string_With_Status(pageInfo, "5V Power Minimum", temp.str().c_str(), vFarmFrame[page].environmentPage.powerMin5v, m_showStatusBits); + + temp.str("");temp.clear(); + temp << std::dec << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax5v)) / 1000 << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.powerMax5v)) % 1000; + set_json_string_With_Status(pageInfo, "5V Power Maximum", temp.str().c_str(), vFarmFrame[page].environmentPage.powerMax5v, m_showStatusBits); + if (m_MajorRev >= 4 && m_MinorRev > 20) + { + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.currLFVibeAct0)); + set_json_string_With_Status(pageInfo, "Current Low Frequency Vibe Score - Actuator 0", temp.str().c_str(), vFarmFrame[page].environmentPage.currLFVibeAct0, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.currMFVibeAct0)); + set_json_string_With_Status(pageInfo, "Current Mid Frequency Vibe Score - Actuator 0", temp.str().c_str(), vFarmFrame[page].environmentPage.currMFVibeAct0, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.currHFVibeAct0)); + set_json_string_With_Status(pageInfo, "Current High Frequency Vibe Score - Actuator 0", temp.str().c_str(), vFarmFrame[page].environmentPage.currHFVibeAct0, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.worstLFVibeAct0)); + set_json_string_With_Status(pageInfo, "Worst Low Frequency Vibe Score - Actuator 0", temp.str().c_str(), vFarmFrame[page].environmentPage.worstLFVibeAct0, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.worstMFVibeAct0)); + set_json_string_With_Status(pageInfo, "Worst Mid Frequency Vibe Score - Actuator 0", temp.str().c_str(), vFarmFrame[page].environmentPage.worstMFVibeAct0, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.worstHFVibeAct0)); + set_json_string_With_Status(pageInfo, "Worst High Frequency Vibe Score - Actuator 0", temp.str().c_str(), vFarmFrame[page].environmentPage.worstHFVibeAct0, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.currLFVibeAct1)); + set_json_string_With_Status(pageInfo, "Current Low Frequency Vibe Score - Actuator 1", temp.str().c_str(), vFarmFrame[page].environmentPage.currLFVibeAct1, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.currMFVibeAct1)); + set_json_string_With_Status(pageInfo, "Current Mid Frequency Vibe Score - Actuator 1", temp.str().c_str(), vFarmFrame[page].environmentPage.currMFVibeAct1, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.currHFVibeAct1)); + set_json_string_With_Status(pageInfo, "Current High Frequency Vibe Score - Actuator 1", temp.str().c_str(), vFarmFrame[page].environmentPage.currHFVibeAct1, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.worstLFVibeAct1)); + set_json_string_With_Status(pageInfo, "Worst Low Frequency Vibe Score - Actuator 1", temp.str().c_str(), vFarmFrame[page].environmentPage.worstLFVibeAct1, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.worstMFVibeAct1)); + set_json_string_With_Status(pageInfo, "Worst Mid Frequency Vibe Score - Actuator 1", temp.str().c_str(), vFarmFrame[page].environmentPage.worstMFVibeAct1, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << std::setfill('0') << static_cast(M_WordInt0(vFarmFrame[page].environmentPage.worstHFVibeAct1)); + set_json_string_With_Status(pageInfo, "Worst High Frequency Vibe Score - Actuator 1", temp.str().c_str(), vFarmFrame[page].environmentPage.worstHFVibeAct1, m_showStatusBits); + } json_push_back(masterData, pageInfo); @@ -904,15 +1150,12 @@ eReturnValues CATA_Farm_Log::print_Enviroment_Information(JSONNODE *masterData, //--------------------------------------------------------------------------- eReturnValues CATA_Farm_Log::print_Reli_Information(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - std::string myHeader = ""; - myHeader.resize(BASIC); + std::string myStr; JSONNODE *pageInfo = json_new(JSON_NODE); #if defined _DEBUG - int16_t whole = 0; - double remander = 0; + //int16_t whole = 0; + //double remander = 0; if (vFarmFrame[page].reliPage.copyNumber == FACTORYCOPY) { printf("\nReliability Information From Farm Log copy FACTORY"); @@ -921,78 +1164,147 @@ eReturnValues CATA_Farm_Log::print_Reli_Information(JSONNODE *masterData, uint32 { printf("\nReliability Information From Farm Log copy %d\n", page); } - printf("\tTimeStamp of last IDD test (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.lastIDDTest & 0x00FFFFFFFFFFFFFFLL); //!< Timestamp of last IDD test - printf("\tSub-command of last IDD test (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.cmdLastIDDTest & 0x00FFFFFFFFFFFFFFLL); //!< Sub-command of last IDD test - - printf("\tNumber of G-List Reclamations(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.gListReclamed & 0x00FFFFFFFFFFFFFFLL); //!< Number of G-List Reclamations - printf("\tServo Status(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.servoStatus & 0x00FFFFFFFFFFFFFFLL); //!< Servo Status (follows standard DST error code definitions) - printf("\tAlts List Entries Before IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.altsBeforeIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Alt List Entries Before IDD Scan - printf("\tAltz List Entries After IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.altsAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Alt List Entries After IDD Scan - printf("\tResident G-List Entries Before IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.gListBeforIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Resident G-List Entries Before IDD Scan - printf("\tResident G-List Entries After IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.gListAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Resident G-List Entries After IDD Scan - printf("\tScrubs List Entries Before IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.scrubsBeforeIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Scrub List Entries Before IDD Scan - printf("\tScrubs List Entries After IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.scrubsAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Scrub List Entries After IDD Scan - printf("\tNumber of DOS Scans Performed(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.numberDOSScans & 0x00FFFFFFFFFFFFFFLL); //!< Number of DOS Scans Performed - printf("\tNumber of LBAs Corrected by ISP(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.numberLBACorrect & 0x00FFFFFFFFFFFFFFLL); //!< Number of LBAs Corrected by ISP - printf("\tNumber of Valid Parity Sector(debug)s: %" PRIu64" \n", vFarmFrame[page].reliPage.numberValidParitySec & 0x00FFFFFFFFFFFFFFLL); //!< Number of Valid Parity Sectors - - printf("\tNumber of RAW Operations (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.numberRAWops & 0x00FFFFFFFFFFFFFFLL); //!< Number of RAW Operations - - printf("\tError Rate (SMART Attribute 1 Raw)(debug): 0x%016" PRIx64"\n", vFarmFrame[page].reliPage.attrErrorRateRaw & 0x00FFFFFFFFFFFFFFLL); //!< Error Rate (SMART Attribute 1 Raw) - printf("\tError Rate (SMART Attribute 1 Normalized)(debug):%" PRIu64" \n", vFarmFrame[page].reliPage.attrErrorRateNormal & 0x00FFFFFFFFFFFFFFLL); //!< Error Rate (SMART Attribute 1 Normalized) - printf("\tError Rate (SMART Attribute 1 Worst)(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.attrErrorRateWorst & 0x00FFFFFFFFFFFFFFLL); //!< Error Rate (SMART Attribute 1 Worst) - printf("\tSeek Error Rate (SMART Attr 7 Raw)(debug): 0x%016" PRIx64" \n", vFarmFrame[page].reliPage.attrSeekErrorRateRaw & 0x00FFFFFFFFFFFFFFLL); //!< Seek Error Rate (SMART Attribute 7 Raw) - printf("\tSeek Error Rate (SMART Attr 7 Normalized)(debug):%" PRIu64" \n", vFarmFrame[page].reliPage.attrSeekErrorRateNormal & 0x00FFFFFFFFFFFFFFLL); //!< Seek Error Rate (SMART Attribute 7 Normalized) - printf("\tSeek Error Rate (SMART Attr 7 Worst)(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.attrSeekErrorRateWorst & 0x00FFFFFFFFFFFFFFLL); //!< Seek Error Rate (SMART Attribute 7 Worst) - printf("\tHigh Priority Unload Events (Raw) (debug): 0x%016" PRIx64" \n", vFarmFrame[page].reliPage.attrUnloadEventsRaw & 0x00FFFFFFFFFFFFFFLL); //!< High Priority Unload Events (SMART Attribute 192 Raw) - printf("\tMicro Actuator Lock-out accumulated (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.microActuatorLockOUt & 0x00FFFFFFFFFFFFFFLL); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames8 - - printf("\tRV Absolute Mean (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.RVAbsoluteMean & 0x00FFFFFFFFFFFFFFLL); //!< RV Absolute Mean, value from the most recent SMART Frame - printf("\tMax RV Absolute Meane (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.maxRVAbsluteMean & 0x00FFFFFFFFFFFFFFLL); //!< Max RV Absolute Mean, value from the most recent SMART Summary Frame - printf("\tIdle Time (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.idleTime & 0x00FFFFFFFFFFFFFFLL); //!< idle Time, Value from most recent SMART Summary Frame - printf("\tNumber of LBAs Corrected by Parity Sector (debug)%" PRIu64" \n", vFarmFrame[page].reliPage.numberLBACorrectedByParitySector & 0x00FFFFFFFFFFFFFFLL); //!< Number of LBAs Corrected by Parity Sector + printf("\tTimeStamp of last IDD test (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.lastIDDTest & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Timestamp of last IDD test + printf("\tSub-command of last IDD test (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.cmdLastIDDTest & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Sub-command of last IDD test + + printf("\tTimeStamp of last IDD test (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.lastIDDTest & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Timestamp of last IDD test + printf("\tSub-command of last IDD test (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.cmdLastIDDTest & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Sub-command of last IDD test + + printf("\tNumber of G-List Reclamations(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.gListReclamed & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of G-List Reclamations + printf("\tServo Status(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.servoStatus & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Servo Status (follows standard DST error code definitions) + printf("\tAlts List Entries Before IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.altsBeforeIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Alt List Entries Before IDD Scan + printf("\tAltz List Entries After IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.altsAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Alt List Entries After IDD Scan + printf("\tResident G-List Entries Before IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.gListBeforIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Resident G-List Entries Before IDD Scan + printf("\tResident G-List Entries After IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.gListAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Resident G-List Entries After IDD Scan + printf("\tScrubs List Entries Before IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.scrubsBeforeIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Scrub List Entries Before IDD Scan + printf("\tScrubs List Entries After IDD Scan(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.scrubsAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Scrub List Entries After IDD Scan + printf("\tNumber of DOS Scans Performed(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.numberDOSScans & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of DOS Scans Performed + printf("\tNumber of LBAs Corrected by ISP(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.numberLBACorrect & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by ISP + printf("\tNumber of Valid Parity Sectors(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.numberValidParitySec & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Valid Parity Sectors + + printf("\tNumber of RAW Operations (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.numberRAWops & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of RAW Operations + + printf("\tError Rate (SMART Attribute 1 Raw)(debug): 0x%016" PRIx64"\n", vFarmFrame[page].reliPage.attrErrorRateRaw & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Error Rate (SMART Attribute 1 Raw) + printf("\tError Rate (SMART Attribute 1 Normalized)(debug):%" PRIu64" \n", vFarmFrame[page].reliPage.attrErrorRateNormal & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Error Rate (SMART Attribute 1 Normalized) + printf("\tError Rate (SMART Attribute 1 Worst)(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.attrErrorRateWorst & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Error Rate (SMART Attribute 1 Worst) + printf("\tSeek Error Rate (SMART Attr 7 Raw)(debug): 0x%016" PRIx64" \n", vFarmFrame[page].reliPage.attrSeekErrorRateRaw & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Seek Error Rate (SMART Attribute 7 Raw) + printf("\tSeek Error Rate (SMART Attr 7 Normalized)(debug):%" PRIu64" \n", vFarmFrame[page].reliPage.attrSeekErrorRateNormal & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Seek Error Rate (SMART Attribute 7 Normalized) + printf("\tSeek Error Rate (SMART Attr 7 Worst)(debug): %" PRIu64" \n", vFarmFrame[page].reliPage.attrSeekErrorRateWorst & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Seek Error Rate (SMART Attribute 7 Worst) + printf("\tHigh Priority Unload Events (Raw) (debug): 0x%016" PRIx64" \n", vFarmFrame[page].reliPage.attrUnloadEventsRaw & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< High Priority Unload Events (SMART Attribute 192 Raw) + printf("\tMicro Actuator Lock-out accumulated (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.microActuatorLockOUt & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames8 + // version 4-0 + if (m_MajorRev >= 4 && m_MinorRev >= 1) + { + printf("\tRV Absolute Mean (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.RVAbsoluteMean & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< RV Absolute Mean, value from the most recent SMART Frame + printf("\tMax RV Absolute Meane (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.maxRVAbsluteMean & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Max RV Absolute Mean, value from the most recent SMART Summary Frame + printf("\tIdle Time (debug): %" PRIu64" \n", vFarmFrame[page].reliPage.idleTime & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< idle Time, Value from most recent SMART Summary Frame + printf("\tNumber of LBAs Corrected by Parity Sector (debug)%" PRIu64" \n", vFarmFrame[page].reliPage.numberLBACorrectedByParitySector & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tPrimary Super Parity Coverage Percentage, Actuator 0%" PRIu64" \n", vFarmFrame[page].reliPage.SuperParityCovPercent & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Primary Super Parity Coverage Percentage + } + // version 4_21 + if (m_MajorRev >= 4 && m_MinorRev > 20) + { + printf("\tTimestamp of last IDD test in Hours(POH), Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.lastIDDTimeAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tSub Command of last IDD Test, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.cmdLastIDDTestAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of Reallocated Sector Reclamations, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.reallocSectorReclamAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tServo Status (follows standard DST error code definitions), Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.servoStatusAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of Slipped Sectors Before IDD Scan, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.slippedSectorsBefIDDAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of Slipped Sectors After IDD Scan, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.slippedSectorsAftIDDAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of Resident Reallocated Sectors Before IDD Scan, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.resReallocSectorsBefIDDAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of Resident Reallocated Sectors After IDD Scan, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.resReallocSectorsAftIDDAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of Successfully Scrubbed Sectors Before IDD Scan, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.scrubbedSectorsBefIDDAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of Successfully Scrubbed Sectors After IDD Scan, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.scrubbedSectorsAftIDDAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of DOS Scans Performed, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.DOSScansAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of LBAs Corrected by ISP, Acuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.correctedLBAsAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\t Number of Valid Parity Sectors, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.validParitySectAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tRV Absolute Mean, value from most recent SMART Summary Frame in rad/s^2, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.rvAbsMeanAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tMax RV Absolute Mean, value from most recent SMART Summary Frame in rad/s^2, Actuator %" PRIu64" \n", vFarmFrame[page].reliPage.rvAbsMeanMaxAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tIdle Time, value from most recent SMART Summary Frame in seconds, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.idleTimeAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tNumber of LBAs Corrected by Parity Sector, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.parityCorrLBAAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + printf("\tPrimary Super Parity Coverage Percentage, Actuator 1%" PRIu64" \n", vFarmFrame[page].reliPage.superParityCovPercentAct1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector + } + + + + #endif + std::ostringstream temp; if (vFarmFrame[page].reliPage.copyNumber == FACTORYCOPY) { - snprintf((char*)myStr.c_str(), BASIC, "Reliability Information From Farm Log copy FACTORY"); + temp << "Reliability Information From Farm Log copy FACTORY"; } else { - snprintf((char*)myStr.c_str(), BASIC, "Reliability Information From Farm Log copy %" PRIu32"", page); + temp << "Reliability Information From Farm Log copy " << std::dec << page; } - json_set_name(pageInfo, (char*)myStr.c_str()); + json_set_name(pageInfo, temp.str().c_str()); - set_json_64_bit_With_Status(pageInfo, "TimeStamp of last IDD test", vFarmFrame[page].reliPage.lastIDDTest, false, m_showStatusBits); //!< Timestamp of last IDD test - set_json_64_bit_With_Status(pageInfo, "Sub-Command of Last IDD Test", vFarmFrame[page].reliPage.cmdLastIDDTest, false, m_showStatusBits); //!< Sub-command of last IDD test - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sector Reclamations", vFarmFrame[page].reliPage.gListReclamed, false, m_showStatusBits); //!< Number of Reallocated Sector Reclamations - set_json_64_bit_With_Status(pageInfo, "Servo Status", vFarmFrame[page].reliPage.servoStatus, false, m_showStatusBits); //!< Servo Status (follows standard DST error code definitions) - set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors Before IDD Scan", vFarmFrame[page].reliPage.altsBeforeIDD, false, m_showStatusBits); //!< Number of Slipped Sectors Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors After IDD Scan", vFarmFrame[page].reliPage.altsAfterIDD, false, m_showStatusBits); //!< Number of Slipped Sectors After IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors Before IDD Scan", vFarmFrame[page].reliPage.gListBeforIDD, false, m_showStatusBits); //!< Number of Resident Reallocated Sectors Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors After IDD Scan", vFarmFrame[page].reliPage.gListAfterIDD, false, m_showStatusBits); //!< Number of Resident Reallocated Sectors After IDD Scan + set_json_64_bit_With_Status(pageInfo, "TimeStamp of last IDD test", vFarmFrame[page].reliPage.lastIDDTest, false, m_showStatusBits); //!< Timestamp of last IDD test + set_json_64_bit_With_Status(pageInfo, "Sub-Command of Last IDD Test", vFarmFrame[page].reliPage.cmdLastIDDTest, false, m_showStatusBits); //!< Sub-command of last IDD test + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sector Reclamations", vFarmFrame[page].reliPage.gListReclamed, false, m_showStatusBits); //!< Number of Reallocated Sector Reclamations + set_json_64_bit_With_Status(pageInfo, "Servo Status", vFarmFrame[page].reliPage.servoStatus, false, m_showStatusBits); //!< Servo Status (follows standard DST error code definitions) + set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors Before IDD Scan", vFarmFrame[page].reliPage.altsBeforeIDD, false, m_showStatusBits); //!< Number of Slipped Sectors Before IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors After IDD Scan", vFarmFrame[page].reliPage.altsAfterIDD, false, m_showStatusBits); //!< Number of Slipped Sectors After IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors Before IDD Scan", vFarmFrame[page].reliPage.gListBeforIDD, false, m_showStatusBits); //!< Number of Resident Reallocated Sectors Before IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors After IDD Scan", vFarmFrame[page].reliPage.gListAfterIDD, false, m_showStatusBits); //!< Number of Resident Reallocated Sectors After IDD Scan set_json_64_bit_With_Status(pageInfo, "Successfully Scrubbed Sectors Before IDD Scan", vFarmFrame[page].reliPage.scrubsBeforeIDD, false, m_showStatusBits); //!< Number of Successfully Scrubbed Sectors Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Successfully Scrubbed Sectors After IDD Scan", vFarmFrame[page].reliPage.scrubsAfterIDD, false, m_showStatusBits); //!< Number of Successfully Scrubbed Sectors After IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of DOS Scans Performed", vFarmFrame[page].reliPage.numberDOSScans, false, m_showStatusBits); //!< Number of DOS Scans Performed - set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by ISP", vFarmFrame[page].reliPage.numberLBACorrect, false, m_showStatusBits); //!< Number of LBAs Corrected by ISP - set_json_64_bit_With_Status(pageInfo, "Number of Valid Parity Sectors", vFarmFrame[page].reliPage.numberValidParitySec, false, m_showStatusBits); //!< Number of Valid Parity Sector + set_json_64_bit_With_Status(pageInfo, "Successfully Scrubbed Sectors After IDD Scan", vFarmFrame[page].reliPage.scrubsAfterIDD, false, m_showStatusBits); //!< Number of Successfully Scrubbed Sectors After IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of DOS Scans Performed", vFarmFrame[page].reliPage.numberDOSScans, false, m_showStatusBits); //!< Number of DOS Scans Performed + set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by ISP", vFarmFrame[page].reliPage.numberLBACorrect, false, m_showStatusBits); //!< Number of LBAs Corrected by ISP + set_json_64_bit_With_Status(pageInfo, "Number of Valid Parity Sectors", vFarmFrame[page].reliPage.numberValidParitySec, false, m_showStatusBits); //!< Number of Valid Parity Sector set_json_64_bit_With_Status(pageInfo, "Number of RAW Operations", vFarmFrame[page].reliPage.numberRAWops, false, m_showStatusBits); //!< Number of RAW Operations - set_json_64_bit_With_Status(pageInfo, "Error Rate (SMART Attribute 1 Raw)", vFarmFrame[page].reliPage.attrErrorRateRaw, true, m_showStatusBits); //!< Error Rate (SMART Attribute 1 Raw) - set_json_64_bit_With_Status(pageInfo, "Error Rate (SMART Attribute 1 Normalized)", vFarmFrame[page].reliPage.attrErrorRateNormal, false, m_showStatusBits); //!< Error Rate (SMART Attribute 1 Normalized) - set_json_64_bit_With_Status(pageInfo, "Error Rate (SMART Attribute 1 Worst)", vFarmFrame[page].reliPage.attrErrorRateWorst, false, m_showStatusBits); //!< Error Rate (SMART Attribute 1 Worst) - set_json_64_bit_With_Status(pageInfo, "Seek Error Rate (SMART Attr 7 Raw)", vFarmFrame[page].reliPage.attrSeekErrorRateRaw, true, m_showStatusBits); //!< Seek Error Rate (SMART Attribute 7 Raw) + set_json_64_bit_With_Status(pageInfo, "Error Rate (SMART Attribute 1 Raw)", vFarmFrame[page].reliPage.attrErrorRateRaw, true, m_showStatusBits); //!< Error Rate (SMART Attribute 1 Raw) + set_json_64_bit_With_Status(pageInfo, "Error Rate (SMART Attribute 1 Normalized)", vFarmFrame[page].reliPage.attrErrorRateNormal, false, m_showStatusBits); //!< Error Rate (SMART Attribute 1 Normalized) + set_json_64_bit_With_Status(pageInfo, "Error Rate (SMART Attribute 1 Worst)", vFarmFrame[page].reliPage.attrErrorRateWorst, false, m_showStatusBits); //!< Error Rate (SMART Attribute 1 Worst) + set_json_64_bit_With_Status(pageInfo, "Seek Error Rate (SMART Attr 7 Raw)", vFarmFrame[page].reliPage.attrSeekErrorRateRaw, true, m_showStatusBits); //!< Seek Error Rate (SMART Attribute 7 Raw) set_json_64_bit_With_Status(pageInfo, "Seek Error Rate (SMART Attr 7 Normalized)", vFarmFrame[page].reliPage.attrSeekErrorRateNormal, false, m_showStatusBits); //!< Seek Error Rate (SMART Attribute 7 Normalized) - set_json_64_bit_With_Status(pageInfo, "Seek Error Rate (SMART Attr 7 Worst)", vFarmFrame[page].reliPage.attrSeekErrorRateWorst, false, m_showStatusBits); //!< Seek Error Rate (SMART Attribute 7 Worst) - set_json_64_bit_With_Status(pageInfo, "High Priority Unload Events", vFarmFrame[page].reliPage.attrUnloadEventsRaw, false, m_showStatusBits); //!< High Priority Unload Events (SMART Attribute 192 Raw) - set_json_64_bit_With_Status(pageInfo, "Micro Actuator Lock-out accumulated", vFarmFrame[page].reliPage.microActuatorLockOUt, false, m_showStatusBits); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames8 - + set_json_64_bit_With_Status(pageInfo, "Seek Error Rate (SMART Attr 7 Worst)", vFarmFrame[page].reliPage.attrSeekErrorRateWorst, false, m_showStatusBits); //!< Seek Error Rate (SMART Attribute 7 Worst) + set_json_64_bit_With_Status(pageInfo, "High Priority Unload Events", vFarmFrame[page].reliPage.attrUnloadEventsRaw, false, m_showStatusBits); //!< High Priority Unload Events (SMART Attribute 192 Raw) + set_json_64_bit_With_Status(pageInfo, "Micro Actuator Lock-out accumulated", vFarmFrame[page].reliPage.microActuatorLockOUt, false, m_showStatusBits); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames set_json_64_bit_With_Status(pageInfo, "Number of Disc Slip Recalibrations Performed", vFarmFrame[page].reliPage.diskSlipRecalPerformed, false, m_showStatusBits); //!< Number of disc slip recalibrations performed set_json_64_bit_With_Status(pageInfo, "Helium Pressure Threshold Tripped", vFarmFrame[page].reliPage.heliumPresureTrip, false, m_showStatusBits); //!< Helium Pressure Threshold Tripped ( 1- trip, 0 -no trip)//!< idle Time, Value from most recent SMART Summary Frame - set_json_64_bit_With_Status(pageInfo, "RV Absolute Mean", vFarmFrame[page].reliPage.RVAbsoluteMean, false, m_showStatusBits); //!< RV Absolute Mean, value from the most recent SMART Frame - set_json_64_bit_With_Status(pageInfo, "Max RV Absolute Mean", vFarmFrame[page].reliPage.maxRVAbsluteMean, false, m_showStatusBits); //!< Max RV Absolute Mean, value from the most recent SMART Summary Frame - snprintf((char*)myStr.c_str(), BASIC, "%0.03lf", static_cast(M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].reliPage.idleTime))* 1.0) / 3600); - set_json_string_With_Status(pageInfo, "Idle Time (hours)", (char*)myStr.c_str(), vFarmFrame[page].reliPage.idleTime, m_showStatusBits); //!< Idle Time - set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by Parity Sector", vFarmFrame[page].reliPage.numberLBACorrectedByParitySector, false, m_showStatusBits);//!< Number of LBAs Corrected by Parity Sector + if (m_MajorRev >= 4 && m_MinorRev >= 1) + { + set_json_64_bit_With_Status(pageInfo, "RV Absolute Mean, Actuator 0", vFarmFrame[page].reliPage.RVAbsoluteMean, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Max RV Absolute Mean, Actuator 0", vFarmFrame[page].reliPage.maxRVAbsluteMean, false, m_showStatusBits); + + temp.str(""); temp.clear(); + temp << std::fixed << std::setprecision(6) << std::setfill('0') << static_cast(check_Status_Strip_Status(vFarmFrame[page].reliPage.idleTime)) / 3600; + set_json_string_With_Status(pageInfo, "Idle Time (hours), Actuator 0", temp.str(), vFarmFrame[page].reliPage.idleTime, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by Parity Sector, Actuator 0", vFarmFrame[page].reliPage.numberLBACorrectedByParitySector, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Primary Super Parity Coverage Percentage, Actuator 0", vFarmFrame[page].reliPage.SuperParityCovPercent, false, m_showStatusBits); + } + + if (m_MajorRev >= 4 && m_MinorRev >= 19) + { + // information for Actuator 0 + set_json_64_bit_With_Status(pageInfo, "Primary Super Parity Coverage Percentage SMR SWR, Actuator 0", vFarmFrame[page].reliPage.superParityCoveragePercentageAct0, false, m_showStatusBits); //!< Primary Super Parity Coverage Percentage SMR/SWR, Actuator 0 + + // information for Actuator 1 + set_json_64_bit_With_Status(pageInfo, "Timestamp of last IDD test in Hours(POH), Actuator 1", vFarmFrame[page].reliPage.lastIDDTimeAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Sub Command of last IDD Test, Actuator 1", vFarmFrame[page].reliPage.cmdLastIDDTestAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sector Reclamations, Actuator 1", vFarmFrame[page].reliPage.reallocSectorReclamAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Servo Status, Actuator 1", vFarmFrame[page].reliPage.servoStatusAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors Before IDD Scan, Actuator 1", vFarmFrame[page].reliPage.slippedSectorsBefIDDAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors After IDD Scan, Actuator 1", vFarmFrame[page].reliPage.slippedSectorsAftIDDAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors Before IDD Scan, Actuator 1", vFarmFrame[page].reliPage.resReallocSectorsBefIDDAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors After IDD Scan, Actuator 1", vFarmFrame[page].reliPage.resReallocSectorsAftIDDAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Successfully Scrubbed Sectors Before IDD Scan, Actuator 1", vFarmFrame[page].reliPage.scrubbedSectorsBefIDDAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Successfully Scrubbed Sectors After IDD Scan, Actuator 1", vFarmFrame[page].reliPage.scrubbedSectorsAftIDDAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of DOS Scans Performed, Actuator 1", vFarmFrame[page].reliPage.DOSScansAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by ISP, Acuator 1", vFarmFrame[page].reliPage.correctedLBAsAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Valid Parity Sectors, Actuator 1", vFarmFrame[page].reliPage.validParitySectAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "RV Absolute Mean, Actuator 1", vFarmFrame[page].reliPage.rvAbsMeanAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Max RV Absolute Mean, Actuator 1", vFarmFrame[page].reliPage.rvAbsMeanMaxAct1, false, m_showStatusBits); + temp.str(""); temp.clear(); + temp << std::fixed << std::setprecision(6) << std::setfill('0') << static_cast(check_Status_Strip_Status(vFarmFrame[page].reliPage.idleTimeAct1)) / 3600; + set_json_string_With_Status(pageInfo, "Idle Time (hours), Actuator 1", temp.str(),vFarmFrame[page].reliPage.idleTimeAct1, m_showStatusBits); + //set_json_64_bit_With_Status(pageInfo, "Idle Time (hours), Actuator 1", vFarmFrame[page].reliPage.idleTimeAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by Parity Sector, Actuator 1", vFarmFrame[page].reliPage.parityCorrLBAAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Primary Super Parity Coverage Percentage, Actuator 1", vFarmFrame[page].reliPage.superParityCovPercentAct1, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Primary Super Parity Coverage Percentage SMR SWR, Actuator 1", vFarmFrame[page].reliPage.superParityCoveragePercentageAct1, false, m_showStatusBits); + } json_push_back(masterData, pageInfo); return SUCCESS; } @@ -1014,396 +1326,616 @@ eReturnValues CATA_Farm_Log::print_Reli_Information(JSONNODE *masterData, uint32 eReturnValues CATA_Farm_Log::print_Head_Information(JSONNODE *masterData, uint32_t page) { uint32_t loopCount = 0; - std::string myStr = " "; - myStr.resize(BASIC); - std::string myHeader = ""; - myHeader.resize(BASIC); + std::string myHeader; JSONNODE *headInfo = json_new(JSON_NODE); - -#if defined _DEBUG int16_t whole = 0; +#if defined _DEBUG double remander = 0; + if (vFarmFrame[page].reliPage.copyNumber == FACTORYCOPY) { printf("\n Head Information From Farm Log copy FACTORY"); } else { - printf("\n Head Information From Farm Log copy %d\n", page); + printf("\n Head Information From Farm Log copy %" PRIu32"\n", page); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { whole = M_WordInt2(vFarmFrame[page].reliPage.discSlip[loopCount]); - remander = (double)M_DoubleWordInt0(vFarmFrame[page].reliPage.discSlip[loopCount]); + remander = static_cast(M_DoubleWordInt0(vFarmFrame[page].reliPage.discSlip[loopCount])); printf("\tDisc Slip in micro-inches by Head %d: %" PRIi16".%04.0f (debug)\n", loopCount, whole, remander); //!< Disc Slip in micro-inches by Head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { whole = M_WordInt2(vFarmFrame[page].reliPage.bitErrorRate[loopCount]); - remander = (double)M_DoubleWordInt0(vFarmFrame[page].reliPage.bitErrorRate[loopCount]); + remander = static_cast(M_DoubleWordInt0(vFarmFrame[page].reliPage.bitErrorRate[loopCount])); printf("\tBit Error Rate of Zone 0 by Head %d: %" PRIi16".%04.0f (debug)\n", loopCount, whole, remander); //!< Bit Error Rate of Zone 0 by Drive Head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tDOS Write Refresh Count Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.dosWriteCount[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] DOS Write Refresh Count7 + printf("\tDOS Write Refresh Count Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.dosWriteCount[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] DOS Write Refresh Count7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tDVGA Skip Write Detect by Head %d: %" PRIu64"(debug) \n", loopCount, vFarmFrame[page].reliPage.DVGASkipWriteDetect[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] DVGA Skip Write Detect by Head7 + printf("\tDVGA Skip Write Detect by Head %d: %" PRIu64"(debug) \n", loopCount, vFarmFrame[page].reliPage.DVGASkipWriteDetect[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] DVGA Skip Write Detect by Head7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tRVGA Skip Write Detect by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.RVGASkipWriteDetect[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] RVGA Skip Write Detect by Head7 + printf("\tRVGA Skip Write Detect by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.RVGASkipWriteDetect[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] RVGA Skip Write Detect by Head7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tFVGA Skip Write Detect by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.FVGASkipWriteDetect[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] FVGA Skip Write Detect by Head7 + printf("\tFVGA Skip Write Detect by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.FVGASkipWriteDetect[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] FVGA Skip Write Detect by Head7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tSkip Write Detect Threshold Exceeded by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.skipWriteDetectThresExceeded[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] Skip Write Detect Threshold Exceeded Count by Head7 + printf("\tSkip Write Detect Threshold Exceeded by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.skipWriteDetectThresExceeded[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] Skip Write Detect Threshold Exceeded Count by Head7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tACFF Sine 1X by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.sineACFF[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] ACFF Sine 1X, value from most recent SMART Summary Frame by Head7,8 + printf("\tACFF Sine 1X by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.sineACFF[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] ACFF Sine 1X, value from most recent SMART Summary Frame by Head7,8 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tACFF Cosine 1X by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.cosineACFF[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] ACFF Cosine 1X, value from most recent SMART Summary Frame by Head7,8 + printf("\tACFF Cosine 1X by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.cosineACFF[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] ACFF Cosine 1X, value from most recent SMART Summary Frame by Head7,8 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tPZT Calibration by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.PZTCalibration[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] PZT Calibration, value from most recent SMART Summary Frame by Head9,10 + printf("\tPZT Calibration by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.PZTCalibration[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] PZT Calibration, value from most recent SMART Summary Frame by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tMR Head Resistance from Head %d: %" PRIu64" (debug) \n", loopCount, vFarmFrame[page].reliPage.MRHeadResistance[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] MR Head Resistance from most recent SMART Summary Frame by Head9,10 + printf("\tMR Head Resistance from Head %d: %" PRIu64" (debug) \n", loopCount, vFarmFrame[page].reliPage.MRHeadResistance[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] MR Head Resistance from most recent SMART Summary Frame by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tNumber of TMD for Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.numberOfTMD[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] Number of TMD over last 3 SMART Summary Frames by Head9,10 + printf("\tNumber of TMD for Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.numberOfTMD[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] Number of TMD over last 3 SMART Summary Frames by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tVelocity Observer by Head %d: %" PRIu64"(debug) \n", loopCount, vFarmFrame[page].reliPage.velocityObserver[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] Velocity Observer over last 3 SMART Summary Frames by Head9,10 + printf("\tVelocity Observer by Head %d: %" PRIu64"(debug) \n", loopCount, vFarmFrame[page].reliPage.velocityObserver[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] Velocity Observer over last 3 SMART Summary Frames by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tNumber of Velocity Observer by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.numberOfVelocityObserver[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] Number of Velocity Observer over last 3 SMART Summary Frames by Head9,10 + printf("\tNumber of Velocity Observer by Head %d: %" PRIu64" (debug)\n", loopCount, vFarmFrame[page].reliPage.numberOfVelocityObserver[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] Number of Velocity Observer over last 3 SMART Summary Frames by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { + printf("\tFly height outer clearance delta by Head %d: raw 0x%" PRIx64" outer, calculated %0.02f (debug)\n", loopCount, vFarmFrame[page].reliPage.flyHeightClearance[loopCount].outer, \ + static_cast(M_WordInt0((check_Status_Strip_Status(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].outer))) * .001)); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. printf("\tFly height inner clearance delta by Head %d: raw 0x%" PRIx64" inner, calculated %0.02f (debug)\n", loopCount, vFarmFrame[page].reliPage.flyHeightClearance[loopCount].inner, \ - (float)static_cast(M_WordInt0((check_Status_Strip_Status(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].inner))) * .001)); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. + static_cast(M_WordInt0((check_Status_Strip_Status(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].inner))) * .001)); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. printf("\tFly height middle clearance delta by Head %d: raw 0x%" PRIx64" middle, calculated %0.02f (debug)\n", loopCount, vFarmFrame[page].reliPage.flyHeightClearance[loopCount].middle, \ - (float)static_cast(M_WordInt0(check_Status_Strip_Status((vFarmFrame[page].reliPage.flyHeightClearance[loopCount].middle))) * .001)); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. - printf("\tFly height outer clearance delta by Head %d: raw 0x%" PRIx64" outer, calculated %0.02f (debug)\n", loopCount, vFarmFrame[page].reliPage.flyHeightClearance[loopCount].outer, \ - (float)static_cast(M_WordInt0((check_Status_Strip_Status(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].outer))) * .001)); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. + static_cast(M_WordInt0(check_Status_Strip_Status((vFarmFrame[page].reliPage.flyHeightClearance[loopCount].middle))) * .001)); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. } - printf("\tNumber of disc slip recalibrations performed: %" PRId64" (debug)\n", vFarmFrame[page].reliPage.diskSlipRecalPerformed & 0x00FFFFFFFFFFFFFFLL); //!< Number of disc slip recalibrations performed + printf("\tNumber of disc slip recalibrations performed: %" PRId64" (debug)\n", vFarmFrame[page].reliPage.diskSlipRecalPerformed & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of disc slip recalibrations performed for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tNumber of Reallocated Sectors by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.gList[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] Number of Resident G-List per Head + printf("\tNumber of Reallocated Sectors by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.gList[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] Number of Resident G-List per Head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tNumber of pending Entries by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.pendingEntries[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] Number of pending Entries per Head + printf("\tNumber of pending Entries by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.pendingEntries[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] Number of pending Entries per Head } - printf("\tHelium Pressure Threshold Tripped: %" PRId64" (debug)\n", vFarmFrame[page].reliPage.heliumPresureTrip & 0x00FFFFFFFFFFFFFFLL); //!< Helium Pressure Threshold Tripped ( 1- trip, 0 -no trip) + printf("\tHelium Pressure Threshold Tripped: %" PRId64" (debug)\n", vFarmFrame[page].reliPage.heliumPresureTrip & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Helium Pressure Threshold Tripped ( 1- trip, 0 -no trip) for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tDOS Ought to scan count by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.oughtDOS[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] DOS Ought to scan count per head + printf("\tDOS Ought to scan count by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.oughtDOS[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] DOS Ought to scan count per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tDOS needs to scans count by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.needDOS[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] DOS needs to scans count per head + printf("\tDOS needs to scans count by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.needDOS[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] DOS needs to scans count per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tDOS write Fault scans by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.writeDOSFault[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] DOS write Fault scans per head + printf("\tDOS write Fault scans by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.writeDOSFault[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] DOS write Fault scans per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\twrite POS in sec value by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.writePOH[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] write POS in sec value from most recent SMART Frame by head + printf("\twrite POS in sec value by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.writePOH[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] write POS in sec value from most recent SMART Frame by head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - printf("\tDOS Write Count Threshold by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.countDOSWrite[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< [24] DOS Write Count Threshold per head + printf("\tDOS Write Count Threshold by Head %d: %" PRId64" (debug)\n", loopCount, vFarmFrame[page].reliPage.countDOSWrite[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< [24] DOS Write Count Threshold per head } #endif - + std::ostringstream temp; if (vFarmFrame[page].reliPage.copyNumber == FACTORYCOPY) { - snprintf((char*)myStr.c_str(), BASIC, "Head Information From Farm Log copy FACTORY"); + temp << "Head Information From Farm Log copy FACTORY"; } else { - snprintf((char*)myStr.c_str(), BASIC, "Head Information From Farm Log copy %d", page); + temp << "Head Information From Farm Log copy " << std::dec << page; } - - json_set_name(headInfo, (char*)myStr.c_str()); + json_set_name(headInfo, temp.str().c_str()); for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "Disc Slip in micro-inches by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi16".%04.0f", M_WordInt2(vFarmFrame[page].reliPage.discSlip[loopCount]), (double)M_DoubleWordInt0(vFarmFrame[page].reliPage.discSlip[loopCount])); //!< Disc Slip in micro-inches by Head - json_push_back(headInfo, json_new_a((char*)myHeader.c_str(), (char*)myStr.c_str())); + uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].reliPage.discSlip[loopCount]); + whole = M_WordInt2(dsHead); // get 5:4 whole part of the float + double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } + + temp.str("");temp.clear(); + temp << "Disc Slip in micro-inches by Head " << std::dec << loopCount;// Head count + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.discSlip[loopCount], m_showStatusBits); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "Bit Error Rate of Zone 0 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi16".%04.0f", M_WordInt2(vFarmFrame[page].reliPage.bitErrorRate[loopCount]), (double)M_DoubleWordInt0(vFarmFrame[page].reliPage.bitErrorRate[loopCount])); - json_push_back(headInfo, json_new_a((char*)myHeader.c_str(), (char*)myStr.c_str())); + uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].reliPage.bitErrorRate[loopCount]); + whole = M_WordInt2(dsHead); // get 5:4 whole part of the float + double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } + + temp.str(""); temp.clear(); + temp << "Bit Error Rate of Zone 0 by Head " << std::dec << loopCount;// Head count + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.bitErrorRate[loopCount], m_showStatusBits); + + + //temp.str("");temp.clear(); + //temp << "Bit Error Rate of Zone 0 by Head " << std::dec << loopCount;// Head count + //myHeader.assign(temp.str()); + //temp.str("");temp.clear(); + //temp << std::dec << M_WordInt2(vFarmFrame[page].reliPage.bitErrorRate[loopCount]) << "." << std::fixed << std::setprecision(4) << std::setfill('0') << static_cast(M_DoubleWordInt0(vFarmFrame[page].reliPage.bitErrorRate[loopCount])); + //json_push_back(headInfo, json_new_a(myHeader.c_str(), temp.str().c_str())); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "DOS Write Refresh Count by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.dosWriteCount[loopCount], false, m_showStatusBits); //!< [24] DOS Write Refresh Count7 + temp.str("");temp.clear(); + temp << "DOS Write Refresh Count by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.dosWriteCount[loopCount], false, m_showStatusBits); //!< [24] DOS Write Refresh Count7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "DVGA Skip Write Detect by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.DVGASkipWriteDetect[loopCount], false, m_showStatusBits); //!< [24] DVGA Skip Write Detect by Head7 + temp.str("");temp.clear(); + temp << "DVGA Skip Write Detect by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.DVGASkipWriteDetect[loopCount], false, m_showStatusBits); //!< [24] DVGA Skip Write Detect by Head7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "RVGA Skip Write Detect by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.RVGASkipWriteDetect[loopCount], false, m_showStatusBits); //!< [24] RVGA Skip Write Detect by Head7 + temp.str("");temp.clear(); + temp << "RVGA Skip Write Detect by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.RVGASkipWriteDetect[loopCount], false, m_showStatusBits); //!< [24] RVGA Skip Write Detect by Head7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "FVGA Skip Write Detect by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.FVGASkipWriteDetect[loopCount], false, m_showStatusBits); //!< [24] FVGA Skip Write Detect by Head7 + temp.str("");temp.clear(); + temp << "FVGA Skip Write Detect by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.FVGASkipWriteDetect[loopCount], false, m_showStatusBits); //!< [24] FVGA Skip Write Detect by Head7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Skip Write Detect Threshold Exceeded by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.skipWriteDetectThresExceeded[loopCount], false, m_showStatusBits); //!< [24] Skip Write Detect Threshold Exceeded Count by Head7 + temp.str("");temp.clear(); + temp << "Skip Write Detect Threshold Exceeded by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.skipWriteDetectThresExceeded[loopCount], false, m_showStatusBits); //!< [24] Skip Write Detect Threshold Exceeded Count by Head7 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "ACFF Sine 1X for Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi8"", (M_ByteInt0(vFarmFrame[page].reliPage.sineACFF[loopCount]) * 16)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.sineACFF[loopCount], m_showStatusBits); //!< [24] ACFF Sine 1X, value from most recent SMART Summary Frame by Head7,8 + temp.str("");temp.clear(); + temp << "ACFF Sine 1X for Head " << std::dec << loopCount;// Head count + set_json_int_Check_Status(headInfo, temp.str().c_str(), static_cast(M_Byte0(vFarmFrame[page].reliPage.sineACFF[loopCount])) * 16, vFarmFrame[page].reliPage.sineACFF[loopCount], m_showStatusBits); //!< ACFF Sine 1X, value from most recent SMART Summary Frame } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "ACFF Cosine 1X for Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi8"", (M_ByteInt0(vFarmFrame[page].reliPage.cosineACFF[loopCount]) * 16)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.cosineACFF[loopCount], m_showStatusBits); //!< [24] ACFF Cosine 1X, value from most recent SMART Summary Frame by Head7,8 + temp.str("");temp.clear(); + temp << "ACFF Cosine 1X for Head " << std::dec << loopCount;// Head count + set_json_int_Check_Status(headInfo, temp.str().c_str(), static_cast(M_Byte0(vFarmFrame[page].reliPage.cosineACFF[loopCount])) * 16, vFarmFrame[page].reliPage.cosineACFF[loopCount], m_showStatusBits); //!< ACFF Cosine 1X, value from most recent SMART Summary Frame } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "PZT Calibration for Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.PZTCalibration[loopCount], false, m_showStatusBits); //!< [24] PZT Calibration, value from most recent SMART Summary Frame by Head9,10 + temp.str("");temp.clear(); + temp << "PZT Calibration for Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.PZTCalibration[loopCount], false, m_showStatusBits); //!< [24] PZT Calibration, value from most recent SMART Summary Frame by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "MR Head Resistance from Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.MRHeadResistance[loopCount], false, m_showStatusBits); //!< [24] MR Head Resistance from most recent SMART Summary Frame by Head9,10 + temp.str("");temp.clear(); + temp << "MR Head Resistance for Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.MRHeadResistance[loopCount], false, m_showStatusBits); //!< [24] MR Head Resistance from most recent SMART Summary Frame by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Number of TMD for Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.numberOfTMD[loopCount], false, m_showStatusBits); //!< [24] Number of TMD over last 3 SMART Summary Frames by Head9,10 + temp.str("");temp.clear(); + temp << "Servo No Timing Mark Detect for Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.numberOfTMD[loopCount], false, m_showStatusBits); //!< [24] Number of TMD over last 3 SMART Summary Frames by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Velocity Observer by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.velocityObserver[loopCount], false, m_showStatusBits); //!< [24] Velocity Observer over last 3 SMART Summary Frames by Head9,10 + temp.str("");temp.clear(); + temp << "Velocity Observer by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.velocityObserver[loopCount], false, m_showStatusBits); //!< [24] Velocity Observer over last 3 SMART Summary Frames by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Number of Velocity Observer by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.numberOfVelocityObserver[loopCount], false, m_showStatusBits); //!< [24] Number of Velocity Observer over last 3 SMART Summary Frames by Head9,10 + temp.str("");temp.clear(); + temp << "Servo Velocity No Timing Mark Detect by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.numberOfVelocityObserver[loopCount], false, m_showStatusBits); //!< [24] Number of Velocity Observer over last 3 SMART Summary Frames by Head9,10 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Fly height clearance delta inner by Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].inner)*.1)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.flyHeightClearance[loopCount].inner, m_showStatusBits); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. + temp.str("");temp.clear(); + temp << "Fly height clearance delta outer by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_WordInt0(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].outer) * 0.001); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.flyHeightClearance[loopCount].outer, m_showStatusBits); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "Fly height clearance delta middle by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].middle) * .1)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.flyHeightClearance[loopCount].middle, m_showStatusBits); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. + temp.str("");temp.clear(); + temp << "Fly height clearance delta inner by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_WordInt0(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].inner) * 0.001); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.flyHeightClearance[loopCount].inner, m_showStatusBits); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "Fly height clearance delta outer by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].outer) * .1)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.flyHeightClearance[loopCount].outer, m_showStatusBits);//!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. + temp.str("");temp.clear(); + temp << "Fly height clearance delta middle by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_WordInt0(vFarmFrame[page].reliPage.flyHeightClearance[loopCount].middle) * 0.001);; + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.flyHeightClearance[loopCount].middle, m_showStatusBits); //!< [24][3] Applied fly height clearance delta per head in thousandths of one Angstrom. } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Current H2SAT trimmed mean bits in error Zone 0 by Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%0.01f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].reliPage.currentH2SAT[loopCount].inner)) *.1)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.currentH2SAT[loopCount].inner, m_showStatusBits); //!< [24] Current H2SAT trimmed mean bits in error by Head, by Test Zone 9, + temp.str("");temp.clear(); + temp << "Current H2SAT trimmed mean bits in error Zone 0 by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_Word0(vFarmFrame[page].reliPage.currentH2SAT[loopCount].zone0) * 0.10); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.currentH2SAT[loopCount].zone0, m_showStatusBits); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 0 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT trimmed mean bits in error Zone 1 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.01f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].reliPage.currentH2SAT[loopCount].middle)) *.1)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.currentH2SAT[loopCount].middle, m_showStatusBits); //!< [24] Current H2SAT trimmed mean bits in error by Head, by Test Zone 9, + temp.str("");temp.clear(); + temp << "Current H2SAT trimmed mean bits in error Zone 1 by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_Word0(vFarmFrame[page].reliPage.currentH2SAT[loopCount].zone1) * 0.10); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.currentH2SAT[loopCount].zone1, m_showStatusBits); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 1 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT trimmed mean bits in error Zone 2 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.01f", static_cast (M_Word0(check_Status_Strip_Status(vFarmFrame[page].reliPage.currentH2SAT[loopCount].outer)) *.1)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.currentH2SAT[loopCount].outer, m_showStatusBits); //!< [24] Current H2SAT trimmed mean bits in error by Head, by Test Zone 9, + temp.str("");temp.clear(); + temp << "Current H2SAT trimmed mean bits in error Zone 2 by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_Word0(vFarmFrame[page].reliPage.currentH2SAT[loopCount].zone2) * 0.10); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.currentH2SAT[loopCount].zone2, m_showStatusBits); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 2 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Current H2SAT iterations to converge Test Zone 0 by Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%0.01f", static_cast (M_Word0(check_Status_Strip_Status(vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].inner))) *.1); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].inner, m_showStatusBits); //!< [24] Qword[24][3] Current H2SAT iterations to converge by Head, by Test Zone 9, 11 + temp.str("");temp.clear(); + temp << "Current H2SAT iterations to converge Test Zone 0 by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_Word0(vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].zone0) * 0.10); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].zone0, m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 0 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT iterations to converge Test Zone 1 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.01f", static_cast (M_Word0(check_Status_Strip_Status(vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].middle)))*.1); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].middle, m_showStatusBits); //!< [24] Qword[24][3] Current H2SAT iterations to converge by Head, by Test Zone 9, 11 + temp.str("");temp.clear(); + temp << "Current H2SAT iterations to converge Test Zone 1 by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_Word0(vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].zone1) * 0.10); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].zone1, m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 1 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT iterations to converge Test Zone 2 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.01f", static_cast (M_Word0(check_Status_Strip_Status(vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].outer))) *.1); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].outer, m_showStatusBits); //!< [24] Qword[24][3] Current H2SAT iterations to converge by Head, by Test Zone 9, 11 + temp.str("");temp.clear(); + temp << "Current H2SAT iterations to converge Test Zone 2 by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_Word0(vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].zone2) * 0.10); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.currentH2SATIterations[loopCount].zone2, m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 2 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Current H2SAT percentage of codewords at iteration level by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.currentH2SATPercentage[loopCount], false, m_showStatusBits); //!< [24] Qword[24] Current H2SAT percentage of codewords at iteration level by Head, averaged + temp.str("");temp.clear(); + temp << "Current H2SAT percentage of codewords at iteration level by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.currentH2SATPercentage[loopCount], false, m_showStatusBits); //!< [24] Qword[24] Current H2SAT percentage of codewords at iteration level by Head, averaged } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Current H2SAT amplitude by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.currentH2SATamplitude[loopCount], false, m_showStatusBits); //!< [24] Qword[24] Current H2SAT amplitude by Head, averaged across Test Zones 9 + temp.str("");temp.clear(); + temp << "Current H2SAT amplitude by Head " << std::dec << loopCount;// Head count + set_json_int_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.currentH2SATamplitude[loopCount], m_showStatusBits); //!< [24] Qword[24] Current H2SAT amplitude by Head, averaged across Test Zones 9 } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Current H2SAT asymmetry by Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%0.01f", static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].reliPage.currentH2SATasymmetry[loopCount]))) * .1); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.currentH2SATasymmetry[loopCount], m_showStatusBits); //!< [24] Qword[24] Current H2SAT asymmetry by Head, averaged across Test Zones + temp.str("");temp.clear(); + temp << "Current H2SAT asymmetry by Head " << std::dec << loopCount;// Head count + set_json_float_With_Status(headInfo, temp.str(), static_cast(M_WordInt0(vFarmFrame[page].reliPage.currentH2SATasymmetry[loopCount])) * 0.1, vFarmFrame[page].reliPage.currentH2SATasymmetry[loopCount], m_showStatusBits); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Number of Reallocated Sectors by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.gList[loopCount], false, m_showStatusBits); //!< [24] Number of Reallocated Sectors per head + temp.str("");temp.clear(); + temp << "Number of Reallocated Sectors by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.gList[loopCount], false, m_showStatusBits); //!< [24] Number of Reallocated Sectors per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Number of Reallocation Candidate Sectors by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.pendingEntries[loopCount], false, m_showStatusBits); //!< [24] Number of Reallocation Candidate Sectors per head + temp.str("");temp.clear(); + temp << "Number of Reallocation Candidate Sectors by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.pendingEntries[loopCount], false, m_showStatusBits); //!< [24] Number of Reallocation Candidate Sectors per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "DOS Ought to scan count by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.oughtDOS[loopCount], false, m_showStatusBits); //!< [24] DOS Ought to scan count per head + temp.str("");temp.clear(); + temp << "DOS Ought to scan count by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.oughtDOS[loopCount], false, m_showStatusBits); //!< [24] DOS Ought to scan count per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "DOS needs to scans count by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.needDOS[loopCount], false, m_showStatusBits); //!< [24] DOS needs to scans count per head + temp.str("");temp.clear(); + temp << "DOS needs to scans count by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.needDOS[loopCount], false, m_showStatusBits); //!< [24] DOS needs to scans count per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "DOS write Fault scans by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.writeDOSFault[loopCount], false, m_showStatusBits); //!< [24] DOS write Fault scans per head + temp.str("");temp.clear(); + temp << "DOS write Fault scans by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.writeDOSFault[loopCount], false, m_showStatusBits); //!< [24] DOS write Fault scans per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Write Power On (hrs) by Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%0.04f", ROUNDF(static_cast(M_DoubleWord0(vFarmFrame[page].reliPage.writePOH[loopCount])) / 3600,1000)); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.writePOH[loopCount], m_showStatusBits); //!< [24] write POS in sec value from most recent SMART Frame by head + temp.str("");temp.clear(); + temp << "Write Power On (hrs) by Head " << std::dec << loopCount;// Head count + set_json_float_With_Status(headInfo, temp.str().c_str(), static_cast(M_DoubleWord0(vFarmFrame[page].reliPage.writePOH[loopCount])) / 3600, vFarmFrame[page].reliPage.writePOH[loopCount], m_showStatusBits); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "DOS Write Count Threshold by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.countDOSWrite[loopCount], false, m_showStatusBits); //!< [24] DOS Write Count Threshold per head + temp.str("");temp.clear(); + temp << "DOS Write Count Threshold by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.countDOSWrite[loopCount], false, m_showStatusBits); //!< [24] DOS Write Count Threshold per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "Second MR Head Resistance by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.secondMRHeadResistance[loopCount], false, m_showStatusBits); //!< [24] DOS Write Count Threshold per head + temp.str("");temp.clear(); + temp << "Second MR Head Resistance by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.secondMRHeadResistance[loopCount], false, m_showStatusBits); //!< [24] DOS Write Count Threshold per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "FAFH Measurement Status by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.FAFHMeasurementStatus[loopCount], false, m_showStatusBits); //!< [24] FAFH Measurement Status, bitwise OR across all diameters per head + temp.str("");temp.clear(); + temp << "FAFH Measurement Status by Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str(), vFarmFrame[page].reliPage.FAFHMeasurementStatus[loopCount], false, m_showStatusBits); //!< [24] FAFH Measurement Status, bitwise OR across all diameters per head } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "FAFH HF-LF Relative Amplitude by Head %" PRIu32"", loopCount); - //set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.FAFHRelativeAmptitude[loopCount], false, m_showStatusBits); //!< [24] FAFH HF/LF Relative Amplitude in tenths, maximum value across all 3 zones per head - - snprintf((char*)myStr.c_str(), BASIC, "%04.2f", static_cast(M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].reliPage.FAFHRelativeAmptitude[loopCount]))) * .1); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].reliPage.FAFHRelativeAmptitude[loopCount], m_showStatusBits); + temp.str("");temp.clear(); + temp << "FAFH Relative Amplitude by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_WordInt0(vFarmFrame[page].reliPage.FAFHRelativeAmptitude[loopCount]) * 0.1); + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.FAFHRelativeAmptitude[loopCount], m_showStatusBits); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "FAFH Bit Error Rate inner by Head %" PRIu32"", loopCount); - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].inner, false, m_showStatusBits); //!< [24][3] FAFH Bit Error Rate, write then read BER on reserved tracks + uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].inner); //!< [24][3] FAFH Bit Error Rate, write then read BER on reserved tracks + whole = M_WordInt2(dsHead); // get 5:4 whole part of the float + double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } + temp.str("");temp.clear(); + temp << "FAFH Bit Error Rate inner by Head " << std::dec << loopCount;// Head count + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].inner, m_showStatusBits); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Bit Error Rate middle by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].middle, false, m_showStatusBits); //!< [24][3] FAFH Bit Error Rate, write then read BER on reserved tracks + uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].middle); //!< [24][3] FAFH Bit Error Rate, write then read BER on reserved tracks + whole = M_WordInt2(dsHead); // get 5:4 whole part of the float + double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } + temp.str("");temp.clear(); + temp << "FAFH Bit Error Rate middle by Head " << std::dec << loopCount;// Head count + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].middle, m_showStatusBits); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Bit Error Rate outer by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headInfo, (char*)myHeader.c_str(), vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].outer, false, m_showStatusBits); //!< [24][3] FAFH Bit Error Rate, write then read BER on reserved tracks + uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].outer); //!< [24][3] FAFH Bit Error Rate, write then read BER on reserved tracks + whole = M_WordInt2(dsHead); // get 5:4 whole part of the float + double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } + temp.str("");temp.clear(); + temp << "FAFH Bit Error Rate outer by Head " << std::dec << loopCount;// Head count + set_json_float_With_Status(headInfo, temp.str().c_str(), number, vFarmFrame[page].reliPage.FAFHBitErrorRate[loopCount].outer, m_showStatusBits); } - for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "FAFH Low Frequency Passive Clearance in ADC counts inner by Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_DoubleWord0(vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].inner)) / 10.0); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), false, m_showStatusBits); //!< [24][3] FAFH Low Frequency Passive Clearance in ADC counts + temp.str(""); temp.clear(); + temp << "FAFH LF Passive Clearance OD by Head " << std::dec << loopCount;// Head count + set_json_int_Check_Status(headInfo, temp.str().c_str(), M_DoubleWord0(vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].outer), vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].outer, m_showStatusBits); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Low Frequency Passive Clearance in ADC counts middle by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_DoubleWord0(vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].middle)) / 10.0); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), false, m_showStatusBits); //!< [24][3] FAFH Low Frequency Passive Clearance in ADC counts + temp.str("");temp.clear(); + temp << "FAFH LF Passive Clearance ID by Head " << std::dec << loopCount;// Head count + set_json_int_Check_Status(headInfo, temp.str().c_str(), M_DoubleWord0(vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].inner), vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].inner, m_showStatusBits); } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Low Frequency Passive Clearance in ADC counts outer by Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_DoubleWord0(vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].outer)) / 10.0); // Head count - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), false, m_showStatusBits); //!< [24][3] FAFH Low Frequency Passive Clearance in ADC counts + temp.str("");temp.clear(); + temp << "FAFH LF Passive Clearance MD by Head " << std::dec << loopCount;// Head count + set_json_int_Check_Status(headInfo, temp.str().c_str(), M_DoubleWord0(vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].middle), vFarmFrame[page].reliPage.FAFHLowFrequency[loopCount].middle, m_showStatusBits); //!< [24][3] FAFH Low Frequency Passive Clearance in ADC counts } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char *)myHeader.c_str(), BASIC, "FAFH High Frequency Passive Clearance in ADC counts inner by Head %" PRIu32"", loopCount); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_DoubleWord0(vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].inner)) / 10.0); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), false, m_showStatusBits); //!< [24][3] FAFH High Frequency Passive Clearance in ADC counts + temp.str("");temp.clear(); + temp << "FAFH HF Passive Clearance OD by Head " << std::dec << loopCount;// Head count + set_json_int_Check_Status(headInfo, temp.str().c_str(), M_DoubleWord0(vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].outer), vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].outer, m_showStatusBits); //!< [24][3] FAFH High Frequency Passive Clearance in ADC counts } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "FAFH High Frequency Passive Clearance in ADC counts middle by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_DoubleWord0(vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].middle)) / 10.0); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), false, m_showStatusBits); //!< [24][3] FAFH High Frequency Passive Clearance in ADC counts + temp.str("");temp.clear(); + temp << "FAFH HF Passive Clearance ID by Head " << std::dec << loopCount;// Head count + set_json_int_Check_Status(headInfo, temp.str().c_str(), M_DoubleWord0(vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].inner), vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].inner, m_showStatusBits); //!< [24][3] FAFH High Frequency Passive Clearance in ADC counts } for (loopCount = 0; loopCount < m_heads; ++loopCount) { - snprintf((char*)myHeader.c_str(), BASIC, "FAFH High Frequency Passive Clearance in ADC counts outer by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_DoubleWord0(vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].outer)) / 10.0); - set_json_string_With_Status(headInfo, (char*)myHeader.c_str(), (char*)myStr.c_str(), false, m_showStatusBits); //!< [24][3] FAFH High Frequency Passive Clearance in ADC counts + temp.str("");temp.clear(); + temp << "FAFH HF Passive Clearance MD by Head " << std::dec << loopCount;// Head count + set_json_int_Check_Status(headInfo, temp.str().c_str(), M_DoubleWord0(vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].middle), vFarmFrame[page].reliPage.FAFHHighFrequency[loopCount].middle, m_showStatusBits); //!< [24][3] FAFH High Frequency Passive Clearance in ADC counts + } + //4.19 + if (m_MajorRev >= 4 && m_MinorRev >= 19) { + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Total Laser Field iterations performed for Head " << std::dec << loopCount;// Head count + set_json_64_bit_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.numberOfLFAIterations[loopCount], false, m_showStatusBits); + } + + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Laser Operating Current inner Diameter by Head " << std::dec << loopCount;// Head count + myHeader.assign(temp.str()); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(1) << std::setfill('0') << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].reliPage.laserOperCurrent[loopCount].inner))); + set_json_string_With_Status(headInfo, myHeader, temp.str(), vFarmFrame[page].reliPage.laserOperCurrent[loopCount].inner, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Laser Operating Current middle Diameter by Head " << std::dec << loopCount;// Head count + myHeader.assign(temp.str()); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(1) << std::setfill('0') << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].reliPage.laserOperCurrent[loopCount].middle))); + set_json_string_With_Status(headInfo, myHeader, temp.str(), vFarmFrame[page].reliPage.laserOperCurrent[loopCount].middle, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Laser Operating Current outer Diameter by Head " << std::dec << loopCount;// Head count + myHeader.assign(temp.str()); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(1) << std::setfill('0') << static_cast (M_Word0(check_Status_Strip_Status(vFarmFrame[page].reliPage.laserOperCurrent[loopCount].outer))); + set_json_string_With_Status(headInfo, myHeader, temp.str(), vFarmFrame[page].reliPage.laserOperCurrent[loopCount].outer, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Post LFA Optimal BER inner Diameter by Head " << std::dec << loopCount;// Head count + myHeader.assign(temp.str()); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(1) << std::setfill('0') << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].reliPage.postLFABER[loopCount].inner))); + set_json_string_With_Status(headInfo, myHeader, temp.str(), vFarmFrame[page].reliPage.postLFABER[loopCount].inner, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Post LFA Optimal BER middle Diameter by Head " << std::dec << loopCount;// Head count + myHeader.assign(temp.str()); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(1) << std::setfill('0') << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].reliPage.postLFABER[loopCount].middle))); + set_json_string_With_Status(headInfo, myHeader, temp.str(), vFarmFrame[page].reliPage.postLFABER[loopCount].middle, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Post LFA Optimal BER outer Diameter by Head " << std::dec << loopCount;// Head count + myHeader.assign(temp.str()); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(1) << std::setfill('0') << static_cast (M_Word0(check_Status_Strip_Status(vFarmFrame[page].reliPage.postLFABER[loopCount].outer))); + set_json_string_With_Status(headInfo, myHeader, temp.str(), vFarmFrame[page].reliPage.postLFABER[loopCount].outer, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Reader Writer Offset Iterations by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.numOfReaderWriterOffset[loopCount], m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Micro Jog Offset Zone 0 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status( headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.microJogOffset[loopCount].zone0, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Micro Jog Offset Zone 1 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.microJogOffset[loopCount].zone1, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Micro Jog Offset Zone 2 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.microJogOffset[loopCount].zone2, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Pre LFA Bit Error Rate Zone 0 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.preLFABitErrorRate[loopCount].zone0, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Pre LFA Bit Error Rate Zone 1 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.preLFABitErrorRate[loopCount].zone1, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Pre LFA Bit Error Rate Zone 2 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.preLFABitErrorRate[loopCount].zone2, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Zero Percent shift bit Error Rate Zone 0 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.zeroPercentShiftErrorRate[loopCount].zone0, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Zero Percent shift bit Error Rate Zone 1 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.zeroPercentShiftErrorRate[loopCount].zone1, m_showStatusBits); + } + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + temp.str("");temp.clear(); + temp << "Zero Percent shift bit Error Rate Zone 2 by Head " << std::dec << loopCount; // Head count + set_json_int_With_Status(headInfo, temp.str().c_str(), vFarmFrame[page].reliPage.zeroPercentShiftErrorRate[loopCount].zone2, m_showStatusBits); + } } json_push_back(masterData, headInfo); @@ -1487,7 +2019,7 @@ void CATA_Farm_Log::print_Page_Without_Drive_Info(JSONNODE *masterData, uint32_t print_Reli_Information(masterData, page); print_Head_Information(masterData, page); } - + } //----------------------------------------------------------------------------- // @@ -1511,4 +2043,4 @@ void CATA_Farm_Log::print_Page_One_Node(JSONNODE * masterData) print_All_Pages(pageInfo); json_push_back(masterData, pageInfo); } -} \ No newline at end of file +} diff --git a/src/Seagate/CFARM_Log.cpp b/src/Seagate/CFARM_Log.cpp index 718bd66..f347d57 100644 --- a/src/Seagate/CFARM_Log.cpp +++ b/src/Seagate/CFARM_Log.cpp @@ -2,7 +2,7 @@ // CFARM_Log.cpp Implementation of class CFARMLog // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -70,7 +70,7 @@ CFARMLog::CFARMLog(const std::string & fileName,bool showStatus) { m_LogSize = cCLog->get_Size(); bufferData = new uint8_t[m_LogSize]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(bufferData, cCLog->get_Buffer(), m_LogSize); #else memcpy_s(bufferData, m_LogSize, cCLog->get_Buffer(), m_LogSize);// copy the buffer data to the class member pBuf @@ -121,7 +121,7 @@ CFARMLog::CFARMLog(const std::string & fileName) { m_LogSize = cCLog->get_Size(); bufferData = new uint8_t[m_LogSize]; // new a buffer to the point -#ifndef _WIN64 +#ifndef __STDC_SECURE_LIB__ memcpy(bufferData, cCLog->get_Buffer(), m_LogSize); #else memcpy_s(bufferData, m_LogSize, cCLog->get_Buffer(), m_LogSize);// copy the buffer data to the class member pBuf @@ -158,15 +158,15 @@ CFARMLog::CFARMLog(const std::string & fileName) //! \return // //--------------------------------------------------------------------------- -CFARMLog::CFARMLog(uint8_t *bufferData, size_t bufferSize, bool showStatus) - :bufferData(bufferData) +CFARMLog::CFARMLog(uint8_t *farmbufferData, size_t bufferSize, bool showStatus) + :bufferData(farmbufferData) , m_LogSize(bufferSize) , m_status(IN_PROGRESS) , m_isScsi(false) , m_shwoStatus(showStatus) , m_bufferdelete(false) { - if (bufferData != NULL) + if (farmbufferData != NULL) { m_isScsi = is_Device_Scsi(); m_status = IN_PROGRESS; @@ -219,7 +219,7 @@ bool CFARMLog::is_Device_Scsi() { if (M_GETBITRANGE(bufferData[0], 5, 0) == 0x3D ) { - if (bufferData[1] == 03 || bufferData[1] == 04) + if (bufferData[1] == 03 || bufferData[1] == 04 || (bufferData[1] >= FARM_TIME_SERIES_0 && bufferData[1] <= FARM_TEMP_TRIGGER_LOG_PAGE)) { return true; } @@ -247,8 +247,9 @@ eReturnValues CFARMLog::parse_Device_Farm_Log(JSONNODE *masterJson) eReturnValues retStatus = MEMORY_FAILURE; if (m_isScsi) { + uint8_t subpage = bufferData[1]; CSCSI_Farm_Log *pCFarm; - pCFarm = new CSCSI_Farm_Log((uint8_t *)bufferData, m_LogSize, m_shwoStatus); + pCFarm = new CSCSI_Farm_Log(bufferData, m_LogSize, subpage, m_shwoStatus); if (pCFarm->get_Log_Status() == SUCCESS) { pCFarm->print_All_Pages(masterJson); @@ -263,7 +264,7 @@ eReturnValues CFARMLog::parse_Device_Farm_Log(JSONNODE *masterJson) else { CATA_Farm_Log *pCFarm; - pCFarm = new CATA_Farm_Log((uint8_t *)bufferData, m_LogSize, m_shwoStatus); + pCFarm = new CATA_Farm_Log(bufferData, m_LogSize, m_shwoStatus); if (pCFarm->get_Log_Status() == IN_PROGRESS) { try diff --git a/src/Seagate/CScsi_Farm_Log.cpp b/src/Seagate/CScsi_Farm_Log.cpp index 2b5438a..997a88f 100644 --- a/src/Seagate/CScsi_Farm_Log.cpp +++ b/src/Seagate/CScsi_Farm_Log.cpp @@ -2,7 +2,7 @@ // CScsi_Farm_Log.cpp // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates, All Rights Reserved +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates, All Rights Reserved // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -35,14 +35,18 @@ CSCSI_Farm_Log::CSCSI_Farm_Log() , m_heads(0) , m_MaxHeads(0) , m_copies(0) + , m_MajorRev(0) , m_MinorRev(0) , pBuf() , m_status(IN_PROGRESS) , m_logParam() , m_pageParam() + , m_pHeader() , m_pDriveInfo() , m_alreadySet(false) - , m_showStatusBits(false) + , m_showStatusBits(false) + , m_fromScsiLogPages(false) + , m_farmSubPage(0) { m_status = IN_PROGRESS; @@ -63,26 +67,101 @@ CSCSI_Farm_Log::CSCSI_Farm_Log() // //--------------------------------------------------------------------------- -CSCSI_Farm_Log::CSCSI_Farm_Log( uint8_t *bufferData, size_t bufferSize, bool showStatus) +CSCSI_Farm_Log::CSCSI_Farm_Log(uint8_t* bufferData, size_t bufferSize, uint8_t subPage, bool fromLogPage) + : m_totalPages() + , m_logSize(static_cast(bufferSize)) + , m_pageSize(0) + , m_heads(0) + , m_MaxHeads(0) + , m_copies(0) + , m_MajorRev(0) + , m_MinorRev(0) + , pBuf(NULL) + , m_status(IN_PROGRESS) + , m_logParam() + , m_pageParam() + , m_pHeader() + , m_pDriveInfo() + , m_alreadySet(false) + , m_showStatusBits(false) + , m_fromScsiLogPages(fromLogPage) + , m_farmSubPage(subPage) +{ + m_status = IN_PROGRESS; + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("SCSI FARM Log \n"); + } + + pBuf = new uint8_t[bufferSize]; // new a buffer to the point + m_pHeader = new sScsiFarmHeader(); +#ifndef __STDC_SECURE_LIB__ + memcpy(pBuf, bufferData, bufferSize); +#else + memcpy_s(pBuf, bufferSize, bufferData, bufferSize);// copy the buffer data to the class member pBuf +#endif + if (pBuf != NULL) + { + if (init_Header_Data() == SUCCESS) // init the data for getting the log + { + m_status = parse_Farm_Log(); + } + else + { + m_status = FAILURE; + } + } + else + { + m_status = FAILURE; + } + delete[] pBuf; +} +//----------------------------------------------------------------------------- +// +//! \fn CSCSI_Farm_Log::CSCSI_Farm_Log() +// +//! \brief +//! Description: default Class constructor +// +// Entry: +//! \parma securityPrintLevel = the level of the print +//! \param bufferData = pointer to the buffer data. +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- + +CSCSI_Farm_Log::CSCSI_Farm_Log( uint8_t *bufferData, size_t bufferSize, uint8_t subPage, bool fromLogPage, bool showStatus) : m_totalPages() - , m_logSize(0) + , m_logSize(static_cast(bufferSize)) , m_pageSize(0) , m_heads(0) , m_MaxHeads(0) , m_copies(0) + , m_MajorRev(0) , m_MinorRev(0) , pBuf(NULL) , m_status(IN_PROGRESS) , m_logParam() , m_pageParam() + , m_pHeader() , m_pDriveInfo() , m_alreadySet(false) , m_showStatusBits(showStatus) + , m_fromScsiLogPages(fromLogPage) + , m_farmSubPage(subPage) { m_status = IN_PROGRESS; + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("SCSI FARM Log \n"); + } - pBuf = new uint8_t[bufferSize]; // new a buffer to the point -#ifndef _WIN64 + pBuf = new uint8_t[bufferSize]; // new a buffer to the point + m_pHeader = new sScsiFarmHeader(); // new the pHeader pointer +#ifndef __STDC_SECURE_LIB__ memcpy(pBuf, bufferData, bufferSize); #else memcpy_s(pBuf, bufferSize, bufferData, bufferSize);// copy the buffer data to the class member pBuf @@ -124,6 +203,7 @@ CSCSI_Farm_Log::~CSCSI_Farm_Log() { vFarmFrame.clear(); // clear the vector } + } //----------------------------------------------------------------------------- // @@ -147,17 +227,27 @@ eReturnValues CSCSI_Farm_Log::init_Header_Data() } else { - m_logParam = (sScsiLogParameter *)&pBuf[0]; - m_logSize = m_logParam->length; // set the class log size - byte_Swap_16(&m_logSize); - - m_pHeader = (sScsiFarmHeader *)&pBuf[4]; - swap_Bytes_sFarmHeader(m_pHeader); // swap all the bytes for the header + + if (m_fromScsiLogPages == true) + { + m_pHeader->pPageHeader = *reinterpret_cast(&pBuf[0]); + swap_Bytes_sFarmHeader(m_pHeader, &pBuf[4]); // swap all the bytes for the header + } + else + { + m_logParam = reinterpret_cast(&pBuf[0]); + m_logSize = m_logParam->length; // set the class log size + byte_Swap_16(&m_logSize); + + m_pHeader->pPageHeader = *reinterpret_cast(&pBuf[4]); + swap_Bytes_sFarmHeader(m_pHeader, &pBuf[8]); // swap all the bytes for the header + } + m_totalPages = M_DoubleWord0(m_pHeader->farmHeader.pagesSupported); // get the total pages m_pageSize = M_DoubleWord0(m_pHeader->farmHeader.pageSize); // get the page size if (check_For_Active_Status(&m_pHeader->farmHeader.headsSupported)) // the the number of heads if supported { - if ((m_pHeader->farmHeader.headsSupported & 0x00FFFFFFFFFFFFFFLL) > 0) + if ((m_pHeader->farmHeader.headsSupported & UINT64_C(0x00FFFFFFFFFFFFFF)) > 0) { m_heads = M_DoubleWord0(m_pHeader->farmHeader.headsSupported); m_MaxHeads = M_DoubleWord0(m_pHeader->farmHeader.headsSupported); @@ -185,7 +275,7 @@ bool CSCSI_Farm_Log::strip_Active_Status(uint64_t *value) { if( check_For_Active_Status(value)) { - *value = *value & 0x00FFFFFFFFFFFFFFLL; + *value = *value & UINT64_C(0x00FFFFFFFFFFFFFF); return true; } return false; @@ -205,9 +295,9 @@ bool CSCSI_Farm_Log::strip_Active_Status(uint64_t *value) //! Void // //--------------------------------------------------------------------------- -void CSCSI_Farm_Log::set_Head_Header(std::string &headerName, eLogPageTypes index) +bool CSCSI_Farm_Log::set_Head_Header(std::string &headerName, eLogPageTypes index) { - + bool ret = true; switch (index) { case FARM_HEADER_PARAMETER: @@ -218,7 +308,7 @@ void CSCSI_Farm_Log::set_Head_Header(std::string &headerName, eLogPageTypes inde case RELIABILITY_STATISTICS_PARAMETER: case GENERAL_DRIVE_INFORMATION_06: case ENVIRONMENT_STATISTICS_PAMATER_07: - case RESERVED_FOR_FUTURE_STATISTICS_3: + case WORKLOAD_STATISTICS_PAMATER_08: case RESERVED_FOR_FUTURE_STATISTICS_4: case RESERVED_FOR_FUTURE_STATISTICS_5: case RESERVED_FOR_FUTURE_STATISTICS_6: @@ -305,13 +395,23 @@ void CSCSI_Farm_Log::set_Head_Header(std::string &headerName, eLogPageTypes inde case CUM_LIFETIME_UNRECOVERABLE_READ_UNIQUE_PER_HEAD: headerName = "Cumlative Lifetime Unrecoverable Read Unique by head"; break; - case RESERVED_FOR_FUTURE_EXPANSION_4: - case RESERVED_FOR_FUTURE_EXPANSION_5: - case RESERVED_FOR_FUTURE_EXPANSION_6: - case RESERVED_FOR_FUTURE_EXPANSION_7: - case RESERVED_FOR_FUTURE_EXPANSION_8: - case RESERVED_FOR_FUTURE_EXPANSION_9: - headerName = "Something is wrong. Please report error SAS FARM 613"; + case TOTAL_LASER_FIELD_ADJUST_ITERATIONS: + headerName = "Number of total Laser Field Adjust iterations performed"; + break; + case TOTAL_READER_WRITER_OFFSET_ITERATIONS_PERFORMED: + headerName = "Number of total Reader Writer Offset iterations performed"; + break; + case PRE_LFA_ZONE_0: + headerName = "Pre LFA Zone 0 Bit Error Rate"; + break; + case PRE_LFA_ZONE_1: + headerName = "Pre LFA Zone 1 Bit Error Rate"; + break; + case PRE_LFA_ZONE_2: + headerName = "Pre LFA Zone 2 Bit Error Rate"; + break; + case ZERO_PERCENT_SHIFT: + headerName = "Zero Percent Shift Zone 0 Bit Error Rate"; break; case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_0: headerName = "Current H2SAT trimmed mean bits in error Test Zone 0"; @@ -331,17 +431,35 @@ void CSCSI_Farm_Log::set_Head_Header(std::string &headerName, eLogPageTypes inde case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_2: headerName = "Current H2SAT iterations to converge Test Zone 2"; break; - case RESERVED_FOR_FUTURE_EXPANSION_10: - case RESERVED_FOR_FUTURE_EXPANSION_11: - case RESERVED_FOR_FUTURE_EXPANSION_12: - case RESERVED_FOR_FUTURE_EXPANSION_13: - case RESERVED_FOR_FUTURE_EXPANSION_14: - case RESERVED_FOR_FUTURE_EXPANSION_15: - case RESERVED_FOR_FUTURE_EXPANSION_16: - case RESERVED_FOR_FUTURE_EXPANSION_17: - case RESERVED_FOR_FUTURE_EXPANSION_18: - case RESERVED_FOR_FUTURE_EXPANSION_19: - headerName = "Something is wrong. Please report error SAS FARM 614"; + case LASER_OPERATING_ZONE_0: + headerName = "Laser Operating Current Zone 2"; + break; + case LASER_OPERATING_ZONE_1: + headerName = "Laser Operating Current Zone 2"; + break; + case LASER_OPERATING_ZONE_2: + headerName = "Laser Operating Current Zone 2"; + break; + case POST_LFA_OPTIMAL_BER_ZONE_0: + headerName = "Post LFA Optimal BER Zone 0"; + break; + case POST_LFA_OPTIMAL_BER_ZONE_1: + headerName = "Post LFA Optimal BER Zone 1"; + break; + case POST_LFA_OPTIMAL_BER_ZONE_2: + headerName = "Post LFA Optimal BER Zone 2"; + break; + case MICRO_JOG_OFFSET_ZONE_0: + headerName = "Micro Jog Offset Zone 0"; + break; + case MICRO_JOG_OFFSET_ZONE_1: + headerName = "Micro Jog Offset Zone 1"; + break; + case MICRO_JOG_OFFSET_ZONE_2: + headerName = "Micro Jog Offset Zone 2"; + break; + case ZERO_PERCENT_SHIFT_ZONE_1: + headerName = "Zero Percent Shift Zone 1"; break; case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_OUTER: if (!m_alreadySet) @@ -401,157 +519,11 @@ void CSCSI_Farm_Log::set_Head_Header(std::string &headerName, eLogPageTypes inde break; default: headerName = "Something is wrong. Please report error SAS FARM 615"; + ret = false; break; } -} -//----------------------------------------------------------------------------- -// -//! \fn create_Serial_Number() -// -//! \brief -//! Description: takes the two uint64 bit seiral number values and create a string serial number -// -// Entry: -//! \param serialNumber - pointer to the serial number, where once constructed, will hold the serial number of the drive -//! \param idInfo = pointer to the drive info structure that holds the infromation needed -// -// Exit: -//! \return serialNumber = the string serialNumber -// -//--------------------------------------------------------------------------- -void CSCSI_Farm_Log::create_Serial_Number(std::string &serialNumber, const sScsiDriveInfo * const idInfo) -{ - uint64_t sn = 0; - uint64_t sn1 = idInfo->serialNumber & 0x00FFFFFFFFFFFFFFLL; - uint64_t sn2 = idInfo->serialNumber2 & 0x00FFFFFFFFFFFFFFLL; - if (m_MajorRev < MAJORVERSION3) - { - sn = (sn2 << 32 | (sn1 )); - byte_Swap_64(&sn); - } - else - { - sn = (sn1 | (sn2 << 32)); - byte_Swap_64(&sn); - } - serialNumber.resize(SERIAL_NUMBER_LEN ); - memset((char*)serialNumber.c_str(),0, SERIAL_NUMBER_LEN ); - strncpy((char *)serialNumber.c_str(), (char*)&sn, SERIAL_NUMBER_LEN); -} -//----------------------------------------------------------------------------- -// -//! \fn create_World_Wide_Name() -// -//! \brief -//! Description: takes the two uint64 bit world wide name values and create a string world wide name -// -// Entry: -//! \param worldWideName - pointer to the world wide name, where once constructed, will hold the world wide name of the drive -//! \param idInfo = pointer to the drive info structure that holds the infromation needed -// -// Exit: -//! \return wordWideName = the string wordWideName -// -//--------------------------------------------------------------------------- -void CSCSI_Farm_Log::create_World_Wide_Name(std::string &worldWideName, const sScsiDriveInfo * const idInfo) -{ - uint64_t wwn = 0; - wwn = (idInfo->worldWideName & 0x00FFFFFFFFFFFFFFLL) | ((idInfo->worldWideName2 & 0x00FFFFFFFFFFFFFFLL) << 32); - worldWideName.resize(WORLD_WIDE_NAME_LEN); - memset((char *)worldWideName.c_str(), 0, WORLD_WIDE_NAME_LEN); - snprintf((char *)worldWideName.c_str(), WORLD_WIDE_NAME_LEN, "0x%" PRIX64"", wwn); -} -//----------------------------------------------------------------------------- -// -//! \fn create_Firmware_String() -// -//! \brief -//! Description: takes the two uint64 bit firmware Rev values and create a string firmware Rev -// -// Entry: -//! \param firmwareRev - pointer to the firmware Rev, where once constructed, will hold the firmware Rev of the drive -//! \param idInfo = pointer to the drive info structure that holds the infromation needed -// -// Exit: -//! \return firmwareRev = the string firmwareRev -// -//--------------------------------------------------------------------------- -void CSCSI_Farm_Log::create_Firmware_String(std::string &firmwareRev, const sScsiDriveInfo * const idInfo) -{ - uint64_t firm = 0; - uint64_t firm1 = idInfo->firmware & 0x00FFFFFFFFFFFFFFLL; - uint64_t firm2 = idInfo->firmwareRev & 0x00FFFFFFFFFFFFFFLL; - firm = (firm2 | (firm1 << 32)); - byte_Swap_64(&firm); - firmwareRev.resize(8); - memset((char *)firmwareRev.c_str(), 0, 8); - strncpy((char *)firmwareRev.c_str(), (char*)&firm, 8); -} -//----------------------------------------------------------------------------- -// -//! \fn create_Device_Interface_String() -// -//! \brief -//! Description: takes the two uint64 bit Devie interface string values and create a string device interface -// -// Entry: -//! \param dInterface - pointer to the Devie interface v, where once constructed, will hold the Devie interface of the drive -//! \param idInfo = pointer to the drive info structure that holds the infromation needed -// -// Exit: -//! \return dInterface = the string dInterface -// -//--------------------------------------------------------------------------- -void CSCSI_Farm_Log::create_Device_Interface_String(std::string &dInterface, const sScsiDriveInfo * const idInfo) -{ - uint64_t dFace = 0; - dFace = (idInfo->deviceInterface & 0x00FFFFFFFFFFFFFFLL); - dInterface.resize(DEVICE_INTERFACE_LEN); - memset((char *)dInterface.c_str(), 0, DEVICE_INTERFACE_LEN); - strncpy((char *)dInterface.c_str(), (char*)&dFace, DEVICE_INTERFACE_LEN); - -} -//----------------------------------------------------------------------------- -// -//! \fn create_Model_Number_String() -// -//! \brief -//! Description: fill in the model number of the drive -// -// Entry: -//! \param model - pointer to the model number of the drive -//! \param idInfo = pointer to the drive info structure that holds the infromation needed -// -// Exit: -//! \return void -// -//--------------------------------------------------------------------------- -void CSCSI_Farm_Log::create_Model_Number_String(std::string &model, sGeneralDriveInfoPage06 *idInfo) -{ -#define MAXSIZE 4 - uint32_t modelParts[MAXSIZE] = { 0,0,0,0}; - // loop for and get the information from the lower bits - for (uint8_t i = 0; i < MAXSIZE; i++) - { - modelParts[i] = M_DoubleWord0(idInfo->productID[i]); - byte_Swap_32(&modelParts[i]); - } - // temp string for coping the hex to text, have to resize for c98 issues - std::string tempStr = ""; - tempStr.resize(MODEL_NUMBER_LEN); - model.resize(MODEL_NUMBER_LEN); - // memset them to 0 - memset((char *)model.c_str(), 0, MODEL_NUMBER_LEN); - memset((char *)tempStr.c_str(), 0, MODEL_NUMBER_LEN); - // loop to copy the info into the modeleNumber string - for (uint8_t n = 0; n < MAXSIZE; n++) - { - strncpy((char *)tempStr.c_str(), (char*)&modelParts[n], MAXSIZE); - strncat((char *)model.c_str(), (char*)tempStr.c_str(), sizeof(tempStr)); - } - remove_Trailing_Whitespace((char *)model.c_str()); - + return ret; } //----------------------------------------------------------------------------- // @@ -669,6 +641,16 @@ bool CSCSI_Farm_Log::swap_Bytes_sWorkLoadStat(sScsiWorkLoadStat *wl) byte_Swap_64(&wl->workLoad.totalWriteCmdsFromFrames2); byte_Swap_64(&wl->workLoad.totalWriteCmdsFromFrames3); byte_Swap_64(&wl->workLoad.totalWriteCmdsFromFrames4); + + byte_Swap_64(&wl->workLoad.numReadTransferSmall); + byte_Swap_64(&wl->workLoad.numReadTransferMid1); + byte_Swap_64(&wl->workLoad.numReadTransferMid2); + byte_Swap_64(&wl->workLoad.numReadTransferLarge); + byte_Swap_64(&wl->workLoad.numWriteTransferSmall); + byte_Swap_64(&wl->workLoad.numWriteTransferMid1); + byte_Swap_64(&wl->workLoad.numWriteTransferMid2); + byte_Swap_64(&wl->workLoad.numWriteTransferLarge); + } return true; } @@ -791,6 +773,37 @@ bool CSCSI_Farm_Log::swap_Bytes_EnvironmentPage07(sScsiEnvStatPage07 *ep) return true; } +//----------------------------------------------------------------------------- +// +//! \fn swap_Bytes_WorkloadPage08() +// +//! \brief +//! Description: takes the pointer to the structure an does a byte swap on all the data for the environment stat +// +// Entry: +//! \param ep = pointer to the environment stat +// +// Exit: +//! \return bool +// +//--------------------------------------------------------------------------- +bool CSCSI_Farm_Log::swap_Bytes_WorkloadPage08(sScsiWorkloadStatPage08 *ep) +{ + byte_Swap_64(&ep->pageNumber); + byte_Swap_64(&ep->copyNumber); + byte_Swap_64(&ep->countQueDepth1); + byte_Swap_64(&ep->countQueDepth2); + byte_Swap_64(&ep->countQueDepth3_4); + byte_Swap_64(&ep->countQueDepth5_8); + byte_Swap_64(&ep->countQueDepth9_16); + byte_Swap_64(&ep->countQueDepth17_32); + byte_Swap_64(&ep->countQueDepth33_64); + byte_Swap_64(&ep->countQueDepth_gt_64); + return true; +} + + + //----------------------------------------------------------------------------- // //! \fn swap_Bytes_sScsiReliabilityStat() @@ -821,14 +834,14 @@ bool CSCSI_Farm_Log::swap_Bytes_sScsiReliabilityStat(sScsiReliablility *ss) byte_Swap_64(&ss->reli.idleTime); byte_Swap_64(&ss->reli.lastIDDTest); byte_Swap_16(&ss->reli.pPageHeader.pramCode); - byte_Swap_64(&ss->reli.maxRVAbsuluteMean); + byte_Swap_64(&ss->reli.maxRVAbsoluteMean); byte_Swap_64(&ss->reli.microActuatorLockOut); byte_Swap_64(&ss->reli.numberDOSScans); byte_Swap_64(&ss->reli.numberLBACorrect); byte_Swap_64(&ss->reli.numberRAWops); byte_Swap_64(&ss->reli.numberValidParitySec); byte_Swap_64(&ss->reli.pageNumber); - byte_Swap_64(&ss->reli.rvAbsuluteMean); + byte_Swap_64(&ss->reli.rvAbsoluteMean); byte_Swap_64(&ss->reli.scrubsAfterIDD); byte_Swap_64(&ss->reli.scrubsBeforeIDD); byte_Swap_64(&ss->reli.servoStatus); @@ -848,29 +861,31 @@ bool CSCSI_Farm_Log::swap_Bytes_sScsiReliabilityStat(sScsiReliablility *ss) } //----------------------------------------------------------------------------- // -//! \fn swap_Bytes_sScsiReliabilityStat() +//! \fn swap_Bytes_sFarmHeader() // //! \brief //! Description: takes the pointer to the structure an does a byte swap on all the data for the farm header // // Entry: -//! \param sScsiReliabilityStat = pointer to the reliability stat +//! \param sScsiFarmHeader = pointer to the Farm header information +//! \param pData = pointer to the buffer data // // Exit: //! \return bool // //--------------------------------------------------------------------------- -bool CSCSI_Farm_Log::swap_Bytes_sFarmHeader(sScsiFarmHeader *fh) +bool CSCSI_Farm_Log::swap_Bytes_sFarmHeader(sScsiFarmHeader *fh, uint8_t* pData) { - byte_Swap_64(&fh->farmHeader.copies); - byte_Swap_64(&fh->farmHeader.headsSupported); - byte_Swap_64(&fh->farmHeader.logSize); - byte_Swap_64(&fh->farmHeader.majorRev); - byte_Swap_64(&fh->farmHeader.minorRev); - byte_Swap_64(&fh->farmHeader.pageSize); - byte_Swap_64(&fh->farmHeader.pagesSupported); - byte_Swap_64(&fh->farmHeader.signature); - //m_MinorRev = fh->minorRev & 0x00FFLL; + fh->farmHeader.signature = M_BytesTo8ByteValue(pData[0], pData[1], pData[2], pData[3], pData[4], pData[5], pData[6], pData[7] ); + fh->farmHeader.majorRev = M_BytesTo8ByteValue(pData[8], pData[9], pData[10], pData[11], pData[12], pData[13], pData[14], pData[15]); + fh->farmHeader.minorRev = M_BytesTo8ByteValue(pData[16], pData[17], pData[18], pData[19], pData[20], pData[21], pData[22], pData[23]); + fh->farmHeader.pagesSupported = M_BytesTo8ByteValue(pData[24], pData[25], pData[26], pData[27], pData[28], pData[29], pData[30], pData[31]); + fh->farmHeader.logSize = M_BytesTo8ByteValue(pData[32], pData[33], pData[34], pData[35], pData[36], pData[37], pData[38], pData[39]); + fh->farmHeader.pageSize = M_BytesTo8ByteValue(pData[40], pData[41], pData[42], pData[43], pData[44], pData[45], pData[46], pData[47]); + fh->farmHeader.headsSupported = M_BytesTo8ByteValue(pData[48], pData[49], pData[50], pData[51], pData[52], pData[53], pData[54], pData[55]); + fh->farmHeader.copies = M_BytesTo8ByteValue(pData[56], pData[57], pData[58], pData[59], pData[60], pData[61], pData[62], pData[63]); + fh->farmHeader.reasonForFrameCapture = M_BytesTo8ByteValue(pData[64], pData[65], pData[66], pData[67], pData[68], pData[69], pData[70], pData[71]); + return true; } //----------------------------------------------------------------------------- @@ -891,26 +906,35 @@ bool CSCSI_Farm_Log::swap_Bytes_sLUNStruct(sLUNStruct *LUN) { byte_Swap_64(&LUN->pageNumber); byte_Swap_64(&LUN->copyNumber); - byte_Swap_64(&LUN->correctedLBAbyISP); - byte_Swap_64(&LUN->dosScansPerformed); - byte_Swap_64(&LUN->headLoadEvents); - byte_Swap_64(&LUN->idleTime); byte_Swap_64(&LUN->LUNID); - byte_Swap_64(&LUN->maxRVabsolue); - byte_Swap_64(&LUN->paritySectors); - byte_Swap_64(&LUN->reallocatedCandidates); + byte_Swap_64(&LUN->headLoadEvents); byte_Swap_64(&LUN->reallocatedSectors); + byte_Swap_64(&LUN->reallocatedCandidates); + byte_Swap_64(&LUN->timeStampOfIDD); + byte_Swap_64(&LUN->subCmdOfIDD); byte_Swap_64(&LUN->reclamedGlist); - byte_Swap_64(&LUN->residentReallocatedAfterIDD); - byte_Swap_64(&LUN->residentReallocatedBeforeIDD); - byte_Swap_64(&LUN->RVabsolue); byte_Swap_64(&LUN->servoStatus); - byte_Swap_64(&LUN->slippedSectorsAfterIDD); byte_Swap_64(&LUN->slippedSectorsBeforeIDD); - byte_Swap_64(&LUN->subCmdOfIDD); - byte_Swap_64(&LUN->successScrubbedAfterIDD); + byte_Swap_64(&LUN->slippedSectorsAfterIDD); + byte_Swap_64(&LUN->residentReallocatedBeforeIDD); + byte_Swap_64(&LUN->residentReallocatedAfterIDD); byte_Swap_64(&LUN->successScrubbedBeforeIDD); - byte_Swap_64(&LUN->timeStampOfIDD); + byte_Swap_64(&LUN->successScrubbedAfterIDD); + byte_Swap_64(&LUN->dosScansPerformed); + byte_Swap_64(&LUN->correctedLBAbyISP); + byte_Swap_64(&LUN->paritySectors); + byte_Swap_64(&LUN->RVabsolue); + byte_Swap_64(&LUN->maxRVabsolue); + byte_Swap_64(&LUN->idleTime); + byte_Swap_64(&LUN->lbasCorrectedByParity); //!< total valid parity sectors + byte_Swap_64(&LUN->currentLowFrequencyVibe); //!< Current Low Frequency Vibe Score + byte_Swap_64(&LUN->currentMidFrequencyVibe); //!< Current Mid Frequency Vibe Score + byte_Swap_64(&LUN->currentHighFrequencyVibe); //!< Current High Frequency Vibe Score + byte_Swap_64(&LUN->worstLowFrequencyVibe); //!< Worst Low Frequency Vibe Score + byte_Swap_64(&LUN->worstMidFrequencyVibe); //!< Worst Mid Frequency Vibe Score + byte_Swap_64(&LUN->worstHighFrequencyVibe); //!< Worst High Frequency Vibe Score + byte_Swap_64(&LUN->primarySPCovPercentage); //!< Primary Super Parity Coverage Percentage + byte_Swap_64(&LUN->primarySPCovPercentageSMR); //!< Primary Super Parity Coverage Percentage SMR return true; } //----------------------------------------------------------------------------- @@ -975,9 +999,9 @@ bool CSCSI_Farm_Log::swap_Bytes_Reallocation_Data(sActReallocationData *real) //--------------------------------------------------------------------------- bool CSCSI_Farm_Log::get_Head_Info(sHeadInformation *phead, uint8_t *buffer) { - memcpy(phead->headValue, (sHeadInformation *)&buffer[4], (sizeof(uint64_t) * (size_t) m_heads)); - memcpy(&phead->pageHeader, (sScsiPageParameter *)&buffer[0], sizeof(sScsiPageParameter)); - for (uint32_t index = 0; index < m_heads; index++) + memcpy(phead->headValue, reinterpret_cast(&buffer[4]), (sizeof(uint64_t) * static_cast(m_heads))); + memcpy(&phead->pageHeader, reinterpret_cast(&buffer[0]), sizeof(sScsiPageParameter)); + for (uint64_t index = 0; index < m_heads; index++) { byte_Swap_64(&phead->headValue[index] ); } @@ -1000,8 +1024,8 @@ bool CSCSI_Farm_Log::get_Head_Info(sHeadInformation *phead, uint8_t *buffer) //--------------------------------------------------------------------------- void CSCSI_Farm_Log::get_LUN_Info(sLUNStruct *pLUN, uint8_t *buffer) { - memcpy(pLUN, (sLUNStruct *)&buffer[4], sizeof(sLUNStruct) ); - memcpy(&pLUN->pageHeader, (sScsiPageParameter *)&buffer[0], sizeof(sScsiPageParameter)); + memcpy(pLUN, reinterpret_cast(&buffer[4]), sizeof(sLUNStruct)); + memcpy(&pLUN->pageHeader, reinterpret_cast(&buffer[0]), sizeof(sScsiPageParameter)); swap_Bytes_sLUNStruct(pLUN); } //----------------------------------------------------------------------------- @@ -1020,21 +1044,35 @@ void CSCSI_Farm_Log::get_LUN_Info(sLUNStruct *pLUN, uint8_t *buffer) //--------------------------------------------------------------------------- eReturnValues CSCSI_Farm_Log::parse_Farm_Log() { - uint64_t offset = 4; // the first page starts at offset 4 + uint64_t offset = 0; // the first page starts at offset 4 bool headerAlreadyFound = false; // set to false, for files that are missing data sScsiFarmFrame *pFarmFrame = new sScsiFarmFrame(); // create the pointer to the union + if (m_fromScsiLogPages == false) + { + offset = 4; + } + + if (VERBOSITY_COMMAND_VERBOSE <= g_verbosity) + { + printf("SCSI parse FARM Log\n"); + } + if (pBuf == NULL) { return FAILURE; } - uint64_t signature = m_pHeader->farmHeader.signature & 0x00FFFFFFFFFFFFFFLL; + uint64_t signature = m_pHeader->farmHeader.signature & UINT64_C(0x00FFFFFFFFFFFFFF); m_MajorRev = M_DoubleWord0(m_pHeader->farmHeader.majorRev); - if (signature != FARMSIGNATURE || signature == 0x00FFFFFFFFFFFFFF) + m_MinorRev = M_DoubleWord0(m_pHeader->farmHeader.minorRev); + if ((signature != FARMSIGNATURE && signature != FACTORYCOPY) || signature == FARMEMPTYSIGNATURE) { - return VALIDATION_FAILURE; + if (signature == FARMEMPTYSIGNATURE) + return SUCCESS; + else + return VALIDATION_FAILURE; } - if (signature == FARMSIGNATURE) // check the head to see if it has the farm signature else fail + if (signature == FARMSIGNATURE || signature == FACTORYCOPY) // check the head to see if it has the farm signature else fail { for (uint32_t index = 0; index <= m_copies; ++index) // loop for the number of copies. I don't think it's zero base as of now @@ -1046,11 +1084,11 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() while (offset < m_logSize) { - m_pageParam = (sScsiPageParameter *)&pBuf[offset]; // get the page params, so we know what the param code is. + m_pageParam = reinterpret_cast(&pBuf[offset]); // get the page params, so we know what the param code is. byte_Swap_16(&m_pageParam->pramCode); if (!headerAlreadyFound || (m_pageParam->pramCode != 0x0000 && m_pageParam->pramCode < 0x008F)) { - pFarmFrame->vFramesFound.push_back((eLogPageTypes)m_pageParam->pramCode); // collect all the log page types in a vector to pump them out at the end + pFarmFrame->vFramesFound.push_back(static_cast(m_pageParam->pramCode)); // collect all the log page types in a vector to pump them out at the end } switch (m_pageParam->pramCode) { @@ -1059,9 +1097,7 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() { if (headerAlreadyFound == false) // check to see if we have already found the header { - m_pHeader = (sScsiFarmHeader *)&pBuf[offset]; // get the Farm Header information - memcpy((sScsiFarmHeader *)&pFarmFrame->farmHeader, m_pHeader, m_pageParam->plen + 4); - byte_Swap_64(&pFarmFrame->farmHeader.farmHeader.reasonForFrameCpature); // need to swap the header information + memcpy(reinterpret_cast(&pFarmFrame->farmHeader), m_pHeader, m_pageParam->plen + PARAMSIZE); offset += (m_pageParam->plen + sizeof(sScsiPageParameter)); headerAlreadyFound = true; // set the header to true so we will not look at the data a second time } @@ -1074,14 +1110,14 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case GENERAL_DRIVE_INFORMATION_PARAMETER: { - m_pDriveInfo = (sScsiDriveInfo *)&pBuf[offset ]; + m_pDriveInfo = reinterpret_cast(&pBuf[offset ]); swap_Bytes_sDriveInfo(m_pDriveInfo);// get the id drive information at the time. memcpy(&pFarmFrame->driveInfo,m_pDriveInfo, m_pDriveInfo->pPageHeader.plen); - create_Serial_Number(pFarmFrame->identStringInfo.serialNumber, m_pDriveInfo); // create the serial number - create_World_Wide_Name(pFarmFrame->identStringInfo.worldWideName, m_pDriveInfo); // create the wwwn - create_Firmware_String(pFarmFrame->identStringInfo.firmwareRev, m_pDriveInfo); // create the firmware string - create_Device_Interface_String(pFarmFrame->identStringInfo.deviceInterface, m_pDriveInfo); // get / create the device interface string + create_Serial_Number(pFarmFrame->identStringInfo.serialNumber, M_DoubleWord0(m_pDriveInfo->serialNumber), M_DoubleWord0(m_pDriveInfo->serialNumber2), m_MajorRev,true ); // create the serial number + create_World_Wide_Name(pFarmFrame->identStringInfo.worldWideName, m_pDriveInfo->worldWideName, m_pDriveInfo->worldWideName2,true); // create the wwwn + create_Firmware_String(pFarmFrame->identStringInfo.firmwareRev, M_DoubleWord0(m_pDriveInfo->firmware), M_DoubleWord0(m_pDriveInfo->firmwareRev),true); // create the firmware string + create_Device_Interface_String(pFarmFrame->identStringInfo.deviceInterface, M_DoubleWord0(m_pDriveInfo->deviceInterface),true); // get / create the device interface string offset += (m_pageParam->plen + sizeof(sScsiPageParameter)); } break; @@ -1090,8 +1126,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() { sScsiWorkLoadStat *pworkLoad = NULL; // get the work load information - pworkLoad = (sScsiWorkLoadStat *)&pBuf[offset ]; - memcpy((sScsiWorkLoadStat *)&pFarmFrame->workLoadPage, pworkLoad, pworkLoad->PageHeader.plen + 4); + pworkLoad = reinterpret_cast(&pBuf[offset ]); + memcpy(reinterpret_cast(&pFarmFrame->workLoadPage), pworkLoad, pworkLoad->PageHeader.plen + PARAMSIZE); swap_Bytes_sWorkLoadStat(&pFarmFrame->workLoadPage); offset += (pworkLoad->PageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1102,16 +1138,16 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() if (m_MajorRev < 4) { sScsiErrorStat *pError; // get the error status - pError = (sScsiErrorStat *)&pBuf[offset]; - memcpy((sScsiErrorStat *)&pFarmFrame->errorPage.errorStat, pError, pError->pPageHeader.plen); + pError = reinterpret_cast(&pBuf[offset]); + memcpy(reinterpret_cast(&pFarmFrame->errorPage.errorStat), pError, pError->pPageHeader.plen); swap_Bytes_sErrorStat(&pFarmFrame->errorPage); offset += (pError->pPageHeader.plen + sizeof(sScsiPageParameter)); } else { sScsiErrorVersion4 *pError; // get the error status - pError = (sScsiErrorVersion4 *)&pBuf[offset]; - memcpy((sScsiErrorVersion4 *)&pFarmFrame->errorPage.errorV4, pError, pError->pPageHeader.plen); + pError = reinterpret_cast(&pBuf[offset]); + memcpy(reinterpret_cast(&pFarmFrame->errorPage.errorV4), pError, pError->pPageHeader.plen + PARAMSIZE); swap_Bytes_sErrorStat(&pFarmFrame->errorPage); offset += (pError->pPageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1121,8 +1157,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case ENVIRONMENTAL_STATISTICS_PARAMETER: { sScsiEnvironmentStat *pEnvironment; // get the envirmonent information - pEnvironment = (sScsiEnvironmentStat *)&pBuf[offset]; - memcpy((sScsiEnvironmentStat *)&pFarmFrame->environmentPage, pEnvironment, pEnvironment->pPageHeader.plen +4); + pEnvironment = reinterpret_cast(&pBuf[offset]); + memcpy(reinterpret_cast(&pFarmFrame->environmentPage), pEnvironment, pEnvironment->pPageHeader.plen + PARAMSIZE); swap_Bytes_sEnvironmentStat(&pFarmFrame->environmentPage); offset += (pEnvironment->pPageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1133,16 +1169,16 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() if (m_MajorRev < 4) { sScsiReliabilityStat *pReli; // get the Reliabliity stat - pReli = (sScsiReliabilityStat *)&pBuf[offset]; - memcpy((sScsiReliabilityStat *)&pFarmFrame->reliPage, pReli, pReli->pPageHeader.plen + 4); + pReli = reinterpret_cast(&pBuf[offset]); + memcpy(reinterpret_cast(&pFarmFrame->reliPage.reli), pReli, pReli->pPageHeader.plen + PARAMSIZE); swap_Bytes_sScsiReliabilityStat(&pFarmFrame->reliPage); offset += (pReli->pPageHeader.plen + sizeof(sScsiPageParameter)); } else { sScsiReliStatVersion4 *pReli; // get the Reliabliity stat - pReli = (sScsiReliStatVersion4 *)&pBuf[offset]; - memcpy((sScsiReliStatVersion4 *)&pFarmFrame->reliPage, pReli, pReli->pPageHeader.plen + 4); + pReli = reinterpret_cast(&pBuf[offset]); + memcpy(reinterpret_cast(&pFarmFrame->reliPage.reli4), pReli, pReli->pPageHeader.plen + PARAMSIZE); swap_Bytes_sScsiReliabilityStat(&pFarmFrame->reliPage); offset += (pReli->pPageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1151,23 +1187,31 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case GENERAL_DRIVE_INFORMATION_06: { sGeneralDriveInfoPage06 *pDriveInfo; - pDriveInfo = (sGeneralDriveInfoPage06 *)&pBuf[offset]; - memcpy((sGeneralDriveInfoPage06 *)&pFarmFrame->gDPage06, pDriveInfo, pDriveInfo->pPageHeader.plen + 4); + pDriveInfo = reinterpret_cast(&pBuf[offset]); + memcpy(reinterpret_cast(&pFarmFrame->gDPage06), pDriveInfo, pDriveInfo->pPageHeader.plen + PARAMSIZE); swap_Bytes_sDrive_Info_Page_06(&pFarmFrame->gDPage06); - create_Model_Number_String(pFarmFrame->identStringInfo.modelNumber, pDriveInfo); + create_Model_Number_String(pFarmFrame->identStringInfo.modelNumber, pDriveInfo->productID,true); offset += (pDriveInfo->pPageHeader.plen + sizeof(sScsiPageParameter)); } break; case ENVIRONMENT_STATISTICS_PAMATER_07: { sScsiEnvStatPage07 *pEnvStat; - pEnvStat = (sScsiEnvStatPage07 *)&pBuf[offset]; - memcpy((sScsiEnvStatPage07 *)&pFarmFrame->envStatPage07, pEnvStat, pEnvStat->pPageHeader.plen + 4); + pEnvStat = reinterpret_cast(&pBuf[offset]); + memcpy(reinterpret_cast(&pFarmFrame->envStatPage07), pEnvStat, pEnvStat->pPageHeader.plen + PARAMSIZE); swap_Bytes_EnvironmentPage07(&pFarmFrame->envStatPage07); offset += (pEnvStat->pPageHeader.plen + sizeof(sScsiPageParameter)); } break; - case RESERVED_FOR_FUTURE_STATISTICS_3: + case WORKLOAD_STATISTICS_PAMATER_08: + { + sScsiWorkloadStatPage08 *pWorkloadStat; + pWorkloadStat = reinterpret_cast(&pBuf[offset]); + memcpy(reinterpret_cast(&pFarmFrame->workloadStatPage08), pWorkloadStat, pWorkloadStat->pPageHeader.plen + PARAMSIZE); + swap_Bytes_WorkloadPage08(&pFarmFrame->workloadStatPage08); + offset += (pWorkloadStat->pPageHeader.plen + sizeof(sScsiPageParameter)); + } + break; case RESERVED_FOR_FUTURE_STATISTICS_4: case RESERVED_FOR_FUTURE_STATISTICS_5: case RESERVED_FOR_FUTURE_STATISTICS_6: @@ -1184,328 +1228,464 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() } break; case DISC_SLIP_IN_MICRO_INCHES_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->discSlipPerHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->discSlipPerHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case BIT_ERROR_RATE_OF_ZONE_0_BY_DRIVE_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->bitErrorRateByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->bitErrorRateByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case DOS_WRITE_REFRESH_COUNT: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->dosWriteRefreshCountByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->dosWriteRefreshCountByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case DVGA_SKIP_WRITE_DETECT_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->dvgaSkipWriteDetectByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->dvgaSkipWriteDetectByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case RVGA_SKIP_WRITE_DETECT_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->rvgaSkipWriteDetectByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; - case FVGA_SKIP_WRITE_DETECT_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->fvgaSkipWriteDetectByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->rvgaSkipWriteDetectByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case FVGA_SKIP_WRITE_DETECT_BY_HEAD: + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->fvgaSkipWriteDetectByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case SKIP_WRITE_DETECT_THRESHOLD_EXCEEDED_COUNT_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->skipWriteDectedThresholdExceededByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->skipWriteDectedThresholdExceededByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case ACFF_SINE_1X_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->acffSine1xValueByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->acffSine1xValueByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case ACFF_COSINE_1X_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->acffCosine1xValueByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->acffCosine1xValueByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case PZT_CALIBRATION_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->pztCalibrationValueByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->pztCalibrationValueByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case MR_HEAD_RESISTANCE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->mrHeadResistanceByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->mrHeadResistanceByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case NUMBER_OF_TMD_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->numberOfTMDByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->numberOfTMDByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case VELOCITY_OBSERVER_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->velocityObserverByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->velocityObserverByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case NUMBER_OF_VELOCITY_OBSERVER_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->numberOfVelocityObservedByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->numberOfVelocityObservedByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_PERCENTAGE_OF_CODEWORDS_AT_ITERATION_LEVEL_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2SATPercentagedbyHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2SATPercentagedbyHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_AMPLITUDE_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2STAmplituedByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2STAmplituedByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_ASYMMETRY_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2STAsymmetryByHead, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2STAsymmetryByHead, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case NUMBER_OF_RESIDENT_GLIST_ENTRIES: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->ResidentGlistEntries, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->ResidentGlistEntries, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case NUMBER_OF_PENDING_ENTRIES: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->ResidentPlistEntries, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; - case DOS_OUGHT_TO_SCAN_COUNT_PER_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->DOSOoughtToScan, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; - case DOS_NEED_TO_SCAN_COUNT_PER_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->DOSNeedToScan, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; - case DOS_WRITE_FAULT_SCAN_COUNT_PER_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->DOSWriteFaultScan, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; - - case WRITE_POWERON_HOURS_FROM_MOST_RECENT_SMART: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->writePowerOnHours, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->ResidentPlistEntries, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case DOS_OUGHT_TO_SCAN_COUNT_PER_HEAD: + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->DOSOoughtToScan, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case DOS_NEED_TO_SCAN_COUNT_PER_HEAD: + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->DOSNeedToScan, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case DOS_WRITE_FAULT_SCAN_COUNT_PER_HEAD: + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->DOSWriteFaultScan, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case WRITE_POWERON_HOURS_FROM_MOST_RECENT_SMART: + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->writePowerOnHours, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case DOS_WRITE_COUNT_THRESHOLD_PER_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->dosWriteCount, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; - case CUM_LIFETIME_UNRECOVERALBE_READ_REPET_PER_HEAD: - { + { sHeadInformation *pHeadInfo = new sHeadInformation(); get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->cumECCReadRepeat, pHeadInfo, sizeof(*pHeadInfo)); + memcpy(&pFarmFrame->dosWriteCount, pHeadInfo, sizeof(*pHeadInfo)); offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + delete pHeadInfo; + } + break; + case CUM_LIFETIME_UNRECOVERALBE_READ_REPET_PER_HEAD: + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->cumECCReadRepeat, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CUM_LIFETIME_UNRECOVERABLE_READ_UNIQUE_PER_HEAD: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->cumECCReadUnique, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; - case RESERVED_FOR_FUTURE_EXPANSION_4: - case RESERVED_FOR_FUTURE_EXPANSION_5: - case RESERVED_FOR_FUTURE_EXPANSION_6: - case RESERVED_FOR_FUTURE_EXPANSION_7: - case RESERVED_FOR_FUTURE_EXPANSION_8: - case RESERVED_FOR_FUTURE_EXPANSION_9: - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->cumECCReadUnique, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case TOTAL_LASER_FIELD_ADJUST_ITERATIONS: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->totalLaserFieldAdjustIterations, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case TOTAL_READER_WRITER_OFFSET_ITERATIONS_PERFORMED: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->totalReaderWriteerOffsetIterationsPerformed, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case PRE_LFA_ZONE_0: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->pre_lfaZone_0, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case PRE_LFA_ZONE_1: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->pre_lfaZone_1, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case PRE_LFA_ZONE_2: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->pre_lfaZone_2, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case ZERO_PERCENT_SHIFT: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->zeroPercentShift, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_0: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2STTrimmedbyHeadZone0, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2STTrimmedbyHeadZone0, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_1: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2STTrimmedbyHeadZone1, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2STTrimmedbyHeadZone1, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_2: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2STTrimmedbyHeadZone2, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2STTrimmedbyHeadZone2, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_0: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2STIterationsByHeadZone0, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2STIterationsByHeadZone0, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_1: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2STIterationsByHeadZone1, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2STIterationsByHeadZone1, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_2: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->currentH2STIterationsByHeadZone2, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->currentH2STIterationsByHeadZone2, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case LASER_OPERATING_ZONE_0: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->laser_operatingZone_0, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case LASER_OPERATING_ZONE_1: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->laser_operatingZone_1, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case LASER_OPERATING_ZONE_2: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->laserOperatingZone_2, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case POST_LFA_OPTIMAL_BER_ZONE_0: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->postLFAOptimalBERZone_0, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case POST_LFA_OPTIMAL_BER_ZONE_1: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->postLFAOptimalBERZone_1, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case POST_LFA_OPTIMAL_BER_ZONE_2: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->postLFAOptimalBERZone_2, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case MICRO_JOG_OFFSET_ZONE_0: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->microJogOffsetZone_0, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case MICRO_JOG_OFFSET_ZONE_1: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->microJogOffsetZone_1, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case MICRO_JOG_OFFSET_ZONE_2: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->microJogOffsetZone_2, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; + case ZERO_PERCENT_SHIFT_ZONE_1: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->zeroPercentShiftZone_1, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_OUTER: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->appliedFlyHeightByHeadOuter, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->appliedFlyHeightByHeadOuter, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_INNER: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->appliedFlyHeightByHeadInner, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->appliedFlyHeightByHeadInner, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_MIDDLE: - { - sHeadInformation *pHeadInfo = new sHeadInformation(); - get_Head_Info(pHeadInfo, &pBuf[offset]); - memcpy(&pFarmFrame->appliedFlyHeightByHeadMiddle, pHeadInfo, sizeof(*pHeadInfo)); - offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); - delete pHeadInfo; - } - break; + { + sHeadInformation *pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->appliedFlyHeightByHeadMiddle, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case SECOND_MR_HEAD_RESISTANCE: { sHeadInformation *pHeadInfo = new sHeadInformation(); @@ -1614,11 +1794,20 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() delete pHeadInfo; } break; + case ZERO_PERCENT_SHIFT_ZONE_2: + { + sHeadInformation* pHeadInfo = new sHeadInformation(); + get_Head_Info(pHeadInfo, &pBuf[offset]); + memcpy(&pFarmFrame->zeroPercentShiftZone_2, pHeadInfo, sizeof(*pHeadInfo)); + offset += (pHeadInfo->pageHeader.plen + sizeof(sScsiPageParameter)); + delete pHeadInfo; + } + break; case LUN_0_ACTUATOR: { sLUNStruct *pLUNInfo; - pLUNInfo = (sLUNStruct *)&pBuf[offset]; - memcpy(&pFarmFrame->vLUN50,pLUNInfo, pLUNInfo->pageHeader.plen + 4); + pLUNInfo = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->vLUN50,pLUNInfo, static_cast(pLUNInfo->pageHeader.plen) + 4); swap_Bytes_sLUNStruct(&pFarmFrame->vLUN50); offset += (pLUNInfo->pageHeader.plen + sizeof(sScsiPageParameter)); @@ -1627,8 +1816,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_0_FLASH_LED: { sActuatorFLEDInfo *pFLEDInfo; - pFLEDInfo = (sActuatorFLEDInfo *)&pBuf[offset]; - memcpy(&pFarmFrame->fled51, pFLEDInfo, pFLEDInfo->pageHeader.plen + 4); + pFLEDInfo = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->fled51, pFLEDInfo, static_cast(pFLEDInfo->pageHeader.plen) + 4); swap_Bytes_Flash_LED(&pFarmFrame->fled51); offset += (pFLEDInfo->pageHeader.plen + sizeof(sScsiPageParameter)); @@ -1637,8 +1826,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_REALLOCATION_0: { sActReallocationData *pReall; - pReall = (sActReallocationData *)&pBuf[offset]; - memcpy(&pFarmFrame->reall52, pReall, pReall->pageHeader.plen + 4); + pReall = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->reall52, pReall, static_cast(pReall->pageHeader.plen) + 4); swap_Bytes_Reallocation_Data(&pFarmFrame->reall52); offset += (pReall->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1646,8 +1835,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_1_ACTUATOR: { sLUNStruct *pLUNInfo; - pLUNInfo = (sLUNStruct *)&pBuf[offset]; - memcpy(&pFarmFrame->vLUN60, pLUNInfo, pLUNInfo->pageHeader.plen + 4); + pLUNInfo = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->vLUN60, pLUNInfo, static_cast(pLUNInfo->pageHeader.plen) + 4); swap_Bytes_sLUNStruct(&pFarmFrame->vLUN60); offset += (pLUNInfo->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1655,8 +1844,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_1_FLASH_LED: { sActuatorFLEDInfo *pFLEDInfo; - pFLEDInfo = (sActuatorFLEDInfo *)&pBuf[offset]; - memcpy(&pFarmFrame->fled61, pFLEDInfo, pFLEDInfo->pageHeader.plen + 4); + pFLEDInfo = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->fled61, pFLEDInfo, static_cast(pFLEDInfo->pageHeader.plen) + 4); swap_Bytes_Flash_LED(&pFarmFrame->fled61); offset += (pFLEDInfo->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1664,8 +1853,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_REALLOCATION_1: { sActReallocationData *pReall; - pReall = (sActReallocationData *)&pBuf[offset]; - memcpy(&pFarmFrame->reall62, pReall, pReall->pageHeader.plen + 4); + pReall = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->reall62, pReall, static_cast(pReall->pageHeader.plen) + 4); swap_Bytes_Reallocation_Data(&pFarmFrame->reall62); offset += (pReall->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1673,8 +1862,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_2_ACTUATOR: { sLUNStruct *pLUNInfo; - pLUNInfo = (sLUNStruct *)&pBuf[offset]; - memcpy(&pFarmFrame->vLUN70, pLUNInfo, pLUNInfo->pageHeader.plen + 4); + pLUNInfo = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->vLUN70, pLUNInfo, static_cast(pLUNInfo->pageHeader.plen) + 4); swap_Bytes_sLUNStruct(&pFarmFrame->vLUN70); offset += (pLUNInfo->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1682,8 +1871,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_2_FLASH_LED: { sActuatorFLEDInfo *pFLEDInfo; - pFLEDInfo = (sActuatorFLEDInfo *)&pBuf[offset]; - memcpy(&pFarmFrame->fled71, pFLEDInfo, pFLEDInfo->pageHeader.plen + 4); + pFLEDInfo = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->fled71, pFLEDInfo, static_cast(pFLEDInfo->pageHeader.plen) + 4); swap_Bytes_Flash_LED(&pFarmFrame->fled71); offset += (pFLEDInfo->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1691,8 +1880,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_REALLOCATION_2: { sActReallocationData *pReall; - pReall = (sActReallocationData *)&pBuf[offset]; - memcpy(&pFarmFrame->reall72, pReall, pReall->pageHeader.plen + 4); + pReall = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->reall72, pReall, static_cast(pReall->pageHeader.plen) + 4); swap_Bytes_Reallocation_Data(&pFarmFrame->reall72); offset += (pReall->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1700,8 +1889,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_3_ACTUATOR: { sLUNStruct *pLUNInfo; - pLUNInfo = (sLUNStruct *)&pBuf[offset]; - memcpy(&pFarmFrame->vLUN80, pLUNInfo, pLUNInfo->pageHeader.plen + 4); + pLUNInfo = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->vLUN80, pLUNInfo, static_cast(pLUNInfo->pageHeader.plen) + 4); swap_Bytes_sLUNStruct(&pFarmFrame->vLUN80); offset += (pLUNInfo->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1709,8 +1898,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_3_FLASH_LED: { sActuatorFLEDInfo *pFLEDInfo; - pFLEDInfo = (sActuatorFLEDInfo *)&pBuf[offset]; - memcpy(&pFarmFrame->fled81, pFLEDInfo, pFLEDInfo->pageHeader.plen + 4); + pFLEDInfo = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->fled81, pFLEDInfo, static_cast(pFLEDInfo->pageHeader.plen) + 4); swap_Bytes_Flash_LED(&pFarmFrame->fled81); offset += (pFLEDInfo->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1718,8 +1907,8 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() case LUN_REALLOCATION_3: { sActReallocationData *pReall; - pReall = (sActReallocationData *)&pBuf[offset]; - memcpy(&pFarmFrame->reall82, pReall, pReall->pageHeader.plen + 4); + pReall = reinterpret_cast(&pBuf[offset]); + memcpy(&pFarmFrame->reall82, pReall, static_cast(pReall->pageHeader.plen) + 4); swap_Bytes_Reallocation_Data(&pFarmFrame->reall82); offset += (pReall->pageHeader.plen + sizeof(sScsiPageParameter)); } @@ -1756,34 +1945,87 @@ eReturnValues CSCSI_Farm_Log::parse_Farm_Log() eReturnValues CSCSI_Farm_Log::print_Header(JSONNODE *masterData) { uint32_t page = 0; - std::string myStr = ""; - JSONNODE *pageInfo = json_new(JSON_NODE); - #if defined _DEBUG printf("\tLog Signature: 0x%" PRIX64" \n", vFarmFrame[page].farmHeader.farmHeader.signature ); //!< Log Signature = 0x00004641524D4552 - printf("\tMajor Revision: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.majorRev & 0x00FFFFFFFFFFFFFFLL); //!< Log Major rev - printf("\tMinor Revision: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.minorRev & 0x00FFFFFFFFFFFFFFLL); //!< minor rev - printf("\tPages Supported: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.pagesSupported & 0x00FFFFFFFFFFFFFFLL); //!< number of pages supported - printf("\tLog Size: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.logSize & 0x00FFFFFFFFFFFFFFLL); //!< log size in bytes - printf("\tPage Size: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.pageSize & 0x00FFFFFFFFFFFFFFLL); //!< page size in bytes - printf("\tHeads Supported: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.headsSupported & 0x00FFFFFFFFFFFFFFLL); //!< Maximum Drive Heads Supported - printf("\tReason for Frame Capture(debug): %" PRId64" \n", vFarmFrame[page].farmHeader.farmHeader.reasonForFrameCpature & 0x00FFFFFFFFFFFFF); //!< Reason for Frame Capture -#endif - json_set_name(pageInfo, "FARM Log Header"); - - snprintf((char*)myStr.c_str(), BASIC, "0x%" PRIX64"", check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.signature)); - json_push_back(pageInfo, json_new_a("Log Signature", (char*)myStr.c_str() )); - json_push_back(pageInfo, json_new_i("Major Revision", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.majorRev)))); - json_push_back(pageInfo, json_new_i("Minor Revision", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.minorRev)))); - json_push_back(pageInfo, json_new_i("Pages Supported", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.pagesSupported)))); - json_push_back(pageInfo, json_new_i("Log Size", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.logSize)))); - json_push_back(pageInfo, json_new_i("Page Size", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.pageSize)))); - json_push_back(pageInfo, json_new_i("Heads Supported", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.headsSupported)))); - json_push_back(pageInfo, json_new_i("Reason for Frame Capture", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.reasonForFrameCpature)))); - get_SMART_Save_Flages(pageInfo, M_Byte0(vFarmFrame[page].farmHeader.farmHeader.reasonForFrameCpature)); - - json_push_back(masterData, pageInfo); + printf("\tMajor Revision: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.majorRev & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Log Major rev + printf("\tMinor Revision: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.minorRev & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< minor rev + printf("\tPages Supported: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.pagesSupported & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< number of pages supported + printf("\tLog Size: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.logSize & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< log size in bytes + if (m_MajorRev < MAJORVERSION4) + { + printf("\tPage Size: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.pageSize & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< page size in bytes + } + printf("\tHeads Supported: %" PRIu64" \n", vFarmFrame[page].farmHeader.farmHeader.headsSupported & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Maximum Drive Heads Supported + printf("\tReason for Frame Capture(debug): %" PRId64" \n", vFarmFrame[page].farmHeader.farmHeader.reasonForFrameCapture & 0x00FFFFFFFFFFFFF); //!< Reason for Frame Capture +#endif + if (g_dataformat == PREPYTHON_DATA) + { + JSONNODE* data = json_new(JSON_NODE); + + json_push_back(data, json_new_a("name", "FARM")); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << FARM_HEADER_PARAMETER; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(label, json_new_a("location", "FARM header")); + + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::nouppercase << check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.signature); + json_push_back(label, json_new_a("log_signature", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.majorRev)); + json_push_back(label, json_new_a("major_revision", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.minorRev)); + json_push_back(label, json_new_a("minor_revision", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.pagesSupported)); + json_push_back(label, json_new_a("pages_supported", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.headsSupported)); + json_push_back(label, json_new_a("heads_supported", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.logSize)) << " bytes"; + json_push_back(label, json_new_a("log_size", temp.str().c_str())); + //temp.str("");temp.clear(); + //temp << std::dec << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.pageSize)) << " bytes"; + //json_push_back(label, json_new_a("page_size", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.reasonForFrameCapture)); + json_push_back(label, json_new_a("reason_for_frame_capture", temp.str().c_str())); + std::string reason; + Get_FARM_Reason_For_Capture(&reason, M_Byte0(vFarmFrame[page].farmHeader.farmHeader.reasonForFrameCapture)); + //std_string_to_lowercase(reason); // don't need this to be lower case do to acronym stay upper case + json_push_back(label, json_new_a("reason_meaning", reason.c_str())); + json_push_back(label, json_new_a("units", "reported")); + json_push_back(data, label); + json_push_back(data, json_new_i("value", 1)); + json_push_back(masterData, data); + } + else + { + JSONNODE* pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, "FARM Log Header"); + std::ostringstream temp; + temp << "0x" <(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.majorRev)))); + json_push_back(pageInfo, json_new_i("Minor Revision", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.minorRev)))); + json_push_back(pageInfo, json_new_i("Pages Supported", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.pagesSupported)))); + json_push_back(pageInfo, json_new_i("Log Size", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.logSize)))); + if (m_MajorRev < MAJORVERSION4) + { + json_push_back(pageInfo, json_new_i("Page Size", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.pageSize)))); + } + json_push_back(pageInfo, json_new_i("Heads Supported", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.headsSupported)))); + json_push_back(pageInfo, json_new_i("Reason for Frame Capture", static_cast(check_Status_Strip_Status(vFarmFrame[page].farmHeader.farmHeader.reasonForFrameCapture)))); + std::string meaning; + Get_FARM_Reason_For_Capture(&meaning, M_Byte0(vFarmFrame[page].farmHeader.farmHeader.reasonForFrameCapture)); + json_push_back(pageInfo, json_new_a("Reason meaning", meaning.c_str())); + json_push_back(masterData, pageInfo); + } return SUCCESS; } @@ -1805,10 +2047,6 @@ eReturnValues CSCSI_Farm_Log::print_Header(JSONNODE *masterData) eReturnValues CSCSI_Farm_Log::print_Drive_Information(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - #if defined _DEBUG if (vFarmFrame[page].driveInfo.copyNumber == FACTORYCOPY) { @@ -1819,103 +2057,200 @@ eReturnValues CSCSI_Farm_Log::print_Drive_Information(JSONNODE *masterData, uint printf("\nDrive Information From Farm Log copy %d:\n", page); } printf("\tDevice Interface: %s \n", vFarmFrame[page].identStringInfo.deviceInterface.c_str()); - printf("\tDevice Capcaity in sectors: %" PRId64" \n", vFarmFrame[page].driveInfo.deviceCapacity & 0x00FFFFFFFFFFFFFFLL); - printf("\tPhysical Sector size: %" PRIX64" \n", vFarmFrame[page].driveInfo.psecSize & 0x00FFFFFFFFFFFFFFLL); //!< Physical Sector Size in Bytes - printf("\tLogical Sector Size: %" PRIX64" \n", vFarmFrame[page].driveInfo.lsecSize & 0x00FFFFFFFFFFFFFFLL); //!< Logical Sector Size in Bytes - printf("\tDevice Buffer Size: %" PRIX64" \n", vFarmFrame[page].driveInfo.deviceBufferSize & 0x00FFFFFFFFFFFFFFLL); //!< Device Buffer Size in Bytes - printf("\tNumber of heads: %" PRId64" \n", vFarmFrame[page].driveInfo.heads & 0x00FFFFFFFFFFFFFFLL); //!< Number of Heads - printf("\tDevice form factor: %" PRIX64" \n", vFarmFrame[page].driveInfo.factor & 0x00FFFFFFFFFFFFFFLL); //!< Device Form Factor (ID Word 168) + printf("\tDevice Capcaity in sectors: %" PRId64" \n", vFarmFrame[page].driveInfo.deviceCapacity & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tPhysical Sector size: %" PRIX64" \n", vFarmFrame[page].driveInfo.psecSize & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Physical Sector Size in Bytes + printf("\tLogical Sector Size: %" PRIX64" \n", vFarmFrame[page].driveInfo.lsecSize & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Logical Sector Size in Bytes + printf("\tDevice Buffer Size: %" PRIX64" \n", vFarmFrame[page].driveInfo.deviceBufferSize & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Device Buffer Size in Bytes + printf("\tNumber of heads: %" PRId64" \n", vFarmFrame[page].driveInfo.heads & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Heads + printf("\tDevice form factor: %" PRIX64" \n", vFarmFrame[page].driveInfo.factor & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Device Form Factor (ID Word 168) printf("\tserial number: %s \n", vFarmFrame[page].identStringInfo.serialNumber.c_str()); printf("\tworkd wide name: %s \n", vFarmFrame[page].identStringInfo.worldWideName.c_str()); printf("\tfirmware Rev: %s \n", vFarmFrame[page].identStringInfo.firmwareRev.c_str()); //!< Firmware Revision [0:3] - printf("\tRotation Rate: %" PRIu64" \n", vFarmFrame[page].driveInfo.rotationRate & 0x00FFFFFFFFFFFFFFLL); //!< Rotational Rate of Device - printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved & 0x00FFFFFFFFFFFFFFLL); //!< reserved - printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved1 & 0x00FFFFFFFFFFFFFFLL); //!< reserved - printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved2 & 0x00FFFFFFFFFFFFFFLL); //!< reserved - printf("\tPower on Hours: %" PRIu64" \n", vFarmFrame[page].driveInfo.poh & 0x00FFFFFFFFFFFFFFLL); //!< Power-on Hour - printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved3 & 0x00FFFFFFFFFFFFFFLL); //!< reserved - printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved4 & 0x00FFFFFFFFFFFFFFLL); //!< reserved - printf("\tHead Load Events: %" PRIu64" \n", vFarmFrame[page].driveInfo.headLoadEvents & 0x00FFFFFFFFFFFFFFLL); //!< Head Load Events - printf("\tPower Cycle count: %" PRIu64" \n", vFarmFrame[page].driveInfo.powerCycleCount & 0x00FFFFFFFFFFFFFFLL); //!< Power Cycle Count - printf("\tHardware Reset count: %" PRIu64" \n", vFarmFrame[page].driveInfo.resetCount & 0x00FFFFFFFFFFFFFFLL); //!< Hardware Reset Count - printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved5 & 0x00FFFFFFFFFFFFFFLL); //!< treserved - printf("\tNVC Status @ power on: %" PRIu64" \n", vFarmFrame[page].driveInfo.NVC_StatusATPowerOn & 0x00FFFFFFFFFFFFFFLL); //!< NVC Status on Power-on - printf("\tTime Available to save: %" PRIu64" \n", vFarmFrame[page].driveInfo.timeAvailable & 0x00FFFFFFFFFFFFFFLL); //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) - printf("\tTime of latest frame: %" PRIu64" \n", vFarmFrame[page].driveInfo.firstTimeStamp & 0x00FFFFFFFFFFFFFFLL); //!< Timestamp of first SMART Summary Frame in Power-On Hours microseconds (spec is wrong) - printf("\tTime of latest frame (milliseconds): %" PRIu64" \n", vFarmFrame[page].driveInfo.lastTimeStamp & 0x00FFFFFFFFFFFFFFLL); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds1 + printf("\tRotation Rate: %" PRIu64" \n", vFarmFrame[page].driveInfo.rotationRate & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Rotational Rate of Device + printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< reserved + printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< reserved + printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< reserved + printf("\tPower on Hours: %" PRIu64" \n", vFarmFrame[page].driveInfo.poh & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Power-on Hour + printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< reserved + printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< reserved + if (m_MajorRev < MAJORVERSION4) + { + printf("\tHead Load Events: %" PRIu64" \n", vFarmFrame[page].driveInfo.headLoadEvents & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Head Load Events + } + printf("\tPower Cycle count: %" PRIu64" \n", vFarmFrame[page].driveInfo.powerCycleCount & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Power Cycle Count + printf("\tHardware Reset count: %" PRIu64" \n", vFarmFrame[page].driveInfo.resetCount & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Hardware Reset Count + printf("\treserved: %" PRIu64" \n", vFarmFrame[page].driveInfo.reserved5 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< treserved + printf("\tNVC Status @ power on: %" PRIu64" \n", vFarmFrame[page].driveInfo.NVC_StatusATPowerOn & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< NVC Status on Power-on + printf("\tTime Available to save: %" PRIu64" \n", vFarmFrame[page].driveInfo.timeAvailable & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) + printf("\tTime of latest frame: %" PRIu64" \n", vFarmFrame[page].driveInfo.firstTimeStamp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Timestamp of first SMART Summary Frame in Power-On Hours microseconds (spec is wrong) + printf("\tTime of latest frame (milliseconds): %" PRIu64" \n", vFarmFrame[page].driveInfo.lastTimeStamp & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds1 #endif - if (vFarmFrame[page].driveInfo.copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "Drive Information From Farm Log copy FACTORY"); + JSONNODE* data = json_new(JSON_NODE); + + json_push_back(data, json_new_a("name", "drive")); + + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << GENERAL_DRIVE_INFORMATION_PARAMETER; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(label, json_new_a("serial_number", vFarmFrame[page].identStringInfo.serialNumber.c_str())); + json_push_back(label, json_new_a("world_wide_name", vFarmFrame[page].identStringInfo.worldWideName.c_str())); + json_push_back(label, json_new_a("firmware_rev", vFarmFrame[page].identStringInfo.firmwareRev.c_str())); + + if (vFarmFrame[page].identStringInfo.modelNumber != "") + { + json_push_back(label, json_new_a("model_number", vFarmFrame[page].identStringInfo.modelNumber.c_str())); + } + + json_push_back(label, json_new_a("device_interface", vFarmFrame[page].identStringInfo.deviceInterface.c_str())); + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.deviceCapacity & UINT64_C(0x00FFFFFFFFFFFFFF)) << " sectors"; + json_push_back(label, json_new_a("device_capacity", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.psecSize & UINT64_C(0x00FFFFFFFFFFFFFF)) << " bytes"; + json_push_back(label, json_new_a("physical_sector_size", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.lsecSize & UINT64_C(0x00FFFFFFFFFFFFFF)) << " bytes"; + json_push_back(label, json_new_a("logical_sector_size", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.deviceBufferSize & UINT64_C(0x00FFFFFFFFFFFFFF)) << " bytes"; + json_push_back(label, json_new_a("device_buffer_size", temp.str().c_str())); //!< Device Buffer Size in Bytes + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.factor & UINT64_C(0x00FFFFFFFFFFFFFF)); + json_push_back(label, json_new_a("device_form_factor", temp.str().c_str())); //!< Device Form Factor (ID Word 168) + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.rotationRate & UINT64_C(0x00FFFFFFFFFFFFFF)) << " rpm"; + json_push_back(label, json_new_a("rotation_rate", temp.str().c_str())); //!< Rotational Rate of Device (ID Word 217) + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.poh & UINT64_C(0x00FFFFFFFFFFFFFF)) << " hours"; + json_push_back(label, json_new_a("power_on", temp.str().c_str())); //!< Power-on Hour + if (m_MajorRev < MAJORVERSION4) + { + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.headLoadEvents & UINT64_C(0x00FFFFFFFFFFFFFF)); + json_push_back(label, json_new_a("head_load_events", temp.str().c_str())); //!< Head Load Events + } + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.powerCycleCount & UINT64_C(0x00FFFFFFFFFFFFFF)) << " counts"; + json_push_back(label, json_new_a("power_cycle", temp.str().c_str())); //!< Power Cycle Count + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.resetCount & UINT64_C(0x00FFFFFFFFFFFFFF)) << " counts"; + json_push_back(label, json_new_a("hardware_reset", temp.str().c_str())); //!< Hardware Reset Count + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.NVC_StatusATPowerOn & UINT64_C(0x00FFFFFFFFFFFFFF)); + json_push_back(label, json_new_a("nvc_status_power_on", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(6) << ((vFarmFrame[page].driveInfo.timeAvailable & UINT64_C(0x00FFFFFFFFFFFFFF)) * .01) << " milliseconds"; + json_push_back(label, json_new_a("nvc_time_available_to_save", temp.str().c_str())); + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.firstTimeStamp & UINT64_C(0x00FFFFFFFFFFFFFF)) << " milliseconds"; + json_push_back(label, json_new_a("timestamp_of_first_smart_summary_frame", temp.str().c_str())); //!< Timestamp of first SMART Summary Frame in Power-On Hours Milliseconds + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.lastTimeStamp & UINT64_C(0x00FFFFFFFFFFFFFF)) << " milliseconds"; + json_push_back(label, json_new_a("timeStamp_of_last_smart_summary_frame", temp.str().c_str())); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.heads & UINT64_C(0x00FFFFFFFFFFFFFF)); + json_push_back(label, json_new_a("number_of_heads", temp.str().c_str())); + if (check_For_Active_Status(&vFarmFrame[page].driveInfo.dateOfAssembly) || \ + (vFarmFrame[page].driveInfo.dateOfAssembly < 0x40000000 && vFarmFrame[page].driveInfo.dateOfAssembly > 0x3030)) + { + std::string dataAndTime; + uint16_t year = M_Word1(vFarmFrame[page].driveInfo.dateOfAssembly); + uint16_t week = M_Word0(vFarmFrame[page].driveInfo.dateOfAssembly); + + create_Year_Assembled_String(dataAndTime, year, true); + json_push_back(label, json_new_a("year_of_assembled", dataAndTime.c_str())); + dataAndTime.clear(); + create_Year_Assembled_String(dataAndTime, week, true); + json_push_back(label, json_new_a("week_of_assembled", dataAndTime.c_str())); + } + json_push_back(label, json_new_a("units", "reported")); + json_push_back(data, label); + json_push_back(data, json_new_i("value", 1)); + json_push_back(masterData, data); } else { - snprintf((char*)myStr.c_str(), BASIC, "Drive Information From Farm Log copy %" PRId32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); + std::ostringstream temp; + JSONNODE* pageInfo = json_new(JSON_NODE); + std::string header; + if (vFarmFrame[page].driveInfo.copyNumber == FACTORYCOPY) + { + header.assign("Drive Information From Farm Log copy FACTORY"); + } + else + { + temp.str("");temp.clear(); + temp << "Drive Information From Farm Log copy " << std::dec << page; + header.assign(temp.str()); + } + json_set_name(pageInfo, header.c_str()); + + json_push_back(pageInfo, json_new_a("Serial Number", vFarmFrame[page].identStringInfo.serialNumber.c_str())); + json_push_back(pageInfo, json_new_a("World Wide Name", vFarmFrame[page].identStringInfo.worldWideName.c_str())); + json_push_back(pageInfo, json_new_a("Firmware Rev", vFarmFrame[page].identStringInfo.firmwareRev.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.serialNumber.c_str()); - json_push_back(pageInfo, json_new_a("Serial Number", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.worldWideName.c_str()); - json_push_back(pageInfo, json_new_a("World Wide Name", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.firmwareRev.c_str()); //!< Firmware Revision [0:3] - json_push_back(pageInfo, json_new_a("Firmware Rev", (char*)myStr.c_str())); + if (vFarmFrame[page].identStringInfo.modelNumber == "") + { + vFarmFrame[page].identStringInfo.modelNumber = "ST12345678"; + } + json_push_back(pageInfo, json_new_a("Model Number", vFarmFrame[page].identStringInfo.modelNumber.c_str())); - if (vFarmFrame[page].identStringInfo.modelNumber == "") - { - vFarmFrame[page].identStringInfo.modelNumber = "ST12345678"; - } - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.modelNumber.c_str()); - json_push_back(pageInfo, json_new_a("Model Number", (char*)myStr.c_str())); + json_push_back(pageInfo, json_new_a("Device Interface", vFarmFrame[page].identStringInfo.deviceInterface.c_str())); + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].driveInfo.deviceCapacity & UINT64_C(0x00FFFFFFFFFFFFFF)); + set_json_string_With_Status(pageInfo, "Device Capacity in Sectors", temp.str(), vFarmFrame[page].driveInfo.deviceCapacity, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Physical Sector size", vFarmFrame[page].driveInfo.psecSize, false, m_showStatusBits); //!< Physical Sector Size in Bytes + set_json_64_bit_With_Status(pageInfo, "Logical Sector Size", vFarmFrame[page].driveInfo.lsecSize, false, m_showStatusBits); //!< Logical Sector Size in Bytes + set_json_64_bit_With_Status(pageInfo, "Device Buffer Size", vFarmFrame[page].driveInfo.deviceBufferSize, false, m_showStatusBits); //!< Device Buffer Size in Bytes + set_json_64_bit_With_Status(pageInfo, "Number of heads", vFarmFrame[page].driveInfo.heads, false, m_showStatusBits); //!< Number of Heads + if (check_Status_Strip_Status(vFarmFrame[page].driveInfo.heads) != 0) + { + m_heads = check_Status_Strip_Status(vFarmFrame[page].driveInfo.heads); + } + set_json_64_bit_With_Status(pageInfo, "Device form factor", vFarmFrame[page].driveInfo.factor, false, m_showStatusBits); //!< Device Form Factor (ID Word 168) - snprintf((char*)myStr.c_str(), BASIC, "%s", vFarmFrame[page].identStringInfo.deviceInterface.c_str()); - json_push_back(pageInfo, json_new_a("Device Interface", (char*)myStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "%llu", vFarmFrame[page].driveInfo.deviceCapacity & 0x00FFFFFFFFFFFFFFLL); - set_json_string_With_Status(pageInfo, "Device Capacity in Sectors", (char*)myStr.c_str(), vFarmFrame[page].driveInfo.deviceCapacity, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Physical Sector size", vFarmFrame[page].driveInfo.psecSize, false, m_showStatusBits); //!< Physical Sector Size in Bytes - set_json_64_bit_With_Status(pageInfo, "Logical Sector Size", vFarmFrame[page].driveInfo.lsecSize, false, m_showStatusBits); //!< Logical Sector Size in Bytes - set_json_64_bit_With_Status(pageInfo, "Device Buffer Size", vFarmFrame[page].driveInfo.deviceBufferSize, false, m_showStatusBits); //!< Device Buffer Size in Bytes - set_json_64_bit_With_Status(pageInfo, "Number of heads", vFarmFrame[page].driveInfo.heads, false, m_showStatusBits); //!< Number of Heads - if (check_Status_Strip_Status(vFarmFrame[page].driveInfo.heads) != 0) - { - m_heads = check_Status_Strip_Status(vFarmFrame[page].driveInfo.heads); - } - set_json_64_bit_With_Status(pageInfo, "Device form factor" , vFarmFrame[page].driveInfo.factor, false, m_showStatusBits); //!< Device Form Factor (ID Word 168) + set_json_64_bit_With_Status(pageInfo, "Rotation Rate", vFarmFrame[page].driveInfo.rotationRate, false, m_showStatusBits); //!< Rotational Rate of Device (ID Word 217) + set_json_64_bit_With_Status(pageInfo, "Power on Hour", vFarmFrame[page].driveInfo.poh, false, m_showStatusBits); //!< Power-on Hour + if (m_MajorRev < MAJORVERSION4) + { + set_json_64_bit_With_Status(pageInfo, "Head Load Events", vFarmFrame[page].driveInfo.headLoadEvents, false, m_showStatusBits); //!< Head Load Events + } + set_json_64_bit_With_Status(pageInfo, "Power Cycle count", vFarmFrame[page].driveInfo.powerCycleCount, false, m_showStatusBits); //!< Power Cycle Count + set_json_64_bit_With_Status(pageInfo, "Hardware Reset count", vFarmFrame[page].driveInfo.resetCount, false, m_showStatusBits); //!< Hardware Reset Count + set_json_64_bit_With_Status(pageInfo, "NVC Status @ power on", vFarmFrame[page].driveInfo.NVC_StatusATPowerOn, false, m_showStatusBits); //!< NVC Status on Power-on - set_json_64_bit_With_Status(pageInfo, "Rotation Rate", vFarmFrame[page].driveInfo.rotationRate, false, m_showStatusBits); //!< Rotational Rate of Device (ID Word 217) - set_json_64_bit_With_Status(pageInfo, "Power on Hour", vFarmFrame[page].driveInfo.poh, false, m_showStatusBits); //!< Power-on Hour - if (m_MajorRev < MAJORVERSION4) - { - set_json_64_bit_With_Status(pageInfo, "Head Load Events", vFarmFrame[page].driveInfo.headLoadEvents, false, m_showStatusBits); //!< Head Load Events - } - set_json_64_bit_With_Status(pageInfo, "Power Cycle count", vFarmFrame[page].driveInfo.powerCycleCount, false, m_showStatusBits); //!< Power Cycle Count - set_json_64_bit_With_Status(pageInfo, "Hardware Reset count", vFarmFrame[page].driveInfo.resetCount, false, m_showStatusBits); //!< Hardware Reset Count - set_json_64_bit_With_Status(pageInfo, "NVC Status @ power on", vFarmFrame[page].driveInfo.NVC_StatusATPowerOn, false, m_showStatusBits); //!< NVC Status on Power-on - set_json_64_bit_With_Status(pageInfo, "NVC Time Available to save (in 100us)", vFarmFrame[page].driveInfo.timeAvailable, false, m_showStatusBits); //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) - set_json_64_bit_With_Status(pageInfo, "Timestamp of First SMART Summary Frame (ms)",vFarmFrame[page].driveInfo.firstTimeStamp, false, m_showStatusBits); //!< Timestamp of first SMART Summary Frame in Power-On Hours Milliseconds - set_json_64_bit_With_Status(pageInfo, "TimeStamp of Last SMART Summary Frame (ms)", vFarmFrame[page].driveInfo.lastTimeStamp, false, m_showStatusBits); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds + Get_NVC_Status(pageInfo, vFarmFrame[page].driveInfo.NVC_StatusATPowerOn); - if (check_For_Active_Status(&vFarmFrame[page].driveInfo.dateOfAssembly) || \ - (vFarmFrame[page].driveInfo.dateOfAssembly < 0x40000000 && vFarmFrame[page].driveInfo.dateOfAssembly > 0x3030)) - { - myStr.resize(DATE_YEAR_DATE_SIZE); - memset((char*)myStr.c_str(), 0, DATE_YEAR_DATE_SIZE); - uint16_t year = M_Word1(vFarmFrame[page].driveInfo.dateOfAssembly); - uint16_t week = M_Word0(vFarmFrame[page].driveInfo.dateOfAssembly); - _common.create_Year_Assembled_String(myStr, year, true); - json_push_back(pageInfo, json_new_a("Year of Assembled", (char*)myStr.c_str())); + set_json_64_bit_With_Status(pageInfo, "NVC Time Available to save (in 100us)", vFarmFrame[page].driveInfo.timeAvailable, false, m_showStatusBits); //!< Time Available to Save User Data to Media Over Last Power Cycle (in 100us) + set_json_64_bit_With_Status(pageInfo, "Timestamp of First SMART Summary Frame (ms)", vFarmFrame[page].driveInfo.firstTimeStamp, false, m_showStatusBits); //!< Timestamp of first SMART Summary Frame in Power-On Hours Milliseconds + set_json_64_bit_With_Status(pageInfo, "TimeStamp of Last SMART Summary Frame (ms)", vFarmFrame[page].driveInfo.lastTimeStamp, false, m_showStatusBits); //!< Timestamp of latest SMART Summary Frame in Power-On Hours Milliseconds - _common.create_Year_Assembled_String(myStr, week, true); - json_push_back(pageInfo, json_new_a("Week of Assembled", (char*)myStr.c_str())); - } - else - { - json_push_back(pageInfo, json_new_a("Year of Assembled", "00")); - json_push_back(pageInfo, json_new_a("Week of Assembled", "00")); + if (check_For_Active_Status(&vFarmFrame[page].driveInfo.dateOfAssembly) || \ + (vFarmFrame[page].driveInfo.dateOfAssembly < 0x40000000 && vFarmFrame[page].driveInfo.dateOfAssembly > 0x3030)) + { + std::string dataAndTime; + uint16_t year = M_Word1(vFarmFrame[page].driveInfo.dateOfAssembly); + uint16_t week = M_Word0(vFarmFrame[page].driveInfo.dateOfAssembly); + + create_Year_Assembled_String(dataAndTime, year, true); + json_push_back(pageInfo, json_new_a("Year of Assembled", dataAndTime.c_str())); + dataAndTime.clear(); + create_Year_Assembled_String(dataAndTime, week, true); + json_push_back(pageInfo, json_new_a("Week of Assembled", dataAndTime.c_str())); + } + else + { + json_push_back(pageInfo, json_new_a("Year of Assembled", "00")); + json_push_back(pageInfo, json_new_a("Week of Assembled", "00")); + } + json_push_back(masterData, pageInfo); } - json_push_back(masterData, pageInfo); return SUCCESS; } //----------------------------------------------------------------------------- @@ -1933,52 +2268,100 @@ eReturnValues CSCSI_Farm_Log::print_Drive_Information(JSONNODE *masterData, uint //! \return SUCCESS // //--------------------------------------------------------------------------- -eReturnValues CSCSI_Farm_Log::print_General_Drive_Information_Continued(JSONNODE *masterData, uint32_t page) +eReturnValues CSCSI_Farm_Log::print_General_Drive_Information_Continued(JSONNODE* masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - - if (vFarmFrame[page].driveInfo.copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "GeneralDrive Informatio From Farm Log copy FACTORY"); + std::ostringstream temp; + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + json_push_back(label, json_new_a("stat_type", "general drive information")); + + json_push_back(label, json_new_a("units", "counts")); + json_push_back(label, json_new_i("depopulation_head_mask", M_DoubleWordInt0(vFarmFrame[page].gDPage06.Depop))); //!< Depopulation Head Mask + std::string type = "cmr"; + if (vFarmFrame[page].gDPage06.driveType & BIT0) + { + type = "smr"; + } + json_push_back(label, json_new_a("drive_recording_type", type.c_str())); + + if (check_Status_Strip_Status(vFarmFrame[page].gDPage06.Depop) != 0) + { + set_Json_Bool(label, "has_drive_been_depopped", true); + } + else + { + set_Json_Bool(label, "has_drive_been_depopped", false); + } + temp.str("");temp.clear(); + temp << std::dec << M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].gDPage06.maxNumAvaliableSectors)) << " sectors"; + json_push_back(label, json_new_a("max number of available sectors for reassignment", temp.str().c_str())); //!< Max Number of Available Sectors for Reassignment � Value in disc sectors(started in 3.3 ) + temp.str("");temp.clear(); + temp << (static_cast(M_Word0(vFarmFrame[page].gDPage06.timeToReady)) * .001F) << " seconds"; + json_push_back(label, json_new_a("time to ready of the last power cycle", temp.str().c_str())); //!< time to ready of the last power cycle + temp.str("");temp.clear(); + temp << (static_cast(M_Word0(vFarmFrame[page].gDPage06.holdTime)) * .001F) << " seconds"; + json_push_back(label, json_new_a("time drive is held in staggered spin", temp.str().c_str())); //!< time drive is held in staggered spin during the last power on sequence + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(3) << (static_cast(M_Word0(vFarmFrame[page].gDPage06.servoSpinUpTime)) * .001F) << " seconds"; + json_push_back(label, json_new_a("last servo spin up time", temp.str().c_str())); //!< time to ready of the last power cycle + temp.str("");temp.clear(); + temp << "scsi-log-page:0x" << std::hex << FARMLOGPAGE << "," << std::hex << static_cast(m_farmSubPage) << ":0x" << std::hex << GENERAL_DRIVE_INFORMATION_06; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(masterData, label); + json_push_back(masterData, json_new_i("value", 0)); + json_push_back(masterData, json_new_a("name", "farm")); } else { - snprintf((char*)myStr.c_str(), BASIC, "General Drive Information From Farm Log copy %" PRId32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - set_json_64_bit_With_Status(pageInfo, "Depopulation Head Mask", vFarmFrame[page].gDPage06.Depop, false, m_showStatusBits); //!< Depopulation Head Mask + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + std::string header; + if (vFarmFrame[page].driveInfo.copyNumber == FACTORYCOPY) + { + header.assign("General Drive Informatio From Farm Log copy FACTORY"); + } + else + { + temp << "General Drive Information From Farm Log copy " << std::dec << page; + header.assign(temp.str()); + } + json_set_name(pageInfo, header.c_str()); + + set_json_64_bit_With_Status(pageInfo, "Depopulation Head Mask", vFarmFrame[page].gDPage06.Depop, false, m_showStatusBits); //!< Depopulation Head Mask - myStr = "Drive Recording Type"; - std::string type = "CMR"; - if (vFarmFrame[page].gDPage06.driveType & BIT0) - { - type = "SMR"; - } + std::string type = "CMR"; + if (vFarmFrame[page].gDPage06.driveType & BIT0) + { + type = "SMR"; + } - set_json_string_With_Status(pageInfo, myStr, type, vFarmFrame[page].gDPage06.driveType, m_showStatusBits); + set_json_string_With_Status(pageInfo, "Drive Recording Type", type, vFarmFrame[page].gDPage06.driveType, m_showStatusBits); - myStr = "Has Drive been Depopped"; - if (check_Status_Strip_Status(vFarmFrame[page].gDPage06.Depop) != 0) - { - set_Json_Bool(pageInfo, myStr, true); - } - else - { - set_Json_Bool(pageInfo, myStr, false); - } + if (check_Status_Strip_Status(vFarmFrame[page].gDPage06.Depop) != 0) + { + set_Json_Bool(pageInfo, "Has Drive been Depopped", true); + } + else + { + set_Json_Bool(pageInfo, "Has Drive been Depopped", false); + } - set_json_64_bit_With_Status(pageInfo, "Max Number of Available Sectors for Reassignment", vFarmFrame[page].gDPage06.maxNumAvaliableSectors, false, m_showStatusBits); //!< Max Number of Available Sectors for Reassignment – Value in disc sectors(started in 3.3 ) - snprintf((char*)myStr.c_str(), BASIC, "%0.03f", static_cast(M_Word0(vFarmFrame[page].gDPage06.timeToReady)) * .001); - set_json_string_With_Status(pageInfo, "Time to ready of the last power cycle (sec)", (char*)myStr.c_str(), vFarmFrame[page].gDPage06.timeToReady, m_showStatusBits); //!< time to ready of the last power cycle - snprintf((char*)myStr.c_str(), BASIC, "%0.03f", static_cast(M_Word0(vFarmFrame[page].gDPage06.holdTime)) *.001); - set_json_string_With_Status(pageInfo, "Time drive is held in staggered spin (sec)", (char*)myStr.c_str(), vFarmFrame[page].gDPage06.holdTime, m_showStatusBits); //!< time drive is held in staggered spin during the last power on sequence - snprintf((char*)myStr.c_str(), BASIC, "%0.03f", static_cast(M_Word0(vFarmFrame[page].gDPage06.servoSpinUpTime)) * .001); - set_json_string_With_Status(pageInfo, "Last Servo Spin up Time (sec)", (char*)myStr.c_str(), vFarmFrame[page].gDPage06.servoSpinUpTime, m_showStatusBits); //!< time to ready of the last power cycle + set_json_64_bit_With_Status(pageInfo, "Max Number of Available Sectors for Reassignment", vFarmFrame[page].gDPage06.maxNumAvaliableSectors, false, m_showStatusBits); //!< Max Number of Available Sectors for Reassignment � Value in disc sectors(started in 3.3 ) + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(3) << (static_cast(M_Word0(vFarmFrame[page].gDPage06.timeToReady)) * .001F); + set_json_string_With_Status(pageInfo, "Time to ready of the last power cycle (sec)", temp.str().c_str(), vFarmFrame[page].gDPage06.timeToReady, m_showStatusBits); //!< time to ready of the last power cycle + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(3) << (static_cast(M_Word0(vFarmFrame[page].gDPage06.holdTime)) * .001F); + set_json_string_With_Status(pageInfo, "Time drive is held in staggered spin (sec)", temp.str().c_str(), vFarmFrame[page].gDPage06.holdTime, m_showStatusBits); //!< time drive is held in staggered spin during the last power on sequence + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(3) << (static_cast(M_Word0(vFarmFrame[page].gDPage06.servoSpinUpTime)) * .001F); + set_json_string_With_Status(pageInfo, "Last Servo Spin up Time (sec)", temp.str().c_str(), vFarmFrame[page].gDPage06.servoSpinUpTime, m_showStatusBits); //!< time to ready of the last power cycle - json_push_back(masterData, pageInfo); + json_push_back(masterData, pageInfo); + } return SUCCESS; } //----------------------------------------------------------------------------- @@ -1998,10 +2381,6 @@ eReturnValues CSCSI_Farm_Log::print_General_Drive_Information_Continued(JSONNODE //--------------------------------------------------------------------------- eReturnValues CSCSI_Farm_Log::print_WorkLoad(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - #if defined _DEBUG if (vFarmFrame[page].workLoadPage.workLoad.copyNumber == FACTORYCOPY) { @@ -2011,56 +2390,134 @@ eReturnValues CSCSI_Farm_Log::print_WorkLoad(JSONNODE *masterData, uint32_t page { printf("\nWork Load From Farm Log copy %d: \n", page); } - printf("\tRated Workload Percentaged: %llu \n", vFarmFrame[page].workLoadPage.workLoad.workloadPercentage & 0x00FFFFFFFFFFFFFFLL); //!< rated Workload Percentage - printf("\tTotal Number of Read Commands: %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCommands & 0x00FFFFFFFFFFFFFFLL); //!< Total Number of Read Commands - printf("\tTotal Number of Write Commands: %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCommands & 0x00FFFFFFFFFFFFFFLL); //!< Total Number of Write Commands - printf("\tTotal Number of Random Read Cmds: %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalRandomReads & 0x00FFFFFFFFFFFFFFLL); //!< Total Number of Random Read Commands - printf("\tTotal Number of Random Write Cmds: %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalRandomWrites & 0x00FFFFFFFFFFFFFFLL); //!< Total Number of Random Write Commands - printf("\tTotal Number of Other Commands: %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalNumberofOtherCMDS & 0x00FFFFFFFFFFFFFFLL); //!< Total Number Of Other Commands - printf("\tLogical Sectors Written: %llu \n", vFarmFrame[page].workLoadPage.workLoad.logicalSecWritten & 0x00FFFFFFFFFFFFFFLL); //!< Logical Sectors Written - printf("\tLogical Sectors Read: %llu \n", vFarmFrame[page].workLoadPage.workLoad.logicalSecRead & 0x00FFFFFFFFFFFFFFLL); //!< Logical Sectors Read - printf("\tNumber of Read commands from 0-3.125%% of LBA space %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames1 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames - printf("\tNumber of Read commands from 3.125-25%% of LBA space %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames2 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames - printf("\tNumber of Read commands from 25-50%% of LBA space %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames3 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames - printf("\tNumber of Read commands from 50-100%% of LBA space %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames4 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames - printf("\tNumber of Write commands from 0-3.125%% of LBA space %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames1 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames - printf("\tNumber of Write commands from 3.125-25%% of LBA space %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames2 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames - printf("\tNumber of Write commands from 25-50%% of LBA space %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames3 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames - printf("\tNumber of Write commands from 50-100%% of LBA space %llu \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames4 & 0x00FFFFFFFFFFFFFFLL); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames + printf("\tRated Workload Percentage: %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.workloadPercentage & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< rated Workload Percentage + printf("\tTotal Number of Read Commands: %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCommands & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number of Read Commands + printf("\tTotal Number of Write Commands: %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCommands & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number of Write Commands + printf("\tTotal Number of Random Read Cmds: %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalRandomReads & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number of Random Read Commands + printf("\tTotal Number of Random Write Cmds: %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalRandomWrites & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number of Random Write Commands + printf("\tTotal Number of Other Commands: %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalNumberofOtherCMDS & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Number Of Other Commands + printf("\tLogical Sectors Written: %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.logicalSecWritten & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Logical Sectors Written + printf("\tLogical Sectors Read: %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.logicalSecRead & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Logical Sectors Read + printf("\tNumber of Read commands from 0-3.125%% of LBA space %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Read commands from 3.125-25%% of LBA space %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Read commands from 25-50%% of LBA space %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Read commands from 50-100%% of LBA space %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Write commands from 0-3.125%% of LBA space %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Write commands from 3.125-25%% of LBA space %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Write commands from 25-50%% of LBA space %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Write commands from 50-100%% of LBA space %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames + //4.21 + if (m_MajorRev >= 4 && m_MinorRev > 20) { + printf("\tNumber of Read Commands of transfer length <=16KB for last 3 SMART Summary Frames %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.numReadTransferSmall & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Read Commands of transfer length (16KB � 512KB] for last 3 SMART Summary Frames %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.numReadTransferMid1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Read Commands of transfer length (512KB � 2MB] for last 3 SMART Summary Frames %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.numReadTransferMid2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Read Commands of transfer length > 2MB for last 3 SMART Summary Frames %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.numReadTransferLarge & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Write Commands of transfer length <=16KB for last 3 SMART Summary Frames %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.numWriteTransferSmall & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Write Commands of transfer length (16KB � 512KB] for last 3 SMART Summary Frames %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.numWriteTransferMid1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Write Commands of transfer length (512KB � 2MB] for last 3 SMART Summary Frames %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.numWriteTransferMid2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames + printf("\tNumber of Write Commands of transfer length > 2MB for last 3 SMART Summary Frames %" PRIu64" \n", vFarmFrame[page].workLoadPage.workLoad.numWriteTransferLarge & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames + + } + + #endif - if (vFarmFrame[page].workLoadPage.workLoad.copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "Work Load From Farm Log copy FACTORY"); + + farm_PrePython_Int(masterData, "stat", "rated workload", "workload", "percentage", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.workloadPercentage)); + farm_PrePython_Int(masterData, "read", "total read", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalReadCommands)); + farm_PrePython_Int(masterData, "write", "total write", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalWriteCommands)); + farm_PrePython_Int(masterData, "read", "total random read", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalRandomReads)); + farm_PrePython_Int(masterData, "write", "total random write", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalRandomWrites)); + farm_PrePython_Int(masterData, "other", "total other", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalNumberofOtherCMDS)); + + farm_PrePython_Int(masterData, "write", "logical sectors written", "workload", "sectors", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.logicalSecWritten)); + farm_PrePython_Int(masterData, "read", "logical sectors read", "workload", "sectors", WORKLOAD_STATISTICS_PARAMETER, static_cast(check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.logicalSecRead))); + + if (vFarmFrame[page].workLoadPage.PageHeader.plen > 0x50) + { + + // found a log where the length of the workload log does not match the spec. Need to check for the 0x50 length + farm_PrePython_Int(masterData, "read", "total read commands from 0-3.125% of LBA space", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< total Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames + farm_PrePython_Int(masterData, "read", "total read commands from 3.125-25% of LBA space", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< total Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames + farm_PrePython_Int(masterData, "read", "total read commands from 25-50% of LBA space", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< total Read commands from 25-50% of LBA space for last 3 SMART Summary Frames + farm_PrePython_Int(masterData, "read", "total read commands from 50-100% of LBA space", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< total Read commands from 50-100% of LBA space for last 3 SMART Summary Frames + farm_PrePython_Int(masterData, "write", "total write commands from 0-3.125% of LBA space", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< total Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames + farm_PrePython_Int(masterData, "write", "total write commands from 3.125-25% of LBA space", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< total Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames + farm_PrePython_Int(masterData, "write", "total write commands from 25-50% of LBA space", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< total Write commands from 25-50% of LBA space for last 3 SMART Summary Frames + farm_PrePython_Int(masterData, "write", "total write commands from 50-100% of LBA space", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< total Write commands from 50-100% of LBA space for last 3 SMART Summary Frames + + if (m_MajorRev >= 4 && m_MinorRev >= 19) + { + farm_PrePython_Int(masterData, "read", "total read commands of transfer length <4kb", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numReadTransferSmall)); + farm_PrePython_Int(masterData, "read", "total read commands of transfer length 4kb - 16kb", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numReadTransferMid1)); + farm_PrePython_Int(masterData, "read", "total read commands of transfer length 16kb - 128kb", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numReadTransferMid2)); + farm_PrePython_Int(masterData, "read", "total read commands of transfer length >= 128kb", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numReadTransferLarge)); + farm_PrePython_Int(masterData, "write", "total write commands of transfer length <4kb", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numWriteTransferSmall)); + farm_PrePython_Int(masterData, "write", "total write commands of transfer length 4kb - 16kb", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numWriteTransferMid1)); + farm_PrePython_Int(masterData, "write", "total write commands of transfer length 16kb - 128kb", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numWriteTransferMid2)); + farm_PrePython_Int(masterData, "write", "total write commands of transfer length >= 128kb", "workload", "commands", WORKLOAD_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numWriteTransferLarge)); + } + + + } + } else { - snprintf((char*)myStr.c_str(), BASIC, "Work Load From Farm Log copy %" PRId32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - set_json_64_bit_With_Status(pageInfo, "Rated Workload Percentaged",vFarmFrame[page].workLoadPage.workLoad.workloadPercentage, false, m_showStatusBits); //!< rated Workload Percentage - set_json_64_bit_With_Status(pageInfo, "Total Number of Read Commands", vFarmFrame[page].workLoadPage.workLoad.totalReadCommands, false, m_showStatusBits); //!< Total Number of Read Commands - set_json_64_bit_With_Status(pageInfo, "Total Number of Write Commands", vFarmFrame[page].workLoadPage.workLoad.totalWriteCommands, false, m_showStatusBits); //!< Total Number of Write Commands - set_json_64_bit_With_Status(pageInfo, "Total Number of Random Read Cmds", vFarmFrame[page].workLoadPage.workLoad.totalRandomReads, false, m_showStatusBits); //!< Total Number of Random Read Commands - set_json_64_bit_With_Status(pageInfo, "Total Number of Random Write Cmds", vFarmFrame[page].workLoadPage.workLoad.totalRandomWrites, false, m_showStatusBits); //!< Total Number of Random Write Commands - set_json_64_bit_With_Status(pageInfo, "Total Number of Other Commands", vFarmFrame[page].workLoadPage.workLoad.totalNumberofOtherCMDS, false, m_showStatusBits); //!< Total Number Of Other Commands - snprintf((char*)myStr.c_str(), BASIC, "%llu", vFarmFrame[page].workLoadPage.workLoad.logicalSecWritten & 0x00FFFFFFFFFFFFFFLL); - set_json_string_With_Status(pageInfo, "Logical Sectors Written", (char*)myStr.c_str(), vFarmFrame[page].workLoadPage.workLoad.logicalSecWritten, m_showStatusBits); //!< Logical Sectors Written - snprintf((char*)myStr.c_str(), BASIC, "%llu", vFarmFrame[page].workLoadPage.workLoad.logicalSecRead & 0x00FFFFFFFFFFFFFFLL); - set_json_string_With_Status(pageInfo, "Logical Sectors Read", (char*)myStr.c_str(), vFarmFrame[page].workLoadPage.workLoad.logicalSecRead, m_showStatusBits); //!< Logical Sectors Read - // found a log where the length of the workload log does not match the spec. Need to check for the 0x50 length - if (vFarmFrame[page].workLoadPage.PageHeader.plen > 0x50) - { - set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 0-3.125% of LBA space", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames1, false, m_showStatusBits); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames - set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 3.125-25% of LBA space", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames2, false, m_showStatusBits); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames - set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 25-50% of LBA space", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames3, false, m_showStatusBits); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames - set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 50-100% of LBA space", vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames4, false, m_showStatusBits); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames - set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 0-3.125% of LBA space", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames1, false, m_showStatusBits); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames - set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 3.125-25% of LBA space", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames2, false, m_showStatusBits); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames - set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 25-50% of LBA space", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames3, false, m_showStatusBits); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames - set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 50-100% of LBA space", vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames4, false, m_showStatusBits); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames - } - json_push_back(masterData, pageInfo); + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + std::string header; + if (vFarmFrame[page].workLoadPage.workLoad.copyNumber == FACTORYCOPY) + { + header.assign("Workload From Farm Log copy FACTORY"); + } + else + { + temp << "Workload From Farm Log copy " << std::dec << page; + header.assign(temp.str()); + } + json_set_name(pageInfo, header.c_str()); + set_json_64_bit_With_Status(pageInfo, "Rated Workload Percentage", vFarmFrame[page].workLoadPage.workLoad.workloadPercentage, false, m_showStatusBits); //!< rated Workload Percentage + set_json_64_bit_With_Status(pageInfo, "Total Read Commands", vFarmFrame[page].workLoadPage.workLoad.totalReadCommands, false, m_showStatusBits); //!< Total Number of Read Commands + set_json_64_bit_With_Status(pageInfo, "Total Write Commands", vFarmFrame[page].workLoadPage.workLoad.totalWriteCommands, false, m_showStatusBits); //!< Total Number of Write Commands + set_json_64_bit_With_Status(pageInfo, "Total Random Read Cmds", vFarmFrame[page].workLoadPage.workLoad.totalRandomReads, false, m_showStatusBits); //!< Total Number of Random Read Commands + set_json_64_bit_With_Status(pageInfo, "Total Random Write Cmds", vFarmFrame[page].workLoadPage.workLoad.totalRandomWrites, false, m_showStatusBits); //!< Total Number of Random Write Commands + set_json_64_bit_With_Status(pageInfo, "Total Other Commands", vFarmFrame[page].workLoadPage.workLoad.totalNumberofOtherCMDS, false, m_showStatusBits); //!< Total Number Of Other Commands + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].workLoadPage.workLoad.logicalSecWritten & UINT64_C(0x00FFFFFFFFFFFFFF)); + set_json_string_With_Status(pageInfo, "Logical Sectors Written", temp.str().c_str(), vFarmFrame[page].workLoadPage.workLoad.logicalSecWritten, m_showStatusBits); //!< Logical Sectors Written + temp.str("");temp.clear(); + temp << std::dec << (vFarmFrame[page].workLoadPage.workLoad.logicalSecRead & UINT64_C(0x00FFFFFFFFFFFFFF)); + set_json_string_With_Status(pageInfo, "Logical Sectors Read", temp.str().c_str(), vFarmFrame[page].workLoadPage.workLoad.logicalSecRead, m_showStatusBits); //!< Logical Sectors Read + // found a log where the length of the workload log does not match the spec. Need to check for the 0x50 length + if (vFarmFrame[page].workLoadPage.PageHeader.plen > 0x50) + { + set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 0-3.125% of LBA space", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames1), false, m_showStatusBits); //!< Number of Read commands from 0-3.125% of LBA space for last 3 SMART Summary Frames + set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 3.125-25% of LBA space", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames2), false, m_showStatusBits); //!< Number of Read commands from 3.125-25% of LBA space for last 3 SMART Summary Frames + set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 25-50% of LBA space", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames3), false, m_showStatusBits); //!< Number of Read commands from 25-50% of LBA space for last 3 SMART Summary Frames + set_json_64_bit_With_Status(pageInfo, "Number of Read commands from 50-100% of LBA space", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalReadCmdsFromFrames4), false, m_showStatusBits); //!< Number of Read commands from 50-100% of LBA space for last 3 SMART Summary Frames + set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 0-3.125% of LBA space", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames1), false, m_showStatusBits); //!< Number of Write commands from 0-3.125% of LBA space for last 3 SMART Summary Frames + set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 3.125-25% of LBA space", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames2), false, m_showStatusBits); //!< Number of Write commands from 3.125-25% of LBA space for last 3 SMART Summary Frames + set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 25-50% of LBA space", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames3), false, m_showStatusBits); //!< Number of Write commands from 25-50% of LBA space for last 3 SMART Summary Frames + set_json_64_bit_With_Status(pageInfo, "Number of Write commands from 50-100% of LBA space", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.totalWriteCmdsFromFrames4), false, m_showStatusBits); //!< Number of Write commands from 50-100% of LBA space for last 3 SMART Summary Frames + } + + // 4.21 + if (m_MajorRev >= 4 && m_MinorRev >= 19) + { + set_json_64_bit_With_Status(pageInfo, "Number of Read Commands of transfer length <4kb", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numReadTransferSmall), false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Read Commands of transfer length (4kb - 16kb)", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numReadTransferMid1), false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Read Commands of transfer length (16kb - 128kb)", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numReadTransferMid2), false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Read Commands of transfer length >= 128kb", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numReadTransferLarge), false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Write Commands of transfer length <4kb", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numWriteTransferSmall), false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Write Commands of transfer length (4kb - 16kb)", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numWriteTransferMid1), false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Write Commands of transfer length (16kb - 128kb)", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numWriteTransferMid2), false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Number of Write Commands of transfer length >= 128kb", check_Status_Strip_Status(vFarmFrame[page].workLoadPage.workLoad.numWriteTransferLarge), false, m_showStatusBits); + } + json_push_back(masterData, pageInfo); + } return SUCCESS; } @@ -2081,10 +2538,6 @@ eReturnValues CSCSI_Farm_Log::print_WorkLoad(JSONNODE *masterData, uint32_t page //--------------------------------------------------------------------------- eReturnValues CSCSI_Farm_Log::print_Error_Information(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - #if defined _DEBUG if (vFarmFrame[page].errorPage.errorStat.copyNumber == FACTORYCOPY) { @@ -2094,48 +2547,69 @@ eReturnValues CSCSI_Farm_Log::print_Error_Information(JSONNODE *masterData, uint { printf("\nError Information Log From Farm Log copy %d: \n", page); } - printf("\tUnrecoverable Read Errors: %llu \n", vFarmFrame[page].errorPage.errorStat.totalReadECC & 0x00FFFFFFFFFFFFFFLL); //!< Number of Unrecoverable Read Errors - printf("\tUnrecoverable Write Errors: %llu \n", vFarmFrame[page].errorPage.errorStat.totalWriteECC & 0x00FFFFFFFFFFFFFFLL); //!< Number of Unrecoverable Write Errors - printf("\tNumber of Reallocated Sectors: %llu \n", vFarmFrame[page].errorPage.errorStat.totalReallocations & 0x00FFFFFFFFFFFFFFLL); //!< Number of Reallocated Sectors - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tNumber of Mechanical Start Failures: %llu \n", vFarmFrame[page].errorPage.errorStat.totalMechanicalFails & 0x00FFFFFFFFFFFFFFLL); //!< Number of Mechanical Start Failures - printf("\tNumber of Reallocated Candidate Sectors: %llu \n", vFarmFrame[page].errorPage.errorStat.totalReallocatedCanidates & 0x00FFFFFFFFFFFFFFLL); //!< Number of Reallocated Candidate Sectors - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved1 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved2 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved3 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved4 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved5 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tNumber of IOEDC Errors (Raw): %llu \n", vFarmFrame[page].errorPage.errorStat.attrIOEDCErrors & 0x00FFFFFFFFFFFFFFLL); //!< Number of IOEDC Errors - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved6 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved7 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved8 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tTotal Flash LED (Assert) Events: %llu \n", vFarmFrame[page].errorPage.errorStat.totalFlashLED & 0x00FFFFFFFFFFFFFFLL); //!< Total Flash LED (Assert) Events - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorStat.reserved9 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tFRU code if smart trip: %llu \n", vFarmFrame[page].errorPage.errorStat.FRUCode & 0x00FFFFFFFFFFFFFFLL); - printf("\tSuper Parity on the Fly Recovery %llu \n", vFarmFrame[page].errorPage.errorStat.parity & 0x00FFFFFFFFFFFFFFLL); + printf("\tUnrecoverable Read Errors: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.totalReadECC & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Unrecoverable Read Errors + printf("\tUnrecoverable Write Errors: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.totalWriteECC & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Unrecoverable Write Errors + printf("\tNumber of Reallocated Sectors: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.totalReallocations & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Reallocated Sectors + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tNumber of Mechanical Start Failures: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.totalMechanicalFails & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Mechanical Start Failures + printf("\tNumber of Reallocated Candidate Sectors: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.totalReallocatedCanidates & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Reallocated Candidate Sectors + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved5 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tIOEDC Errors (not supported in sas): %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.attrIOEDCErrors & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of IOEDC Errors + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved6 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved7 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved8 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tTotal Flash LED (Assert) Events: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.totalFlashLED & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Flash LED (Assert) Events + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.reserved9 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tFRU code if smart trip: %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.FRUCode & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tSuper Parity on the Fly Recovery %" PRIu64" \n", vFarmFrame[page].errorPage.errorStat.parity & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - if (vFarmFrame[page].errorPage.errorStat.copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "Error Information From Farm Log copy FACTORY"); + farm_PrePython_Int(masterData, "read_error", "unrecoverable read errors", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.totalReadECC)); + farm_PrePython_Int(masterData, "write_error", "unrecoverable write errors", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.totalWriteECC)); //!< number of unrecoverable write errors + farm_PrePython_Int(masterData, "read_error", "reallocated sectors", "error information", "counst", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.totalReallocations)); + farm_PrePython_Int(masterData, "mechanical_start_erorr", "total mechanical start failures", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.totalMechanicalFails)); + farm_PrePython_Int(masterData, "read_error", "total reallocated candidate sectors", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.totalReallocatedCanidates)); + + farm_PrePython_Int(masterData, "ioedc_error", "total ioedc errors", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.attrIOEDCErrors)); + farm_PrePython_Int(masterData, "protocol_erro", "fru code if smart trip", "error information", "code", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.FRUCode)); + farm_PrePython_Int(masterData, "flash_led", "total flash led events", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.totalFlashLED)); + farm_PrePython_Int(masterData, "error", "super parity on the fly recovery", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(vFarmFrame[page].errorPage.errorStat.parity)); + + } else { - snprintf((char*)myStr.c_str(), BASIC, "Error Information Log From Farm Log copy %" PRId32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - - set_json_64_bit_With_Status(pageInfo, "Unrecoverable Read Errors", vFarmFrame[page].errorPage.errorStat.totalReadECC, false, m_showStatusBits); //!< Number of Unrecoverable Read Errors - set_json_64_bit_With_Status(pageInfo, "Unrecoverable Write Errors", vFarmFrame[page].errorPage.errorStat.totalWriteECC, false, m_showStatusBits); //!< Number of Unrecoverable Write Errors - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors",vFarmFrame[page].errorPage.errorStat.totalReallocations, false, m_showStatusBits); //!< Number of Reallocated Sectors - set_json_64_bit_With_Status(pageInfo, "Number of Mechanical Start Failures",vFarmFrame[page].errorPage.errorStat.totalMechanicalFails, false, m_showStatusBits); //!< Number of Mechanical Start Failures - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Candidate Sectors",vFarmFrame[page].errorPage.errorStat.totalReallocatedCanidates, false, m_showStatusBits); //!< Number of Reallocated Candidate Sectors - set_json_64_bit_With_Status(pageInfo, "Number of IOEDC Errors (Raw)",vFarmFrame[page].errorPage.errorStat.attrIOEDCErrors, false, m_showStatusBits); //!< Number of IOEDC Errors (SMART Attribute 184 Raw) - set_json_64_bit_With_Status(pageInfo, "Total Flash LED (Assert) Events",vFarmFrame[page].errorPage.errorStat.totalFlashLED, false, m_showStatusBits); //!< Total Flash LED (Assert) Events - set_json_64_bit_With_Status(pageInfo, "SMART Trip FRU code", vFarmFrame[page].errorPage.errorStat.FRUCode, false, m_showStatusBits); //!< FRU code if smart trip from most recent SMART Frame - set_json_64_bit_With_Status(pageInfo, "Super Parity on the Fly Recovery", vFarmFrame[page].errorPage.errorStat.parity, false, m_showStatusBits); //!< Super Parity on the Fly Recovery + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + std::string header; + if (vFarmFrame[page].errorPage.errorStat.copyNumber == FACTORYCOPY) + { + header.assign("Error Information From Farm Log copy FACTORY"); + } + else + { + temp << "Error Information Log From Farm Log copy " << std::dec << page; + header.assign(temp.str()); + } + json_set_name(pageInfo, header.c_str()); - json_push_back(masterData, pageInfo); + set_json_64_bit_With_Status(pageInfo, "Unrecoverable Read Errors", vFarmFrame[page].errorPage.errorStat.totalReadECC, false, m_showStatusBits); //!< Number of Unrecoverable Read Errors + set_json_64_bit_With_Status(pageInfo, "Unrecoverable Write Errors", vFarmFrame[page].errorPage.errorStat.totalWriteECC, false, m_showStatusBits); //!< Number of Unrecoverable Write Errors + set_json_64_bit_With_Status(pageInfo, "Reallocated Sectors", vFarmFrame[page].errorPage.errorStat.totalReallocations, false, m_showStatusBits); //!< Number of Reallocated Sectors + set_json_64_bit_With_Status(pageInfo, "Number of Mechanical Start Failures", vFarmFrame[page].errorPage.errorStat.totalMechanicalFails, false, m_showStatusBits); //!< Number of Mechanical Start Failures + set_json_64_bit_With_Status(pageInfo, "Reallocated Candidate Sectors", vFarmFrame[page].errorPage.errorStat.totalReallocatedCanidates, false, m_showStatusBits); //!< Number of Reallocated Candidate Sectors + set_json_64_bit_With_Status(pageInfo, "Number of IOEDC Errors (Raw)", vFarmFrame[page].errorPage.errorStat.attrIOEDCErrors, false, m_showStatusBits); //!< Number of IOEDC Errors (SMART Attribute 184 Raw) + set_json_64_bit_With_Status(pageInfo, "Total Flash LED (Assert) Events", vFarmFrame[page].errorPage.errorStat.totalFlashLED, false, m_showStatusBits); //!< Total Flash LED (Assert) Events + set_json_64_bit_With_Status(pageInfo, "SMART Trip FRU code", vFarmFrame[page].errorPage.errorStat.FRUCode, false, m_showStatusBits); //!< FRU code if smart trip from most recent SMART Frame + set_json_64_bit_With_Status(pageInfo, "Super Parity on the Fly Recovery", vFarmFrame[page].errorPage.errorStat.parity, false, m_showStatusBits); //!< Super Parity on the Fly Recovery + json_push_back(masterData, pageInfo); + } return SUCCESS; } @@ -2156,10 +2630,6 @@ eReturnValues CSCSI_Farm_Log::print_Error_Information(JSONNODE *masterData, uint //--------------------------------------------------------------------------- eReturnValues CSCSI_Farm_Log::print_Error_Information_Version_4(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - #if defined _DEBUG if (vFarmFrame[page].errorPage.errorV4.copyNumber == FACTORYCOPY) { @@ -2169,59 +2639,80 @@ eReturnValues CSCSI_Farm_Log::print_Error_Information_Version_4(JSONNODE *master { printf("\nError Information Log From Farm Log copy %d: \n", page); } - printf("\tUnrecoverable Read Errors: %llu \n", vFarmFrame[page].errorPage.errorV4.totalReadECC & 0x00FFFFFFFFFFFFFFLL); //!< Number of Unrecoverable Read Errors - printf("\tUnrecoverable Write Errors: %llu \n", vFarmFrame[page].errorPage.errorV4.totalWriteECC & 0x00FFFFFFFFFFFFFFLL); //!< Number of Unrecoverable Write Errors - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved & 0x00FFFFFFFFFFFFFFLL); - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.totalMechanicalFails & 0x00FFFFFFFFFFFFFFLL); //!< Number of Mechanical Start Failures - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved & 0x00FFFFFFFFFFFFFFLL); - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved1 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved2 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved3 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved4 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved5 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tNumber of IOEDC Errors (Raw): %llu \n", vFarmFrame[page].errorPage.errorV4.attrIOEDCErrors & 0x00FFFFFFFFFFFFFFLL); //!< Number of IOEDC Errors - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved6 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved7 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved8 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved & 0x00FFFFFFFFFFFFFFLL); - printf("\tReserved: %llu \n", vFarmFrame[page].errorPage.errorV4.reserved9 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tFRU code if smart trip from most recent SMART Frame:%llu \n", vFarmFrame[page].errorPage.errorV4.FRUCode & 0x00FFFFFFFFFFFFFFLL); - printf("\tInvalid DWord Count Port A %llu \n", vFarmFrame[page].errorPage.errorV4.portAInvalidDwordCount & 0x00FFFFFFFFFFFFFFLL); - printf("\tInvalid DWord Count Port B %llu \n", vFarmFrame[page].errorPage.errorV4.portBInvalidDwordCount & 0x00FFFFFFFFFFFFFFLL); - printf("\tDisparity Error Count Port A %llu \n", vFarmFrame[page].errorPage.errorV4.portADisparityErrorCount & 0x00FFFFFFFFFFFFFFLL); - printf("\tDisparity Error Count Port B %llu \n", vFarmFrame[page].errorPage.errorV4.portBDisparityErrorCount & 0x00FFFFFFFFFFFFFFLL); - printf("\tLoss Of DWord Sync Port A %llu \n", vFarmFrame[page].errorPage.errorV4.portALossDwordSync & 0x00FFFFFFFFFFFFFFLL); - printf("\tLoss Of DWord Sync Port B %llu \n", vFarmFrame[page].errorPage.errorV4.portBLossDwordSync & 0x00FFFFFFFFFFFFFFLL); - printf("\tPhy Reset Problem Port A %llu \n", vFarmFrame[page].errorPage.errorV4.portAPhyResetProblem & 0x00FFFFFFFFFFFFFFLL); - printf("\tPhy Reset Problem Port B %llu \n", vFarmFrame[page].errorPage.errorV4.portBPhyResetProblem & 0x00FFFFFFFFFFFFFFLL); + printf("\tUnrecoverable Read Errors: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.totalReadECC & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Unrecoverable Read Errors + printf("\tUnrecoverable Write Errors: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.totalWriteECC & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Unrecoverable Write Errors + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.totalMechanicalFails & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Mechanical Start Failures + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved5 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tIOEDC Errors (not supported in sas): %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.attrIOEDCErrors & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of IOEDC Errors + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved6 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved7 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved8 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.reserved9 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tSMART Trip FRU code: %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.FRUCode & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tInvalid DWord Count Port A %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.portAInvalidDwordCount & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tInvalid DWord Count Port B %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.portBInvalidDwordCount & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tDisparity Error Count Port A %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.portADisparityErrorCount & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tDisparity Error Count Port B %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.portBDisparityErrorCount & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tLoss Of DWord Sync Port A %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.portALossDwordSync & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tLoss Of DWord Sync Port B %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.portBLossDwordSync & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tPhy Reset Problem Port A %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.portAPhyResetProblem & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tPhy Reset Problem Port B %" PRIu64" \n", vFarmFrame[page].errorPage.errorV4.portBPhyResetProblem & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - if (vFarmFrame[page].errorPage.errorV4.copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "Error Information From Farm Log copy FACTORY"); + farm_PrePython_Int(masterData, "read_error", "unrecoverable read errors", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.totalReadECC))); + farm_PrePython_Int(masterData, "write_error", "unrecoverable write errors", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.totalWriteECC))); //!< number of unrecoverable write errors + farm_PrePython_Int(masterData, "mechanical_start_erorr", "total mechanical start failures", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.totalMechanicalFails))); + farm_PrePython_Int(masterData, "ioedc_errors", "total ioedc errors", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.attrIOEDCErrors))); + farm_PrePython_Int(masterData, "protocol_error", "fru code if smart trip", "error information", "code", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.FRUCode))); + farm_PrePython_Int(masterData, "protocol_error", "invalid dword (port a)", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.portAInvalidDwordCount))); + farm_PrePython_Int(masterData, "protocol_error", "invalid dword (port b)", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.portBInvalidDwordCount))); + farm_PrePython_Int(masterData, "protocol_error", "disparity error (port a)", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.portADisparityErrorCount))); + farm_PrePython_Int(masterData, "protocol_error", "disparity error (port b)", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.portBDisparityErrorCount))); + farm_PrePython_Int(masterData, "protocol_error", "loss of dword sync (port a)", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.portALossDwordSync))); + farm_PrePython_Int(masterData, "protocol_error", "loss of dword sync (port b)", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.portBLossDwordSync))); + farm_PrePython_Int(masterData, "protocol_error", "phy reset problems (port a)", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.portAPhyResetProblem))); + farm_PrePython_Int(masterData, "protocol_error", "phy reset problems (port b)", "error information", "counts", ERROR_STATISTICS_PARAMETER, M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].errorPage.errorV4.portBPhyResetProblem))); + } else { - snprintf((char*)myStr.c_str(), BASIC, "Error Information Log From Farm Log copy %" PRId32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - - set_json_64_bit_With_Status(pageInfo, "Unrecoverable Read Errors", vFarmFrame[page].errorPage.errorV4.totalReadECC, false, m_showStatusBits); //!< Number of Unrecoverable Read Errors - set_json_64_bit_With_Status(pageInfo, "Unrecoverable Write Errors", vFarmFrame[page].errorPage.errorV4.totalWriteECC, false, m_showStatusBits); //!< Number of Unrecoverable Write Errors - set_json_64_bit_With_Status(pageInfo, "Number of Mechanical Start Failures", vFarmFrame[page].errorPage.errorV4.totalMechanicalFails, false, m_showStatusBits); //!< Number of Mechanical Start Failures - set_json_64_bit_With_Status(pageInfo, "Number of IOEDC Errors (Raw)", vFarmFrame[page].errorPage.errorV4.attrIOEDCErrors, false, m_showStatusBits); //!< Number of IOEDC Errors (SMART Attribute 184 Raw) - set_json_64_bit_With_Status(pageInfo, "FRU code if smart trip from most recent SMART Frame", vFarmFrame[page].errorPage.errorV4.FRUCode, false, m_showStatusBits); //!< FRU code if smart trip from most recent SMART Frame - set_json_64_bit_With_Status(pageInfo, "Invalid DWord Count Port A ", vFarmFrame[page].errorPage.errorV4.portAInvalidDwordCount, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Invalid DWord Count Port B", vFarmFrame[page].errorPage.errorV4.portBInvalidDwordCount, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Disparity Error Count Port A", vFarmFrame[page].errorPage.errorV4.portADisparityErrorCount, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Disparity Error Count Port B", vFarmFrame[page].errorPage.errorV4.portBDisparityErrorCount, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Loss Of DWord Sync Port A", vFarmFrame[page].errorPage.errorV4.portALossDwordSync, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Loss Of DWord Sync Port B", vFarmFrame[page].errorPage.errorV4.portBLossDwordSync, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Phy Reset Problem Port A", vFarmFrame[page].errorPage.errorV4.portAPhyResetProblem, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Phy Reset Problem Port B", vFarmFrame[page].errorPage.errorV4.portBPhyResetProblem, false, m_showStatusBits); + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + if (vFarmFrame[page].errorPage.errorV4.copyNumber == FACTORYCOPY) + { + temp << "Error Information From Farm Log copy FACTORY"; + } + else + { + temp << "Error Information Log From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); - json_push_back(masterData, pageInfo); + set_json_64_bit_With_Status(pageInfo, "Unrecoverable Read Errors", vFarmFrame[page].errorPage.errorV4.totalReadECC, false, m_showStatusBits); //!< Number of Unrecoverable Read Errors + set_json_64_bit_With_Status(pageInfo, "Unrecoverable Write Errors", vFarmFrame[page].errorPage.errorV4.totalWriteECC, false, m_showStatusBits); //!< Number of Unrecoverable Write Errors + set_json_64_bit_With_Status(pageInfo, "Number of Mechanical Start Failures", vFarmFrame[page].errorPage.errorV4.totalMechanicalFails, false, m_showStatusBits); //!< Number of Mechanical Start Failures + set_json_64_bit_With_Status(pageInfo, "Number of IOEDC Errors (Raw)", vFarmFrame[page].errorPage.errorV4.attrIOEDCErrors, false, m_showStatusBits); //!< Number of IOEDC Errors (SMART Attribute 184 Raw) + set_json_64_bit_With_Status(pageInfo, "SMART Trip FRU code", vFarmFrame[page].errorPage.errorV4.FRUCode, false, m_showStatusBits); //!< FRU code if smart trip from most recent SMART Frame + set_json_64_bit_With_Status(pageInfo, "Invalid DWord Count Port A ", vFarmFrame[page].errorPage.errorV4.portAInvalidDwordCount, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Invalid DWord Count Port B", vFarmFrame[page].errorPage.errorV4.portBInvalidDwordCount, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Disparity Error Count Port A", vFarmFrame[page].errorPage.errorV4.portADisparityErrorCount, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Disparity Error Count Port B", vFarmFrame[page].errorPage.errorV4.portBDisparityErrorCount, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Loss Of DWord Sync Port A", vFarmFrame[page].errorPage.errorV4.portALossDwordSync, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Loss Of DWord Sync Port B", vFarmFrame[page].errorPage.errorV4.portBLossDwordSync, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Phy Reset Problem Port A", vFarmFrame[page].errorPage.errorV4.portAPhyResetProblem, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Phy Reset Problem Port B", vFarmFrame[page].errorPage.errorV4.portBPhyResetProblem, false, m_showStatusBits); + json_push_back(masterData, pageInfo); + } return SUCCESS; } //----------------------------------------------------------------------------- @@ -2241,10 +2732,6 @@ eReturnValues CSCSI_Farm_Log::print_Error_Information_Version_4(JSONNODE *master //--------------------------------------------------------------------------- eReturnValues CSCSI_Farm_Log::print_Enviroment_Information(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - #if defined _DEBUG if (vFarmFrame[page].environmentPage.copyNumber == FACTORYCOPY) { @@ -2258,80 +2745,141 @@ eReturnValues CSCSI_Farm_Log::print_Enviroment_Information(JSONNODE *masterData, printf("\tCurrent Temperature: %0.02f \n", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.curentTemp)*.10)); //!< Current Temperature in Celsius printf("\tHighest Temperature: %0.02f \n", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.highestTemp)*.10)); //!< Highest Temperature in Celsius printf("\tLowest Temperature: %0.02f \n", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.lowestTemp)*.10)); //!< Lowest Temperature - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved1 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved2 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved3 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved4 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved5 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved6 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved7 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved5 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved6 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved7 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved printf("\tSpecified Max Operating Temperature: %0.02f \n", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.maxTemp) * 1.00)); //!< Specified Max Operating Temperature printf("\tSpecified Min Operating Temperature: %0.02f \n", static_cast(M_WordInt0(vFarmFrame[page].environmentPage.minTemp) * 1.00)); //!< Specified Min Operating Temperature - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved8 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved9 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tCurrent Relative Humidity: %" PRId32".%" PRId32" \n", M_DoubleWord1(vFarmFrame[page].environmentPage.humidity & 0x00FFFFFFFFFFFFFFLL), M_DoubleWord0(vFarmFrame[page].environmentPage.humidity & 0x00FFFFFFFFFFFFFFLL)); //!< Current Relative Humidity (in units of .1%) - printf("\tHumidity Mixed Ratio: %0.02f \n", static_cast((vFarmFrame[page].environmentPage.humidityRatio & 0x00FFFFFFFFFFFFFFLL) / 8.0)); //!< Humidity Mixed Ratio multiplied by 8 (divide by 8 to get actual value) + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved8 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].environmentPage.reserved9 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tCurrent Relative Humidity: %" PRId32".%" PRId32" \n", M_DoubleWord1(vFarmFrame[page].environmentPage.humidity & UINT64_C(0x00FFFFFFFFFFFFFF)), M_DoubleWord0(vFarmFrame[page].environmentPage.humidity & UINT64_C(0x00FFFFFFFFFFFFFF))); //!< Current Relative Humidity (in units of .1%) + printf("\tHumidity Mixed Ratio: %0.02f \n", static_cast((vFarmFrame[page].environmentPage.humidityRatio & UINT64_C(0x00FFFFFFFFFFFFFF)) / 8.0)); //!< Humidity Mixed Ratio multiplied by 8 (divide by 8 to get actual value) printf("\tCurrent Motor Power: %" PRIu16" \n", (M_Word0(vFarmFrame[page].environmentPage.currentMotorPower))); - printf("\t12v Power Average(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.average12v & 0x00FFFFFFFFFFFFFFLL); - printf("\12v Power Min(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.min12v & 0x00FFFFFFFFFFFFFFLL); - printf("\12v Power Max(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.max12v & 0x00FFFFFFFFFFFFFFLL); - printf("\5v Power Average(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.average5v & 0x00FFFFFFFFFFFFFFLL); - printf("\5v Power Min(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.min5v & 0x00FFFFFFFFFFFFFFLL); - printf("\5v Power Max(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.max5v & 0x00FFFFFFFFFFFFFFLL); + printf("\t12v Power Average(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.average12v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\t12v Power Min(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.min12v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\t12v Power Max(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.max12v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\t5v Power Average(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.average5v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\t5v Power Min(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.min5v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\t5v Power Max(mw): %" PRIu64" \n", vFarmFrame[page].environmentPage.max5v & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - if (vFarmFrame[page].environmentPage.copyNumber == FACTORYCOPY) + + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "Environment Information From Farm Log copy FACTORY"); + + farm_PrePython_Float(masterData, "environment_temperature", "current", "environment", "celsius", ENVIRONMENTAL_STATISTICS_PARAMETER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.curentTemp)) * .10)); + farm_PrePython_Float(masterData, "environment_temperature", "highest", "environment", "celsius", ENVIRONMENTAL_STATISTICS_PARAMETER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.highestTemp)) * .10)); + farm_PrePython_Float(masterData, "environment_temperature", "lowest", "environment", "celsius", ENVIRONMENTAL_STATISTICS_PARAMETER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.lowestTemp)) * .10)); + farm_PrePython_Float(masterData, "environment_temperature", "specified max operating temperature", "environment", "celsius", ENVIRONMENTAL_STATISTICS_PARAMETER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.maxTemp)) * 1.00)); + farm_PrePython_Float(masterData, "environment_temperature", "specified min operating temperature", "environment", "celsius", ENVIRONMENTAL_STATISTICS_PARAMETER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.minTemp)) * 1.00)); + + farm_PrePython_Float(masterData, "environment_humidity", "current", "environment", "percent", ENVIRONMENTAL_STATISTICS_PARAMETER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidity)) * 0.1)); + farm_PrePython_Float(masterData, "environment_humidity", "mixed", "environment", "ratio", ENVIRONMENTAL_STATISTICS_PARAMETER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidityRatio)) / 8.0)); + farm_PrePython_Float(masterData, "motor_power", "current", "environment", "volts", ENVIRONMENTAL_STATISTICS_PARAMETER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.currentMotorPower)))); + if (m_MajorRev >= 4) + { + double min = 0.0; + double max = 0.0; + double average = static_cast(M_WordInt0(vFarmFrame[page].environmentPage.average12v) / 1000) + \ + static_cast(M_WordInt0(vFarmFrame[page].environmentPage.average12v) % 1000); + farm_PrePython_Float(masterData, "power_12v", "average", "environment", "volts", ENVIRONMENTAL_STATISTICS_PARAMETER, average); + if (m_MinorRev >= 9) + { + min = static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) / 1000) + \ + static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) % 1000); + farm_PrePython_Float(masterData, "power_12v", "minimum", "environment", "volts", ENVIRONMENTAL_STATISTICS_PARAMETER, min); + max = static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) / 1000) + \ + static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) % 1000); + farm_PrePython_Float(masterData, "power_12v", "maximum", "environment", "volts", ENVIRONMENTAL_STATISTICS_PARAMETER, max); + } + average = static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average5v)) / 1000) + \ + static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average5v)) % 1000); + farm_PrePython_Float(masterData, "power_5v", "average", "environment", "volts", ENVIRONMENTAL_STATISTICS_PARAMETER, average); + if (m_MinorRev >= 9) + { + min = static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) / 1000) + \ + static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) % 1000); + farm_PrePython_Float(masterData, "power_5v", "minimum", "environment", "volts", ENVIRONMENTAL_STATISTICS_PARAMETER, min); + max = static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) / 1000) + \ + static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) % 1000); + farm_PrePython_Float(masterData, "power_5v", "maximum", "environment", "volts", ENVIRONMENTAL_STATISTICS_PARAMETER, max); + } + } } else { - snprintf((char*)myStr.c_str(), BASIC, "Environment Information From Farm Log copy %" PRId32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.curentTemp))*.10)); //!< Current Temperature in Celsius - set_json_string_With_Status(pageInfo, "Current Temperature (Celsius)", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.curentTemp, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.highestTemp))*.10)); //!< Highest Average Long Term Temperature - set_json_string_With_Status(pageInfo, "Highest Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.highestTemp, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.lowestTemp))*.10)); //!< Lowest Average Long Term Temperature - set_json_string_With_Status(pageInfo, "Lowest Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.lowestTemp, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.maxTemp))*1.00)); //!< Specified Max Operating Temperature - set_json_string_With_Status(pageInfo, "Specified Max Operating Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.maxTemp, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.minTemp))*1.00)); //!< Specified Min Operating Temperature - set_json_string_With_Status(pageInfo, "Specified Min Operating Temperature", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.minTemp, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidity))*0.1)); //!< Current Relative Humidity (in units of .1%) - set_json_string_With_Status(pageInfo, "Current Relative Humidity", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.humidity, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidityRatio)) / 8.0)); //!< Humidity Mixed Ratio multiplied by 8 (divide by 8 to get actual value) - set_json_string_With_Status(pageInfo, "Humidity Mixed Ratio", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.humidityRatio, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16"", M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.currentMotorPower))); - set_json_string_With_Status(pageInfo, "Current Motor Power", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.currentMotorPower, m_showStatusBits); //!< Current Motor Power, value from most recent SMART Summary Frame6 - - if (m_MajorRev >= 4) - { - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average12v)) / 1000), \ - static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average12v)) % 1000)); - set_json_string_With_Status(pageInfo, "12V Power Average", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.average12v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) / 1000), \ - static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) % 1000)); - set_json_string_With_Status(pageInfo, "12V Power Minimum", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.min12v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) / 1000), \ - static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) % 1000)); - set_json_string_With_Status(pageInfo, "12V Power Maximum", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.max12v, m_showStatusBits); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average5v)) / 1000), \ - static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average5v)) % 1000)); - set_json_string_With_Status(pageInfo, "5V Power Average", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.average5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) / 1000), \ - static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) % 1000)); - set_json_string_With_Status(pageInfo, "5V Power Minimum", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.min5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) / 1000), \ - static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) % 1000)); - set_json_string_With_Status(pageInfo, "5V Power Maximum", (char*)myStr.c_str(), vFarmFrame[page].environmentPage.max5v, m_showStatusBits); - } - - json_push_back(masterData, pageInfo); + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + std::string header; + if (vFarmFrame[page].environmentPage.copyNumber == FACTORYCOPY) + { + header.assign("Environment Information From Farm Log copy FACTORY"); + } + else + { + temp << "Environment Information From Farm Log copy " << std::dec << page; + header.assign(temp.str()); + } + json_set_name(pageInfo, header.c_str()); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << (static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.curentTemp)) * .10)); //!< Current Temperature in Celsius + set_json_string_With_Status(pageInfo, "Current Temperature (Celsius)", temp.str().c_str(), vFarmFrame[page].environmentPage.curentTemp, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << (static_cast(M_Byte0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.highestTemp)) * .10)); //!< Highest Average Long Term Temperature + set_json_string_With_Status(pageInfo, "Highest Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.highestTemp, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << (static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.lowestTemp)) * .10)); //!< Lowest Average Long Term Temperature + set_json_string_With_Status(pageInfo, "Lowest Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.lowestTemp, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << (static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.maxTemp)) * 1.00)); //!< Specified Max Operating Temperature + set_json_string_With_Status(pageInfo, "Specified Max Operating Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.maxTemp, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << (static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.minTemp)) * 1.00)); //!< Specified Min Operating Temperature + set_json_string_With_Status(pageInfo, "Specified Min Operating Temperature", temp.str().c_str(), vFarmFrame[page].environmentPage.minTemp, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << (static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidity)) * 0.1)); //!< Current Relative Humidity (in units of .1%) + set_json_string_With_Status(pageInfo, "Current Relative Humidity", temp.str().c_str(), vFarmFrame[page].environmentPage.humidity, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(2) << (static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.humidityRatio)) / 8.0)); //!< Humidity Mixed Ratio multiplied by 8 (divide by 8 to get actual value) + set_json_string_With_Status(pageInfo, "Humidity Mixed Ratio", temp.str().c_str(), vFarmFrame[page].environmentPage.humidityRatio, m_showStatusBits); + temp.str("");temp.clear(); + temp << std::dec << M_Word0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.currentMotorPower)); + set_json_string_With_Status(pageInfo, "Current Motor Power", temp.str().c_str(), vFarmFrame[page].environmentPage.currentMotorPower, m_showStatusBits); //!< Current Motor Power, value from most recent SMART Summary Frame6 + + if (m_MajorRev >= 4) + { + temp.str("");temp.clear(); + temp << std::dec << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average12v)) % 1000); + set_json_string_With_Status(pageInfo, "12V Power Average", temp.str().c_str(), vFarmFrame[page].environmentPage.average12v, m_showStatusBits); + if (m_MinorRev <= 9) + { + temp.str(""); temp.clear(); + temp << std::dec << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min12v)) % 1000); + set_json_string_With_Status(pageInfo, "12V Power Minimum", temp.str().c_str(), vFarmFrame[page].environmentPage.min12v, m_showStatusBits); + temp.str(""); temp.clear(); + temp << std::dec << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max12v)) % 1000); + set_json_string_With_Status(pageInfo, "12V Power Maximum", temp.str().c_str(), vFarmFrame[page].environmentPage.max12v, m_showStatusBits); + } + temp.str("");temp.clear(); + temp << std::dec << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.average5v)) % 1000); + set_json_string_With_Status(pageInfo, "5V Power Average", temp.str().c_str(), vFarmFrame[page].environmentPage.average5v, m_showStatusBits); + if (m_MinorRev <= 9) + { + temp.str(""); temp.clear(); + temp << std::dec << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.min5v)) % 1000); + set_json_string_With_Status(pageInfo, "5V Power Minimum", temp.str().c_str(), vFarmFrame[page].environmentPage.min5v, m_showStatusBits); + temp.str(""); temp.clear(); + temp << std::dec << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].environmentPage.max5v)) % 1000); + set_json_string_With_Status(pageInfo, "5V Power Maximum", temp.str().c_str(), vFarmFrame[page].environmentPage.max5v, m_showStatusBits); + } + } + json_push_back(masterData, pageInfo); + } return SUCCESS; } //----------------------------------------------------------------------------- @@ -2351,10 +2899,6 @@ eReturnValues CSCSI_Farm_Log::print_Enviroment_Information(JSONNODE *masterData, //--------------------------------------------------------------------------- eReturnValues CSCSI_Farm_Log::print_Enviroment_Statistics_Page_07(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - #if defined _DEBUG if (vFarmFrame[page].envStatPage07.copyNumber == FACTORYCOPY) { @@ -2364,47 +2908,179 @@ eReturnValues CSCSI_Farm_Log::print_Enviroment_Statistics_Page_07(JSONNODE *mast { printf("\nEnvironment Information Continued From Farm Log copy %d: \n", page); } - printf("\tCurrent 12 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.average12v & 0x00FFFFFFFFFFFFFFLL); - printf("\tMinimum 12 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.min12v & 0x00FFFFFFFFFFFFFFLL); - printf("\tMaximum 12 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.max12v & 0x00FFFFFFFFFFFFFFLL); - printf("\tCurrent 5 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.average5v & 0x00FFFFFFFFFFFFFFLL); - printf("\tMinimum 5 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.min5v & 0x00FFFFFFFFFFFFFFLL); - printf("\tMaximum 5 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.max5v & 0x00FFFFFFFFFFFFFFLL); + printf("\tCurrent 12 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.average12v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tMinimum 12 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.min12v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tMaximum 12 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.max12v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCurrent 5 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.average5v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tMinimum 5 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.min5v & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tMaximum 5 volts: %" PRIu64" \n", vFarmFrame[page].envStatPage07.max5v & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - if (vFarmFrame[page].envStatPage07.copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "Environment Information Continued From Farm Log copy FACTORY"); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + json_push_back(label, json_new_a("stat_type", "environment information")); + + json_push_back(label, json_new_a("units", "count")); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << ENVIRONMENT_STATISTICS_PAMATER_07; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(masterData, label); + json_push_back(masterData, json_new_i("value", 0)); + json_push_back(masterData, json_new_a("name", "farm")); + double min = 0.0; + double max = 0.0; + double current = static_cast(M_Word0(vFarmFrame[page].envStatPage07.average12v) / 1000) + \ + static_cast(M_Word0(vFarmFrame[page].envStatPage07.average12v) % 1000); + farm_PrePython_Float(masterData, "power_12v", "current", "environment information", "volts", ENVIRONMENT_STATISTICS_PAMATER_07, current); + if (m_MinorRev > 9) + { + min = static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min12v)) / 1000) + \ + static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min12v)) % 1000); + farm_PrePython_Float(masterData, "power_12v", "minimum", "environment information", "volts", ENVIRONMENT_STATISTICS_PAMATER_07, min); + max = static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max12v)) / 1000) + \ + static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max12v)) % 1000); + farm_PrePython_Float(masterData, "power_12v", "maximum", "environment information", "volts", ENVIRONMENT_STATISTICS_PAMATER_07, max); + } + current = static_cast (M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average5v)) / 1000) + \ + static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average5v)) % 1000); + farm_PrePython_Float(masterData, "power_5v", "current", "environment information", "volts", ENVIRONMENT_STATISTICS_PAMATER_07, current); + if (m_MinorRev > 9) + { + min = static_cast (M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min5v)) / 1000) + \ + static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min5v)) % 1000); + farm_PrePython_Float(masterData, "power_5v", "minimum", "environment information", "volts", ENVIRONMENT_STATISTICS_PAMATER_07, min); + + max = static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max5v)) / 1000) + \ + static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max5v)) % 1000); + farm_PrePython_Float(masterData, "power_5v", "maximum", "environment information", "volts", ENVIRONMENT_STATISTICS_PAMATER_07, max); + } } else { - snprintf((char*)myStr.c_str(), BASIC, "Environment Information Continued From Farm Log copy %" PRId32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average12v)) / 1000), \ - static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average12v)) % 1000)); - set_json_string_With_Status(pageInfo, "Current 12 volts", (char*)myStr.c_str(), vFarmFrame[page].envStatPage07.average12v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min12v)) / 1000), \ - static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min12v)) % 1000)); - set_json_string_With_Status(pageInfo, "Minimum 12 volts", (char*)myStr.c_str(), vFarmFrame[page].envStatPage07.min12v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max12v)) / 1000), \ - static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max12v)) % 1000)); - set_json_string_With_Status(pageInfo, "Maximum 12 volts", (char*)myStr.c_str(), vFarmFrame[page].envStatPage07.max12v, m_showStatusBits); - - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average5v)) / 1000), \ - static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average5v)) % 1000)); - set_json_string_With_Status(pageInfo, "Current 5 volts", (char*)myStr.c_str(), vFarmFrame[page].envStatPage07.average5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min5v)) / 1000), \ - M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min5v)) % 1000); - set_json_string_With_Status(pageInfo, "Minimum 5 volts", (char*)myStr.c_str(), vFarmFrame[page].envStatPage07.min5v, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%" PRIu16".%03" PRIu16"", (M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max5v)) / 1000), \ - M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max5v)) % 1000); - set_json_string_With_Status(pageInfo, "Maximum 5 volts", (char*)myStr.c_str(), vFarmFrame[page].envStatPage07.max5v, m_showStatusBits); + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + if (vFarmFrame[page].envStatPage07.copyNumber == FACTORYCOPY) + { + temp << "Environment Information Continued From Farm Log copy FACTORY"; + } + else + { + temp << "Environment Information Continued From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); + + temp.str("");temp.clear(); + temp << std::dec << static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average12v)) % 1000); + set_json_string_With_Status(pageInfo, "Current 12 volts", temp.str().c_str(), vFarmFrame[page].envStatPage07.average12v, m_showStatusBits); + if (m_MinorRev > 9) + { + temp.str(""); temp.clear(); + temp << std::dec << static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min12v)) % 1000); + set_json_string_With_Status(pageInfo, "Minimum 12 volts", temp.str().c_str(), vFarmFrame[page].envStatPage07.min12v, m_showStatusBits); + temp.str(""); temp.clear(); + temp << std::dec << static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max12v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max12v)) % 1000); + set_json_string_With_Status(pageInfo, "Maximum 12 volts", temp.str().c_str(), vFarmFrame[page].envStatPage07.max12v, m_showStatusBits); + } + temp.str("");temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << static_cast(M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.average5v)) % 1000); + set_json_string_With_Status(pageInfo, "Current 5 volts", temp.str().c_str(), vFarmFrame[page].envStatPage07.average5v, m_showStatusBits); + if (m_MinorRev > 9) + { + temp.str(""); temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.min5v)) % 1000; + set_json_string_With_Status(pageInfo, "Minimum 5 volts", temp.str().c_str(), vFarmFrame[page].envStatPage07.min5v, m_showStatusBits); + temp.str(""); temp.clear(); + temp << std::dec << (M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max5v)) / 1000) << "." << std::dec << std::setfill('0') << std::setw(3) << M_Word0(check_Status_Strip_Status(vFarmFrame[page].envStatPage07.max5v)) % 1000; + set_json_string_With_Status(pageInfo, "Maximum 5 volts", temp.str().c_str(), vFarmFrame[page].envStatPage07.max5v, m_showStatusBits); + } + + json_push_back(masterData, pageInfo); + } + return SUCCESS; +} + + +//----------------------------------------------------------------------------- +// +//! \fn print_Workload_Statistics_Page_08() +// +//! \brief +//! Description: print out the Workload log information +// +// Entry: +//! \param masterData - pointer to the json data that will be printed or passed on +//! \param page = the page copy number of the data we want to print. +// +// Exit: +//! \return SUCCESS +// +//--------------------------------------------------------------------------- +eReturnValues CSCSI_Farm_Log::print_Workload_Statistics_Page_08(JSONNODE *masterData, uint32_t page) +{ + if (m_MajorRev >= 4 && m_MinorRev >= 19) + { + JSONNODE *pageInfo = json_new(JSON_NODE); + + #if defined _DEBUG + if (vFarmFrame[page].workloadStatPage08.copyNumber == FACTORYCOPY) + { + printf("Workload Information Continued From Farm Log copy FACTORY \n"); + } + else + { + printf("\nWorkload Information Continued From Farm Log copy %d: \n", page); + } + printf("\tCount of Queue Depth =1 at 30s intervals: %" PRIu64" \n", vFarmFrame[page].workloadStatPage08.countQueDepth1 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth =2 at 30s intervals: %" PRIu64" \n", vFarmFrame[page].workloadStatPage08.countQueDepth2 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth 2-4 at 30s intervals: %" PRIu64" \n", vFarmFrame[page].workloadStatPage08.countQueDepth3_4 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth 5-8 at 30s intervals: %" PRIu64" \n", vFarmFrame[page].workloadStatPage08.countQueDepth5_8 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth 9-16 at 30s intervals: %" PRIu64" \n", vFarmFrame[page].workloadStatPage08.countQueDepth9_16 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth 17-32 at 30s intervals: %" PRIu64" \n", vFarmFrame[page].workloadStatPage08.countQueDepth17_32 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth 33-64 at 30s intervals: %" PRIu64" \n", vFarmFrame[page].workloadStatPage08.countQueDepth33_64 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCount of Queue Depth gt 64 at 30s intervals:%" PRIu64" \n", vFarmFrame[page].workloadStatPage08.countQueDepth_gt_64 & UINT64_C(0x00FFFFFFFFFFFFFF)); - json_push_back(masterData, pageInfo); + #endif + if (g_dataformat == PREPYTHON_DATA) + { + + farm_PrePython_Int(pageInfo, "workload_information", "total queue depth =1", "workload queue", "counts", WORKLOAD_STATISTICS_PAMATER_08, vFarmFrame[page].workloadStatPage08.countQueDepth1); + farm_PrePython_Int(pageInfo, "workload_information", "total queue depth =2", "workload queue", "counts", WORKLOAD_STATISTICS_PAMATER_08, vFarmFrame[page].workloadStatPage08.countQueDepth2); + farm_PrePython_Int(pageInfo, "workload_information", "total queue depth 2-4", "workload queue", "counts", WORKLOAD_STATISTICS_PAMATER_08, vFarmFrame[page].workloadStatPage08.countQueDepth3_4); + farm_PrePython_Int(pageInfo, "workload_information", "total queue depth 5-8", "workload queue", "counts", WORKLOAD_STATISTICS_PAMATER_08, vFarmFrame[page].workloadStatPage08.countQueDepth5_8); + farm_PrePython_Int(pageInfo, "workload_information", "total queue depth 9-16", "workload queue", "counts", WORKLOAD_STATISTICS_PAMATER_08, vFarmFrame[page].workloadStatPage08.countQueDepth9_16); + farm_PrePython_Int(pageInfo, "workload_information", "total queue depth 17-32", "workload queue", "counts", WORKLOAD_STATISTICS_PAMATER_08, vFarmFrame[page].workloadStatPage08.countQueDepth17_32); + farm_PrePython_Int(pageInfo, "workload_information", "total queue depth 33-64", "workload queue", "counts", WORKLOAD_STATISTICS_PAMATER_08, vFarmFrame[page].workloadStatPage08.countQueDepth33_64); + farm_PrePython_Int(pageInfo, "workload_information", "total queue depth > 64", "workload queue", "counts", WORKLOAD_STATISTICS_PAMATER_08, vFarmFrame[page].workloadStatPage08.countQueDepth_gt_64); + + } + else + { + std::ostringstream temp; + if (vFarmFrame[page].workloadStatPage08.copyNumber == FACTORYCOPY) + { + temp << "Workload Information Continued From Farm Log copy FACTORY"; + } + else + { + temp << "Workload Information Continued From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); + set_json_int_With_Status(pageInfo, "Count of Queue Depth =1 at 30s", vFarmFrame[page].workloadStatPage08.countQueDepth1, m_showStatusBits); + set_json_int_With_Status(pageInfo, "Count of Queue Depth =2 at 30s", vFarmFrame[page].workloadStatPage08.countQueDepth2, m_showStatusBits); + set_json_int_With_Status(pageInfo, "Count of Queue Depth 2-4 at 30s", vFarmFrame[page].workloadStatPage08.countQueDepth3_4, m_showStatusBits); + set_json_int_With_Status(pageInfo, "Count of Queue Depth 5-8 at 30s", vFarmFrame[page].workloadStatPage08.countQueDepth5_8, m_showStatusBits); + set_json_int_With_Status(pageInfo, "Count of Queue Depth 9-16 at 30s", vFarmFrame[page].workloadStatPage08.countQueDepth9_16, m_showStatusBits); + set_json_int_With_Status(pageInfo, "Count of Queue Depth 17-32 at 30s", vFarmFrame[page].workloadStatPage08.countQueDepth17_32, m_showStatusBits); + set_json_int_With_Status(pageInfo, "Count of Queue Depth 33-64 at 30s", vFarmFrame[page].workloadStatPage08.countQueDepth33_64, m_showStatusBits); + set_json_int_With_Status(pageInfo, "Count of Queue Depth > 64 at 30s", vFarmFrame[page].workloadStatPage08.countQueDepth_gt_64, m_showStatusBits); + json_push_back(masterData, pageInfo); + } + } return SUCCESS; } + //----------------------------------------------------------------------------- // //! \fn print_Reli_Information() @@ -2422,12 +3098,9 @@ eReturnValues CSCSI_Farm_Log::print_Enviroment_Statistics_Page_07(JSONNODE *mast //--------------------------------------------------------------------------- eReturnValues CSCSI_Farm_Log::print_Reli_Information(JSONNODE *masterData, uint32_t page) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); +#if defined _DEBUG if (m_MajorRev < 4) { -#if defined _DEBUG if (vFarmFrame[page].reliPage.reli.copyNumber == FACTORYCOPY) { printf("Reliability Information From Farm Log copy FACTORY"); @@ -2436,124 +3109,169 @@ eReturnValues CSCSI_Farm_Log::print_Reli_Information(JSONNODE *masterData, uint3 { printf("\nReliability Information From Farm Log copy: %d\n", page); } - printf("\tTimeStamp of last IDD test: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.lastIDDTest & 0x00FFFFFFFFFFFFFFLL); //!< Timestamp of last IDD test - printf("\tSub-command of last IDD test: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.cmdLastIDDTest & 0x00FFFFFFFFFFFFFFLL); //!< Sub-command of last IDD test - printf("\tNumber of Reclamations Sectors: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.gListReclamed & 0x00FFFFFFFFFFFFFFLL); //!< Number of G-List Reclamations - printf("\tServo Status: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.servoStatus & 0x00FFFFFFFFFFFFFFLL); //!< Servo Status (follows standard DST error code definitions) - printf("\tNumber of Slipped Secotrs Before IDD Scan:%" PRIu64" \n", vFarmFrame[page].reliPage.reli.altsBeforeIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Alt List Entries Before IDD Scan - printf("\tNumber of Slipped Secotrs After IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.altsAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Alt List Entries After IDD Scan - printf("\tResident G-List Entries Before IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.gListBeforIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Resident G-List Entries Before IDD Scan - printf("\tResident G-List Entries After IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.gListAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Resident G-List Entries After IDD Scan - printf("\tScrubs List Entries Before IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.scrubsBeforeIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Scrub List Entries Before IDD Scan - printf("\tScrubs List Entries After IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.scrubsAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Scrub List Entries After IDD Scan - printf("\tNumber of DOS Scans Performed: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.numberDOSScans & 0x00FFFFFFFFFFFFFFLL); //!< Number of DOS Scans Performed - printf("\tNumber of LBAs Corrected by ISP: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.numberLBACorrect & 0x00FFFFFFFFFFFFFFLL); //!< Number of LBAs Corrected by ISP - printf("\tNumber of Valid Parity Sectors: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.numberValidParitySec & 0x00FFFFFFFFFFFFFFLL); //!< Number of Valid Parity Sectors - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved1 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved2 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved3 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved4 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved5 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved6 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tNumber of RAW Operations: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.numberRAWops & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tMicro Actuator Lock-out accumulated: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.microActuatorLockOut & 0x00FFFFFFFFFFFFFFLL); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames - printf("\t# of Disc Slip Recalibrations Performed : %" PRIu64" \n", vFarmFrame[page].reliPage.reli.diskSlipRecalPerformed & 0x00FFFFFFFFFFFFFFLL); //!< Number of disc slip recalibrations performed - printf("\tHelium Pressure Threshold Trip: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.heliumPressuretThreshold & 0x00FFFFFFFFFFFFFFLL); //!< helium Pressure Threshold Trip - printf("\tRV Absulute Mean: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.rvAbsuluteMean & 0x00FFFFFFFFFFFFFFLL); //!< RV Absulute Mean - printf("\tMax RV absulute Mean: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.maxRVAbsuluteMean & 0x00FFFFFFFFFFFFFFLL); //!< Max RV absulute Mean - printf("\tIdle Time value from the most recent SMART Summary Frame: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.idleTime & 0x00FFFFFFFFFFFFFFLL); //!< idle Time value from the most recent SMART Summary Frame - + printf("\tTimeStamp of last IDD test: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.lastIDDTest & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Timestamp of last IDD test + printf("\tSub-command of last IDD test: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.cmdLastIDDTest & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Sub-command of last IDD test + printf("\tNumber of Reclamations Sectors: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.gListReclamed & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of G-List Reclamations + printf("\tServo Status: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.servoStatus & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Servo Status (follows standard DST error code definitions) + printf("\tNumber of Slipped Secotrs Before IDD Scan:%" PRIu64" \n", vFarmFrame[page].reliPage.reli.altsBeforeIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Alt List Entries Before IDD Scan + printf("\tNumber of Slipped Secotrs After IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.altsAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Alt List Entries After IDD Scan + printf("\tResident G-List Entries Before IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.gListBeforIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Resident G-List Entries Before IDD Scan + printf("\tResident G-List Entries After IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.gListAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Resident G-List Entries After IDD Scan + printf("\tScrubs List Entries Before IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.scrubsBeforeIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Scrub List Entries Before IDD Scan + printf("\tScrubs List Entries After IDD Scan: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.scrubsAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Scrub List Entries After IDD Scan + printf("\tNumber of DOS Scans Performed: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.numberDOSScans & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of DOS Scans Performed + printf("\tNumber of LBAs Corrected by ISP: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.numberLBACorrect & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by ISP + printf("\tNumber of Valid Parity Sectors: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.numberValidParitySec & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Valid Parity Sectors + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved5 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.reserved6 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tNumber of RAW Operations: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.numberRAWops & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tMicro Actuator Lock-out accumulated: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.microActuatorLockOut & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames + printf("\t# of Disc Slip Recalibrations Performed : %" PRIu64" \n", vFarmFrame[page].reliPage.reli.diskSlipRecalPerformed & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of disc slip recalibrations performed + printf("\tHelium Pressure Threshold Trip: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.heliumPressuretThreshold & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< helium Pressure Threshold Trip + printf("\tRV Absolute Mean: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.rvAbsoluteMean & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< RV Absulute Mean + printf("\tMax RV absolute Mean: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.maxRVAbsoluteMean & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Max RV absulute Mean + printf("\tIdle Time value from the most recent SMART Summary Frame: %" PRIu64" \n", vFarmFrame[page].reliPage.reli.idleTime & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< idle Time value from the most recent SMART Summary Frame + } #endif - if (vFarmFrame[page].reliPage.reli.copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) + { + if (m_MajorRev < 4) { - snprintf((char*)myStr.c_str(), BASIC, "Reliability Information From Farm Log copy FACTORY"); + + farm_PrePython_Int(masterData, "idd_operations", "timestamp of last idd test", "reliability information", "milliseconds", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.lastIDDTest)); + farm_PrePython_Int(masterData, "idd_operations", "sub-command of Last idd test", "reliability information", "commmand", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.cmdLastIDDTest)); + farm_PrePython_Int(masterData, "idd_operations", "total reallocated sector reclamations", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.gListReclamed)); + farm_PrePython_Int(masterData, "servo", " status", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.servoStatus)); + farm_PrePython_Int(masterData, "idd_operations", "total slipped sectors before idd scan", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.altsBeforeIDD)); + farm_PrePython_Int(masterData, "idd_operations", "total slipped sectors after idd scan", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.altsAfterIDD)); + farm_PrePython_Int(masterData, "idd_operations", "total resident reallocated sectors before idd scan", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.gListBeforIDD)); + farm_PrePython_Int(masterData, "idd_operations", "total resident reallocated sectors after idd scan", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.gListAfterIDD)); + farm_PrePython_Int(masterData, "idd_operations", "total successfully scrubbed sectors before idd scan", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.scrubsBeforeIDD)); + farm_PrePython_Int(masterData, "idd_operations", "total successfully scrubbed sectors after idd scan", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.scrubsAfterIDD)); + farm_PrePython_Int(masterData, "idd_operations", "total dos scans performed", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.numberDOSScans)); + farm_PrePython_Int(masterData, "idd_operations", "total lbas corrected by isp", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.numberLBACorrect)); + farm_PrePython_Int(masterData, "idd_operations", "total valid parity sectors", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.numberValidParitySec)); + farm_PrePython_Int(masterData, "raw_operations", "total operations", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.numberRAWops)); + farm_PrePython_Int(masterData, "micro_actuator", "lock-out accumulate", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.microActuatorLockOut))); + farm_PrePython_Int(masterData, "disc_slip_reacalibration", "performed", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.diskSlipRecalPerformed)); + farm_PrePython_Int(masterData, "helium_threshold_exceeded", "helium pressure", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.heliumPressuretThreshold)); + farm_PrePython_Int(masterData, "rv_absolute", "mean", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.rvAbsoluteMean))); + farm_PrePython_Int(masterData, "rv_absolute", "max mean", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.maxRVAbsoluteMean)); + farm_PrePython_Int(masterData, "idle_time", "value from smart (most recent)", "reliability information", "milliseconds", RELIABILITY_STATISTICS_PARAMETER, check_Status_Strip_Status(vFarmFrame[page].reliPage.reli.idleTime)); + } else { - snprintf((char*)myStr.c_str(), BASIC, "Reliability Information From Farm Log copy %" PRId32"", page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - - set_json_64_bit_With_Status(pageInfo, "TimeStamp of last IDD test", vFarmFrame[page].reliPage.reli.lastIDDTest, false, m_showStatusBits); //!< Timestamp of last IDD test - set_json_64_bit_With_Status(pageInfo, "Sub-Command of Last IDD Test", vFarmFrame[page].reliPage.reli.cmdLastIDDTest, false, m_showStatusBits); //!< Sub-command of last IDD test - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sector Reclamations", vFarmFrame[page].reliPage.reli.gListReclamed, false, m_showStatusBits); //!< Number of G-List Reclamations - set_json_64_bit_With_Status(pageInfo, "Servo Status", vFarmFrame[page].reliPage.reli.servoStatus, false, m_showStatusBits); //!< Servo Status (follows standard DST error code definitions) - set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors Before IDD Scan", vFarmFrame[page].reliPage.reli.altsBeforeIDD, false, m_showStatusBits); //!< Number of Alt List Entries Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors After IDD Scan", vFarmFrame[page].reliPage.reli.altsAfterIDD, false, m_showStatusBits); //!< Number of Alt List Entries After IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors Before IDD Scan", vFarmFrame[page].reliPage.reli.gListBeforIDD, false, m_showStatusBits); //!< Number of Resident G-List Entries Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors After IDD Scan", vFarmFrame[page].reliPage.reli.gListAfterIDD, false, m_showStatusBits); //!< Number of Resident G-List Entries After IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Successfully Scrubbed Sectors Before IDD Scan", vFarmFrame[page].reliPage.reli.scrubsBeforeIDD, false, m_showStatusBits); //!< Number of Scrub List Entries Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Successfully Scrubbed Sectors After IDD Scan", vFarmFrame[page].reliPage.reli.scrubsAfterIDD, false, m_showStatusBits); //!< Number of Scrub List Entries After IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of DOS Scans Performed", vFarmFrame[page].reliPage.reli.numberDOSScans, false, m_showStatusBits); //!< Number of DOS Scans Performed - set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by ISP", vFarmFrame[page].reliPage.reli.numberLBACorrect, false, m_showStatusBits); //!< Number of LBAs Corrected by ISP - set_json_64_bit_With_Status(pageInfo, "Number of Valid Parity Sectors", vFarmFrame[page].reliPage.reli.numberValidParitySec, false, m_showStatusBits); //!< Number of Valid Parity Sectors - set_json_64_bit_With_Status(pageInfo, "Number of RAW Operations", vFarmFrame[page].reliPage.reli.numberRAWops, false, m_showStatusBits); //!< Number of RAW Operations - set_json_64_bit_With_Status(pageInfo, "Micro Actuator Lock-out accumulated", vFarmFrame[page].reliPage.reli.microActuatorLockOut, false, m_showStatusBits); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames8 - set_json_64_bit_With_Status(pageInfo, "Number of Disc Slip Recalibrations Performed", vFarmFrame[page].reliPage.reli.diskSlipRecalPerformed, false, m_showStatusBits); //!< Number of disc slip recalibrations performed - set_json_64_bit_With_Status(pageInfo, "Helium Pressure Threshold Trip", vFarmFrame[page].reliPage.reli.heliumPressuretThreshold, false, m_showStatusBits); //!< helium Pressure Threshold Trip - set_json_64_bit_With_Status(pageInfo, "RV Absulute Mean", vFarmFrame[page].reliPage.reli.rvAbsuluteMean, false, m_showStatusBits); //!< RV Absulute Mean - set_json_64_bit_With_Status(pageInfo, "Max RV absulute Mean", vFarmFrame[page].reliPage.reli.maxRVAbsuluteMean, false, m_showStatusBits); //!< Max RV absulute Mean - set_json_64_bit_With_Status(pageInfo, "Idle Time value from the most recent SMART Summary Frame", vFarmFrame[page].reliPage.reli.idleTime, false, m_showStatusBits); //!< idle Time value from the most recent SMART Summary Frame + + farm_PrePython_Int(masterData, "raw_operations", "total operations", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, M_DoubleWord0(vFarmFrame[page].reliPage.reli4.numberRAWops)); + farm_PrePython_Int(masterData, "ecc", "total due to erc", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, M_DoubleWord0(vFarmFrame[page].reliPage.reli4.cumECCDueToERC)); + farm_PrePython_Int(masterData, "micro_actuator", "lock-out accumulate", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, M_DoubleWord0(vFarmFrame[page].reliPage.reli4.microActuatorLockOut)); + farm_PrePython_Int(masterData, "disc_slip_reacalibration", "performed", "reliability information", "counts", RELIABILITY_STATISTICS_PARAMETER, M_DoubleWord0(vFarmFrame[page].reliPage.reli4.diskSlipRecalPerformed)); + farm_PrePython_Int(masterData, "helium_threshold_exceeded", "helium pressure", "reliability information", "flag", RELIABILITY_STATISTICS_PARAMETER, M_DoubleWord0(vFarmFrame[page].reliPage.reli4.heliumPressuretThreshold)); + + } } else { -#if defined _DEBUG - if (vFarmFrame[page].reliPage.reli.copyNumber == FACTORYCOPY) + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + if (m_MajorRev < 4) { - printf("Reliability Information From Farm Log copy FACTORY"); + if (vFarmFrame[page].reliPage.reli.copyNumber == FACTORYCOPY) + { + temp << "Reliability Information From Farm Log copy FACTORY"; + } + else + { + temp << "Reliability Information From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); + + set_json_64_bit_With_Status(pageInfo, "Timestamp of last IDD test", vFarmFrame[page].reliPage.reli.lastIDDTest, false, m_showStatusBits); //!< Timestamp of last IDD test + set_json_64_bit_With_Status(pageInfo, "Sub-Command of Last IDD Test", vFarmFrame[page].reliPage.reli.cmdLastIDDTest, false, m_showStatusBits); //!< Sub-command of last IDD test + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sector Reclamations", vFarmFrame[page].reliPage.reli.gListReclamed, false, m_showStatusBits); //!< Number of G-List Reclamations + set_json_64_bit_With_Status(pageInfo, "Servo Status", vFarmFrame[page].reliPage.reli.servoStatus, false, m_showStatusBits); //!< Servo Status (follows standard DST error code definitions) + set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors Before IDD Scan", vFarmFrame[page].reliPage.reli.altsBeforeIDD, false, m_showStatusBits); //!< Number of Alt List Entries Before IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors After IDD Scan", vFarmFrame[page].reliPage.reli.altsAfterIDD, false, m_showStatusBits); //!< Number of Alt List Entries After IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors Before IDD Scan", vFarmFrame[page].reliPage.reli.gListBeforIDD, false, m_showStatusBits); //!< Number of Resident G-List Entries Before IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors After IDD Scan", vFarmFrame[page].reliPage.reli.gListAfterIDD, false, m_showStatusBits); //!< Number of Resident G-List Entries After IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Successfully Scrubbed Sectors Before IDD Scan", vFarmFrame[page].reliPage.reli.scrubsBeforeIDD, false, m_showStatusBits); //!< Number of Scrub List Entries Before IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Successfully Scrubbed Sectors After IDD Scan", vFarmFrame[page].reliPage.reli.scrubsAfterIDD, false, m_showStatusBits); //!< Number of Scrub List Entries After IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of DOS Scans Performed", vFarmFrame[page].reliPage.reli.numberDOSScans, false, m_showStatusBits); //!< Number of DOS Scans Performed + set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by ISP", vFarmFrame[page].reliPage.reli.numberLBACorrect, false, m_showStatusBits); //!< Number of LBAs Corrected by ISP + set_json_64_bit_With_Status(pageInfo, "Number of Valid Parity Sectors", vFarmFrame[page].reliPage.reli.numberValidParitySec, false, m_showStatusBits); //!< Number of Valid Parity Sectors + //set_json_64_bit_With_Status(pageInfo, "Number of RAW Operations", vFarmFrame[page].reliPage.reli.numberRAWops, false, m_showStatusBits); //!< Number of RAW Operations + //set_json_64_bit_With_Status(pageInfo, "Micro Actuator Lock-out accumulated", vFarmFrame[page].reliPage.reli.microActuatorLockOut, false, m_showStatusBits); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames8 + //set_json_64_bit_With_Status(pageInfo, "Number of Disc Slip Recalibrations Performed", vFarmFrame[page].reliPage.reli.diskSlipRecalPerformed, false, m_showStatusBits); //!< Number of disc slip recalibrations performed + //set_json_64_bit_With_Status(pageInfo, "Helium Pressure Threshold Trip", vFarmFrame[page].reliPage.reli.heliumPressuretThreshold, false, m_showStatusBits); //!< helium Pressure Threshold Trip + set_json_64_bit_With_Status(pageInfo, "RV Absolute Mean", vFarmFrame[page].reliPage.reli.rvAbsoluteMean, false, m_showStatusBits); //!< RV Absulute Mean + set_json_64_bit_With_Status(pageInfo, "Max RV absolute Mean", vFarmFrame[page].reliPage.reli.maxRVAbsoluteMean, false, m_showStatusBits); //!< Max RV absulute Mean + set_json_64_bit_With_Status(pageInfo, "Idle Time value from the most recent SMART Summary Frame", vFarmFrame[page].reliPage.reli.idleTime, false, m_showStatusBits); //!< idle Time value from the most recent SMART Summary Frame } else { - printf("\nReliability Information From Farm Log copy: %d\n", page); - } - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved1 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved2 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved3 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved4 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved5 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved6 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved7 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved8 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved9 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved10 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved11 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved12 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tNumber of RAW Operations: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.numberRAWops & 0x00FFFFFFFFFFFFFFLL); - printf("\tCumulative Lifetime ECC due to ERC: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.cumECCDueToERC & 0x00FFFFFFFFFFFFFFLL); - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved13 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved14 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved15 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved16 & 0x00FFFFFFFFFFFFFFLL); //!< Reserved - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved17 & 0x00FFFFFFFFFFFFFFLL); - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved18 & 0x00FFFFFFFFFFFFFFLL); - printf("\tMicro Actuator Lock-out accumulated: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.microActuatorLockOut & 0x00FFFFFFFFFFFFFFLL); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames - printf("\t# of Disc Slip Recalibrations Performed : %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.diskSlipRecalPerformed & 0x00FFFFFFFFFFFFFFLL); //!< Number of disc slip recalibrations performed - printf("\tHelium Pressure Threshold Trip: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.heliumPressuretThreshold & 0x00FFFFFFFFFFFFFFLL); //!< helium Pressure Threshold Trip - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved19 & 0x00FFFFFFFFFFFFFFLL); //!< RV Absulute Mean - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved20 & 0x00FFFFFFFFFFFFFFLL); //!< Max RV absulute Mean - printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved21 & 0x00FFFFFFFFFFFFFFLL); //!< idle Time value from the most recent SMART Summary Frame +#if defined _DEBUG + if (vFarmFrame[page].reliPage.reli.copyNumber == FACTORYCOPY) + { + printf("Reliability Information From Farm Log copy FACTORY"); + } + else + { + printf("\nReliability Information From Farm Log copy: %d\n", page); + } + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved1 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved2 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved3 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved4 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved5 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved6 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved7 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved8 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved9 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved10 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved11 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved12 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tNumber of RAW Operations: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.numberRAWops & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tCumulative Lifetime ECC due to ERC: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.cumECCDueToERC & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved13 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved14 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved15 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved16 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Reserved + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved17 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved18 & UINT64_C(0x00FFFFFFFFFFFFFF)); + printf("\tMicro Actuator Lock-out accumulated: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.microActuatorLockOut & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames + printf("\t# of Disc Slip Recalibrations Performed : %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.diskSlipRecalPerformed & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of disc slip recalibrations performed + printf("\tHelium Pressure Threshold Trip: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.heliumPressuretThreshold & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< helium Pressure Threshold Trip + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved19 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< RV Absulute Mean + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved20 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Max RV absulute Mean + printf("\tReserved: %" PRIu64" \n", vFarmFrame[page].reliPage.reli4.reserved21 & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< idle Time value from the most recent SMART Summary Frame #endif - if (vFarmFrame[page].reliPage.reli.copyNumber == FACTORYCOPY) - { - snprintf((char*)myStr.c_str(), BASIC, "Reliability Information From Farm Log copy FACTORY"); - } - else - { - snprintf((char*)myStr.c_str(), BASIC, "Reliability Information From Farm Log copy %" PRId32"", page); + if (vFarmFrame[page].reliPage.reli.copyNumber == FACTORYCOPY) + { + temp << "Reliability Information From Farm Log copy FACTORY"; + } + else + { + temp << "Reliability Information From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); + + set_json_64_bit_With_Status(pageInfo, "Number of RAW Operations", vFarmFrame[page].reliPage.reli4.numberRAWops, false, m_showStatusBits); //!< Number of RAW Operations + set_json_64_bit_With_Status(pageInfo, "Cumulative Lifetime ECC due to ERC", vFarmFrame[page].reliPage.reli4.cumECCDueToERC, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "Micro Actuator Lock-out accumulated", vFarmFrame[page].reliPage.reli4.microActuatorLockOut, false, m_showStatusBits); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames8 + set_json_64_bit_With_Status(pageInfo, "Number of Disc Slip Recalibrations Performed", vFarmFrame[page].reliPage.reli4.diskSlipRecalPerformed, false, m_showStatusBits); //!< Number of disc slip recalibrations performed + set_json_64_bit_With_Status(pageInfo, "Helium Pressure Threshold Tripped", vFarmFrame[page].reliPage.reli4.heliumPressuretThreshold, false, m_showStatusBits); //!< helium Pressure Threshold Trip } - json_set_name(pageInfo, (char*)myStr.c_str()); - set_json_64_bit_With_Status(pageInfo, "Number of RAW Operations", vFarmFrame[page].reliPage.reli4.numberRAWops, false, m_showStatusBits); //!< Number of RAW Operations - set_json_64_bit_With_Status(pageInfo, "Cumulative Lifetime ECC due to ERC", vFarmFrame[page].reliPage.reli4.cumECCDueToERC, false, m_showStatusBits); - set_json_64_bit_With_Status(pageInfo, "Micro Actuator Lock-out accumulated", vFarmFrame[page].reliPage.reli4.microActuatorLockOut, false, m_showStatusBits); //!< Micro Actuator Lock-out, head mask accumulated over last 3 Summary Frames8 - set_json_64_bit_With_Status(pageInfo, "Number of Disc Slip Recalibrations Performed", vFarmFrame[page].reliPage.reli4.diskSlipRecalPerformed, false, m_showStatusBits); //!< Number of disc slip recalibrations performed - set_json_64_bit_With_Status(pageInfo, "Helium Pressure Threshold Tripped", vFarmFrame[page].reliPage.reli4.heliumPressuretThreshold, false, m_showStatusBits); //!< helium Pressure Threshold Trip + json_push_back(masterData, pageInfo); } - json_push_back(masterData, pageInfo); - return SUCCESS; } //----------------------------------------------------------------------------- @@ -2574,22 +3292,13 @@ eReturnValues CSCSI_Farm_Log::print_Reli_Information(JSONNODE *masterData, uint3 eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNODE *headPage, uint32_t page) { uint32_t loopCount = 0; - std::string myStr = " "; - myStr.resize(BASIC); - - std::string myHeader = " "; - myHeader.resize(BASIC); - - set_Head_Header(myHeader, type); + std::string myHeader; - if (type == NULL) + if (set_Head_Header(myHeader, type) == false) { return FAILURE; } - if (type != RESERVED_FOR_FUTURE_EXPANSION_10 && type != RESERVED_FOR_FUTURE_EXPANSION_11 && type != RESERVED_FOR_FUTURE_EXPANSION_12 && - type != RESERVED_FOR_FUTURE_EXPANSION_13 && type != RESERVED_FOR_FUTURE_EXPANSION_14 && type != RESERVED_FOR_FUTURE_EXPANSION_15 && - type != RESERVED_FOR_FUTURE_EXPANSION_16 && type != RESERVED_FOR_FUTURE_EXPANSION_17 && type != RESERVED_FOR_FUTURE_EXPANSION_18 && - type != RESERVED_FOR_FUTURE_EXPANSION_19 && type != RESERVED_FOR_FUTURE_EXPANSION) + if (type != RESERVED_FOR_FUTURE_EXPANSION) { @@ -2602,404 +3311,1024 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD case ENVIRONMENTAL_STATISTICS_PARAMETER: case RELIABILITY_STATISTICS_PARAMETER: break; - case DISC_SLIP_IN_MICRO_INCHES_BY_HEAD: + case DISC_SLIP_IN_MICRO_INCHES_BY_HEAD: + { + std::ostringstream header; + + //JSONNODE* myArray = json_new(JSON_ARRAY); + //json_set_name(myArray, "Disc Slip in micro-inches"); + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + header.str(""); header.clear(); + header << "Disc Slip in micro-inches by Head " << std::dec << loopCount; + uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].discSlipPerHead.headValue[loopCount]); + int16_t whole = M_WordInt2(dsHead); // get 5:4 whole part of the float + double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } +#if defined _DEBUG + printf("\tDisc Slip in micro-inches for Head %" PRIu32": raw 0x%" PRIx64", calculated %" PRIi16".%04.0f (debug) \n" \ + , loopCount, vFarmFrame[page].discSlipPerHead.headValue[loopCount], whole, decimal); //!< Disc Slip in micro-inches +#endif + + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "head_disc_slip", NULL, loopCount, "micro-inches", DISC_SLIP_IN_MICRO_INCHES_BY_HEAD, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].discSlipPerHead.headValue[loopCount], m_showStatusBits); + } + + } + //json_push_back(headPage, myArray); + } + break; + case BIT_ERROR_RATE_OF_ZONE_0_BY_DRIVE_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { + uint64_t beHead = check_Status_Strip_Status(vFarmFrame[page].bitErrorRateByHead.headValue[loopCount]); + int16_t whole = M_WordInt2(beHead); // get 5:4 whole part of the float + double decimal = static_cast(M_DoubleWordInt0(beHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } +#if defined _DEBUG + printf("\tBit Error Rate of Zone 0 by Head %" PRIu32": raw 0x%" PRIx64", %" PRIi16".%04.0f \n", loopCount, vFarmFrame[page].bitErrorRateByHead.headValue[loopCount], whole, decimal); //!< Bit Error Rate of Zone 0 by Drive Head +#endif + std::ostringstream header; + header << "Bit Error Rate of Zone 0 for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "head_error_rate", "zone 0", loopCount, "bit-error-rate", BIT_ERROR_RATE_OF_ZONE_0_BY_DRIVE_HEAD, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(),number , vFarmFrame[page].bitErrorRateByHead.headValue[loopCount], m_showStatusBits); + } + + } + break; + case DOS_WRITE_REFRESH_COUNT: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tDOS Write Refresh Count by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].dosWriteRefreshCountByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< DOS Write Refresh Count +#endif + std::ostringstream header; + header << "DOS Write Refresh Count for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_dos", "write refresh", loopCount, "counts", DOS_WRITE_REFRESH_COUNT, M_DoubleWord0(check_Status_Strip_Status(vFarmFrame[page].dosWriteRefreshCountByHead.headValue[loopCount]))); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].dosWriteRefreshCountByHead.headValue[loopCount], false, m_showStatusBits); //!< DOS Write Refresh Count + } + } + break; + case DVGA_SKIP_WRITE_DETECT_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tDVGA Skip Write 0 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].dvgaSkipWriteDetectByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< DVGA Skip Write +#endif + std::ostringstream header; + header << "DVGA Skip Write Detect for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_dvga", "skip write detect", loopCount, "counts", DVGA_SKIP_WRITE_DETECT_BY_HEAD, M_DoubleWord0(vFarmFrame[page].dvgaSkipWriteDetectByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].dvgaSkipWriteDetectByHead.headValue[loopCount], false, m_showStatusBits); //!< DVGA Skip Write + } + } + break; + case RVGA_SKIP_WRITE_DETECT_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tRVGA Skip Write 0 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].rvgaSkipWriteDetectByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< RVGA Skip Write +#endif + std::ostringstream header; + header << "RVGA Skip Write Detect for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_rvga", "skip write detect", loopCount, "counts", RVGA_SKIP_WRITE_DETECT_BY_HEAD, M_DoubleWord0(vFarmFrame[page].rvgaSkipWriteDetectByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].rvgaSkipWriteDetectByHead.headValue[loopCount], false, m_showStatusBits); //!< RVGA Skip Write + } + } + break; + case FVGA_SKIP_WRITE_DETECT_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tFVGA Skip Write 0 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fvgaSkipWriteDetectByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< FVGA Skip Write +#endif + std::ostringstream header; + header << "FVGA Skip Write Detect for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_fvga", "skip write detect", loopCount, "counts", FVGA_SKIP_WRITE_DETECT_BY_HEAD, M_DoubleWord0(vFarmFrame[page].fvgaSkipWriteDetectByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].fvgaSkipWriteDetectByHead.headValue[loopCount], false, m_showStatusBits); //!< FVGA Skip Write + } + } + break; + case SKIP_WRITE_DETECT_THRESHOLD_EXCEEDED_COUNT_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tSkip Write Detect Threshold Exceeded Count by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].skipWriteDectedThresholdExceededByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Skip Write Detect Threshold Exceeded Count +#endif + std::ostringstream header; + header << "Skip Write Detect Threshold Exceeded for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_threshold_exceeded", "skip write detect", loopCount, "counts", SKIP_WRITE_DETECT_THRESHOLD_EXCEEDED_COUNT_BY_HEAD, M_DoubleWord0(vFarmFrame[page].skipWriteDectedThresholdExceededByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].skipWriteDectedThresholdExceededByHead.headValue[loopCount], false, m_showStatusBits); //!< Skip Write Detect Threshold Exceeded Count + } + } + break; + case ACFF_SINE_1X_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tACFF Sine 1X for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].acffSine1xValueByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< ACFF Sine 1X, value from most recent SMART Summary Frame +#endif + std::ostringstream header; + header << "ACFF Sine 1X for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_acff", "sine (1x)", loopCount, "counts", ACFF_SINE_1X_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD, static_cast(check_for_signed_int(M_Byte0(check_Status_Strip_Status(vFarmFrame[page].acffSine1xValueByHead.headValue[loopCount])), 8)) * 16); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), static_cast(M_Byte0(vFarmFrame[page].acffSine1xValueByHead.headValue[loopCount])) * 16, vFarmFrame[page].acffSine1xValueByHead.headValue[loopCount], m_showStatusBits); //!< ACFF Sine 1X, value from most recent SMART Summary Frame + } + } + break; + case ACFF_COSINE_1X_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tACFF Cosine 1X for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].acffCosine1xValueByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< ACFF Cosine 1X, value from most recent SMART Summary Frame +#endif + std::ostringstream header; + header << "ACFF Cosine 1X for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_acff", "cosine (1x)", loopCount, "counts", ACFF_COSINE_1X_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD, static_cast(check_for_signed_int(M_Byte0(check_Status_Strip_Status(vFarmFrame[page].acffCosine1xValueByHead.headValue[loopCount])), 8)) * 16); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), static_cast(M_Byte0(vFarmFrame[page].acffCosine1xValueByHead.headValue[loopCount])) * 16, vFarmFrame[page].acffCosine1xValueByHead.headValue[loopCount], m_showStatusBits); //!< ACFF Cosine 1X, value from most recent SMART Summary Frame + } + } + break; + case PZT_CALIBRATION_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tPZT Calibration for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].pztCalibrationValueByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< PZT Calibration, value from most recent SMART Summary Frame +#endif + std::ostringstream header; + header << "PZT Calibration for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_pzt", "calibration", loopCount, "counts", PZT_CALIBRATION_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD, M_DoubleWord0(vFarmFrame[page].pztCalibrationValueByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].pztCalibrationValueByHead.headValue[loopCount], false, m_showStatusBits); //!< PZT Calibration, value from most recent SMART SummaryFrame + } + } + break; + case MR_HEAD_RESISTANCE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tMR Head Resistance for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].mrHeadResistanceByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< MR Head Resistance from most recent SMART Summary Frame +#endif + std::ostringstream header; + header << "MR Head Resistance for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_mr", "resistance", loopCount, "counts", MR_HEAD_RESISTANCE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD, M_DoubleWord0(vFarmFrame[page].mrHeadResistanceByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].mrHeadResistanceByHead.headValue[loopCount], false, m_showStatusBits); //!< MR Head Resistance from most recent SMART Summary Frame + } + } + break; + case NUMBER_OF_TMD_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tNumber of TMD for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].numberOfTMDByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of TMD over last 3 SMART Summary Frame +#endif + std::ostringstream header; + header << "Servo No Timing Mark Detect for Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_tmd", NULL, loopCount, "counts", NUMBER_OF_TMD_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD, M_DoubleWord0(vFarmFrame[page].numberOfTMDByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].numberOfTMDByHead.headValue[loopCount], false, m_showStatusBits); //!< Number of TMD over last 3 SMART Summary Frame + } + } + break; + case VELOCITY_OBSERVER_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tVelocity Observer by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].velocityObserverByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Velocity Observer over last 3 SMART Summary Frame +#endif + std::ostringstream header; + header << "Velocity Observer by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "velocity_observer", "stat head", loopCount, "counts", VELOCITY_OBSERVER_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD, M_DoubleWord0(vFarmFrame[page].velocityObserverByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].velocityObserverByHead.headValue[loopCount], false, m_showStatusBits); //!< Velocity Observer over last 3 SMART Summary Frame + } + } + break; + case NUMBER_OF_VELOCITY_OBSERVER_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tNumber of Velocity Observer by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].numberOfVelocityObservedByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Velocity Observer over last 3 SMART Summary Frame +#endif + std::ostringstream header; + header << "Servo Velocity No Timing Mark Detect by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "number_of_velocity_observer", "stat head", loopCount, "counts", NUMBER_OF_VELOCITY_OBSERVER_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD, M_DoubleWord0(vFarmFrame[page].numberOfVelocityObservedByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].numberOfVelocityObservedByHead.headValue[loopCount], false, m_showStatusBits); //!< Number of Velocity Observer over last 3 SMART Summary Frame + } + } + break; + case CURRENT_H2SAT_PERCENTAGE_OF_CODEWORDS_AT_ITERATION_LEVEL_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tCurrent H2SAT percentage of codewords at iteration level by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2SATPercentagedbyHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT percentage of codewords at iteration level +#endif + std::ostringstream header; + header << "Current H2SAT percentage of codewords at iteration level by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "h2sat", "codeword at iteration level", loopCount, "counts", CURRENT_H2SAT_PERCENTAGE_OF_CODEWORDS_AT_ITERATION_LEVEL_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES, M_DoubleWord0(vFarmFrame[page].currentH2SATPercentagedbyHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].currentH2SATPercentagedbyHead.headValue[loopCount], false, m_showStatusBits); //!< Current H2SAT percentage of codewords at iteration level + } + } + break; + case CURRENT_H2SAT_AMPLITUDE_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: for (loopCount = 0; loopCount < m_heads; ++loopCount) { - uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].discSlipPerHead.headValue[loopCount]); - int16_t whole = M_WordInt2(dsHead); // get 5:4 whole part of the float - double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float #if defined _DEBUG - printf("\tDisc Slip in micro-inches for Head %" PRIu32": raw 0x%" PRIx64", calculated %" PRIi16".%04.0f (debug) \n" \ - , loopCount, vFarmFrame[page].discSlipPerHead.headValue[loopCount], whole, decimal); //!< Disc Slip in micro-inches + printf("\tCurrent H2SAT amplitude by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STAmplituedByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT amplitude, averaged across Test Zone #endif - snprintf((char*)myHeader.c_str(), BASIC, "Disc Slip in micro-inches for Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi16".%04.0f", whole,decimal); //!< Disc Slip in micro-inches by Head - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].discSlipPerHead.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "Current H2SAT amplitude by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "h2sat_amplitude", "current", loopCount, "counts", CURRENT_H2SAT_AMPLITUDE_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES, M_DoubleWord0(vFarmFrame[page].currentH2STAmplituedByHead.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].currentH2STAmplituedByHead.headValue[loopCount], false, m_showStatusBits); //!< Current H2SAT amplitude, averaged across Test Zone + } } break; - case BIT_ERROR_RATE_OF_ZONE_0_BY_DRIVE_HEAD: + case CURRENT_H2SAT_ASYMMETRY_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: for (loopCount = 0; loopCount < m_heads; ++loopCount) { - - uint64_t beHead = check_Status_Strip_Status(vFarmFrame[page].bitErrorRateByHead.headValue[loopCount]); - int16_t whole = M_WordInt2(beHead); // get 5:4 whole part of the float - double decimal = static_cast(M_DoubleWordInt0(beHead)); // get 3:0 for the Deciaml Part of the float #if defined _DEBUG - printf("\tBit Error Rate of Zone 0 by Head %" PRIu32": raw 0x%" PRIx64", %" PRIi16".%04.0f \n", loopCount, vFarmFrame[page].bitErrorRateByHead.headValue[loopCount], whole, decimal); //!< Bit Error Rate of Zone 0 by Drive Head + printf("\tCurrent H2SAT asymmetry by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STAsymmetryByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT asymmetry, averaged across Test Zone #endif - snprintf((char*)myHeader.c_str(), BASIC, "Bit Error Rate of Zone 0 for Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi16".%04.0f", whole, decimal); //!< Bit Error Rate of Zone 0 by Drive Head - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].bitErrorRateByHead.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "Current H2SAT asymmetry by Head " << std::dec << loopCount;// Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "h2sat_asymmetry", "current", loopCount, "counts", CURRENT_H2SAT_ASYMMETRY_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES, static_cast(M_WordInt0(vFarmFrame[page].currentH2STAsymmetryByHead.headValue[loopCount]) * 0.1F)); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), static_cast(M_WordInt0(vFarmFrame[page].currentH2STAsymmetryByHead.headValue[loopCount]) * 0.1F), vFarmFrame[page].currentH2STAsymmetryByHead.headValue[loopCount], m_showStatusBits); //!< Current H2SAT asymmetry, averaged across Test Zone + } } break; - case DOS_WRITE_REFRESH_COUNT: + case NUMBER_OF_RESIDENT_GLIST_ENTRIES: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tDOS Write Refresh Count by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].dosWriteRefreshCountByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< DOS Write Refresh Count + printf("\tNumber of Reallocated Sectors by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].ResidentGlistEntries.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "DOS Write Refresh Count for Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].dosWriteRefreshCountByHead.headValue[loopCount], false, m_showStatusBits); //!< DOS Write Refresh Count + std::ostringstream header; + header << "Reallocated Sectors by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_reallocated", "sectors", loopCount, "counts", NUMBER_OF_RESIDENT_GLIST_ENTRIES, M_DoubleWord0(vFarmFrame[page].ResidentGlistEntries.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].ResidentGlistEntries.headValue[loopCount], false, m_showStatusBits); + } } break; - case DVGA_SKIP_WRITE_DETECT_BY_HEAD: + case NUMBER_OF_PENDING_ENTRIES: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tDVGA Skip Write 0 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].dvgaSkipWriteDetectByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< DVGA Skip Write + printf("\tReallocated Candidate Sectors by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].ResidentPlistEntries.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "DVGA Skip Write Detect for Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].dvgaSkipWriteDetectByHead.headValue[loopCount], false, m_showStatusBits); //!< DVGA Skip Write + std::ostringstream header; + header << "Reallocated Candidate Sectors by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_reallocated", "candidate sectors", loopCount, "counts", NUMBER_OF_PENDING_ENTRIES, M_DoubleWord0(vFarmFrame[page].ResidentPlistEntries.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].ResidentPlistEntries.headValue[loopCount], false, m_showStatusBits); + } } break; - case RVGA_SKIP_WRITE_DETECT_BY_HEAD: + case DOS_OUGHT_TO_SCAN_COUNT_PER_HEAD: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tRVGA Skip Write 0 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].rvgaSkipWriteDetectByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< RVGA Skip Write + printf("\tDOS Ought to scan count by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].DOSOoughtToScan.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "RVGA Skip Write Detect for Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].rvgaSkipWriteDetectByHead.headValue[loopCount], false, m_showStatusBits); //!< RVGA Skip Write + std::ostringstream header; + header << "DOS Ought to scan count by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_dos", "ought to scan", loopCount, "counts", DOS_OUGHT_TO_SCAN_COUNT_PER_HEAD, M_DoubleWord0(vFarmFrame[page].DOSOoughtToScan.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].DOSOoughtToScan.headValue[loopCount], false, m_showStatusBits); + } } break; - case FVGA_SKIP_WRITE_DETECT_BY_HEAD: + case DOS_NEED_TO_SCAN_COUNT_PER_HEAD: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFVGA Skip Write 0 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fvgaSkipWriteDetectByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< FVGA Skip Write + printf("\tDOS needs to scans count by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].DOSNeedToScan.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FVGA Skip Write Detect for Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].fvgaSkipWriteDetectByHead.headValue[loopCount], false, m_showStatusBits); //!< FVGA Skip Write + std::ostringstream header; + header << "DOS needs to scans count by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_dos", "needs to scan", loopCount, "counts", DOS_NEED_TO_SCAN_COUNT_PER_HEAD, M_DoubleWord0(vFarmFrame[page].DOSNeedToScan.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), M_DoubleWord0(vFarmFrame[page].DOSNeedToScan.headValue[loopCount]), false, m_showStatusBits); + } } break; - case SKIP_WRITE_DETECT_THRESHOLD_EXCEEDED_COUNT_BY_HEAD: + case DOS_WRITE_FAULT_SCAN_COUNT_PER_HEAD: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tSkip Write Detect Threshold Exceeded Count by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].skipWriteDectedThresholdExceededByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Skip Write Detect Threshold Exceeded Count + printf("\tDOS write Fault scans by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].DOSWriteFaultScan.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Skip Write Detect Threshold Exceeded for Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].skipWriteDectedThresholdExceededByHead.headValue[loopCount], false, m_showStatusBits); //!< Skip Write Detect Threshold Exceeded Count + std::ostringstream header; + header << "DOS write Fault scans by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_dos", "write fault scan", loopCount, "counts", DOS_WRITE_FAULT_SCAN_COUNT_PER_HEAD, M_DoubleWord0(vFarmFrame[page].DOSWriteFaultScan.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), M_DoubleWord0(vFarmFrame[page].DOSWriteFaultScan.headValue[loopCount]), false, m_showStatusBits); + } } break; - case ACFF_SINE_1X_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: + case WRITE_POWERON_HOURS_FROM_MOST_RECENT_SMART: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tACFF Sine 1X for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].acffSine1xValueByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< ACFF Sine 1X, value from most recent SMART Summary Frame + printf("\tWrite Power On (hrs) value by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].writePowerOnHours.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "ACFF Sine 1X for Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi8"", static_cast(check_for_signed_int(M_Byte0(check_Status_Strip_Status(vFarmFrame[page].acffSine1xValueByHead.headValue[loopCount])), 8)) * 16); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].acffSine1xValueByHead.headValue[loopCount], m_showStatusBits); //!< ACFF Sine 1X, value from most recent SMART Summary Frame + std::ostringstream header; + header << "Write Power On (hrs) by Head " << std::dec << loopCount; // Head count + double number = static_cast(M_DoubleWord0(vFarmFrame[page].writePowerOnHours.headValue[loopCount]) / 3600.0); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "head_write_power_on", NULL, loopCount, "hours", WRITE_POWERON_HOURS_FROM_MOST_RECENT_SMART, number ); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].discSlipPerHead.headValue[loopCount], m_showStatusBits); + } } break; - case ACFF_COSINE_1X_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: + case DOS_WRITE_COUNT_THRESHOLD_PER_HEAD: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tACFF Cosine 1X for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].acffCosine1xValueByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< ACFF Cosine 1X, value from most recent SMART Summary Frame + printf("\tDOS Write Count Threshold by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].dosWriteCount.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "ACFF Cosine 1X for Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi8"", (static_cast(check_for_signed_int(M_Byte0(check_Status_Strip_Status(vFarmFrame[page].acffCosine1xValueByHead.headValue[loopCount])), 8)) * 16)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].acffCosine1xValueByHead.headValue[loopCount], m_showStatusBits); //!< ACFF Cosine 1X, value from most recent SMART Summary Frame + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "head_DOS_write", "threshold", loopCount, "counts", DOS_WRITE_COUNT_THRESHOLD_PER_HEAD, check_Status_Strip_Status(vFarmFrame[page].dosWriteCount.headValue[loopCount])); + } + else + { + std::ostringstream header; + header << "DOS Write Count Threshold by Head " << std::dec << loopCount; // Head count + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].dosWriteCount.headValue[loopCount], false, m_showStatusBits); + } } break; - case PZT_CALIBRATION_VALUE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: + case CUM_LIFETIME_UNRECOVERALBE_READ_REPET_PER_HEAD: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tPZT Calibration for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].pztCalibrationValueByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< PZT Calibration, value from most recent SMART Summary Frame + printf("\tCum Lifetime Unrecoverable Read Repeat %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].cumECCReadRepeat.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "PZT Calibration for Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].pztCalibrationValueByHead.headValue[loopCount], false, m_showStatusBits); //!< PZT Calibration, value from most recent SMART SummaryFrame + std::ostringstream header; + header << "Cum Lifetime Unrecoverable Read Repeating " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "unrecoverable_read", "lifetime repeat", loopCount, "counts", CUM_LIFETIME_UNRECOVERALBE_READ_REPET_PER_HEAD, vFarmFrame[page].cumECCReadRepeat.headValue[loopCount]); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].cumECCReadRepeat.headValue[loopCount], false, m_showStatusBits); + } } break; - case MR_HEAD_RESISTANCE_FROM_MOST_RECENT_SMART_SUMMARY_FRAME_BY_HEAD: + case CUM_LIFETIME_UNRECOVERABLE_READ_UNIQUE_PER_HEAD: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tMR Head Resistance for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].mrHeadResistanceByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< MR Head Resistance from most recent SMART Summary Frame + printf("\tCumlative Lifetime Unrecoverable Read Unique per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].cumECCReadUnique.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "MR Head Resistance for Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].mrHeadResistanceByHead.headValue[loopCount], false, m_showStatusBits); //!< MR Head Resistance from most recent SMART Summary Frame + std::ostringstream header; + header << "Cum Lifetime Unrecoverable Read Unique " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "unrecoverable_read", "lifetime unique", loopCount, "counts", CUM_LIFETIME_UNRECOVERABLE_READ_UNIQUE_PER_HEAD, vFarmFrame[page].cumECCReadUnique.headValue[loopCount]); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].cumECCReadUnique.headValue[loopCount], false, m_showStatusBits); + } } break; - case NUMBER_OF_TMD_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: + case TOTAL_LASER_FIELD_ADJUST_ITERATIONS: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tNumber of TMD for Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].numberOfTMDByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Number of TMD over last 3 SMART Summary Frame + printf("\tFine Laser Calibrations per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].totalLaserFieldAdjustIterations.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Number of TMD for Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].numberOfTMDByHead.headValue[loopCount], false, m_showStatusBits); //!< Number of TMD over last 3 SMART Summary Frame + std::ostringstream header; + header << "Fine Laser Calibrations per head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "laser", "fine calibrations", loopCount, "counts", TOTAL_LASER_FIELD_ADJUST_ITERATIONS, vFarmFrame[page].totalLaserFieldAdjustIterations.headValue[loopCount]); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].totalLaserFieldAdjustIterations.headValue[loopCount], false, m_showStatusBits); + } } - break; - case VELOCITY_OBSERVER_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: + } + break; + case TOTAL_READER_WRITER_OFFSET_ITERATIONS_PERFORMED: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tVelocity Observer by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].velocityObserverByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Velocity Observer over last 3 SMART Summary Frame + printf("\tReader Writer offset Iterations per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].totalReaderWriteerOffsetIterationsPerformed.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Velocity Observer by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].velocityObserverByHead.headValue[loopCount], false, m_showStatusBits); //!< Velocity Observer over last 3 SMART Summary Frame + std::ostringstream header; + header << "Reader Writer offset Iterations per head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "reader_writer", "offset iterations", loopCount, "counts", TOTAL_READER_WRITER_OFFSET_ITERATIONS_PERFORMED, vFarmFrame[page].totalReaderWriteerOffsetIterationsPerformed.headValue[loopCount]); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].totalReaderWriteerOffsetIterationsPerformed.headValue[loopCount], false, m_showStatusBits); + } } - break; - case NUMBER_OF_VELOCITY_OBSERVER_OVER_LAST_3_SMART_SUMMARY_FRAMES_BY_HEAD: + } + break; + case PRE_LFA_ZONE_0: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tNumber of Velocity Observer by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].numberOfVelocityObservedByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Number of Velocity Observer over last 3 SMART Summary Frame + printf("\tPre LFA Optimal BER Zone 0 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].pre_lfaZone_0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Number of Velocity Observer by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].numberOfVelocityObservedByHead.headValue[loopCount], false, m_showStatusBits); //!< Number of Velocity Observer over last 3 SMART Summary Frame + std::ostringstream header; + header << "Pre LFA Optimal BER Zone 0 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].pre_lfaZone_0.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "lfa", "pre optimal zone 0", loopCount, "ber", PRE_LFA_ZONE_0, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].pre_lfaZone_0.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_PERCENTAGE_OF_CODEWORDS_AT_ITERATION_LEVEL_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: + } + break; + case PRE_LFA_ZONE_1: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT percentage of codewords at iteration level by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2SATPercentagedbyHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT percentage of codewords at iteration level + printf("\tPre LFA Optimal BER Zone 1 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].pre_lfaZone_1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT percentage of codewords at iteration level by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].currentH2SATPercentagedbyHead.headValue[loopCount], false, m_showStatusBits); //!< Current H2SAT percentage of codewords at iteration level + std::ostringstream header; + header << "Pre LFA Optimal BER Zone 1 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].pre_lfaZone_1.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "lfa", "pre optimal zone 1", loopCount, "ber", PRE_LFA_ZONE_1, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(),number, vFarmFrame[page].pre_lfaZone_1.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_AMPLITUDE_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: + } + break; + case PRE_LFA_ZONE_2: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT amplitude by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STAmplituedByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT amplitude, averaged across Test Zone + printf("\tPre LFA Optimal BER Zone 2 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].pre_lfaZone_2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT amplitude by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].currentH2STAmplituedByHead.headValue[loopCount], false, m_showStatusBits); //!< Current H2SAT amplitude, averaged across Test Zone + std::ostringstream header; + header << "Pre LFA Optimal BER Zone 2 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].pre_lfaZone_2.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "lfa", "pre optimal zone 2", loopCount, "ber", PRE_LFA_ZONE_2, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].pre_lfaZone_2.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_ASYMMETRY_BY_HEAD_AVERAGED_ACROSS_TEST_ZONES: + } + break; + case ZERO_PERCENT_SHIFT: + { + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tZero Percent Shift Zone 0 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].zeroPercentShift.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); +#endif + std::ostringstream header; + header << "Zero Percent Shift Zone 0 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].zeroPercentShift.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "zero_percent_shift", "zone 0", loopCount, "counts", ZERO_PERCENT_SHIFT, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].zeroPercentShift.headValue[loopCount], m_showStatusBits); + } + } + } + break; + case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_0: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT asymmetry by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STAsymmetryByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT asymmetry, averaged across Test Zone + printf("\tCurrent H2SAT trimmed mean bits in error by Head %" PRIu32": by Test Zone 0: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STTrimmedbyHeadZone0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 0 #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT asymmetry by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].currentH2STAsymmetryByHead.headValue[loopCount], false, m_showStatusBits); //!< Current H2SAT asymmetry, averaged across Test Zone + std::ostringstream header; + header << "Current H2SAT trimmed mean bits in error Zone 0 by Head " << std::dec << loopCount; // Head count + double number = static_cast(M_Word0(vFarmFrame[page].currentH2STTrimmedbyHeadZone0.headValue[loopCount]) * 0.10F); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "h2sat", "trimmed mean zone 0", loopCount, "mean-bits-in-error", CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_0, ROUNDF(number,1000)); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].currentH2STTrimmedbyHeadZone0.headValue[loopCount], m_showStatusBits); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 0 + } } break; - case NUMBER_OF_RESIDENT_GLIST_ENTRIES: + case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_1: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tNumber of Reallocated Sectors by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].ResidentGlistEntries.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tCurrent H2SAT trimmed mean bits in error by Head %" PRIu32": by Test Zone 1: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STTrimmedbyHeadZone1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 1 #endif - snprintf((char*)myHeader.c_str(), BASIC, "Number of Reallocated Sectors by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].ResidentGlistEntries.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "Current H2SAT trimmed mean bits in error Zone 1 by Head " << std::dec << loopCount; // Head count + double number = static_cast(M_Word0(vFarmFrame[page].currentH2STTrimmedbyHeadZone1.headValue[loopCount]) * 0.10F); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "h2sat", "trimmed mean zone 1", loopCount, "mean-bits-in-error", CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_1, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].currentH2STTrimmedbyHeadZone1.headValue[loopCount], m_showStatusBits); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 1 + } } break; - case NUMBER_OF_PENDING_ENTRIES: + case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_2: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tNumber of Reallocation Candidate Sectors by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].ResidentPlistEntries.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tCurrent H2SAT trimmed mean bits in error by Head %" PRIu32" , by Test Zone 2: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STTrimmedbyHeadZone2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 2 #endif - snprintf((char*)myHeader.c_str(), BASIC, "Number of Reallocation Candidate Sectors by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].ResidentPlistEntries.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "Current H2SAT trimmed mean bits in error Zone 2 by Head " << std::dec << loopCount;// Head count + double number = static_cast(M_Word0(vFarmFrame[page].currentH2STTrimmedbyHeadZone2.headValue[loopCount]) * 0.10F); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "h2sat", "trimmed mean zone 2", loopCount, "mean-bits-in-error", CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_2, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].currentH2STTrimmedbyHeadZone2.headValue[loopCount], m_showStatusBits); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 2 + } } break; - case DOS_OUGHT_TO_SCAN_COUNT_PER_HEAD: + case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_0: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tDOS Ought to scan count by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].DOSOoughtToScan.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tCurrent H2SAT iterations to converge by Head %" PRIu32" , by Test Zone 0: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STIterationsByHeadZone0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 0 #endif - snprintf((char*)myHeader.c_str(), BASIC, "DOS Ought to scan count by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].DOSOoughtToScan.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "Current H2SAT iterations to converge Test Zone 0 by Head " << std::dec << loopCount; // Head count + double number = static_cast(M_Word0(vFarmFrame[page].currentH2STIterationsByHeadZone0.headValue[loopCount]) * 0.10F); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "h2sat", "iterations to converge zone 0", loopCount, "counts", CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_0, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].currentH2STIterationsByHeadZone0.headValue[loopCount], m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 0 + } } break; - case DOS_NEED_TO_SCAN_COUNT_PER_HEAD: + case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_1: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tDOS needs to scans count by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].DOSNeedToScan.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tCurrent H2SAT iterations to converge by Head %" PRIu32" , by Test Zone 1: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STIterationsByHeadZone1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 1 #endif - snprintf((char*)myHeader.c_str(), BASIC, "DOS needs to scans count by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].DOSNeedToScan.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "Current H2SAT iterations to converge Test Zone 1 by Head " << std::dec << loopCount; // Head count + double number = static_cast(M_Word0(vFarmFrame[page].currentH2STIterationsByHeadZone1.headValue[loopCount]) * 0.10F); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "h2sat", "iterations to converge zone 1", loopCount, "counts", CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_1, number); + } + else + { + + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].currentH2STIterationsByHeadZone1.headValue[loopCount], m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 1 + } } break; - case DOS_WRITE_FAULT_SCAN_COUNT_PER_HEAD: + case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_2: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tDOS write Fault scans by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].DOSWriteFaultScan.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tCurrent H2SAT iterations to converge by Head %" PRIu32" , by Test Zone 2: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STIterationsByHeadZone2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 2 #endif - snprintf((char*)myHeader.c_str(), BASIC, "DOS write Fault scans by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].DOSWriteFaultScan.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "Current H2SAT iterations to converge Test Zone 2 by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "h2sat", "iterations to converge zone 2", loopCount, "counts", CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_2, static_cast(M_Word0(vFarmFrame[page].currentH2STIterationsByHeadZone2.headValue[loopCount]) * .10F)); + } + else + { + double number = static_cast(M_Word0(vFarmFrame[page].currentH2STIterationsByHeadZone1.headValue[loopCount]) * 0.10F); + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].currentH2STIterationsByHeadZone2.headValue[loopCount], m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 2 + } } break; - case WRITE_POWERON_HOURS_FROM_MOST_RECENT_SMART: + case LASER_OPERATING_ZONE_0: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tWrite Power On (hrs) value by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].writePowerOnHours.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tLaser Operating Current Zone 0 by Head %" PRIu32" : %" PRIu64" \n", loopCount, vFarmFrame[page].laser_operatingZone_0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 2 #endif - snprintf((char*)myHeader.c_str(), BASIC, "Write Power On (hrs) by Head %" PRIu32"", loopCount); // Head count - //set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].writePowerOnHours.headValue[loopCount], false, m_showStatusBits); - snprintf((char*)myStr.c_str(), BASIC, "%0.04f", ROUNDF((static_cast( M_DoubleWord0(vFarmFrame[page].writePowerOnHours.headValue[loopCount])) /3600),1000)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].writePowerOnHours.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "Laser Operating Current Zone 0 by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "laser", "operating current zone 0", loopCount, "count", LASER_OPERATING_ZONE_0, M_DoubleWord0(vFarmFrame[page].laser_operatingZone_0.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), M_DoubleWord0(vFarmFrame[page].laser_operatingZone_0.headValue[loopCount]), false, m_showStatusBits); + } } break; - case DOS_WRITE_COUNT_THRESHOLD_PER_HEAD: + case LASER_OPERATING_ZONE_1: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tDOS Write Count Threshold by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].dosWriteCount.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tLaser Operating Current Zone 1 by Head %" PRIu32" : %" PRIu64" \n", loopCount, vFarmFrame[page].laser_operatingZone_1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 2 #endif - snprintf((char*)myHeader.c_str(), BASIC, "DOS Write Count Threshold by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].dosWriteCount.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "Laser Operating Current Zone 1 by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "laser", "operating current zone 1", loopCount, "count", LASER_OPERATING_ZONE_1, M_DoubleWord0(vFarmFrame[page].laser_operatingZone_1.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), M_DoubleWord0(vFarmFrame[page].laser_operatingZone_1.headValue[loopCount]), false, m_showStatusBits); + } } break; - case CUM_LIFETIME_UNRECOVERALBE_READ_REPET_PER_HEAD: + case LASER_OPERATING_ZONE_2: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCumlative Lifetime Unrecoverable Read Repeat per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].cumECCReadRepeat.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tLaser Operating Current Zone 2 by Head %" PRIu32" : %" PRIu64" \n", loopCount, vFarmFrame[page].laserOperatingZone_2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 2 #endif - snprintf((char*)myHeader.c_str(), BASIC, "Cumlative Lifetime Unrecoverable Read Repeat %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].cumECCReadRepeat.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "Laser Operating Current Zone 2 by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "laser", "operating current zone 2", loopCount, "count", LASER_OPERATING_ZONE_2, M_DoubleWord0(vFarmFrame[page].laserOperatingZone_2.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), M_DoubleWord0(vFarmFrame[page].laserOperatingZone_2.headValue[loopCount]), false, m_showStatusBits); + } } break; - case CUM_LIFETIME_UNRECOVERABLE_READ_UNIQUE_PER_HEAD: + case POST_LFA_OPTIMAL_BER_ZONE_0: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCumlative Lifetime Unrecoverable Read Unique per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].cumECCReadUnique.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tPost LFA Optimal BER Zone 0 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].postLFAOptimalBERZone_0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Cumlative Lifetime Unrecoverable Read Unique %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].cumECCReadUnique.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "Post LFA Optimal BER Zone 0 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].postLFAOptimalBERZone_0.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "lfa", "post optimal zone 0", loopCount, "ber", POST_LFA_OPTIMAL_BER_ZONE_0, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].postLFAOptimalBERZone_0.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_0: + } + break; + case POST_LFA_OPTIMAL_BER_ZONE_1: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT trimmed mean bits in error by Head %" PRIu32": by Test Zone 0: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STTrimmedbyHeadZone0.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 0 + printf("\tPost LFA Optimal BER Zone 1 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].postLFAOptimalBERZone_1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT trimmed mean bits in error Zone 0 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_Word0(vFarmFrame[page].currentH2STTrimmedbyHeadZone0.headValue[loopCount])*.10)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].currentH2STTrimmedbyHeadZone0.headValue[loopCount], m_showStatusBits); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 0 + std::ostringstream header; + header << "Post LFA Optimal BER Zone 1 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].postLFAOptimalBERZone_1.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "lfa", "post optimal zone 1", loopCount, "ber", POST_LFA_OPTIMAL_BER_ZONE_1, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].postLFAOptimalBERZone_1.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_1: + } + break; + case POST_LFA_OPTIMAL_BER_ZONE_2: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT trimmed mean bits in error by Head %" PRIu32": by Test Zone 1: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STTrimmedbyHeadZone1.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 1 + printf("\tPost LFA Optimal BER Zone 2 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].postLFAOptimalBERZone_2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT trimmed mean bits in error Zone 1 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_Word0(vFarmFrame[page].currentH2STTrimmedbyHeadZone1.headValue[loopCount])*.10)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].currentH2STTrimmedbyHeadZone1.headValue[loopCount], m_showStatusBits); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 1 + std::ostringstream header; + header << "Post LFA Optimal BER Zone 2 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].postLFAOptimalBERZone_2.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "lfa", "post optimal zone 2", loopCount, "ber", POST_LFA_OPTIMAL_BER_ZONE_2, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].postLFAOptimalBERZone_2.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_2: + } + break; + case MICRO_JOG_OFFSET_ZONE_0: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT trimmed mean bits in error by Head %" PRIu32" , by Test Zone 2: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STTrimmedbyHeadZone2.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 2 + printf("\tMicro Jog offset Zone 0 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].microJogOffsetZone_0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT trimmed mean bits in error Zone 2 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_Word0(vFarmFrame[page].currentH2STTrimmedbyHeadZone2.headValue[loopCount])*.10)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].currentH2STTrimmedbyHeadZone2.headValue[loopCount], m_showStatusBits);//!< Current H2SAT trimmed mean bits in error by Head, by Test Zone 2 + std::ostringstream header; + header << "Micro Jog offset Zone 0 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].microJogOffsetZone_0.headValue[loopCount])), 16)); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "micro_jog", "zone 0", loopCount, "offset", MICRO_JOG_OFFSET_ZONE_0, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].microJogOffsetZone_0.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_0: + } + break; + case MICRO_JOG_OFFSET_ZONE_1: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT iterations to converge by Head %" PRIu32" , by Test Zone 0: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STIterationsByHeadZone0.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 0 + printf("\tMicro Jog offset Zone 1 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].microJogOffsetZone_1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT iterations to converge Test Zone 0 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_Word0(vFarmFrame[page].currentH2STIterationsByHeadZone0.headValue[loopCount])*.10)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].currentH2STIterationsByHeadZone0.headValue[loopCount], m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 0 + std::ostringstream header; + header << "Micro Jog offset Zone 1 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].microJogOffsetZone_1.headValue[loopCount])), 16)); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "micro_jog", "zone 1", loopCount, "offset", MICRO_JOG_OFFSET_ZONE_1, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].microJogOffsetZone_1.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_1: + } + break; + case MICRO_JOG_OFFSET_ZONE_2: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT iterations to converge by Head %" PRIu32" , by Test Zone 1: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STIterationsByHeadZone1.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 1 + printf("\tMicro Jog offset Zone 2 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].microJogOffsetZone_2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT iterations to converge Test Zone 1 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_Word0(vFarmFrame[page].currentH2STIterationsByHeadZone1.headValue[loopCount])*.10)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].currentH2STIterationsByHeadZone1.headValue[loopCount], m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 1 + std::ostringstream header; + header << "Micro Jog offset Zone 2 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].microJogOffsetZone_2.headValue[loopCount])), 16)); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "micro_jog", "zone 2", loopCount, "offset", MICRO_JOG_OFFSET_ZONE_2, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].microJogOffsetZone_2.headValue[loopCount], m_showStatusBits); + } } - break; - case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_2: + } + break; + case ZERO_PERCENT_SHIFT_ZONE_1: + { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tCurrent H2SAT iterations to converge by Head %" PRIu32" , by Test Zone 2: %" PRIu64" \n", loopCount, vFarmFrame[page].currentH2STIterationsByHeadZone2.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 2 + printf("\tZero Percent Shift Zone 1 per head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].zeroPercentShiftZone_1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "Current H2SAT iterations to converge Test Zone 2 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_Word0(vFarmFrame[page].currentH2STIterationsByHeadZone2.headValue[loopCount])*.10)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].currentH2STIterationsByHeadZone2.headValue[loopCount], m_showStatusBits); //!< Current H2SAT iterations to cnverge by Head, by Test Zone 2 + std::ostringstream header; + header << "Zero Percent Shift Zone 1 per head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].zeroPercentShiftZone_1.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "zero_percent_shift", "zone 1", loopCount, "counts", ZERO_PERCENT_SHIFT_ZONE_1, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(),number, vFarmFrame[page].zeroPercentShiftZone_1.headValue[loopCount], m_showStatusBits); + } } - break; + } + break; case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_OUTER: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFly height clearance delta outer by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].appliedFlyHeightByHeadOuter.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Applied fly height clearance delta per head in thousandths of one Angstrom: Outer by Head + printf("\tFly height clearance delta outer by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].appliedFlyHeightByHeadOuter.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Applied fly height clearance delta per head in thousandths of one Angstrom: Outer by Head #endif - snprintf((char*)myHeader.c_str(), BASIC, "Fly height clearance delta outer by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.03f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].appliedFlyHeightByHeadOuter.headValue[loopCount]))*.001)); //!< Applied fly height clearance delta per head in thousandths of one Angstrom: Outer by Head - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].appliedFlyHeightByHeadOuter.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "Fly height clearance delta outer by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "head_fly_height", "clearance delta (outer)", loopCount, "counts", APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_OUTER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].appliedFlyHeightByHeadOuter.headValue[loopCount])) * .001F)); + } + else + { + double number = static_cast(M_WordInt0(vFarmFrame[page].appliedFlyHeightByHeadOuter.headValue[loopCount]) * 0.001); + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].appliedFlyHeightByHeadOuter.headValue[loopCount], m_showStatusBits); + } } break; case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_INNER: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFly height clearance delta inner by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].appliedFlyHeightByHeadInner.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Applied fly height clearance delta per head in thousandths of one Angstrom: Inner by Head + printf("\tFly height clearance delta inner by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].appliedFlyHeightByHeadInner.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Applied fly height clearance delta per head in thousandths of one Angstrom: Inner by Head #endif - snprintf((char*)myHeader.c_str(), BASIC, "Fly height clearance delta inner by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].appliedFlyHeightByHeadInner.headValue[loopCount]))*.001)); //!< Applied fly height clearance delta per head in thousandths of one Angstrom: Inner by Head - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].appliedFlyHeightByHeadInner.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "Fly height clearance delta inner by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "head_fly_height", "clearance delta (inner)", loopCount, "counts", APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_INNER, static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].appliedFlyHeightByHeadInner.headValue[loopCount])) * .001F)); + } + else + { + double number = static_cast(M_WordInt0(vFarmFrame[page].appliedFlyHeightByHeadInner.headValue[loopCount]) * 0.001); + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].appliedFlyHeightByHeadInner.headValue[loopCount], m_showStatusBits); + } } break; case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_MIDDLE: for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFly height clearance delta middle by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].appliedFlyHeightByHeadMiddle.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Applied fly height clearance delta per head in thousandths of one Angstrom: middle by Head + printf("\tFly height clearance delta middle by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].appliedFlyHeightByHeadMiddle.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Applied fly height clearance delta per head in thousandths of one Angstrom: middle by Head #endif - snprintf((char*)myHeader.c_str(), BASIC, "Fly height clearance delta middle by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].appliedFlyHeightByHeadMiddle.headValue[loopCount])) *.001)); //!< Applied fly height clearance delta per head in thousandths of one Angstrom:middle by Head - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].appliedFlyHeightByHeadMiddle.headValue[loopCount], m_showStatusBits); + std::ostringstream header, temp; + header << "Fly height clearance delta middle by Head " << std::dec << loopCount; // Head count + double number = static_cast(M_WordInt0(vFarmFrame[page].appliedFlyHeightByHeadMiddle.headValue[loopCount]) * 0.001); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "head_fly_height", "clearance delta (middle)", loopCount, "counts", APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_MIDDLE, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].appliedFlyHeightByHeadMiddle.headValue[loopCount], m_showStatusBits); + } } break; - case RESERVED_FOR_FUTURE_EXPANSION_10: - case RESERVED_FOR_FUTURE_EXPANSION_11: - case RESERVED_FOR_FUTURE_EXPANSION_12: - case RESERVED_FOR_FUTURE_EXPANSION_13: - case RESERVED_FOR_FUTURE_EXPANSION_14: - case RESERVED_FOR_FUTURE_EXPANSION_15: - case RESERVED_FOR_FUTURE_EXPANSION_16: - case RESERVED_FOR_FUTURE_EXPANSION_17: - case RESERVED_FOR_FUTURE_EXPANSION_18: - case RESERVED_FOR_FUTURE_EXPANSION_19: -#if defined _DEBUG - printf("\tSomething went wrong, ERROR \n"); -#endif - return FAILURE; - break; case SECOND_MR_HEAD_RESISTANCE: { for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tSecond MR Head Resistance by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].secondMRHeadResistanceByHead.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< Second MR Head Resistance + printf("\tSecond MR Head Resistance by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].secondMRHeadResistanceByHead.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Second MR Head Resistance #endif - snprintf((char*)myHeader.c_str(), BASIC, "Second MR Head Resistance by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].secondMRHeadResistanceByHead.headValue[loopCount]) *.1)); //!< Second MR Head Resistance - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].secondMRHeadResistanceByHead.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "Second MR Head Resistance by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "head_mr", "resistance (second)", loopCount, "counts", SECOND_MR_HEAD_RESISTANCE, static_cast(M_WordInt0(vFarmFrame[page].secondMRHeadResistanceByHead.headValue[loopCount]))); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].secondMRHeadResistanceByHead.headValue[loopCount], false, m_showStatusBits); //!< Second MR Head Resistance + } } } break; @@ -3008,10 +4337,18 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFAFH Measurement Status by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhMeasurementStatus.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); //!< FAFH Measurement Status + printf("\tFAFH Measurement Status by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhMeasurementStatus.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< FAFH Measurement Status #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Measurement Status by Head %" PRIu32"", loopCount); // Head count - set_json_64_bit_With_Status(headPage, (char*)myHeader.c_str(), vFarmFrame[page].fafhMeasurementStatus.headValue[loopCount], false, m_showStatusBits); + std::ostringstream header; + header << "FAFH Measurement Status by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "fafh", "measurement", loopCount, "status", FAFH_MEASUREMENT_STATUS, M_WordInt0(vFarmFrame[page].fafhMeasurementStatus.headValue[loopCount])); + } + else + { + set_json_64_bit_With_Status(headPage, header.str().c_str(), vFarmFrame[page].fafhMeasurementStatus.headValue[loopCount], false, m_showStatusBits); + } } } break; @@ -3019,17 +4356,22 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD { for (loopCount = 0; loopCount < m_heads; ++loopCount) { - uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].fafhRelativeApmlitude.headValue[loopCount]); - int16_t whole = M_WordInt2(dsHead); // get 5:4 whole part of the float - double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float #if defined _DEBUG printf("\tFAFH HF - LF Relative Amplitude by Head%" PRIu32": raw 0x%" PRIx64", calculated %f (debug)\n" , \ loopCount, vFarmFrame[page].fafhRelativeApmlitude.headValue[loopCount], static_cast(M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].fafhRelativeApmlitude.headValue[loopCount]))) * .1); //!< Disc Slip in micro-inches #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH HF-LF Relative Amplitude by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%04.2f", static_cast(M_DoubleWordInt0(check_Status_Strip_Status(vFarmFrame[page].fafhRelativeApmlitude.headValue[loopCount]))) * .1); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafhRelativeApmlitude.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH Relative Amplitude by Head " << std::dec << loopCount; // Head count + double number = static_cast(M_WordInt0(vFarmFrame[page].fafhRelativeApmlitude.headValue[loopCount]) * 0.1); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "fafh", "hf-lf relative", loopCount, "amplitude", FAFH_HF_LF_RELATIVE_APMLITUDE, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].fafhRelativeApmlitude.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3039,13 +4381,29 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD { uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].fafh_bit_error_rate_0.headValue[loopCount]); int16_t whole = M_WordInt2(dsHead); // get 5:4 whole part of the float - double decimal = static_cast(M_DoubleWordInt0(dsHead)) ; // get 3:0 for the Deciaml Part of the float + double decimal = static_cast(M_DoubleWordInt0(dsHead)) ; // get 3:0 for the decimal Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } #if defined _DEBUG - printf("\tFAFH Bit Error Rate 0 by Head %" PRIu32": raw 0x%" PRIx64" calculated %" PRIi16".%03.0f (debug)\n", loopCount, vFarmFrame[page].fafh_bit_error_rate_0.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL, whole,decimal); + printf("\tFAFH Bit Error Rate outer by Head %" PRIu32": raw 0x%" PRIx64" calculated %" PRIi16".%03.0f (debug)\n", loopCount, vFarmFrame[page].fafh_bit_error_rate_0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF), whole,decimal); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Bit Error Rate 0 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi16".%04.0f", whole, decimal); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafh_bit_error_rate_0.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH Bit Error Rate outer by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "fafh", "reserved tracks diameter 0", loopCount, "bit-error-rate", FAFH_BIT_ERROR_RATE_0, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].fafh_bit_error_rate_0.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3056,12 +4414,28 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].fafh_bit_error_rate_1.headValue[loopCount]); int16_t whole = M_WordInt2(dsHead); // get 5:4 whole part of the float double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } #if defined _DEBUG - printf("\tFAFH Bit Error Rate 1 by Head %" PRIu32": raw 0x%" PRIx64" calculated %" PRIi16".%03.0f (debug)\n", loopCount, vFarmFrame[page].fafh_bit_error_rate_1.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL, whole, decimal); + printf("\tFAFH Bit Error Rate inner by Head %" PRIu32": raw 0x%" PRIx64" calculated %" PRIi16".%03.0f (debug)\n", loopCount, vFarmFrame[page].fafh_bit_error_rate_1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF), whole, decimal); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Bit Error Rate 1 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi16".%04.0f", whole, decimal); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafh_bit_error_rate_1.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH Bit Error Rate inner by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "fafh", "reserved tracks diameter 1", loopCount, "bit-error-rate", FAFH_BIT_ERROR_RATE_1, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].fafh_bit_error_rate_1.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3072,12 +4446,28 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD uint64_t dsHead = check_Status_Strip_Status(vFarmFrame[page].fafh_bit_error_rate_2.headValue[loopCount]); int16_t whole = M_WordInt2(dsHead); // get 5:4 whole part of the float double decimal = static_cast(M_DoubleWordInt0(dsHead)); // get 3:0 for the Deciaml Part of the float + double number = 0.0; + if (whole >= 0) + { + number = static_cast(whole) + (decimal * .0001); + } + else + { + number = static_cast(whole) - (decimal * .0001); + } #if defined _DEBUG - printf("\tFAFH Bit Error Rate 2 by Head %" PRIu32": raw 0x%" PRIx64" calculated %" PRIi16".%03.0f (debug)\n", loopCount, vFarmFrame[page].fafh_bit_error_rate_2.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL, whole, decimal); + printf("\tFAFH Bit Error Rate middle by Head %" PRIu32": raw 0x%" PRIx64" calculated %" PRIi16".%03.0f (debug)\n", loopCount, vFarmFrame[page].fafh_bit_error_rate_2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF), whole, decimal); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Bit Error Rate 2 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%" PRIi16".%04.0f", whole, decimal); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafh_bit_error_rate_2.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH Bit Error Rate middle by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Float(headPage, "fafh", "reserved tracks diameter 2", loopCount, "bit-error-rate", FAFH_BIT_ERROR_RATE_2, number); + } + else + { + set_json_float_With_Status(headPage, header.str().c_str(), number, vFarmFrame[page].fafh_bit_error_rate_2.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3086,11 +4476,18 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFAFH Low Frequency 0 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhLowFrequency_0.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tFAFH LF Passive Clearance OD by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhLowFrequency_0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Low Frequency 0 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].fafhLowFrequency_0.headValue[loopCount]) *.001)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafhLowFrequency_0.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH LF Passive Clearance OD by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "fafh", "lf passive clearance 0", loopCount, "counts", FAFH_LOW_FREQUENCY_0, M_Word0(check_Status_Strip_Status(vFarmFrame[page].fafhLowFrequency_0.headValue[loopCount]))); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), M_Word0(vFarmFrame[page].fafhLowFrequency_0.headValue[loopCount]), vFarmFrame[page].fafhLowFrequency_0.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3099,11 +4496,18 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFAFH Low Frequency 1 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhLowFrequency_1.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tFAFH LF Passive Clearance ID by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhLowFrequency_1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Low Frequency 1 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].fafhLowFrequency_1.headValue[loopCount]) *.001)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafhLowFrequency_1.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH LF Passive Clearance ID by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "fafh", "lf passive clearance 1", loopCount, "counts", FAFH_LOW_FREQUENCY_1, M_Word0(vFarmFrame[page].fafhLowFrequency_1.headValue[loopCount])); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), M_Word0(vFarmFrame[page].fafhLowFrequency_1.headValue[loopCount]), vFarmFrame[page].fafhLowFrequency_1.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3112,11 +4516,18 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFAFH Low Frequency 2 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhLowFrequency_2.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tFAFH LF Passive Clearance MD by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhLowFrequency_2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH Low Frequency 2 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].fafhLowFrequency_2.headValue[loopCount]) *.001)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafhLowFrequency_2.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH LF Passive Clearance MD by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "fafh", "lf passive clearance 2", loopCount, "counts", FAFH_LOW_FREQUENCY_2, M_Word0(vFarmFrame[page].fafhLowFrequency_2.headValue[loopCount])); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), M_Word0(vFarmFrame[page].fafhLowFrequency_2.headValue[loopCount]), vFarmFrame[page].fafhLowFrequency_2.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3125,11 +4536,18 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFAFH High Frequency 0 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhHighFrequency_0.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tFAFH HF Passive Clearance OD by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhHighFrequency_0.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH High Frequency 0 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].fafhHighFrequency_0.headValue[loopCount]) *.001)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafhHighFrequency_0.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH HF Passive Clearance OD by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "fafh", "hf passive clearance 0", loopCount, "counts", FAFH_HIGH_FREQUENCY_0, M_Word0(vFarmFrame[page].fafhHighFrequency_0.headValue[loopCount])); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), M_Word0(vFarmFrame[page].fafhHighFrequency_0.headValue[loopCount]), vFarmFrame[page].fafhHighFrequency_0.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3138,11 +4556,18 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFAFH High Frequency 1 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhHighFrequency_1.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tFAFH HF Passive Clearance ID by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhHighFrequency_1.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH High Frequency 1 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].fafhHighFrequency_1.headValue[loopCount]) *.001)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafhHighFrequency_1.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH HF Passive Clearance ID by Head " << std::dec << loopCount; // Head count + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "fafh", "hf passive clearance 1", loopCount, "counts", FAFH_HIGH_FREQUENCY_1, M_Word0(vFarmFrame[page].fafhHighFrequency_1.headValue[loopCount])); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), M_Word0(vFarmFrame[page].fafhHighFrequency_1.headValue[loopCount]), vFarmFrame[page].fafhHighFrequency_1.headValue[loopCount], m_showStatusBits); + } } } break; @@ -3151,15 +4576,43 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD for (loopCount = 0; loopCount < m_heads; ++loopCount) { #if defined _DEBUG - printf("\tFAFH High Frequency 2 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhHighFrequency_2.headValue[loopCount] & 0x00FFFFFFFFFFFFFFLL); + printf("\tFAFH HF Passive Clearance MD by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhHighFrequency_2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); #endif - snprintf((char*)myHeader.c_str(), BASIC, "FAFH High Frequency 2 by Head %" PRIu32"", loopCount); // Head count - snprintf((char*)myStr.c_str(), BASIC, "%0.02f", static_cast(M_WordInt0(vFarmFrame[page].fafhHighFrequency_2.headValue[loopCount]) *.001)); - set_json_string_With_Status(headPage, (char*)myHeader.c_str(), (char*)myStr.c_str(), vFarmFrame[page].fafhHighFrequency_2.headValue[loopCount], m_showStatusBits); + std::ostringstream header; + header << "FAFH HF Passive Clearance MD by Head " << std::dec << loopCount; // Head count + uint32_t number = M_Word0(vFarmFrame[page].fafhHighFrequency_2.headValue[loopCount]); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "fafh", "hf passive clearance 2", loopCount, "counts", FAFH_HIGH_FREQUENCY_2, number); + } + else + { + set_json_int_Check_Status(headPage, header.str().c_str(), number, vFarmFrame[page].fafhHighFrequency_2.headValue[loopCount], m_showStatusBits); + } } } break; - case RESERVED_FOR_FUTURE_EXPANSION_31: + case ZERO_PERCENT_SHIFT_ZONE_2: + { + for (loopCount = 0; loopCount < m_heads; ++loopCount) + { +#if defined _DEBUG + printf("\tZero Percent shift Zone 2 by Head %" PRIu32": %" PRIu64" \n", loopCount, vFarmFrame[page].fafhHighFrequency_2.headValue[loopCount] & UINT64_C(0x00FFFFFFFFFFFFFF)); +#endif + std::ostringstream temp; + temp.str(""); temp.clear(); + temp << "Zero Percent shift Zone 2 by Head " << std::dec << loopCount; // Head count + int16_t number = static_cast(check_for_signed_int(M_WordInt0(check_Status_Strip_Status(vFarmFrame[page].zeroPercentShiftZone_2.headValue[loopCount])), 16) * 1000); + if (g_dataformat == PREPYTHON_DATA) + { + prePython_Head_Int(headPage, "zero_perent_shift", "Zone 2", loopCount, "percent", ZERO_PERCENT_SHIFT_ZONE_2, number); + } + else + { + set_json_int_Check_Status(headPage, temp.str().c_str(),number, vFarmFrame[page].zeroPercentShiftZone_2.headValue[loopCount], m_showStatusBits); + } + } + } case LUN_0_ACTUATOR: case LUN_0_FLASH_LED: case LUN_REALLOCATION_0: @@ -3255,12 +4708,8 @@ eReturnValues CSCSI_Farm_Log::print_Head_Information(eLogPageTypes type, JSONNOD //! \return SUCCESS // //--------------------------------------------------------------------------- -eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Information(JSONNODE *masterData, uint32_t page, uint32_t index, uint16_t actNum) +eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Information(JSONNODE *LUNData, uint32_t page, uint16_t actNum) { - std::string myStr = " "; - myStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - sLUNStruct *pLUN; pLUN = &vFarmFrame[page].vLUN50; if (actNum == LUN_1_ACTUATOR) @@ -3281,66 +4730,121 @@ eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Information(JSONNODE *masterDat { printf("\nLUN Actuator 0x%" PRIx16" Information From Farm Log copy: %" PRIu32"\n", M_Word0(pLUN->LUNID), page); } - printf("\tPage Number: 0x%" PRIx64" \n", pLUN->pageNumber & 0x00FFFFFFFFFFFFFFLL); //!< Page Number - printf("\tCopy Number: %" PRIu64" \n", pLUN->copyNumber & 0x00FFFFFFFFFFFFFFLL); //!< Copy Number - printf("\tLUN ID: %" PRIu64" \n", pLUN->LUNID & 0x00FFFFFFFFFFFFFFLL); //!< LUN ID - printf("\tHead Load Events: %" PRIu64" \n", pLUN->headLoadEvents & 0x00FFFFFFFFFFFFFFLL); //!< Head Load Events - printf("\tNumber of Reallocated Sectors: %" PRIu64" \n", pLUN->reallocatedSectors & 0x00FFFFFFFFFFFFFFLL); //!< Number of Reallocated Sectors - printf("\tNumber of Reallocated Candidate Sectors: %" PRIu64" \n", pLUN->reallocatedCandidates & 0x00FFFFFFFFFFFFFFLL); //!< Number of Reallocated Candidate Sectors - printf("\tTimeStamp of last IDD test: %" PRIu64" \n", pLUN->timeStampOfIDD & 0x00FFFFFFFFFFFFFFLL); //!< Timestamp of last IDD test - printf("\tSub-Command of Last IDD Test: %" PRIu64" \n", pLUN->subCmdOfIDD & 0x00FFFFFFFFFFFFFFLL); //!< Sub-command of last IDD test - printf("\tNumber of Reallocated Sector Reclamations: %" PRIu64" \n", pLUN->reclamedGlist & 0x00FFFFFFFFFFFFFFLL); //!< Number of G-list reclamations - printf("\tServo Status: %" PRIu64" \n", pLUN->servoStatus & 0x00FFFFFFFFFFFFFFLL); //!< Servo Status - printf("\tNumber of Slipped Sectors Before IDD Scan: %" PRIu64" \n", pLUN->slippedSectorsBeforeIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Slipped Sectors Before IDD Scan - printf("\tNumber of Slipped Sectors After IDD Scan: %" PRIu64" \n", pLUN->slippedSectorsAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Slipped Sectors After IDD Scan - printf("\tResident Reallocated Sectors Before IDD Scan: %" PRIu64" \n", pLUN->residentReallocatedBeforeIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Resident Reallocated Sectors Before IDD Scan - printf("\tResident Reallocated Sectors After IDD Scan: %" PRIu64" \n", pLUN->residentReallocatedAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Resident Reallocated Sectors After IDD Scan - printf("\tSuccessfully Scrubbed Sectors Before IDD Scan:%" PRIu64" \n", pLUN->successScrubbedBeforeIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Successfully Scrubbed Sectors Before IDD Scan - printf("\tSuccessfully Scrubbed Sectors After IDD Scan: %" PRIu64" \n", pLUN->successScrubbedAfterIDD & 0x00FFFFFFFFFFFFFFLL); //!< Number of Successfully Scrubbed Sectors After IDD Scan - printf("\tNumber of DOS Scans Performed: %" PRIu64" \n", pLUN->dosScansPerformed & 0x00FFFFFFFFFFFFFFLL); //!< Number of DOS Scans Performed - printf("\tNumber of LBAs Corrected by ISP: %" PRIu64" \n", pLUN->correctedLBAbyISP & 0x00FFFFFFFFFFFFFFLL); //!< Number of LBAs Corrected by ISP - printf("\tNumber of Valid Parity Sectors: %" PRIu64" \n", pLUN->paritySectors & 0x00FFFFFFFFFFFFFFLL); //!< Number of Valid Parity Sectors - printf("\tRV Absulute Mean: %" PRIu64" \n", pLUN->RVabsolue & 0x00FFFFFFFFFFFFFFLL); //!< RV Absulute Mean - printf("\tMax RV absulute Mean: %" PRIu64" \n", pLUN->maxRVabsolue & 0x00FFFFFFFFFFFFFFLL); //!< Max RV absulute Mean - printf("\tIdle Time: %" PRIu64" \n", pLUN->idleTime & 0x00FFFFFFFFFFFFFFLL); //!< idle Time value from the most recent SMART Summary Frame - printf("\tNumber of LBAs Corrected by Parity Sector: %" PRIu64" \n", pLUN->lbasCorrectedByParity & 0x00FFFFFFFFFFFFFFLL); //!< Number of LBAs Corrected by Parity Sector + printf("\tPage Number: 0x%" PRIx64" \n", pLUN->pageNumber & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Page Number + printf("\tCopy Number: %" PRIu64" \n", pLUN->copyNumber & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Copy Number + printf("\tLUN ID: %" PRIu64" \n", pLUN->LUNID & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< LUN ID + printf("\tHead Load Events: %" PRIu64" \n", pLUN->headLoadEvents & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Head Load Events + if (pLUN->reallocatedSectors != 0) + { + printf("\tNumber of Reallocated Sectors: %" PRIu64" \n", pLUN->reallocatedSectors & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Reallocated Sectors + } + if (pLUN->reallocatedCandidates != 0) + { + printf("\tNumber of Reallocated Candidate Sectors: %" PRIu64" \n", pLUN->reallocatedCandidates & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Reallocated Candidate Sectors + } + printf("\tNumber of Reallocated Candidate Sectors: %" PRIu64" \n", pLUN->reallocatedCandidates & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Reallocated Candidate Sectors + printf("\tTimeStamp of last IDD test: %" PRIu64" \n", pLUN->timeStampOfIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Timestamp of last IDD test + printf("\tSub-Command of Last IDD Test: %" PRIu64" \n", pLUN->subCmdOfIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Sub-command of last IDD test + printf("\tNumber of Reallocated Sector Reclamations: %" PRIu64" \n", pLUN->reclamedGlist & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of G-list reclamations + printf("\tServo Status: %" PRIu64" \n", pLUN->servoStatus & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Servo Status + printf("\tNumber of Slipped Sectors Before IDD Scan: %" PRIu64" \n", pLUN->slippedSectorsBeforeIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Slipped Sectors Before IDD Scan + printf("\tNumber of Slipped Sectors After IDD Scan: %" PRIu64" \n", pLUN->slippedSectorsAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Slipped Sectors After IDD Scan + printf("\tResident Reallocated Sectors Before IDD Scan: %" PRIu64" \n", pLUN->residentReallocatedBeforeIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Resident Reallocated Sectors Before IDD Scan + printf("\tResident Reallocated Sectors After IDD Scan: %" PRIu64" \n", pLUN->residentReallocatedAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Resident Reallocated Sectors After IDD Scan + printf("\tSuccessfully Scrubbed Sectors Before IDD Scan:%" PRIu64" \n", pLUN->successScrubbedBeforeIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Successfully Scrubbed Sectors Before IDD Scan + printf("\tSuccessfully Scrubbed Sectors After IDD Scan: %" PRIu64" \n", pLUN->successScrubbedAfterIDD & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Successfully Scrubbed Sectors After IDD Scan + printf("\tNumber of DOS Scans Performed: %" PRIu64" \n", pLUN->dosScansPerformed & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of DOS Scans Performed + printf("\tNumber of LBAs Corrected by ISP: %" PRIu64" \n", pLUN->correctedLBAbyISP & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by ISP + printf("\tNumber of Valid Parity Sectors: %" PRIu64" \n", pLUN->paritySectors & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of Valid Parity Sectors + printf("\tRV Absulute Mean: %" PRIu64" \n", pLUN->RVabsolue & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< RV Absulute Mean + printf("\tMax RV absulute Mean: %" PRIu64" \n", pLUN->maxRVabsolue & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Max RV absulute Mean + printf("\tIdle Time: %" PRIu64" \n", pLUN->idleTime & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< idle Time value from the most recent SMART Summary Frame + printf("\tNumber of LBAs Corrected by Parity Sector: %" PRIu64" \n", pLUN->lbasCorrectedByParity & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Number of LBAs Corrected by Parity Sector #endif - if (pLUN->copyNumber == FACTORYCOPY) + + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "LUN Actuator 0x%" PRIX16" Information From Farm Log copy FACTORY",M_Word0(pLUN->LUNID)); + farm_PrePython_Int(LUNData, "LUN_actuator", "LUN actuator id", "LUN actuator", "id", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->LUNID)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "head load events", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->headLoadEvents)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "timestamp of last IDD", "LUN actuator", "hours", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->timeStampOfIDD)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "sub-command of last IDD", "LUN actuator", "command", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->subCmdOfIDD)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "reallocated sectors reclaimed", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->reclamedGlist)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "servo status", "LUN actuator", "status", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->servoStatus)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "total slipped sectors before IDD scan", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->slippedSectorsBeforeIDD)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "total slipped sectors after IDD scan", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->slippedSectorsAfterIDD)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "total resident reallocated sectors before IDD scan", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->residentReallocatedBeforeIDD)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "total resident reallocated sectors after IDD scan", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->residentReallocatedAfterIDD)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "successfully scrubbed sectors before IDD scan", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->successScrubbedBeforeIDD)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "successfully scrubbed sectors after IDD scan", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->successScrubbedAfterIDD)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "total DOS scans performed", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->dosScansPerformed)))); + farm_PrePython_Int(LUNData, "LUN_actuator", "total LBAs corrected by ISP", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->correctedLBAbyISP)))); //!< Number of LBAs Corrected by ISP + farm_PrePython_Int(LUNData, "LUN_actuator", "total valid parity sectors", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->paritySectors)))); //!< Number of Valid Parity Sectors + farm_PrePython_Int(LUNData, "LUN_actuator", "rv absolute mean", "LUN actuator", "rad", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->RVabsolue)))); //!< RV Absulute Mean + farm_PrePython_Int(LUNData, "LUN_actuator", "max rv absolute mean", "LUN actuator", "rad", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->maxRVabsolue)))); //!< Max RV absulute Mean + + farm_PrePython_Float(LUNData, "LUN_actuator", "idle time", "LUN actuator", "hours", actNum, static_cast(M_DoubleWord0(check_Status_Strip_Status(pLUN->idleTime)) * 1.0) / 3600); //!< idle Time value from the most recent SMART Summary Frame + farm_PrePython_Int(LUNData, "LUN_actuator", "total LBAs corrected by parity sector", "LUN actuator", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pLUN->lbasCorrectedByParity)))); //!< Number of LBAs Corrected by Parity Sector + farm_PrePython_Int(LUNData, "LUN_actuator", "current low vibe score", "LUN actuator", "frequency", actNum, static_cast (check_Status_Strip_Status(pLUN->currentLowFrequencyVibe))); + farm_PrePython_Int(LUNData, "LUN_actuator", "current mid vibe score", "LUN actuator", "frequency", actNum, static_cast (check_Status_Strip_Status(pLUN->currentMidFrequencyVibe))); + farm_PrePython_Int(LUNData, "LUN_actuator", "current high vibe score", "LUN actuator", "frequency", actNum, static_cast (check_Status_Strip_Status(pLUN->currentHighFrequencyVibe))); + farm_PrePython_Int(LUNData, "LUN_actuator", "worst low vibe score", "LUN actuator", "frequency", actNum, static_cast (check_Status_Strip_Status(pLUN->worstLowFrequencyVibe))); + farm_PrePython_Int(LUNData, "LUN_actuator", "worst mid vibe score", "LUN actuator", "frequency", actNum, static_cast (check_Status_Strip_Status(pLUN->worstMidFrequencyVibe))); + farm_PrePython_Int(LUNData, "LUN_actuator", "worst high vibe score", "LUN actuator", "frequency", actNum, static_cast (check_Status_Strip_Status(pLUN->worstHighFrequencyVibe))); + farm_PrePython_Int(LUNData, "LUN_actuator", "primary super parity coverage", "LUN actuator", "percentage", actNum, static_cast (check_Status_Strip_Status(pLUN->primarySPCovPercentage))); + farm_PrePython_Int(LUNData, "LUN_actuator", "primary super parity coverage SMR", "LUN actuator", "percentage", actNum, static_cast (check_Status_Strip_Status(pLUN->primarySPCovPercentageSMR))); } else { - snprintf((char*)myStr.c_str(), BASIC, "LUN Actuator Information 0x%" PRIX16" From Farm Log copy %" PRId32"", M_Word0(pLUN->LUNID), page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); - - set_json_64_bit_With_Status(pageInfo, "Page Number", pLUN->pageNumber, true, m_showStatusBits); //!< Page Number - set_json_64_bit_With_Status(pageInfo, "Copy Number ", pLUN->copyNumber, false, m_showStatusBits); //!< Copy Number - set_json_64_bit_With_Status(pageInfo, "LUN Actuator ID", pLUN->LUNID, false, m_showStatusBits); //!< LUN ID - set_json_64_bit_With_Status(pageInfo, "Head Load Events", pLUN->headLoadEvents, false, m_showStatusBits); //!< Head Load Events - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors", pLUN->reallocatedSectors, false, m_showStatusBits); //!< Number of Reallocated Sectors - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors Candidate", pLUN->reallocatedSectors, false, m_showStatusBits); //!< Number of Reallocated Candidate Sectors - set_json_64_bit_With_Status(pageInfo, "TimeStamp of last IDD test", pLUN->timeStampOfIDD, false, m_showStatusBits); //!< Timestamp of last IDD test - set_json_64_bit_With_Status(pageInfo, "Sub-Command of Last IDD Test", pLUN->subCmdOfIDD, false, m_showStatusBits); //!< Sub-command of last IDD test - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sector Reclamations", pLUN->reclamedGlist, false, m_showStatusBits); //!< Number of G-list reclamations - set_json_64_bit_With_Status(pageInfo, "Servo Status", pLUN->servoStatus, false, m_showStatusBits); //!< Servo Status - set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors Before IDD Scan", pLUN->slippedSectorsBeforeIDD, false, m_showStatusBits); //!< Number of Slipped Sectors Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors After IDD Scan", pLUN->slippedSectorsAfterIDD, false, m_showStatusBits); //!< Number of Slipped Sectors After IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors Before IDD Scan", pLUN->residentReallocatedBeforeIDD, false, m_showStatusBits); //!< Number of Resident Reallocated Sectors Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors After IDD Scan", pLUN->residentReallocatedAfterIDD, false, m_showStatusBits); //!< Number of Resident Reallocated Sectors After IDD Scan - set_json_64_bit_With_Status(pageInfo, "Successfully Scrubbed Sectors Before IDD Scan", pLUN->successScrubbedBeforeIDD, false, m_showStatusBits); //!< Number of Successfully Scrubbed Sectors Before IDD Scan - set_json_64_bit_With_Status(pageInfo, "Successfully Scrubbed Sectors After IDD Scan", pLUN->successScrubbedAfterIDD, false, m_showStatusBits); //!< Number of Successfully Scrubbed Sectors After IDD Scan - set_json_64_bit_With_Status(pageInfo, "Number of DOS Scans Performed", pLUN->dosScansPerformed, false, m_showStatusBits); //!< Number of DOS Scans Performed - set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by ISP", pLUN->correctedLBAbyISP, false, m_showStatusBits); //!< Number of LBAs Corrected by ISP - set_json_64_bit_With_Status(pageInfo, "Number of Valid Parity Sectors", pLUN->paritySectors, false, m_showStatusBits); //!< Number of Valid Parity Sectors - set_json_64_bit_With_Status(pageInfo, "RV Absulute Mean", pLUN->RVabsolue, false, m_showStatusBits); //!< RV Absulute Mean - set_json_64_bit_With_Status(pageInfo, "Max RV Absolute Mean", pLUN->maxRVabsolue, false, m_showStatusBits); //!< Max RV absulute Mean - snprintf((char*)myStr.c_str(), BASIC, "%0.03lf", static_cast(M_DoubleWord0(check_Status_Strip_Status(pLUN->idleTime))* 1.0) / 3600); - set_json_string_With_Status(pageInfo, "Idle Time (hours)", (char*)myStr.c_str(), pLUN->idleTime, m_showStatusBits); //!< idle Time value from the most recent SMART Summary Frame - set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by Parity Sector", pLUN->lbasCorrectedByParity, false, m_showStatusBits); //!< Number of LBAs Corrected by Parity Sector - json_push_back(masterData, pageInfo); + std::ostringstream temp; + JSONNODE* pageInfo = json_new(JSON_NODE); + if (pLUN->copyNumber == FACTORYCOPY) + { + temp << "LUN Actuator 0x" << std::hex << M_Word0(pLUN->LUNID) << " Information From Farm Log copy FACTORY"; + } + else + { + temp << "LUN Actuator Information 0x" << std::hex << M_Word0(pLUN->LUNID) <<" From Farm Log copy " <pageNumber, true, m_showStatusBits); //!< Page Number + set_json_64_bit_With_Status(pageInfo, "Copy Number ", pLUN->copyNumber, false, m_showStatusBits); //!< Copy Number + set_json_64_bit_With_Status(pageInfo, "LUN Actuator ID", pLUN->LUNID, false, m_showStatusBits); //!< LUN ID + set_json_64_bit_With_Status(pageInfo, "Head Load Events", pLUN->headLoadEvents, false, m_showStatusBits); //!< Head Load Events + if (pLUN->reallocatedSectors != 0) + { + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors", pLUN->reallocatedSectors, false, m_showStatusBits); //!< Number of Reallocated Sectors + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors Candidate", pLUN->reallocatedCandidates, false, m_showStatusBits); //!< Number of Reallocated Candidate Sectors + } + set_json_64_bit_With_Status(pageInfo, "TimeStamp of last IDD test", pLUN->timeStampOfIDD, false, m_showStatusBits); //!< Timestamp of last IDD test + set_json_64_bit_With_Status(pageInfo, "Sub-Command of Last IDD Test", pLUN->subCmdOfIDD, false, m_showStatusBits); //!< Sub-command of last IDD test + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sector Reclamations", pLUN->reclamedGlist, false, m_showStatusBits); //!< Number of G-list reclamations + set_json_64_bit_With_Status(pageInfo, "Servo Status", pLUN->servoStatus, false, m_showStatusBits); //!< Servo Status + set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors Before IDD Scan", pLUN->slippedSectorsBeforeIDD, false, m_showStatusBits); //!< Number of Slipped Sectors Before IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Slipped Sectors After IDD Scan", pLUN->slippedSectorsAfterIDD, false, m_showStatusBits); //!< Number of Slipped Sectors After IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors Before IDD Scan", pLUN->residentReallocatedBeforeIDD, false, m_showStatusBits); //!< Number of Resident Reallocated Sectors Before IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of Resident Reallocated Sectors After IDD Scan", pLUN->residentReallocatedAfterIDD, false, m_showStatusBits); //!< Number of Resident Reallocated Sectors After IDD Scan + set_json_64_bit_With_Status(pageInfo, "Successfully Scrubbed Sectors Before IDD Scan", pLUN->successScrubbedBeforeIDD, false, m_showStatusBits); //!< Number of Successfully Scrubbed Sectors Before IDD Scan + set_json_64_bit_With_Status(pageInfo, "Successfully Scrubbed Sectors After IDD Scan", pLUN->successScrubbedAfterIDD, false, m_showStatusBits); //!< Number of Successfully Scrubbed Sectors After IDD Scan + set_json_64_bit_With_Status(pageInfo, "Number of DOS Scans Performed", pLUN->dosScansPerformed, false, m_showStatusBits); //!< Number of DOS Scans Performed + set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by ISP", pLUN->correctedLBAbyISP, false, m_showStatusBits); //!< Number of LBAs Corrected by ISP + set_json_64_bit_With_Status(pageInfo, "Number of Valid Parity Sectors", pLUN->paritySectors, false, m_showStatusBits); //!< Number of Valid Parity Sectors + set_json_64_bit_With_Status(pageInfo, "RV Absulute Mean", pLUN->RVabsolue, false, m_showStatusBits); //!< RV Absulute Mean + set_json_64_bit_With_Status(pageInfo, "Max RV Absolute Mean", pLUN->maxRVabsolue, false, m_showStatusBits); //!< Max RV absulute Mean + temp.str("");temp.clear(); + temp << std::fixed << std::setprecision(3) << (static_cast(M_DoubleWord0(check_Status_Strip_Status(pLUN->idleTime)) * 1.0) / 3600); + set_json_string_With_Status(pageInfo, "Idle Time (hours)", temp.str().c_str(), pLUN->idleTime, m_showStatusBits); //!< idle Time value from the most recent SMART Summary Frame + set_json_64_bit_With_Status(pageInfo, "Number of LBAs Corrected by Parity Sector", pLUN->lbasCorrectedByParity, false, m_showStatusBits); //!< Number of LBAs Corrected by Parity Sector + set_json_64_bit_With_Status(pageInfo, "current low vibe score", pLUN->currentLowFrequencyVibe, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "current mid vibe score", pLUN->currentMidFrequencyVibe, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "current high vibe score", pLUN->currentHighFrequencyVibe, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "worst low vibe score", pLUN->worstLowFrequencyVibe, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "worst mid vibe score", pLUN->worstMidFrequencyVibe, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "worst high vibe score", pLUN->worstHighFrequencyVibe, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "primary super parity coverage", pLUN->primarySPCovPercentage, false, m_showStatusBits); + set_json_64_bit_With_Status(pageInfo, "primary super parity coverage SMR", pLUN->primarySPCovPercentageSMR, false, m_showStatusBits); + json_push_back(LUNData, pageInfo); + } return SUCCESS; } //----------------------------------------------------------------------------- @@ -3358,16 +4862,10 @@ eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Information(JSONNODE *masterDat //! \return SUCCESS // //--------------------------------------------------------------------------- -eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_FLED_Info(JSONNODE *masterData, uint32_t page, uint32_t index, uint16_t actNum) +eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_FLED_Info(JSONNODE *LUNFLED, uint32_t page, uint16_t actNum) { uint16_t i = 0; - std::string myStr = " "; - std::string timeStr = " "; - myStr.resize(BASIC); - timeStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - sActuatorFLEDInfo *pFLED; if (actNum == LUN_1_FLASH_LED) pFLED = &vFarmFrame[page].fled61; @@ -3387,63 +4885,120 @@ eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_FLED_Info(JSONNODE *masterData, { printf("\nActuator 0x%" PRIx16" FLED Info From Farm Log copy %" PRIu32"\n", M_Word0(pFLED->actID), page); } - printf("\tPage Number: 0x%" PRIx64" \n", pFLED->pageNumber & 0x00FFFFFFFFFFFFFFLL); //!< Page Number - printf("\tCopy Number: %" PRIu64" \n", pFLED->copyNumber & 0x00FFFFFFFFFFFFFFLL); //!< Copy Number - printf("\tActuator ID: %" PRIu64" \n", pFLED->actID & 0x00FFFFFFFFFFFFFFLL); //!< Actuator ID - printf("\tTotal Flash LED Events: %" PRIu64" \n", pFLED->totalFLEDEvents & 0x00FFFFFFFFFFFFFFLL); //!< Total Flash LED Events - printf("\tIndex of Last Flash LED: %" PRIu64" \n", pFLED->index & 0x00FFFFFFFFFFFFFFLL); //!< Index of last entry in FLED Info array below, in case the array wraps + printf("\tPage Number: 0x%" PRIx64" \n", pFLED->pageNumber & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Page Number + printf("\tCopy Number: %" PRIu64" \n", pFLED->copyNumber & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Copy Number + printf("\tActuator ID: %" PRIu64" \n", pFLED->actID & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Actuator ID + printf("\tTotal Flash LED Events: %" PRIu64" \n", pFLED->totalFLEDEvents & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Flash LED Events + printf("\tIndex of Last Flash LED: %" PRIu64" \n", pFLED->index & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Index of last entry in FLED Info array below, in case the array wraps for (i = 0; i < FLASH_EVENTS; i++) { - printf("\tInformation of Event %" PRIu16": 0x%" PRIx64" \n", i,pFLED->flashLEDArray[i] & 0x00FFFFFFFFFFFFFFLL); //!< Info on the last 8 Flash LED (assert) Events, wrapping array - printf("\tTimeStamp of Event%" PRIu16": %" PRIu64" \n", i,pFLED->timestampForLED[i] & 0x00FFFFFFFFFFFFFFLL); //!< Universal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array - printf("\tPower Cycle Event %" PRIu16": %" PRIu64" \n", i,pFLED->powerCycleOfLED[i] & 0x00FFFFFFFFFFFFFFLL); //!< SPower Cycle of the last 8 Flash LED (assert) Events, wrapping array + printf("\tInformation of Event %" PRIu16": 0x%" PRIx64" \n", i,pFLED->flashLEDArray[i] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Info on the last 8 Flash LED (assert) Events, wrapping array + printf("\tTimeStamp of Event%" PRIu16": %" PRIu64" \n", i,pFLED->timestampForLED[i] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Universal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array + printf("\tPower Cycle Event %" PRIu16": %" PRIu64" \n", i,pFLED->powerCycleOfLED[i] & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< SPower Cycle of the last 8 Flash LED (assert) Events, wrapping array } #endif - if (pFLED->copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "Actuator Flash LED 0x%" PRIx16" Information From Farm Log copy FACTORY", M_Word0(pFLED->actID)); - } - else - { - snprintf((char*)myStr.c_str(), BASIC, "Actuator Flash LED Information 0x%" PRIx16" From Farm Log copy %" PRId32"", M_Word0(pFLED->actID), page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); + farm_PrePython_Int(LUNFLED, "LUN_flash_LED", "actuator id", "LUN FLED", "id", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pFLED->actID)))); + farm_PrePython_Int(LUNFLED, "LUN_flash_LED", "total flash LED events", "LUN FLED", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pFLED->totalFLEDEvents)))); + farm_PrePython_Int(LUNFLED, "LUN_flash_LED", "last entry", "LUN FLED", "index", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pFLED->index)))); - set_json_64_bit_With_Status(pageInfo, "Page Number", pFLED->pageNumber, true, m_showStatusBits); //!< Page Number - set_json_64_bit_With_Status(pageInfo, "Copy Number", pFLED->copyNumber, false, m_showStatusBits); //!< Copy Number - set_json_64_bit_With_Status(pageInfo, "Actuator ID", pFLED->actID, false, m_showStatusBits); //!< LUN ID - set_json_64_bit_With_Status(pageInfo, "Total Flash LED Evnets", pFLED->totalFLEDEvents, false, m_showStatusBits); //!< Head Load Events - set_json_64_bit_With_Status(pageInfo, "Index of Last Flash LED", pFLED->index, false, m_showStatusBits); - for (i = 0; i < FLASH_EVENTS; i++) - { - JSONNODE *eventInfo = json_new(JSON_NODE); - snprintf((char*)myStr.c_str(), BASIC, "Event %" PRIu16"", i); - json_set_name(eventInfo, (char*)myStr.c_str()); + + + for (i = 0; i < FLASH_EVENTS; i++) + { + std::ostringstream temp; + JSONNODE* data = json_new(JSON_NODE); + json_push_back(data, json_new_a("name", "LUN_flash_LED")); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << actNum; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(label, json_new_a("stat_type", "flash LED event")); + temp.str("");temp.clear(); + temp << "0x" << std::hex << std::nouppercase << std::setfill('0') << std::setw(4) << M_Word2(check_Status_Strip_Status(pFLED->flashLEDArray[i])); + json_push_back(label, json_new_a("flash_LED_code", temp.str().c_str())); + std::string meaning; + get_Assert_Code_Meaning(meaning, M_Word2(check_Status_Strip_Status(pFLED->flashLEDArray[i]))); + json_push_back(label, json_new_a("flash_LED_code_meaning", meaning.c_str())); + temp.str(""); + temp.clear(); + temp << "0x" << std::hex << std::nouppercase << std::setfill('0') << std::setw(8) << M_DoubleWord0(check_Status_Strip_Status(pFLED->flashLEDArray[i])); + json_push_back(label, json_new_a("flash_LED_address", temp.str().c_str())); + + temp.str(""); + temp.clear(); + temp << std::fixed << std::setprecision(3) << (static_cast(check_Status_Strip_Status(pFLED->timestampForLED[i]) / 3600000) * .001) << " hours"; + json_push_back(label, json_new_a("timeStamp_of_event", temp.str().c_str())); //!< Universal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array - set_json_64_bit_With_Status(eventInfo, "Address of Event", pFLED->flashLEDArray[i], true, m_showStatusBits); //!< Info on the last 8 Flash LED (assert) Events, wrapping array + json_push_back(label, json_new_i("power_cycle_event", static_cast (check_Status_Strip_Status(pFLED->powerCycleOfLED[i])))); //!< Power Cycle of the last 8 Flash LED (assert) Events, wrapping array + + json_push_back(label, json_new_a("units", "event")); + json_push_back(data, label); + json_push_back(data, json_new_i("value", i)); + json_push_back(LUNFLED, data); + } - snprintf((char*)myStr.c_str(), BASIC, "0x%04" PRIx16"", M_Word2(check_Status_Strip_Status(pFLED->flashLEDArray[i]))); - json_push_back(eventInfo, json_new_a("Flash LED Code", (char*)myStr.c_str())); - _common.get_Assert_Code_Meaning(timeStr, M_Word2(check_Status_Strip_Status(pFLED->flashLEDArray[i]))); - json_push_back(eventInfo, json_new_a("Flash LED Code Meaning", (char*)timeStr.c_str())); - snprintf((char*)myStr.c_str(), BASIC, "0x%08" PRIx32"", M_DoubleWord0(check_Status_Strip_Status(pFLED->flashLEDArray[i]))); - json_push_back(eventInfo, json_new_a("Flash LED Address", (char*)myStr.c_str())); - - snprintf((char*)myStr.c_str(), BASIC, "TimeStamp of Event(hours) %" PRIu16"", i); - snprintf((char*)timeStr.c_str(), BASIC, "%0.03f", static_cast(M_DoubleWord0(check_Status_Strip_Status(pFLED->timestampForLED[i]))/ 3600000) *.001); - set_json_string_With_Status(eventInfo, (char*)myStr.c_str(), (char*)timeStr.c_str(), pFLED->timestampForLED[i], m_showStatusBits);//!< Universal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array - snprintf((char*)myStr.c_str(), BASIC, "Power Cycle Event %" PRIu16"", i); - set_json_64_bit_With_Status(eventInfo, (char*)myStr.c_str(), pFLED->powerCycleOfLED[i], false, m_showStatusBits); //!< Power Cycle of the last 8 Flash LED (assert) Events, wrapping array - - json_push_back(pageInfo, eventInfo); } + else + { + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + if (pFLED->copyNumber == FACTORYCOPY) + { + temp << "Actuator Flash LED 0x" << std::hex << M_Word0(pFLED->actID) << " Information From Farm Log copy FACTORY"; + } + else + { + temp << "Actuator Flash LED Information 0x" << std::hex << M_Word0(pFLED->actID) << " From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); - json_push_back(masterData, pageInfo); + set_json_64_bit_With_Status(pageInfo, "Page Number", pFLED->pageNumber, true, m_showStatusBits); //!< Page Number + set_json_64_bit_With_Status(pageInfo, "Copy Number", pFLED->copyNumber, false, m_showStatusBits); //!< Copy Number + set_json_64_bit_With_Status(pageInfo, "Actuator ID", pFLED->actID, false, m_showStatusBits); //!< LUN ID + set_json_64_bit_With_Status(pageInfo, "Total Flash LED Events", pFLED->totalFLEDEvents, false, m_showStatusBits); //!< Head Load Events + set_json_64_bit_With_Status(pageInfo, "Index of Last Flash LED", pFLED->index, false, m_showStatusBits); + for (i = 0; i < FLASH_EVENTS; i++) + { + JSONNODE* eventInfo = json_new(JSON_NODE); + temp.str(""); + temp.clear(); + temp << "Event " << std::dec << i; + json_set_name(eventInfo, temp.str().c_str()); + + set_json_64_bit_With_Status(eventInfo, "Address of Event", pFLED->flashLEDArray[i], true, m_showStatusBits); //!< Info on the last 8 Flash LED (assert) Events, wrapping array + temp.str(""); + temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << M_Word2(check_Status_Strip_Status(pFLED->flashLEDArray[i])); + json_push_back(eventInfo, json_new_a("Flash LED Code", temp.str().c_str())); + std::string meaning; + get_Assert_Code_Meaning(meaning, M_Word2(check_Status_Strip_Status(pFLED->flashLEDArray[i]))); + json_push_back(eventInfo, json_new_a("Flash LED Code Meaning", meaning.c_str())); + temp.str(""); + temp.clear(); + temp << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << M_DoubleWord0(check_Status_Strip_Status(pFLED->flashLEDArray[i])); + json_push_back(eventInfo, json_new_a("Flash LED Address", temp.str().c_str())); + temp.str(""); + temp.clear(); + temp << "TimeStamp of Event(hours) " << std::dec << i; + std::ostringstream time; + time << std::setprecision(3) << (static_cast(M_DoubleWord0(check_Status_Strip_Status(pFLED->timestampForLED[i])) / 3600000) * .001); + set_json_string_With_Status(eventInfo, temp.str(), time.str(), pFLED->timestampForLED[i], m_showStatusBits);//!< Universal Timestamp (us) of last 8 Flash LED (assert) Events, wrapping array + temp.str(""); + temp.clear(); + temp << "Power Cycle Event " << std::dec << i; + set_json_64_bit_With_Status(eventInfo, temp.str(), pFLED->powerCycleOfLED[i], false, m_showStatusBits); //!< Power Cycle of the last 8 Flash LED (assert) Events, wrapping array + + json_push_back(pageInfo, eventInfo); + } + json_push_back(LUNFLED, pageInfo); + } return SUCCESS; } @@ -3462,16 +5017,10 @@ eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_FLED_Info(JSONNODE *masterData, //! \return SUCCESS // //--------------------------------------------------------------------------- -eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Reallocation(JSONNODE *masterData, uint32_t page, uint32_t index,uint16_t actNum) +eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Reallocation(JSONNODE* LUNNReallocation, uint32_t page, uint16_t actNum) { uint16_t i = 0; - std::string myStr = " "; - std::string timeStr = " "; - myStr.resize(BASIC); - timeStr.resize(BASIC); - JSONNODE *pageInfo = json_new(JSON_NODE); - - sActReallocationData *pReal; + sActReallocationData* pReal; if (actNum == LUN_REALLOCATION_1) pReal = &vFarmFrame[page].reall62; else if (actNum == LUN_REALLOCATION_2) @@ -3490,41 +5039,59 @@ eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Reallocation(JSONNODE *masterDa { printf("\nLUN Actuator 0x%" PRIx16" Reallocation From Farm Log copy %" PRIu32"\n", M_Word0(pReal->actID), page); } - printf("\tPage Number: 0x%" PRIx64" \n", pReal->pageNumber & 0x00FFFFFFFFFFFFFFLL); //!< Page Number - printf("\tCopy Number: %" PRIu64" \n", pReal->copyNumber & 0x00FFFFFFFFFFFFFFLL); //!< Copy Number - printf("\tActuator ID: %" PRIu64" \n", pReal->actID & 0x00FFFFFFFFFFFFFFLL); //!< Actuator ID - printf("\tNumber of Reallocated Sectors: %" PRIu64" \n", pReal->numberReallocatedSectors & 0x00FFFFFFFFFFFFFFLL); //!< Total Flash LED Events - printf("\tNumber of Reallocated Candidate Sectors: %" PRIu64" \n", pReal->numberReallocatedCandidates & 0x00FFFFFFFFFFFFFFLL); + printf("\tPage Number: 0x%" PRIx64" \n", pReal->pageNumber & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Page Number + printf("\tCopy Number: %" PRIu64" \n", pReal->copyNumber & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Copy Number + printf("\tActuator ID: %" PRIu64" \n", pReal->actID & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Actuator ID + printf("\tNumber of Reallocated Sectors: %" PRIu64" \n", pReal->numberReallocatedSectors & UINT64_C(0x00FFFFFFFFFFFFFF)); //!< Total Flash LED Events + printf("\tNumber of Reallocated Candidate Sectors: %" PRIu64" \n", pReal->numberReallocatedCandidates & UINT64_C(0x00FFFFFFFFFFFFFF)); for (i = 0; i < REALLOCATIONEVENTS; i++) { - - _common.get_Reallocation_Cause_Meanings(myStr, i); - printf("\t%-33s: %" PRIu64" \n",(char*)myStr.c_str(), pReal->reallocatedCauses[i] & 0x00FFFFFFFFFFFFFFLL); + std::string meaning; + get_Reallocation_Cause_Meanings(meaning, i); + printf("\t%-33s: %" PRIu64" \n", meaning.c_str(), pReal->reallocatedCauses[i] & UINT64_C(0x00FFFFFFFFFFFFFF)); } #endif - if (pReal->copyNumber == FACTORYCOPY) + if (g_dataformat == PREPYTHON_DATA) { - snprintf((char*)myStr.c_str(), BASIC, "LUN Actuator 0x%" PRIx16" Reallocation From Farm Log copy FACTORY", M_Word0(pReal->actID)); + + farm_PrePython_Int(LUNNReallocation, "LUN_reallocation", "actuator", "LUN reallocation", "id", actNum, static_cast (M_DoubleWord0(pReal->actID))); + farm_PrePython_Int(LUNNReallocation, "LUN_reallocation", "total reallocated sectors", "LUN reallocation", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pReal->numberReallocatedSectors)))); + farm_PrePython_Int(LUNNReallocation, "LUN_reallocation", "total reallocated sectors candidate", "LUN reallocation", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pReal->numberReallocatedCandidates)))); + for (i = 0; i < REALLOCATIONEVENTS; i++) + { + std::string meaning; + get_Reallocation_Cause_Meanings(meaning, i); + farm_PrePython_Int(LUNNReallocation, "LUN_reallocation", meaning.c_str(), "LUN reallocation", "counts", actNum, static_cast (M_DoubleWord0(check_Status_Strip_Status(pReal->reallocatedCauses[i])))); + } } else { - snprintf((char*)myStr.c_str(), BASIC, "LUN Actuator 0x%" PRIx16" Reallocation From Farm Log copy %" PRId32"", M_Word0(pReal->actID), page); - } - json_set_name(pageInfo, (char*)myStr.c_str()); + JSONNODE* pageInfo = json_new(JSON_NODE); + std::ostringstream temp; + if (pReal->copyNumber == FACTORYCOPY) + { + temp << "LUN Actuator 0x" << std::hex << M_Word0(pReal->actID) << " Reallocation From Farm Log copy FACTORY"; + } + else + { + temp << "LUN Actuator 0x" << std::hex << M_Word0(pReal->actID) << " Reallocation From Farm Log copy " << std::dec << page; + } + json_set_name(pageInfo, temp.str().c_str()); - set_json_64_bit_With_Status(pageInfo, "Page Number", pReal->pageNumber, true, m_showStatusBits); //!< Page Number - set_json_64_bit_With_Status(pageInfo, "Copy Number", pReal->copyNumber, false, m_showStatusBits); //!< Copy Number - set_json_64_bit_With_Status(pageInfo, "Actuator ID", pReal->actID, true, m_showStatusBits); //!< LUN ID - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors", pReal->numberReallocatedSectors, false, m_showStatusBits); //!< Head Load Events - set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Candidate Sectors", pReal->numberReallocatedCandidates, false, m_showStatusBits); - - for (i = 0; i < REALLOCATIONEVENTS; i++) - { - _common.get_Reallocation_Cause_Meanings(myStr, i); - set_json_64_bit_With_Status(pageInfo, (char*)myStr.c_str(), pReal->reallocatedCauses[i] , false, m_showStatusBits); - } - json_push_back(masterData, pageInfo); + set_json_64_bit_With_Status(pageInfo, "Page Number", pReal->pageNumber, true, m_showStatusBits); //!< Page Number + set_json_64_bit_With_Status(pageInfo, "Copy Number", pReal->copyNumber, false, m_showStatusBits); //!< Copy Number + set_json_64_bit_With_Status(pageInfo, "Actuator ID", pReal->actID, true, m_showStatusBits); //!< LUN ID + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Sectors", pReal->numberReallocatedSectors, false, m_showStatusBits); //!< Head Load Events + set_json_64_bit_With_Status(pageInfo, "Number of Reallocated Candidate Sectors", pReal->numberReallocatedCandidates, false, m_showStatusBits); + for (i = 0; i < REALLOCATIONEVENTS; i++) + { + std::string meaning; + get_Reallocation_Cause_Meanings(meaning, i); + set_json_64_bit_With_Status(pageInfo, meaning.c_str(), pReal->reallocatedCauses[i], false, m_showStatusBits); + } + json_push_back(LUNNReallocation, pageInfo); + } return SUCCESS; } @@ -3543,12 +5110,21 @@ eReturnValues CSCSI_Farm_Log::print_LUN_Actuator_Reallocation(JSONNODE *masterDa //--------------------------------------------------------------------------- void CSCSI_Farm_Log::print_All_Pages(JSONNODE *masterData) { + if (vFarmFrame.size() > 0) { print_Header(masterData); - //set_Head_Header(myHeader, type); - JSONNODE *headPage = json_new(JSON_NODE); - json_set_name(headPage, "Head Information From Farm Log copy 0"); + JSONNODE* headPage; + if (g_dataformat == PREPYTHON_DATA) + { + headPage = masterData; + } + else + { + headPage = json_new(JSON_NODE); + json_set_name(headPage, "Head Information From Farm Log copy 0"); + } + for (uint32_t index = 0; index < vFarmFrame.size(); ++index) { @@ -3589,6 +5165,9 @@ void CSCSI_Farm_Log::print_All_Pages(JSONNODE *masterData) case ENVIRONMENT_STATISTICS_PAMATER_07: print_Enviroment_Statistics_Page_07(masterData, index); break; + case WORKLOAD_STATISTICS_PAMATER_08: + print_Workload_Statistics_Page_08(masterData, index); + break; case DISC_SLIP_IN_MICRO_INCHES_BY_HEAD: case BIT_ERROR_RATE_OF_ZONE_0_BY_DRIVE_HEAD: case DOS_WRITE_REFRESH_COUNT: @@ -3612,27 +5191,36 @@ void CSCSI_Farm_Log::print_All_Pages(JSONNODE *masterData) case DOS_NEED_TO_SCAN_COUNT_PER_HEAD: case DOS_WRITE_FAULT_SCAN_COUNT_PER_HEAD: case WRITE_POWERON_HOURS_FROM_MOST_RECENT_SMART: + case DOS_WRITE_COUNT_THRESHOLD_PER_HEAD: + case CUM_LIFETIME_UNRECOVERALBE_READ_REPET_PER_HEAD: + case CUM_LIFETIME_UNRECOVERABLE_READ_UNIQUE_PER_HEAD: + case TOTAL_LASER_FIELD_ADJUST_ITERATIONS: + case TOTAL_READER_WRITER_OFFSET_ITERATIONS_PERFORMED: + case PRE_LFA_ZONE_0: + case PRE_LFA_ZONE_1: + case PRE_LFA_ZONE_2: + case ZERO_PERCENT_SHIFT: case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_0: case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_1: case CURRENT_H2SAT_TRIMMED_MEAN_BITS_IN_ERROR_BY_HEAD_BY_TEST_ZONE_2: case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_0: case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_1: case CURRENT_H2SAT_ITERATIONS_TO_CONVERGE_BY_HEAD_BY_TEST_ZONE_2: + case LASER_OPERATING_ZONE_0: + case LASER_OPERATING_ZONE_1: + case LASER_OPERATING_ZONE_2: + case POST_LFA_OPTIMAL_BER_ZONE_0: + case POST_LFA_OPTIMAL_BER_ZONE_1: + case POST_LFA_OPTIMAL_BER_ZONE_2: + case MICRO_JOG_OFFSET_ZONE_0: + case MICRO_JOG_OFFSET_ZONE_1: + case MICRO_JOG_OFFSET_ZONE_2: + case ZERO_PERCENT_SHIFT_ZONE_1: case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_OUTER: case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_INNER: case APPLIED_FLY_HEIGHT_CLEARANCE_DELTA_PER_HEAD_IN_THOUSANDTHS_OF_ONE_ANGSTROM_MIDDLE: - case RESERVED_FOR_FUTURE_EXPANSION_10: - case RESERVED_FOR_FUTURE_EXPANSION_11: - case RESERVED_FOR_FUTURE_EXPANSION_12: - case RESERVED_FOR_FUTURE_EXPANSION_13: - case RESERVED_FOR_FUTURE_EXPANSION_14: - case RESERVED_FOR_FUTURE_EXPANSION_15: - case RESERVED_FOR_FUTURE_EXPANSION_16: - case RESERVED_FOR_FUTURE_EXPANSION_17: - case RESERVED_FOR_FUTURE_EXPANSION_18: - case RESERVED_FOR_FUTURE_EXPANSION_19: case SECOND_MR_HEAD_RESISTANCE: - print_Head_Information(vFarmFrame.at(index).vFramesFound.at(pramCode), headPage, index); + print_Head_Information(vFarmFrame.at(index).vFramesFound.at(pramCode), headPage, index); break; case FAFH_MEASUREMENT_STATUS: // FAFH Measurement Status, bitwise OR across all diameters per head print_Head_Information(vFarmFrame.at(index).vFramesFound.at(pramCode), headPage, index); @@ -3667,16 +5255,18 @@ void CSCSI_Farm_Log::print_All_Pages(JSONNODE *masterData) case FAFH_HIGH_FREQUENCY_2: // FAFH High Frequency Passive Clearance in ADC counts Diameter 2 : outer print_Head_Information(vFarmFrame.at(index).vFramesFound.at(pramCode), headPage, index); break; - case RESERVED_FOR_FUTURE_EXPANSION_31: + + case ZERO_PERCENT_SHIFT_ZONE_2: + print_Head_Information(vFarmFrame.at(index).vFramesFound.at(pramCode), headPage, index); break; case LUN_0_ACTUATOR: - print_LUN_Actuator_Information(masterData, index, 0, LUN_0_ACTUATOR); + print_LUN_Actuator_Information(masterData, index, LUN_0_ACTUATOR); break; case LUN_0_FLASH_LED : - print_LUN_Actuator_FLED_Info(masterData,index,0, LUN_0_FLASH_LED); + print_LUN_Actuator_FLED_Info(masterData,index,LUN_0_FLASH_LED); break; case LUN_REALLOCATION_0: - print_LUN_Actuator_Reallocation(masterData, index, 0, LUN_REALLOCATION_0); + print_LUN_Actuator_Reallocation(masterData, index, LUN_REALLOCATION_0); break; case RESERVED_FOR_FUTURE_EXPANSION_42: case RESERVED_FOR_FUTURE_EXPANSION_43: @@ -3693,13 +5283,13 @@ void CSCSI_Farm_Log::print_All_Pages(JSONNODE *masterData) case RESERVED_FOR_FUTURE_EXPANSION_54: break; case LUN_1_ACTUATOR: - print_LUN_Actuator_Information(masterData, index, 0, LUN_1_ACTUATOR); + print_LUN_Actuator_Information(masterData, index, LUN_1_ACTUATOR); break; case LUN_1_FLASH_LED: - print_LUN_Actuator_FLED_Info(masterData, index, 0, LUN_1_FLASH_LED); + print_LUN_Actuator_FLED_Info(masterData, index, LUN_1_FLASH_LED); break; case LUN_REALLOCATION_1: - print_LUN_Actuator_Reallocation(masterData, index, 0, LUN_REALLOCATION_1); + print_LUN_Actuator_Reallocation(masterData, index,LUN_REALLOCATION_1); break; case RESERVED_FOR_FUTURE_EXPANSION_62: case RESERVED_FOR_FUTURE_EXPANSION_63: @@ -3716,13 +5306,13 @@ void CSCSI_Farm_Log::print_All_Pages(JSONNODE *masterData) case RESERVED_FOR_FUTURE_EXPANSION_74: break; case LUN_2_ACTUATOR: - print_LUN_Actuator_Information(masterData, index, 0, LUN_2_ACTUATOR); + print_LUN_Actuator_Information(masterData, index, LUN_2_ACTUATOR); break; case LUN_2_FLASH_LED: - print_LUN_Actuator_FLED_Info(masterData, index, 0, LUN_2_FLASH_LED); + print_LUN_Actuator_FLED_Info(masterData, index, LUN_2_FLASH_LED); break; case LUN_REALLOCATION_2: - print_LUN_Actuator_Reallocation(masterData, index, 0, LUN_REALLOCATION_2); + print_LUN_Actuator_Reallocation(masterData, index, LUN_REALLOCATION_2); break; case RESERVED_FOR_FUTURE_EXPANSION_82: case RESERVED_FOR_FUTURE_EXPANSION_83: @@ -3739,13 +5329,13 @@ void CSCSI_Farm_Log::print_All_Pages(JSONNODE *masterData) case RESERVED_FOR_FUTURE_EXPANSION_94: break; case LUN_3_ACTUATOR: - print_LUN_Actuator_Information(masterData, index, 0, LUN_3_ACTUATOR); + print_LUN_Actuator_Information(masterData, index,LUN_3_ACTUATOR); break; case LUN_3_FLASH_LED: - print_LUN_Actuator_FLED_Info(masterData, index, 0, LUN_3_FLASH_LED); + print_LUN_Actuator_FLED_Info(masterData, index, LUN_3_FLASH_LED); break; case LUN_REALLOCATION_3: - print_LUN_Actuator_Reallocation(masterData, index, 0, LUN_REALLOCATION_3); + print_LUN_Actuator_Reallocation(masterData, index, LUN_REALLOCATION_3); break; case RESERVED_FOR_FUTURE_EXPANSION_102: case RESERVED_FOR_FUTURE_EXPANSION_103: @@ -3769,7 +5359,20 @@ void CSCSI_Farm_Log::print_All_Pages(JSONNODE *masterData) } } } - json_push_back(masterData, headPage); + if (g_dataformat != PREPYTHON_DATA) + { + json_push_back(masterData, headPage); + } + } + else + { + uint64_t signature = m_pHeader->farmHeader.signature & UINT64_C(0x00FFFFFFFFFFFFFF); + + if (signature != FARMSIGNATURE || signature == UINT64_C(0x00FFFFFFFFFFFFFF)) + { + json_push_back(masterData, json_new_a("Empty FARM Log", "data has not yet been gathered")); + + } } } //----------------------------------------------------------------------------- @@ -3828,6 +5431,13 @@ void CSCSI_Farm_Log::print_Page_One_Node(JSONNODE *masterData) print_All_Pages(pageInfo); json_push_back(masterData, pageInfo); } + else + { + JSONNODE* pageInfo = json_new(JSON_NODE); + json_set_name(pageInfo, "FARM Log"); + json_push_back(pageInfo, json_new_a("Empty FARM Log", "data has not yet been gathered")); + json_push_back(masterData, pageInfo); + } } //----------------------------------------------------------------------------- // @@ -3853,18 +5463,199 @@ void CSCSI_Farm_Log::print_Page_Without_Drive_Info(JSONNODE *masterData, uint32_ print_Error_Information(masterData, page); print_Enviroment_Information(masterData, page); print_Reli_Information(masterData, page); - JSONNODE *headInfoPage = json_new(JSON_NODE); - std::string myStr = " "; - myStr.resize(BASIC); - snprintf((char*)myStr.c_str(), BASIC, "Head Information From Farm Log copy: %" PRId32"", page); - - json_set_name(headInfoPage, (char*)myStr.c_str()); - for (uint32_t frame = 0; frame < vFarmFrame.at(page).vFramesFound.size(); frame++) + if (g_dataformat == PREPYTHON_DATA) { - print_Head_Information(vFarmFrame.at(page).vFramesFound.at(frame), masterData, page); + for (uint32_t frame = 0; frame < vFarmFrame.at(page).vFramesFound.size(); frame++) + { + print_Head_Information(vFarmFrame.at(page).vFramesFound.at(frame), masterData, page); + } + } + else + { + + JSONNODE* headInfoPage = json_new(JSON_NODE); + std::ostringstream temp; + temp << "Head Information From Farm Log copy: " << std::dec << page; + + json_set_name(headInfoPage, temp.str().c_str()); + + for (uint32_t frame = 0; frame < vFarmFrame.at(page).vFramesFound.size(); frame++) + { + print_Head_Information(vFarmFrame.at(page).vFramesFound.at(frame), headInfoPage, page); + } + json_push_back(masterData, headInfoPage); } - json_push_back(masterData, headInfoPage); } } } +//----------------------------------------------------------------------------- +// +//! \fn farm_PrePython_Str() +// +//! \brief +//! Description: format the data for the prepython data +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +void CSCSI_Farm_Log::farm_PrePython_Str(JSONNODE* masterData, const char* name, const char* statType, const char* unit, const char* location, int pageNum, const char* value) +{ + JSONNODE* data = json_new(JSON_NODE); + + json_push_back(data, json_new_a("name", name)); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << pageNum; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(label, json_new_a("stat_type", statType)); + json_push_back(label, json_new_a("location", location)); + json_push_back(label, json_new_a("units", unit)); + json_push_back(data, label); + json_push_back(data, json_new_a("value", value)); + json_push_back(masterData, data); +} + +//----------------------------------------------------------------------------- +// +//! \fn farm_PrePython_Int() +// +//! \brief +//! Description: format the data for the prepython data int type +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +void CSCSI_Farm_Log::farm_PrePython_Int(JSONNODE* masterData, const char* name, const char* statType, const char* header, const char* unit, int pageNum, int64_t value) +{ + JSONNODE* data = json_new(JSON_NODE); + + json_push_back(data, json_new_a("name", name)); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << pageNum; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(label, json_new_a("stat_type", statType)); + json_push_back(label, json_new_a("location", header)); + json_push_back(label, json_new_a("units", unit)); + json_push_back(data, label); + json_push_back(data, json_new_i("value", value)); + json_push_back(masterData, data); + +} +//----------------------------------------------------------------------------- +// +//! \fn farm_PrePython_Float() +// +//! \brief +//! Description: format the data for the prepython data float type +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +void CSCSI_Farm_Log::farm_PrePython_Float(JSONNODE* masterData, const char* name, const char* statType, const char* header, \ + const char* unit, int pageNum, double value) +{ + JSONNODE* data = json_new(JSON_NODE); + + json_push_back(data, json_new_a("name", name)); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << pageNum; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + json_push_back(label, json_new_a("stat_type", statType)); + json_push_back(label, json_new_a("location", header)); + json_push_back(label, json_new_a("units", unit)); + json_push_back(data, label); + json_push_back(data, json_new_f("value", value)); // float is limited to 53 bits of precision (2^53) + json_push_back(masterData, data); +} +//----------------------------------------------------------------------------- +// +//! \fn prePython_Head() +// +//! \brief +//! Description: format the data for the prepython data head data float type +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +void CSCSI_Farm_Log::prePython_Head_Float(JSONNODE* masterData, const char* name, const char* statType, uint32_t headNumber, \ + const char* unit, int pageNum, double value) +{ + JSONNODE* data = json_new(JSON_NODE); + json_push_back(data, json_new_a("name", name)); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << pageNum; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + if (statType != NULL) + { + json_push_back(label, json_new_a("stat_type", statType)); + } + temp.str(""); + temp.clear(); + temp << std::dec << headNumber; + json_push_back(label, json_new_a("head_number", temp.str().c_str())); + json_push_back(label, json_new_a("units", unit)); + json_push_back(data, label); + json_push_back(data, json_new_f("value", value)); // float is limited to 53 bits of precision (2^53) + json_push_back(masterData, data); +} +//----------------------------------------------------------------------------- +// +//! \fn prePython_Head_Int() +// +//! \brief +//! Description: format the data for the prepython data head data int type +// +// Entry: +//! \param +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- +void CSCSI_Farm_Log::prePython_Head_Int(JSONNODE* masterData, const char* name, const char* statType, uint32_t headNumber, \ + const char* unit, int pageNum, int64_t value) +{ + JSONNODE* data = json_new(JSON_NODE); + json_push_back(data, json_new_a("name", name)); + JSONNODE* label = json_new(JSON_NODE); + json_set_name(label, "labels"); + std::ostringstream temp; + temp << "scsi-log-page:0x" << std::hex << std::nouppercase << FARMLOGPAGE << "," << std::hex << std::nouppercase << static_cast(m_farmSubPage) << ":0x" << std::hex << std::nouppercase << pageNum; + json_push_back(label, json_new_a("metric_source", temp.str().c_str())); + if (statType != NULL) + { + json_push_back(label, json_new_a("stat_type", statType)); + } + temp.str(""); + temp.clear(); + temp << std::dec << headNumber; + json_push_back(label, json_new_a("head_number", temp.str().c_str())); + json_push_back(label, json_new_a("units", unit)); + json_push_back(data, label); + json_push_back(data, json_new_f("value", static_cast(value))); // float is limited to 53 bits of precision (2^53) + json_push_back(masterData, data); +} diff --git a/src/Seagate/Farm_Common.cpp b/src/Seagate/Farm_Common.cpp index 88eb4b8..89f6ce7 100644 --- a/src/Seagate/Farm_Common.cpp +++ b/src/Seagate/Farm_Common.cpp @@ -2,7 +2,7 @@ // Farm_Common.cpp // Do NOT modify or remove this copyright and license // -// Copyright (c) 2014 - 2020 Seagate Technology LLC and/or its Affiliates +// Copyright (c) 2014 - 2021 Seagate Technology LLC and/or its Affiliates // // This software is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -51,72 +51,253 @@ CFarmCommon::~CFarmCommon() { } - //----------------------------------------------------------------------------- - // - //! \fn get_Reallocation_Cause_Meanings() - // - //! \brief - //! Description: parse out the meaning of the reallocation - // - // Entry: - //! \param meaning - string for the meaning of the cause - //! \param code - code for the what the meaning is - // - // Exit: - //! \return - // - //--------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +//! \fn create_Serial_Number() +// +//! \brief +//! Description: takes the two uint64 bit seiral number values and create a string serial number +// +// Entry: +//! \param serialNumberStr - pointer to the serial number, where once constructed, will hold the serial number of the drive +//! \param serialNumber = first part of the serial number. +//! \param serialNumber2 = second part of the serial number. +//! \param majorRev = the major Rev infomration. +//! \param sas = True if sas drive +// +// Exit: +//! \return serialNumber = the string serialNumber +// +//--------------------------------------------------------------------------- +void CFarmCommon::create_Serial_Number(std::string& serialNumberStr, uint32_t serialNumber, uint32_t serialNumber2, uint32_t majorRev, bool sas = false ) +{ + uint64_t sn = 0; + uint64_t sn1 = serialNumber; + uint64_t sn2 = serialNumber2; + if (sas) + { + if (majorRev < MAJORVERSION3) + { + sn = (sn2 << 32 | (sn1)); + byte_Swap_64(&sn); + } + else + { + sn = (sn1 | (sn2 << 32)); + byte_Swap_64(&sn); + } + } + else // sata + { + sn = (sn1 | (sn2 << 32)); + } + serialNumberStr.clear(); + serialNumberStr.assign(reinterpret_cast(&sn), SERIAL_NUMBER_LEN); + if (!sas) // sata we need to byte swap the string + { + byte_swap_std_string(serialNumberStr); + } +} +//----------------------------------------------------------------------------- +// +//! \fn create_Model_Number_String() +// +//! \brief +//! Description: fill in the model number of the drive +// +// Entry: +//! \param modelStr - pointer to the model number of the drive +//! \param productID = pointer to the drive info structure that holds the infromation needed +//! \param sas = True if sas drive +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void CFarmCommon::create_Model_Number_String(std::string& modelStr, uint64_t *productID, bool sas = false) +{ +#define MAXSIZE 5 + uint32_t modelParts[MAXSIZE] = { 0,0,0,0,0 }; + // loop for and get the information from the lower bits + for (uint8_t i = 0; i < MAXSIZE; i++) + { + if (sas) + modelParts[i] = M_DoubleWord1(productID[i]); + else // sata need to be the dword 0 + { + modelParts[i] = M_DoubleWord0(productID[i]); + } + modelStr.append(reinterpret_cast(&modelParts[i]), sizeof(uint32_t)); + } + if (!sas) // sata we need to byte swap the string + { + byte_swap_std_string(modelStr); + } + remove_trailing_whitespace_std_string(modelStr); + +} +//----------------------------------------------------------------------------- +// +//! \fn create_Device_Interface_String() +// +//! \brief +//! Description: takes the two uint64 bit Devie interface string values and create a string device interface +// +// Entry: +//! \param dInterfaceStr - pointer to the Devie interface v, where once constructed, will hold the Devie interface of the drive +//! \param deviceInterface = pointer to the drive info structure that holds the infromation needed +//! \param sas = True if sas drive +// +// Exit: +//! \return dInterface = the string dInterface +// +//--------------------------------------------------------------------------- +void CFarmCommon::create_Device_Interface_String(std::string& dInterfaceStr, uint32_t deviceInterface, bool sas = false) +{ + uint32_t dFace = 0; + dFace = deviceInterface; + if (!sas) + { + byte_Swap_32(&dFace); + } + dInterfaceStr = "0000"; + dInterfaceStr.assign(reinterpret_cast(&dFace), DEVICE_INTERFACE_LEN); +} +//----------------------------------------------------------------------------- +// +//! \fn create_World_Wide_Name() +// +//! \brief +//! Description: takes the two uint64 bit world wide name values and create a string world wide name +// +// Entry: +//! \param worldWideName - pointer to the world wide name, where once constructed, will hold the world wide name of the drive +//! \param idInfo = pointer to the drive info structure that holds the infromation needed +//! \param sas = True if sas drive +// +// Exit: +//! \return wordWideName = the string wordWideName +// +//--------------------------------------------------------------------------- +void CFarmCommon::create_World_Wide_Name(std::string& worldWideName, uint64_t wwn, uint64_t wwn2, bool sas =false) +{ + uint64_t wwnFinal = 0; + uint32_t stwwn = M_DoubleWord0(wwn); + uint32_t stwwn2 = M_DoubleWord0(wwn2); + if (!sas) + { + word_Swap_32(&stwwn); + word_Swap_32(&stwwn2); + } + wwnFinal = M_DWordsTo8ByteValue(stwwn2, stwwn); + worldWideName = "0000000000000000000"; + std::ostringstream temp; + temp << "0x" << std::hex << std::uppercase << wwnFinal; + worldWideName.assign(temp.str()); +} +//----------------------------------------------------------------------------- +// +//! \fn create_Firmware_String() +// +//! \brief +//! Description: takes the two uint64 bit firmware Rev values and create a string firmware Rev +// +// Entry: +//! \param firmwareRevStr - pointer to the firmware Rev, where once constructed, will hold the firmware Rev of the drive +//! \param idInfo = pointer to the drive info structure that holds the infromation needed +//! \param sas = True if sas drive +// +// Exit: +//! \return firmwareRev = the string firmwareRev +// +//--------------------------------------------------------------------------- +void CFarmCommon::create_Firmware_String(std::string& firmwareRevStr, uint32_t firmware, uint32_t firmware2, bool sas = false) +{ + uint64_t firm = 0; + uint64_t firm1 = firmware; + uint64_t firm2 = firmware2; + if (sas) + { + firm = (firm2 | (firm1 << 32)); + byte_Swap_64(&firm); + } + else + { + firm = firmware; + } + firmwareRevStr = "00000000"; + firmwareRevStr.assign(reinterpret_cast(&firm), 8); + if (!sas) + { + byte_swap_std_string(firmwareRevStr); + } +} +//----------------------------------------------------------------------------- +// +//! \fn get_Reallocation_Cause_Meanings() +// +//! \brief +//! Description: parse out the meaning of the reallocation +// +// Entry: +//! \param meaning - string for the meaning of the cause +//! \param code - code for the what the meaning is +// +// Exit: +//! \return +// +//--------------------------------------------------------------------------- void CFarmCommon::get_Reallocation_Cause_Meanings(std::string &meaning, uint16_t code) { switch (code) { case HOST_READ_GENERIC: - meaning = "Host Read - Generic"; + meaning = "host read - generic"; break; case HOST_READ_UNCORRECTABLE: - meaning = "Host Read - Uncorrectable"; + meaning = "host read - uncorrectable"; break; case HOST_READ_RAW: - meaning = "Host Read - RAW"; + meaning = "host read - RAW"; break; case HOST_WRITE_GENERIC: - meaning = "Host Write - Generic"; + meaning = "host write - generic"; break; case HOST_WRITE_UNCORRECTABLE: - meaning = "Host Write - Uncorrectable"; + meaning = "host write - uncorrectable"; break; case HOST_WRITE_RAW: - meaning = "Host Write - RAW"; + meaning = "host write - RAW"; break; case BACKGROUND_READ_GENERIC: - meaning = "Background Read - Generic"; + meaning = "background read - generic"; break; case BACKGROUND_READ_RELIABILITY: - meaning = "Background Read - Reliability"; + meaning = "background read - reliability"; break; case BACKGROUND_READ_RECOVERY: - meaning = "Background Read - Recovery"; + meaning = "background read - recovery"; break; case BACKGROUND_READ_HOST_SELF_TEST: - meaning = "Background Read - Host Self Test"; + meaning = "background read - host self test"; break; case BACKGROUND_WRITE_GENERIC: - meaning = "Background Write - Generic"; + meaning = "background write - generic"; break; case BACKGROUND_WRITE_RELIABILITY: - meaning = "Background Write - Reliability"; + meaning = "background write - reliability"; break; case BACKGROUND_WRITE_RECOVERY: - meaning = "Background Write - Recovery"; + meaning = "background write - recovery"; break; case BACKGROUND_WRITE_HOST_SELF_TEST: - meaning = "Background Write - Host Self Test"; + meaning = "background write - host self test"; break; case SERVO_WEDGE: - meaning = "Servo Wedge"; + meaning = "servo wedge"; break; default: - meaning = "Unknown"; + meaning = "unknown"; break; } } @@ -141,25 +322,25 @@ CFarmCommon::~CFarmCommon() switch (code) { case ASSERT_UNKNOWN: - meaning = "Unknow"; + meaning = "unknown"; break; case MICROPROCESSOR_FAILED: - meaning = "Microprocessor Failed"; + meaning = "microprocessor failed"; break; case DRAM_FAILED_POWERUP_OR_WRAM_FAIL: - meaning = "DRAM Failed powerup or WRAM Failed"; + meaning = "DRAM failed powerup or WRAM failed"; break; case SCC_FAILED_POWERUP_DIAGNOSTICS: - meaning = "SCC Failed Powerup Diagnostics"; + meaning = "SCC failed powerup diagnostics"; break; case FW_DOES_NOT_MATCH_THE_SCC_VERSION: - meaning = "Firmware does not match teh SCC Version"; + meaning = "firmware does not match the SCC version"; break; case UNIMPLEMENTED_OPCODE_INTERRUPT: - meaning = "Unimplemented opcode interrupt"; + meaning = "unimplemented opcode interrupt"; break; case POWER_UP_XOR_FAILURE_FOR_FIBER_CH: - meaning = "Power up XOR failure for fiber CH"; + meaning = "power up XOR failure for fiber CH"; break; case EEPROM_VERIFY_ERROR_EVEN_BYTE: meaning = "EEPROM verify error even byte"; @@ -168,55 +349,55 @@ CFarmCommon::~CFarmCommon() meaning = "EEPROM erase error even byte"; break; case DOWNLOAD_TPM_FAILED_0: - meaning = "Download TPM failed 0"; + meaning = "download TPM failed 0"; break; case DOWNLOAD_TPM_FAILED_1: - meaning = "Download TPM failed 1"; + meaning = "download TPM failed 1"; break; case DOWNLOAD_TPM_FAILED_2: - meaning = "Download TPM failed 2"; + meaning = "download TPM failed 2"; break; case DOWNLOAD_TPM_FAILED_3: - meaning = "Download TPM failed 3"; + meaning = "download TPM failed 3"; break; case DOWNLOAD_TPM_FAILED_4: - meaning = "Download TPM failed 4"; + meaning = "download TPM failed 4"; break; case DOWNLOAD_TPM_FAILED_5: - meaning = "Download TPM failed 5"; + meaning = "download TPM failed 5"; break; case DOWNLOAD_TPM_FAILED_6: - meaning = "Download TPM failed 6"; + meaning = "download TPM failed 6"; break; case DOWNLOAD_TPM_FAILED_7: - meaning = "Download TPM failed 7"; + meaning = "download TPM failed 7"; break; case DOWNLOAD_TPM_FAILED_8: - meaning = "Download TPM failed 8"; + meaning = "download TPM failed 8"; break; case DOWNLOAD_VOLTAGE_FAULT: - meaning = "Download Voltage fault"; + meaning = "download voltage fault"; break; case FAILS_WRITING_ARRAY_DATA_TO_FLASH_0: - meaning = "Fails writting array data to flash 0"; + meaning = "fails writting array data to flash 0"; break; case FLASH_LOOKING_FOR_MEMORY_RANGE_ERROR: - meaning = "Flash Looking for memory range error"; + meaning = "flash Looking for memory range error"; break; case FAILS_WRITING_ARRAY_DATA_TO_FLASH_1: - meaning = "Fails writting array data to flash 1"; + meaning = "fails writting array data to flash 1"; break; case FAILS_WRITING_ARRAY_DATA_TO_FLASH_2: - meaning = "Fails writting array data to flash 2"; + meaning = "fails writting array data to flash 2"; break; case FAILS_WRITING_ARRAY_DATA_TO_FLASH_3: - meaning = "Fails writting array data to flash 3"; + meaning = "fails writting array data to flash 3"; break; case FAILS_WRITING_ARRAY_DATA_TO_FLASH_4: - meaning = "Fails writting array data to flash 4"; + meaning = "fails writting array data to flash 4"; break; case FAILS_WRITING_ARRAY_DATA_TO_FLASH_5: - meaning = "Fails writting array data to flash 5"; + meaning = "fails writting array data to flash 5"; break; case ALU_BUFFER_PARITY_ERROR: meaning = "ALU buffer party error"; @@ -228,133 +409,134 @@ CFarmCommon::~CFarmCommon() meaning = "Error injection assert"; break; case DRAM_CONFIGURATION_PROCESS_FAILED: - meaning = "DRAM Configuration Process Failed"; + meaning = "DRAM configuration process failed"; break; case FDE_BUS_PARITY_ERROR: meaning = "FDE Bus parity error"; break; case PREFETCH_VECTOR_OR_STACK_POINTER_OUT: - meaning = "Prefetch vector or stack pointer out"; + meaning = "prefetch vector or stack pointer out"; break; case ERROR_IN_WRITING_TO_READ_CHIP: - meaning = "Error in writting to read chip"; + meaning = "error in writting to read chip"; break; case IER_STACK_OVERFLOW: - meaning = "IER Stack overflow"; + meaning = "IER stack overflow"; break; case IER_STACK_UNDERFLOW: - meaning = "IER Stack underflow"; + meaning = "IER stack underflow"; break; case IER_STACK_NOT_EMPTY_ON_ENTRY_TO_SLEEP: - meaning = "IER Stack Not Empty on Entry to Sleep"; + meaning = "IER stack Not empty on entry to sleep"; break; case IRAW_HAD_MISCOMPARE: meaning = "IRAW has miscompare"; break; case UNDEFINED_INSTRUCTION: - meaning = "Underfined instruction"; + meaning = "underfined instruction"; break; case LOGGING_SAVE_FAILED_EXCEEDED_ALLOCATED: - meaning = "Logging save failed exceeded allocated"; + meaning = "logging save failed exceeded allocated"; break; case CANT_FIND_BACKPLANE_DATA_RATE: - meaning = "Cant Find backplane data rate"; + meaning = "cant find backplane data rate"; break; case CONTROLLER_I_TCM_DOUBLE_BIT_ECC_ERROR: - meaning = "Controller I TCM Double bit ECC Error"; + meaning = "controller I TCM bouble bit ECC error"; break; case CONTROLLER_D_TCM_DOUBLE_BIT_ECC_ERROR: - meaning = "Controller D TCM double bit ECC Error"; + meaning = "controller D TCM double bit ECC error"; break; case SERVO_I_TCM_DOUBLE_BIT_ECC_ERROR: - meaning = "Servo I TCM Double bit ECC Error"; + meaning = "servo I TCM double bit ECC error"; break; case SERVO_D_TCM_DOUBLE_BIT_ECC_ERROR: - meaning = "Servo D TCM double bit ECC ERROR"; + meaning = "servo D TCM double bit ECC error"; break; case CDPRAM_UNRECOVERABLE_ERROR: - meaning = "CDPRAM unrecoverable Error"; + meaning = "CDPRAM unrecoverable drror"; break; case SDPRAM_UNRECOVERABLE_ERROR: - meaning = "SDPRAM unrecoverable Error"; + meaning = "SDPRAM unrecoverable drror"; break; case TCM_CRC_RESULT_IS_NON_ZERO: meaning = "TCM CRC result is non zero"; break; case SWI_ASSERT_FLASH_CODE_BOOT: - meaning = "SWI Assert Flash Code Boot"; + meaning = "SWI assert flash code boot"; break; case SWI_ASSERT_FLASH_CODE_NQNR: - meaning = "SWI Assert Flash Code NQNR"; + meaning = "SWI assert flash code NQNR"; break; case SWI_ASSERT_FLASH_CODE_DISC: - meaning = "SWI Assert Flash Code DISC"; + meaning = "SWI assert flash code DISC"; break; case REMOTE_ASSERT: - meaning = "Remode Assert"; + meaning = "remode assert"; break; case DRAM_INTEGRITY_FAILURE: - meaning = "DRAM Integrity Failure"; + meaning = "DRAM integrity failure"; break; case CLOCK_FAILURE: - meaning = "Clock Failure"; + meaning = "clock failure"; break; case ASSERT_FLASH_CODE: - meaning = "Assert Flash Code"; + meaning = "assert flash code"; break; case ENSURE_FLASH_CODE: - meaning = "Ensure Flash Code"; + meaning = "ensure flash code"; break; case REQUIRE_FLASH_CODE: - meaning = "Require Flash Code"; + meaning = "Require flash code"; break; case SMART_FLASH_CODE: - meaning = "SMART Flash Code"; + meaning = "SMART flash code"; break; case SCSI_UNEXEPCTED_INTERRUPT: - meaning = "SCSI Unexpected Interrupt"; + meaning = "SCSI unexpected interrupt"; break; case SCSI_TIMEOUT: - meaning = "SCSI Timeout"; + meaning = "SCSI timeout"; break; case ILLEGAL_STATUS_CODE: - meaning = "Illegal Status Code"; + meaning = "illegal status code"; break; case SCSI_UNDER_OVER_RUN_OCCURRED: - meaning = "SCSI Under Over Run Occurred"; + meaning = "SCSI under over run occurred"; break; case UNEXPECTED_STATUS: - meaning = "Unexpected Status"; + meaning = "unexpected status"; break; case DIVIDE_BY_ZERO_INTERRUPT: - meaning = "Divide by Zero Interrupt"; + meaning = "divide by zero interrupt"; break; case DATA_ABORT_CACHE_ECC_ERROR: - meaning = "Data Abort Cache ECC Error"; + meaning = "data abort cache ECC error"; break; case DATA_ABORT_TCM_ECC_ERROR: - meaning = "Data Abort TCM ECC Error"; + meaning = "data abort TCM ECC error"; break; case ABORT_INTERRUPT: - meaning = "Abort Interrupt"; + meaning = "abort interrupt"; break; case SELF_SEEK_FAILURE: - meaning = "Self Seek Failure"; + meaning = "self seek failure"; break; case CONTROLLER_NUKED_BY_FDE: - meaning = "Controller Nuked By FDE"; + meaning = "controller nuked by FDE"; break; case FLASH_IOEDC_PARITY_ERROR: - meaning = "Flash IOEDC Parity Error"; + meaning = "flash IOEDC parity error"; break; case SERIAL_PORT_DUMP_MODE: - meaning = "Serial Port Dump Mode"; + meaning = "serial port Ude"; break; default: - meaning = "Unknow"; + meaning = "unknow"; break; } } + //----------------------------------------------------------------------------- // //! \fn create_Year_Assembled_String() @@ -382,7 +564,120 @@ CFarmCommon::~CFarmCommon() } else { - strncpy((char *)dateStr.c_str(), (char*)&date, DATE_YEAR_DATE_SIZE); + dateStr.assign(reinterpret_cast(&date), sizeof(uint16_t)); } } +//----------------------------------------------------------------------------- +// +//! \fn Get_NVC_Status() +// +//! \brief +//! Description: get the NVC status bits and create meaningful data +// +// Entry: +//! \param NVC_Node - JSON Node to add the array of information to +//! \param status = what the status is for the NVC +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void CFarmCommon::Get_NVC_Status(JSONNODE* NVC_Node, uint64_t status) +{ + if (status != 0) + { + JSONNODE* myArray = json_new(JSON_ARRAY); + json_set_name(myArray, ("NVC Status Events")); + if (status & BIT8) + json_push_back(myArray, json_new_a("NVC Status Events", "flash burn started")); + if (status & BIT9) + json_push_back(myArray, json_new_a("NVC Status Events", "flash burn finished")); + if (status & BIT10) + json_push_back(myArray, json_new_a("NVC Status Events", "validate flash erase pattern skipped")); + if (status & BIT19) + json_push_back(myArray, json_new_a("NVC Status Events", "servo r5 in WFE")); + if (status & BIT20) + json_push_back(myArray, json_new_a("NVC Status Events", "servo m0 in WFI")); + if (status & BIT21) + json_push_back(myArray, json_new_a("NVC Status Events", "servo r5 halt timeout")); + if (status & BIT22) + json_push_back(myArray, json_new_a("NVC Status Events", "servo m0 halt timeout")); + if (status & BIT23) + json_push_back(myArray, json_new_a("NVC Status Events", "AUX LLP stream timeout")); + + json_push_back(NVC_Node, myArray); + } +} +//----------------------------------------------------------------------------- +// +//! \fn get_FARM_Reason_For_Capture() +// +//! \brief +//! Description: From the farm log Reason the FARM log was capture +// +// Entry: +//! \param headerNode - string for the information to be placed +//! \param flag - the uint8 value from the buffer +// +// Exit: +//! \return void +// +//--------------------------------------------------------------------------- +void CFarmCommon::Get_FARM_Reason_For_Capture(std::string* reason, uint8_t flag) +{ + switch (flag) + { + case CURRENT_FRAME: + *reason = "current FARM log"; + break; + case TIME_SERIES_FRAME: + *reason = "time series frame"; + break; + case LONG_TERM_FRAME: + *reason = "long term frame"; + break; + case GLIST_DISC_ENTRIES_FRAME: + *reason = "1000 g-list disc entries frame"; + break; + case FIRST_UNRECOVERED_READ_ERROR_FRAME: + *reason = "1st unrecovered read error"; + break; + case TENTH_UNRECOVERED_READ_ERROR_FRAME: + *reason = "10th unrecovered read error"; + break; + case FIRST_FATAL_CTO_FRAME: + *reason = "1st fatal command time out"; + break; + case BEFORE_CFW_UPDATE_FRAME: + *reason = "last frame prior to most recent CFW or SFW update"; + break; + case TEMP_EXCEDED_FRAME: + *reason = "temperature exceeds 70 degress celsius"; + break; + case RESERVED_FRAME: + *reason = "reserved"; + break; + case FACTORY_COPY_FRAME: + *reason = "FARM factory frame copy"; + break; + case FARM_LOG_DISC_COPY_FRAME: + *reason = "FARM log disc copy"; + break; + case IDD_FARM_LOG_DISC_FRAME: + *reason = "IDD FARM log disc copy"; + break; + case FARM_DRAM_COPY_FARME: + *reason = "FARM log DRAM copy"; + break; + case FARM_DRAM_COPY_DIAG_FRAME: + *reason = "FARM log DRAM copy via diag command"; + break; + case FARM_UDS_COPY_FRAME: + *reason = "FARM log via UDS"; + break; + default: + *reason = "unknown"; + break; + } +}