We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The text was updated successfully, but these errors were encountered:
#include <stdio.h> /* for FILE, fopen, fread, fclose, printf and sprintf / #include <stdlib.h> / for atof */
int main (int argc, char **argv) { FILE *filePtr; char therm_path[64]; /* 64 bytes buffer for building current pseudo file path */ char readBuf[16]; /* 16 bytes buffer for reading ASCII encoded value from pseudo file */ float temp; for (unsigned int curZone = 0; curZone < 8; curZone++) { unsigned int readBytes = 0; sprintf(therm_path, "/sys/devices/virtual/thermal/thermal_zone%u/temp", curZone); printf ("Reading %s: ", therm_path); filePtr = fopen(therm_path, "r"); if (!filePtr) { printf ("Error, failed to open file\n"); continue; } while (readBytes < 16) { int curRead = fread(readBuf + readBytes, 1, 16 - readBytes, filePtr); if (curRead > 0) readBytes += curRead; else break; /* nothing more to be read */ } fclose (filePtr); if (readBytes > 0) *(readBuf + readBytes - 1) = 0; /* Remove last char '\n' */ printf("[%s] ", readBuf); temp = atof(readBuf); temp /= 1000.f; printf("%.02f\n", temp); } exit(0); }
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: