Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » [SysInfo - Improvement - Koldo] Better way to find distribution version & more
Re: [SysInfo - Improvement - Koldo] Better way to find distribution version & more [message #41109 is a reply to message #41093] Thu, 31 October 2013 17:01 Go to previous messageGo to previous message
Klugier is currently offline  Klugier
Messages: 1076
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Koldo,

Alternative paths, can be done in this way:

static double GetCpuTemperatureHWMON()
{
	FindFile ff;
	double sumTemps = 0.0;
	int count       = 0;
	
	String path = "/sys/class/hwmon/";
	
	if (ff.Search(AppendFileName(path, "device"))) {
		path += ff.GetName() + "/";
	}
	else {
		String tempPath;
		for (ff.Search(AppendFileName(path, "hwmon*")); ff; ff.Next()) {
			FindFile hwmonFF;
		
			tempPath = path;
			tempPath += ff.GetName() + "/";
			if (hwmonFF.Search(AppendFileName(tempPath, "device"))) {
				tempPath += hwmonFF.GetName() + "/";
			}
		
			if (hwmonFF.Search(AppendFileName(tempPath, "*input"))) {
				if (!hwmonFF.IsDirectory()) {
					path = tempPath;
					break;
				}
			}
		}
		if (!tempPath.IsEmpty() && tempPath != path)
			path = tempPath;
	}
	
	for (ff.Search(AppendFileName(path, "*input")); ff; ff.Next()) {
		if (!ff.IsHidden()) {
			String temp = LoadFile_Safe(ff.GetPath());
			if (!temp.IsEmpty()) {
				sumTemps += static_cast <double> ((StrInt(temp))) / 1000.0;
				count++;
			}
		}
	}
	if (count == 0)
		return Null;
	return sumTemps / count;
}


* Additional changes:
- change casting method to more safer.
- changed "0." to "0.0" (Are you sure that 0. is more readable than 0.0???)

* TODO:
- create function static String "findHWMONInputFilesPath()" - ALTERNATIVE METHOD

Sincerely,
Klugier


U++ - one framework to rule them all.

[Updated on: Thu, 31 October 2013 19:01]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem with FileBrowser
Next Topic: AES for sqlite database
Goto Forum:
  


Current Time: Mon May 13 00:32:00 CEST 2024

Total time taken to generate the page: 0.02203 seconds