TME-104P-CSR-LX800-R1V11.doc
Rev 1.11
45 (50)
Reading Temperatures
There are temperature sensors available that allow measurement of the CPU's chip temperature as well as the
board's ambient temperature. These are shown in the BIOS setup screens, see above.
#include <stdio.h>
#include <unistd.h>
#include <sys/io.h> // needed for inb/outb
#define EC_INDEX 0x295
#define EC_DATA 0x296
int main()
{
signed char cputemp, ambtemp;
if (iopl(3)) { // Linux-specific, e.g. DOS doesn't need this
printf("Failed to get I/O access permissions.\n");
printf("You must be root to run this.\n");
return 1;
}
printf("Press CTRL+C to cancel!\n");
printf("CPU AMBIENT\n");
while (1) {
outb(0x29, EC_INDEX); //read out CPU temp
cputemp = inb(EC_DATA);
outb(0x2A, EC_INDEX); //read out ambient temp
ambtemp = inb(EC_DATA);
printf("%3d %3d\n", cputemp, ambtemp);
fflush(stdout);
sleep(1);
}
//return 0;
}