Mon, 06 May 2024 15:34:32 +0200
Version 0.9.20a2. Renamed one-wire struct resolution to rd_cache and added wr_cache. The rd_cache and wr_cache values are used by the DS2413. Added these values to the grid so we can see them live.
configure | file | annotate | diff | comparison | revisions | |
configure.ac | file | annotate | diff | comparison | revisions | |
thermferm/one-wire.c | file | annotate | diff | comparison | revisions | |
thermferm/thermferm.h | file | annotate | diff | comparison | revisions | |
www/js/list_onewire.js | file | annotate | diff | comparison | revisions |
--- a/configure Sun May 05 17:24:54 2024 +0200 +++ b/configure Mon May 06 15:34:32 2024 +0200 @@ -2104,7 +2104,7 @@ PACKAGE="mbsePi-apps" -VERSION="0.9.20a1" +VERSION="0.9.20a2" COPYRIGHT="Copyright (C) 2014-2024 Michiel Broek, All Rights Reserved" CYEARS="2014-2024"
--- a/configure.ac Sun May 05 17:24:54 2024 +0200 +++ b/configure.ac Mon May 06 15:34:32 2024 +0200 @@ -8,7 +8,7 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="mbsePi-apps" -VERSION="0.9.20a1" +VERSION="0.9.20a2" COPYRIGHT="Copyright (C) 2014-2024 Michiel Broek, All Rights Reserved" CYEARS="2014-2024" AC_SUBST(PACKAGE)
--- a/thermferm/one-wire.c Sun May 05 17:24:54 2024 +0200 +++ b/thermferm/one-wire.c Mon May 06 15:34:32 2024 +0200 @@ -62,8 +62,11 @@ payload = xstrcat(payload, (char *)"\",\"value\":"); snprintf(vbuf, 63, "%d", dev_w1->value); payload = xstrcat(payload, vbuf); - payload = xstrcat(payload, (char *)",\"resolution\":"); - snprintf(vbuf, 63, "%d", dev_w1->resolution); + payload = xstrcat(payload, (char *)",\"rd_cache\":"); + snprintf(vbuf, 63, "%d", dev_w1->rd_cache); + payload = xstrcat(payload, vbuf); + payload = xstrcat(payload, (char *)",\"wr_cache\":"); + snprintf(vbuf, 63, "%d", dev_w1->wr_cache); payload = xstrcat(payload, vbuf); payload = xstrcat(payload, (char *)",\"timestamp\":"); snprintf(vbuf, 63, "%ld", (long)dev_w1->timestamp); @@ -183,7 +186,8 @@ syslog(LOG_NOTICE, "One-wire device %s is back", buffer); pthread_mutex_lock(&mutexes[LOCK_ONE_WIRE]); dev_w1->present = DEVPRESENT_YES; - dev_w1->resolution = 0; /* Might be wrong, so reset */ + dev_w1->rd_cache = 0; /* Might be wrong, so reset */ + dev_w1->wr_cache = 0; /* Not used here */ dev_w1->timestamp = time(NULL); pthread_mutex_unlock(&mutexes[LOCK_ONE_WIRE]); changed = true; @@ -201,7 +205,7 @@ n_w1->family[2] = '\0'; n_w1->present = DEVPRESENT_YES; n_w1->value = (strcmp(w1type, (char *)"3a") == 0) ? 3:-1; - n_w1->resolution = 0; + n_w1->rd_cache = n_w1->wr_cache = 0; n_w1->timestamp = time(NULL); changed = true; @@ -292,8 +296,10 @@ if ((rc = read_w1(device->address, (char *)"state")) >= 0) /* Read PIO again */ state = (unsigned int)rc; } + dev_w1->rd_cache = state; newval = ((state & 0x04) >> 1) + (state & 0x01); + dev_w1->wr_cache = newval; if (newval != dev_w1->value) { syslog(LOG_NOTICE, "One-wire device %s-%d in %02x value %d => %d", dev_w1->address, i, state, dev_w1->value, newval); dev_w1->value = newval; @@ -329,6 +335,7 @@ newval |= (device->value) ? 0x00 : 0x02; } + dev_w1->wr_cache = newval; if (output != newval) { if ((write_w1(dev_w1->address, (char *)"output", newval)) == 0) { syslog(LOG_NOTICE, "One-wire device %s-%d out %02x -> %02x", dev_w1->address, i, output, newval); @@ -365,7 +372,7 @@ * Check and correct resolution. Only do this for new sensors * or known sensors that are plugged in again. */ - if (cur_w1->resolution != W1_TEMP_RESOLUTION) { + if (cur_w1->rd_cache != W1_TEMP_RESOLUTION) { devfile = xstrcpy((char *)"/sys/bus/w1/devices/"); devfile = xstrcat(devfile, cur_w1->address); devfile = xstrcat(devfile, (char *)"/resolution"); @@ -379,7 +386,7 @@ sprintf(buffer, "%d", W1_TEMP_RESOLUTION); fputs(buffer, fp); } - cur_w1->resolution = W1_TEMP_RESOLUTION; + cur_w1->rd_cache = W1_TEMP_RESOLUTION; } fclose(fp); } else {
--- a/thermferm/thermferm.h Sun May 05 17:24:54 2024 +0200 +++ b/thermferm/thermferm.h Mon May 06 15:34:32 2024 +0200 @@ -330,7 +330,8 @@ char family[3]; ///< Device family int present; ///< Present on bus int value; ///< Last value - int resolution; ///< Actual resolution + int rd_cache; ///< Resolution/Input + int wr_cache; ///< Write patern time_t timestamp; ///< Last seen } w1_list;
--- a/www/js/list_onewire.js Sun May 05 17:24:54 2024 +0200 +++ b/www/js/list_onewire.js Mon May 06 15:34:32 2024 +0200 @@ -31,6 +31,8 @@ { name: 'family', type: 'string' }, { name: 'value', type: 'int' }, { name: 'present', type: 'string' }, + { name: 'rd_cache', type: 'int' }, + { name: 'wr_cache', type: 'int' }, { name: 'timestamp', type: 'int' } ], id: 'address', @@ -57,6 +59,8 @@ { text: 'Address', datafield: 'address' }, { text: 'Family', datafield: 'family', width: 100 }, { text: 'Present', datafield: 'present', width: 120 }, + { text: 'Rd cache', datafield: 'rd_cache', width: 100 }, + { text: 'Wr cache', datafield: 'wr_cache', width: 100 }, { text: 'Value', datafield: 'value', width: 100 }, { text: 'Last change', datafield: 'timestamp', width: 200, cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {