diff --git a/Makefile.am b/Makefile.am
index 6be6482..fb530a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,7 @@ ccminer_SOURCES = elist.h miner.h compat.h \
compat/sys/time.h compat/getopt/getopt.h \
crc32.c hefty1.c scrypt.c \
ccminer.cpp util.cpp \
- api.cpp hashlog.cpp stats.cpp cuda.cpp \
+ api.cpp hashlog.cpp stats.cpp sysinfos.cpp cuda.cpp \
heavy/heavy.cu \
heavy/cuda_blake512.cu heavy/cuda_blake512.h \
heavy/cuda_combine.cu heavy/cuda_combine.h \
diff --git a/api.cpp b/api.cpp
index 482fcc4..28df514 100644
--- a/api.cpp
+++ b/api.cpp
@@ -108,6 +108,10 @@ extern uint32_t accepted_count;
extern uint32_t rejected_count;
extern int device_map[8];
extern char *device_name[8];
+extern int num_cpus;
+
+extern float cpu_temp(int);
+extern uint32_t cpu_clock(int);
/***************************************************************/
@@ -246,13 +250,18 @@ static void gpuhwinfos(int gpu_id)
}
/**
- * To finish
+ * CPU Infos
*/
static void cpuhwinfos()
{
char buf[256];
+
+ float temp = cpu_temp(0);
+ uint32_t clock = cpu_clock(0);
+
memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "CPU=|");
+ snprintf(buf, sizeof(buf), "CPUS=%d;TEMP=%.1f;FREQ=%d|",
+ num_cpus, temp, clock);
strcat(buffer, buf);
}
@@ -277,8 +286,8 @@ static char *gethistory(char *params)
struct stats_data data[50];
int thrid = params ? atoi(params) : -1;
char *p = buffer;
- *buffer = '\0';
int records = stats_get_history(thrid, data, ARRAY_SIZE(data));
+ *buffer = '\0';
for (int i = 0; i < records; i++) {
time_t ts = data[i].tm_stat;
p += sprintf(p, "GPU=%d;H=%u;KHS=%.2f;DIFF=%.6f;"
diff --git a/ccminer.vcxproj b/ccminer.vcxproj
index 3e6fbc5..cbc6dae 100644
--- a/ccminer.vcxproj
+++ b/ccminer.vcxproj
@@ -247,6 +247,7 @@
+
diff --git a/ccminer.vcxproj.filters b/ccminer.vcxproj.filters
index 75e2bee..a50b1fa 100644
--- a/ccminer.vcxproj.filters
+++ b/ccminer.vcxproj.filters
@@ -201,6 +201,9 @@
Source Files
+
+ Source Files
+
Source Files\jansson
@@ -536,4 +539,4 @@
Source Files\CUDA\x11
-
\ No newline at end of file
+
diff --git a/sysinfos.cpp b/sysinfos.cpp
new file mode 100644
index 0000000..c41429d
--- /dev/null
+++ b/sysinfos.cpp
@@ -0,0 +1,94 @@
+/**
+ * Unit to read cpu informations
+ *
+ * TODO: WMI implementation for windows
+ *
+ * tpruvot 2014
+ */
+
+#include
+#include
+#include
+#include
+
+#include "miner.h"
+
+#ifndef WIN32
+
+#define HWMON_PATH \
+ "/sys/class/hwmon/hwmon1/device/temp1_input"
+#define HWMON_ALT \
+ "/sys/class/hwmon/hwmon0/temp1_input"
+
+static float linux_cputemp(int core)
+{
+ float tc = 0.0;
+ FILE *fd = fopen(HWMON_PATH, "r");
+ uint32_t val = 0;
+
+ if (!fd)
+ fd = fopen(HWMON_ALT, "r");
+
+ if (!fd)
+ return tc;
+
+ if (fscanf(fd, "%d", &val))
+ tc = val / 1000.0;
+
+ fclose(fd);
+ return tc;
+}
+
+#define CPUFREQ_PATH \
+ "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq"
+static uint32_t linux_cpufreq(int core)
+{
+ FILE *fd = fopen(CPUFREQ_PATH, "r");
+ uint32_t freq = 0;
+
+ if (!fd)
+ return freq;
+
+ if (!fscanf(fd, "%d", &freq))
+ return freq;
+
+ return freq;
+}
+
+#else /* WIN32 */
+
+static float win32_cputemp(int core)
+{
+ // todo
+ return 0.0;
+}
+
+#endif /* !WIN32 */
+
+
+/* exports */
+
+
+float cpu_temp(int core)
+{
+#ifdef WIN32
+ return win32_cputemp(core);
+#else
+ return linux_cputemp(core);
+#endif
+}
+
+uint32_t cpu_clock(int core)
+{
+#ifdef WIN32
+ return 0;
+#else
+ return linux_cpufreq(core);
+#endif
+}
+
+int cpu_fanpercent()
+{
+ return 0;
+}
+