Skip to content

Commit 8fcbd0d

Browse files
Service: get EC firmware version every time a new config is loaded
1 parent ecb66d5 commit 8fcbd0d

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

YAMDCC.Service/FanControlService.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ protected override void OnStart(string[] args)
8888
{
8989
Log.Info(Strings.GetString("svcStarting"));
9090

91-
// Load the service config.
92-
bool confLoaded = LoadConf();
93-
9491
// Install WinRing0 to get EC access
9592
try
9693
{
@@ -109,31 +106,8 @@ protected override void OnStart(string[] args)
109106
}
110107
Log.Info(Strings.GetString("drvLoadSuccess"));
111108

112-
113-
if (confLoaded && Config.FirmVerSupported)
114-
{
115-
EcInfo = new();
116-
if (_EC.ReadString(0xA0, 0xC, out string ecVer) && ecVer.Length == 0xC)
117-
{
118-
EcInfo.Version = ecVer;
119-
Log.Debug($"EC firmware version: {ecVer}");
120-
}
121-
if (_EC.ReadString(0xAC, 0x10, out string ecDate) && ecDate.Length == 0x10)
122-
{
123-
try
124-
{
125-
string temp = $"{ecDate.Substring(4, 4)}-{ecDate.Substring(0, 2)}-{ecDate.Substring(2, 2)}" +
126-
$"T{ecDate.Substring(8, 2).Replace(' ', '0')}:{ecDate.Substring(11, 2)}:{ecDate.Substring(14, 2)}";
127-
EcInfo.Date = DateTime.ParseExact(temp, "s", CultureInfo.InvariantCulture);
128-
Log.Debug($"EC firmware date: {EcInfo.Date:G}");
129-
}
130-
catch (FormatException ex)
131-
{
132-
Log.Error($"Failed to parse EC firmware date: {ex.Message}");
133-
Log.Debug($"EC firmware date (raw): {ecDate}");
134-
}
135-
}
136-
}
109+
// Load the last applied YAMDCC config.
110+
bool confLoaded = LoadConf();
137111

138112
// Set up IPC server
139113
Log.Info("Starting IPC server...");
@@ -403,6 +377,32 @@ private bool LoadConf()
403377
{
404378
Config = YAMDCC_Config.Load(Paths.CurrentConf);
405379
Log.Info(Strings.GetString("cfgLoaded"));
380+
381+
if (Config.FirmVerSupported)
382+
{
383+
EcInfo = new();
384+
if (_EC.ReadString(0xA0, 0xC, out string ecVer) && ecVer.Length == 0xC)
385+
{
386+
EcInfo.Version = ecVer;
387+
Log.Debug($"EC firmware version: {ecVer}");
388+
}
389+
if (_EC.ReadString(0xAC, 0x10, out string ecDate) && ecDate.Length == 0x10)
390+
{
391+
try
392+
{
393+
string temp = $"{ecDate.Substring(4, 4)}-{ecDate.Substring(0, 2)}-{ecDate.Substring(2, 2)}" +
394+
$"T{ecDate.Substring(8, 2).Replace(' ', '0')}:{ecDate.Substring(11, 2)}:{ecDate.Substring(14, 2)}";
395+
EcInfo.Date = DateTime.ParseExact(temp, "s", CultureInfo.InvariantCulture);
396+
Log.Debug($"EC firmware date: {EcInfo.Date:G}");
397+
}
398+
catch (FormatException ex)
399+
{
400+
Log.Error($"Failed to parse EC firmware date: {ex.Message}");
401+
Log.Debug($"EC firmware date (raw): {ecDate}");
402+
}
403+
}
404+
}
405+
406406
return true;
407407
}
408408
catch (Exception ex)

0 commit comments

Comments
 (0)