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 #58278 is a reply to message #58259] Fri, 08 April 2022 16:11 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 06 April 2022 12:29
Hi,

I attempted to read Raspberry Pi 4 SoC temperature with the below code. For some reason using LoadFile does not work:
double	GetRaspberryPiTemperature(){
	String result = LoadFile("/sys/devices/virtual/thermal/thermal_zone0/temp");
	if(!result.IsEmpty()) return 0.001*ScanDouble(~result);
	return -55.0;
}

So I had to revert using FILE and fgets instead:
double	GetRaspberryPiTemperature(){
	FILE *in=fopen("/sys/devices/virtual/thermal/thermal_zone0/temp","rb");
	char s[8];
	if(fgets(s,8,in)) return 0.001*ScanDouble(s);
	return -55.0;
}

Is this expected or is this a bug?

Best regards,

Tom


Have you tried the exact equivalent? (like reading 8 bytes only).
 
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 Apr 28 09:51:25 CEST 2024

Total time taken to generate the page: 0.02975 seconds