Skip to content

Commit

Permalink
Service: log EC firmware version if Debug logs are enabled
Browse files Browse the repository at this point in the history
EC registers for firmware version and date are currently hard-coded. This will be revised in a future commit.
  • Loading branch information
Sparronator9999 committed Feb 4, 2025
1 parent 88426dd commit 3ccf718
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 17 deletions.
4 changes: 2 additions & 2 deletions YAMDCC.Common/YAMDCC.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<RuntimeIdentifiers>win7-x64;win7-x86;win-x64;win-x86</RuntimeIdentifiers>
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC common code library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
4 changes: 2 additions & 2 deletions YAMDCC.Config/YAMDCC.Config.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<RuntimeIdentifiers>win7-x64;win7-x86;win-x64;win-x86</RuntimeIdentifiers>
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC config library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
1 change: 0 additions & 1 deletion YAMDCC.ConfigEditor/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using YAMDCC.Common;
using YAMDCC.Common.Dialogs;
Expand Down
4 changes: 2 additions & 2 deletions YAMDCC.ConfigEditor/YAMDCC.ConfigEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC config editor</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
60 changes: 60 additions & 0 deletions YAMDCC.ECAccess/EC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;

namespace YAMDCC.ECAccess;
Expand Down Expand Up @@ -141,6 +142,65 @@ public void UnloadDriver()
}
}

/// <summary>
/// Reads a series of bytes from the EC as a text string.
/// </summary>
/// <param name="reg">
/// The EC register to start reading the string from.
/// </param>
/// <param name="len">
/// The maximum length of the string to read.
/// </param>
/// <param name="value">
/// If successful, contains the string value read
/// from the EC, otherwise <see langword="null"/>.
/// </param>
/// <returns>
/// <see langword="true"/> if the operation was
/// successful, otherwise <see langword="false"/>.
/// </returns>
/// <exception cref="ArgumentException"/>
public bool ReadString(byte reg, byte len, out string value)
{
if (len <= 0)
{
throw new ArgumentException("`len` must not be zero or negative.");
}
if (reg + len > 0xFF)
{
throw new ArgumentException("`reg` + `len` must not be over 0xFF (255).");
}

value = null;

if (_Driver.IsOpen)
{
byte[] buffer = new byte[len];
for (int i = 0; i < len; i++)
{
if (ReadByte((byte)(reg + i), out buffer[i]))
{
if (buffer[i] == 0) // null byte
{
value = Encoding.UTF8.GetString(buffer, 0, i);
return true;
}
if (buffer[i] is < 32 or > 126)
{
return false;
}
}
else
{
return false;
}
}
value = Encoding.UTF8.GetString(buffer);
return true;
}
return false;
}

/// <summary>
/// Reads a byte from the EC at the specified register.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions YAMDCC.ECAccess/YAMDCC.ECAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<RuntimeIdentifiers>win7-x64;win7-x86;win-x64;win-x86</RuntimeIdentifiers>
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC EC library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
4 changes: 2 additions & 2 deletions YAMDCC.ECInspector/YAMDCC.ECInspector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC EC inspector</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
4 changes: 2 additions & 2 deletions YAMDCC.Logs/YAMDCC.Logs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<RuntimeIdentifiers>win7-x64;win7-x86;win-x64;win-x86</RuntimeIdentifiers>
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC logging library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
14 changes: 14 additions & 0 deletions YAMDCC.Service/FanControlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ protected override void OnStart(string[] args)
}
Log.Info(Strings.GetString("drvLoadSuccess"));

if (Log.FileLevel == LogLevel.Debug)
{
if (_EC.ReadString(0xA0, 0xC, out string ecVer) && ecVer.Length == 0xC)
{
Log.Debug($"EC firmware version: {ecVer}");
}
if (_EC.ReadString(0xAC, 0x10, out string ecDate) && ecDate.Length == 0x10)
{
Log.Debug("EC firmware date: " +
$"{ecDate.Substring(2, 2)}/{ecDate.Substring(0, 2)}/{ecDate.Substring(4, 4)} " +
$"{ecDate.Substring(8, 2)}:{ecDate.Substring(11, 2)}:{ecDate.Substring(14, 2)}");
}
}

// Set up IPC server
Log.Info("Starting IPC server...");
IPCServer.Start();
Expand Down
4 changes: 2 additions & 2 deletions YAMDCC.Service/YAMDCC.Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<RuntimeIdentifiers>win7-x64;win7-x86;win-x64;win-x86</RuntimeIdentifiers>
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC service</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
4 changes: 2 additions & 2 deletions YAMDCC.Updater/YAMDCC.Updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC updater</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down

0 comments on commit 3ccf718

Please sign in to comment.