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 » U++ Library support » U++ Core » LoadFile("/sys/devices/virtual/thermal/ ...") does not work
Re: LoadFile("/sys/devices/virtual/thermal/ ...") does not work [message #58299 is a reply to message #58297] Wed, 13 April 2022 14:44 Go to previous messageGo to previous message
Tom1
Messages: 1217
Registered: March 2007
Senior Contributor
Hi,

This does work on both Raspberry Pi OS (on RPi4) and Linux Mint (on x86_64):
#include <Core/Core.h>

using namespace Upp;

String LoadFileRaw(const char *filename){
	int fd = open(filename,O_RDONLY);
	if(fd!=-1){
		char buf[4096];
		StringBuffer s;
		int len;
		while((len=read(fd,buf,4096))==4096) s.Cat(buf,len);
		if(len>0) s.Cat(buf,len);
		close(fd);
		if(s.GetCount()>0) return s;
	}
	return String::GetVoid();
}

CONSOLE_APP_MAIN
{
	String meminfo = LoadFileRaw("/proc/meminfo");
	Cout() << meminfo << "\n\n";
}

Also:
LoadFileRaw("/sys/devices/virtual/thermal/thermal_zone0/temp");

works fine on RPi4.

Best regards,

Tom
 
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: BiArray::Create{Head,Tail} with variadic args
Next Topic: Serialize long as uint64 on some platforms
Goto Forum:
  


Current Time: Sun Jun 23 04:31:06 CEST 2024

Total time taken to generate the page: 0.02297 seconds