// iisalive.cpp #include #include #include #include // for watchdog timer #include // needed only if close() is used to close watchdog timer #include // for watchdog timer #include // for watchdog timer #include int main(int argc, char*argv[]) { FILE *fdf; int valor,millamperes; char buffer[100]; char name[50]; int i; struct watchdog_info ident; int fd, ret; int timeout = 0; int timeslice=10; int retfinal; printf("Entrado en iamlive....\r\n"); while (1) { sleep (timeslice); time_t t = time(NULL); struct tm tm = *localtime(&t); fprintf(stdout, "alive: %d-%02d-%02d %02d:%02d:%02d Temp:", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); for(i=0; i<6;i++) { sprintf(buffer,"/sys/devices/virtual/thermal/thermal_zone%d/temp",i); fdf=fopen(buffer,"r"); fscanf (fdf,"%d",&valor); fprintf(stdout,"%.1f,",valor/1000.0); } for(i=0; i<3;i++) { sprintf(buffer,"/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/rail_name_%d",i); fdf=fopen(buffer,"r"); fscanf (fdf,"%s",name); fclose(fdf); sprintf(buffer,"/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_power%d_input",i); fdf=fopen(buffer,"r"); fscanf (fdf,"%d",&millamperes); fclose(fdf); fprintf(stdout,"%s:%.3fW ",name+7,((float)millamperes)/1.0e3); } fprintf (stdout,"\r\n"); } // end while return 0; }