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

Home » U++ Library support » U++ Core » LoadFile("/sys/devices/virtual/thermal/ ...") does not work
LoadFile("/sys/devices/virtual/thermal/ ...") does not work [message #58259] Wed, 06 April 2022 12:29 Go to previous message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
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
 
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: Mon May 04 11:12:47 GMT+2 2026

Total time taken to generate the page: 0.00968 seconds