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 #58300 is a reply to message #58299] Wed, 13 April 2022 17:39 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 13 April 2022 14:44
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


I suspect that the problem is somewhere here: Core/BlockStream.cpp:474

Probably that S_IFREG flag test. Maybe using S_IFBLK would fix it?

Mirek
 
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: Tue Jun 18 01:47:01 CEST 2024

Total time taken to generate the page: 0.01483 seconds