2
0
mirror of https://github.com/hirschmann/nbfc synced 2025-08-30 21:55:18 +00:00

[fix] Fixed MinOSVersion for Linux plugins.

[new] Implemented EmbeddedController plugin for Linux.
[chg] Removed unnecessary usings from StagWare.Configurations.
[chg] Fixed path to Linux plugins project in solution file.
This commit is contained in:
Stefan Hirschmann
2014-08-29 02:24:13 +02:00
parent 6ca8890190
commit cfceef78ca
12 changed files with 125 additions and 58 deletions

View File

@@ -1,20 +1,22 @@
using StagWare.FanControl.Plugins;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StagWare.Linux.NbfcPlugins
{
[Export(typeof(ITemperatureProvider))]
[FanControlPluginMetadata("StagWare.Linux.CpuTempProvider", PlatformID.Unix, MinOSVersion = "13.0")]
[FanControlPluginMetadata("StagWare.Linux.CpuTempProvider", PlatformID.Unix, MinOSVersion = "3.10")]
public class CpuTemperatureProvider : ITemperatureProvider
{
const string cpuTempFilePath = "/sys/class/hwmon/hwmon0/cpu1_input";
#region Constants
const string cpuTempFilePath = "/sys/class/hwmon/hwmon0/temp1_input";
#endregion
#region ITemperatureProvider implementation
public bool IsInitialized
{
@@ -33,11 +35,7 @@ namespace StagWare.Linux.NbfcPlugins
if (double.TryParse(File.ReadAllText(cpuTempFilePath), out temp))
{
Debug.WriteLine("GetTemperature failed");
}
else
{
Debug.WriteLine(string.Format("GetTemperature succeeded: {0.00}", temp));
temp /= 1000;
}
return temp;
@@ -45,7 +43,8 @@ namespace StagWare.Linux.NbfcPlugins
public void Dispose()
{
Debug.WriteLine("Disposed CpuTemperatureProvider");
}
#endregion
}
}

View File

@@ -1,23 +1,31 @@
using StagWare.FanControl.Plugins;
using StagWare.Hardware.LPC;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace StagWare.Linux.NbfcPlugins
{
[Export(typeof(IEmbeddedController))]
[FanControlPluginMetadata("StagWare.Linux.EmbeddedController", PlatformID.Unix, MinOSVersion = "13.0")]
public class EmbeddedController : IEmbeddedController
[FanControlPluginMetadata("StagWare.Linux.EmbeddedController", PlatformID.Unix, MinOSVersion = "3.10")]
public class EmbeddedController : EmbeddedControllerBase, IEmbeddedController
{
public bool IsInitialized
{
get;
private set;
}
#region Constants
const string PortFilePath = "/dev/port";
private const int MaxRetries = 10;
#endregion
#region Private Fields
private FileStream stream;
#endregion
#region IEmbeddedController implementation
public bool IsInitialized { get; private set; }
public void Initialize()
{
@@ -26,40 +34,115 @@ namespace StagWare.Linux.NbfcPlugins
public void WriteByte(byte register, byte value)
{
Debug.WriteLine(string.Format("WriteByte: {0} => {1}", value, register));
int writes = 0;
while (writes < MaxRetries)
{
if (TryWriteByte(register, value))
{
return;
}
writes++;
}
}
public void WriteWord(byte register, ushort value)
{
Debug.WriteLine(string.Format("WriteWord: {0} => {1}", value, register));
int writes = 0;
while (writes < MaxRetries)
{
if (TryWriteWord(register, value))
{
return;
}
writes++;
}
}
public byte ReadByte(byte register)
{
Debug.WriteLine(string.Format("ReadByte: {0}", register));
return 0;
byte result = 0;
int reads = 0;
while (reads < MaxRetries)
{
if (TryReadByte(register, out result))
{
return result;
}
reads++;
}
return result;
}
public ushort ReadWord(byte register)
{
Debug.WriteLine(string.Format("ReadWord: {0}", register));
return 0;
int result = 0;
int reads = 0;
while (reads < MaxRetries)
{
if (TryReadWord(register, out result))
{
return (ushort)result;
}
reads++;
}
return (ushort)result;
}
public bool AquireLock(int timeout)
{
Debug.WriteLine("AquireLock");
return true;
bool success = false;
try
{
this.stream = File.Open(PortFilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch
{
}
return success;
}
public void ReleaseLock()
{
Debug.WriteLine("ReleaseLock");
if (this.stream != null)
{
this.stream.Dispose();
this.stream = null;
}
}
public void Dispose()
{
Debug.WriteLine("Dispose EmbeddedController");
ReleaseLock();
}
#endregion
#region EmbeddedControllerBase implementation
protected override void WritePort(int port, byte value)
{
this.stream.Seek(port, SeekOrigin.Begin);
this.stream.WriteByte(value);
}
protected override byte ReadPort(int port)
{
this.stream.Seek(port, SeekOrigin.Begin);
return (byte)this.stream.ReadByte();
}
#endregion
}
}

View File

@@ -48,10 +48,14 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Libraries\StagWare.FanControl\StagWare.FanControl.csproj">
<ProjectReference Include="..\..\StagWare.FanControl\StagWare.FanControl.csproj">
<Project>{12084b38-c1a2-414c-80a7-b8d02d6f5b84}</Project>
<Name>StagWare.FanControl</Name>
</ProjectReference>
<ProjectReference Include="..\StagWare.Hardware.LPC\StagWare.Hardware.LPC.csproj">
<Project>{1d5d7c81-802f-46e0-913f-8519f157bc3c}</Project>
<Name>StagWare.Hardware.LPC</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
namespace StagWare.Configurations

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StagWare.FanControl.Configurations
{

View File

@@ -1,5 +1,4 @@
using StagWare.Configurations;
using System;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@@ -1,8 +1,4 @@
using StagWare.Configurations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
namespace StagWare.FanControl.Configurations
{

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StagWare.FanControl.Configurations
{

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StagWare.FanControl.Configurations
{

View File

@@ -1,8 +1,4 @@
using StagWare.Configurations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
namespace StagWare.FanControl.Configurations
{

View File

@@ -1,8 +1,4 @@
using StagWare.FanControl.Configurations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
namespace StagWare.FanControl.Configurations
{

View File

@@ -38,7 +38,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StagWare.BiosInfo", "Window
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StagWare.Windows.NbfcPlugins", "Libraries\Plugins\StagWare.Windows.NbfcPlugins\StagWare.Windows.NbfcPlugins.csproj", "{6C6F4E15-FC36-4298-A7E9-83CD854BDFDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StagWare.Linux.NbfcPlugins", "C:\Users\Stefan\Documents\Visual Studio 2012\Projects\Desktop\NoteBookFanControl\Libraries\Plugins\StagWare.Linux.NbfcPlugins\StagWare.Linux.NbfcPlugins.csproj", "{0F5B3D05-7615-4E74-84E6-4F00FAD0413C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StagWare.Linux.NbfcPlugins", "Libraries\Plugins\StagWare.Linux.NbfcPlugins\StagWare.Linux.NbfcPlugins.csproj", "{0F5B3D05-7615-4E74-84E6-4F00FAD0413C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution