U++ framework
Do not panic. Ask here before giving up.

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: 14291
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 Oct 04 12:55:08 GMT+2 2026

Total time taken to generate the page: 0.02441 seconds