From 4ca31d2ce41ae3e3bb36921464df0613213f3117 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Thu, 11 Sep 2008 03:21:39 +0000 Subject: [PATCH] * Improved hddtemp support git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1245 7f574dfc-610e-0410-a909-a81674777703 --- ChangeLog | 3 +++ src/conky.c | 4 ++-- src/hddtemp.c | 13 +++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67916a27..1f8bf072 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ # $Id$ +2008-09-10 + * Improved hddtemp support + 2008-09-07 * Fixed bug with freq_dyn on x86_64 (thanks Miroslav) * Fixed buffer overflow in update_net_stats() (thanks Miroslav) diff --git a/src/conky.c b/src/conky.c index f30f6ee1..d416260d 100644 --- a/src/conky.c +++ b/src/conky.c @@ -5344,7 +5344,7 @@ static void generate_text_internal(char *p, int p_max_size, #endif #ifdef HDDTEMP OBJ(hddtemp) { - if (obj->data.hddtemp.update_time < current_update_time - 30) { +// if (obj->data.hddtemp.update_time < current_update_time - 30) { char *str = get_hddtemp_info(obj->data.hddtemp.dev, obj->data.hddtemp.addr, obj->data.hddtemp.port, &obj->data.hddtemp.unit); if (str) { @@ -5353,7 +5353,7 @@ static void generate_text_internal(char *p, int p_max_size, obj->data.hddtemp.temp[0] = 0; } obj->data.hddtemp.update_time = current_update_time; - } +// } if (!obj->data.hddtemp.temp) { snprintf(p, p_max_size, "N/A"); } else if (obj->data.hddtemp.unit == '*') { diff --git a/src/hddtemp.c b/src/hddtemp.c index f586349a..22566ba3 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -120,11 +120,12 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit) FD_ZERO(&rfds); FD_SET(sockfd, &rfds); - /* We're going to wait up to a quarter a second to see whether there's - * any data available. Polling with timeout set to 0 doesn't seem to work - * with hddtemp. */ + /* We're going to wait up to a half second to see whether there's any + * data available. Polling with timeout set to 0 doesn't seem to work + * with hddtemp. + */ tv.tv_sec = 0; - tv.tv_usec = 250000; + tv.tv_usec = 500000; i = select(sockfd + 1, &rfds, NULL, NULL, &tv); if (i == -1) { @@ -137,6 +138,7 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit) /* No data available */ if (i <= 0) { + ERR("hddtemp had nothing for us"); break; } @@ -153,10 +155,12 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit) } while (i > 0 && p < buf + BUFLEN - 1); if (len < 2) { + ERR("hddtemp returned nada"); break; } buf[len] = 0; +// printf("read: '%s'\n", buf); /* The first character read is the separator. */ sep = buf[0]; @@ -200,5 +204,6 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit) } } while (0); close(sockfd); +// printf("got: '%s'\n", r); return r; }