From 44f96c64b235b0b1b76d704719fe9eaeb5991225 Mon Sep 17 00:00:00 2001 From: Kano Date: Thu, 10 Oct 2013 07:56:41 +1100 Subject: [PATCH 1/3] klondike - display MHz also --- driver-klondike.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/driver-klondike.c b/driver-klondike.c index 797ee377..955c1c61 100644 --- a/driver-klondike.c +++ b/driver-klondike.c @@ -619,7 +619,9 @@ static void get_klondike_statline_before(char *buf, size_t siz, struct cgpu_info struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); uint8_t temp = 0xFF; uint16_t fan = 0; + uint16_t clock = 0; int dev; + char tmp[16]; if (klninfo->status == NULL) return; @@ -629,11 +631,17 @@ static void get_klondike_statline_before(char *buf, size_t siz, struct cgpu_info if (klninfo->status[dev].temp < temp) temp = klninfo->status[dev].temp; fan += klninfo->cfg[dev].fantarget; + clock += klninfo->cfg[dev].hashclock; } fan /= klninfo->status->slavecount+1; + clock /= klninfo->status->slavecount+1; rd_unlock(&(klninfo->stat_lock)); - tailsprintf(buf, siz, " %3.0fC %3d%% | ", cvtKlnToC(temp), fan*100/255); + snprintf(tmp, sizeof(tmp), "%2.0fC", cvtKlnToC(temp)); + if (strlen(tmp) < 4) + strcat(tmp, " "); + + tailsprintf(buf, siz, "%3dMHz %3d%% %s| ", (int)clock, fan*100/255, tmp); } static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu) From 8e82da43205d0e5a3d66d760ad1ae6c62c759753 Mon Sep 17 00:00:00 2001 From: Kano Date: Fri, 4 Oct 2013 10:57:07 +1000 Subject: [PATCH 2/3] Klondike - extra zero value and range checking in temp conversion --- driver-klondike.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/driver-klondike.c b/driver-klondike.c index 955c1c61..523df436 100644 --- a/driver-klondike.c +++ b/driver-klondike.c @@ -120,6 +120,9 @@ static double cvtKlnToC(uint8_t temp) { double Rt, stein, celsius; + if (temp == 0) + return 0.0; + Rt = 1000.0 * 255.0 / (double)temp - 1000.0; stein = log(Rt / 2200.0) / 3987.0; @@ -128,13 +131,39 @@ static double cvtKlnToC(uint8_t temp) celsius = (1.0 / stein) - 273.15; + // For display of bad data + if (celsius < 0.0) + celsius = 0.0; + if (celsius > 200.0) + celsius = 200.0; + return celsius; } static int cvtCToKln(double deg) { - double R = exp((1/(deg+273.15)-1/(273.15+25))*3987)*2200; - return 256*R/(R+1000); + double Rt, stein, temp; + + if (deg < 0.0) + deg = 0.0; + + stein = 1.0 / (deg + 273.15); + + stein -= 1.0 / (double)(25.0 + 273.15); + + Rt = exp(stein * 3987.0) * 2200.0; + + if (Rt == -1000.0) + Rt++; + + temp = 1000.0 * 256.0 / (Rt + 1000.0); + + if (temp > 255) + temp = 255; + if (temp < 0) + temp = 0; + + return (int)temp; } static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, int datalen, void *data) From 595dcdfa94a30d4fd2b3f1dbec756500c75e6eea Mon Sep 17 00:00:00 2001 From: Kano Date: Fri, 4 Oct 2013 14:56:33 +1000 Subject: [PATCH 3/3] Klondike - increase circular read buffer size --- driver-klondike.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver-klondike.c b/driver-klondike.c index 523df436..7dafc1d0 100644 --- a/driver-klondike.c +++ b/driver-klondike.c @@ -39,7 +39,7 @@ #define REPLY_SIZE 15 // adequate for all types of replies #define REPLY_BUFSIZE 16 // reply + 1 byte to mark used -#define MAX_REPLY_COUNT 32 // more unhandled replies than this will result in data loss +#define MAX_REPLY_COUNT 4096 // more unhandled replies than this will result in data loss #define REPLY_WAIT_TIME 100 // poll interval for a cmd waiting it's reply #define CMD_REPLY_RETRIES 8 // how many retries for cmds #define MAX_WORK_COUNT 4 // for now, must be binary multiple and match firmware