diff -Nru digitemp-3.7.1/ChangeLog digitemp-3.7.2/ChangeLog --- digitemp-3.7.1/ChangeLog 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/ChangeLog 2018-11-19 19:01:33.000000000 +0000 @@ -157,7 +157,7 @@ Changed version # to v3.0.0 08/21/2002 Small bug with -i crept in, it wants another command to be - present, it won't just initalize. + present, it won't just initialize. 08/18/2002 Added %N token to allow the time in seconds since Epoch to be selected in the output. @@ -182,7 +182,7 @@ exit if the user doesn't have access to the serial device. 06/23/2002 Releasing new version today. Really! Making -q turn off - the extra output I added for initalizing the 1-wire lan. + the extra output I added for initializing the 1-wire lan. 06/08/2002 Adding patches from John. exit() codes are now #defines and .digitemprc now outputs the serial numbers as hex @@ -339,7 +339,7 @@ Adding support for the DS9097-U adapter for the Linux version. The Solaris version will need changes to be able to support the DS9097-U. - Changed license to GNU Public License v2.0 + Changed license to GNU General Public License v2.0 Added the -q option to make the banner disappear. 01/01/2000 Well, no release last year. Adding -q to make the banner @@ -402,7 +402,7 @@ 08/31/1998 Adding a check for family 0x10 so that we can read DS1820s while they are on a network that includes other 1-wire devices. - Fixed a problem with freeing uninitalized rom_list when + Fixed a problem with freeing uninitialized rom_list when starting a SearchROM. Not sure why this never appeared before. diff -Nru digitemp-3.7.1/COPYRIGHT digitemp-3.7.2/COPYRIGHT --- digitemp-3.7.1/COPYRIGHT 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/COPYRIGHT 2018-11-19 19:01:33.000000000 +0000 @@ -1,8 +1,8 @@ - DigiTemp v3.7.1 + DigiTemp v3.7.2 Dallas Semiconductor one-wire temperature sensor interface http://www.digitemp.com - Copyright (c) 1996-2015 by Brian C. Lane + Copyright (c) 1996-2018 by Brian C. Lane http://www.brianlane.com All rights reserved. diff -Nru digitemp-3.7.1/debian/changelog digitemp-3.7.2/debian/changelog --- digitemp-3.7.1/debian/changelog 2018-04-03 12:19:36.000000000 +0000 +++ digitemp-3.7.2/debian/changelog 2018-11-28 06:43:30.000000000 +0000 @@ -1,8 +1,15 @@ -digitemp (3.7.1-2build1) bionic; urgency=high +digitemp (3.7.2-1) unstable; urgency=medium - * No change rebuild to pick up -fPIE compiler default + [ Helmut Grohne ] + * Fix FTCBFS: Let dh_auto_build pass cross tools to make. (Closes: #914824) - -- Balint Reczey Tue, 03 Apr 2018 12:19:36 +0000 + [ Ryan Finnie ] + * New upstream release + * Bump standards version to 4.2.1 + * Fix depends-on-obsolete-package suggests: + mysql-server => default-mysql-server + + -- Ryan Finnie Wed, 28 Nov 2018 06:43:30 +0000 digitemp (3.7.1-2) unstable; urgency=medium diff -Nru digitemp-3.7.1/debian/control digitemp-3.7.2/debian/control --- digitemp-3.7.1/debian/control 2018-04-03 12:19:36.000000000 +0000 +++ digitemp-3.7.2/debian/control 2018-11-28 06:36:18.000000000 +0000 @@ -1,17 +1,16 @@ Source: digitemp Section: electronics Priority: optional -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Ryan Finnie +Maintainer: Ryan Finnie Build-Depends: debhelper (>= 9), libusb-dev -Standards-Version: 3.9.6 +Standards-Version: 4.2.1 Homepage: http://www.digitemp.com Vcs-Browser: https://github.com/rfinnie/digitemp-pkg-debian Vcs-Git: https://github.com/rfinnie/digitemp-pkg-debian Package: digitemp Architecture: any -Suggests: rrdtool, python, mysql-server +Suggests: rrdtool, python, default-mysql-server Depends: ${shlibs:Depends}, ${misc:Depends} Description: read temperature sensors in a 1-Wire net Digitemp is a program that reads data coming from a 1-Wire network using diff -Nru digitemp-3.7.1/debian/rules digitemp-3.7.2/debian/rules --- digitemp-3.7.1/debian/rules 2015-12-13 07:12:58.000000000 +0000 +++ digitemp-3.7.2/debian/rules 2018-11-28 06:33:24.000000000 +0000 @@ -5,14 +5,14 @@ #export DH_VERBOSE=1 %: - dh $@ + dh $@ --buildsystem=makefile override_dh_auto_build: mkdir -p build-serial/src build-serial/userial/ds9097 build-serial/userial/ds9097u - $(MAKE) -C build-serial -f ../Makefile SRCDIR=.. ds9097 ds9097u + dh_auto_build --builddirectory=build-serial -- -f ../Makefile SRCDIR=.. ds9097 ds9097u mkdir -p build-usb/src build-usb/userial/ds2490 - $(MAKE) -C build-usb -f ../Makefile SRCDIR=.. ds2490 + dh_auto_build --builddirectory=build-usb -- -f ../Makefile SRCDIR=.. ds2490 override_dh_auto_install: install -m 0755 -d debian/digitemp/usr/bin diff -Nru digitemp-3.7.1/digitemp.spec digitemp-3.7.2/digitemp.spec --- digitemp-3.7.1/digitemp.spec 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/digitemp.spec 2018-11-19 19:01:33.000000000 +0000 @@ -2,7 +2,7 @@ Summary: Dallas Semiconductor 1-wire device reading console application Name: digitemp -Version: 3.7.1 +Version: 3.7.2 Release: 1%{?dist} License: GPLv2+ Group: Applications/System @@ -59,6 +59,24 @@ %{_mandir}/man1/%{name}.* %changelog +* Mon Nov 19 2018 Brian C. Lane - 3.7.2-1 +- Fix digitemp.spec Version in bumpver target (bcl) +- Make sure strncpy uses are null-terminated (bcl) +- Add a check for ROM number vs. SENSORS count (bcl) +- Log the scratchpad diagnostics (bcl) +- Bump Copyright Year to 2018 (bcl) +- Fix strftime use of log_file (bcl) +- Add strftime formating to logfile name (peje) +- Clean up the start_time switch statement usage (bcl) +- Add log_type 4 & 5 (peje) +- Check for bad Get_Temperature result (bcl) +- Fix the return value of Get_Temperature in ad26.c (bcl) +- Display DS2438 temperature even if humidity calculation fails. (bcl) +- Always include types.h and time.h (bcl) +- Bump copyright year to 2016 (bcl) +- Add bumpver target (bcl) +- Spelling corrections (ryan) + * Sat Dec 12 2015 Brian C. Lane 3.7.1-1 - Update version to 3.7.1 - Fix version in digitemp.h diff -Nru digitemp-3.7.1/FAQ digitemp-3.7.2/FAQ --- digitemp-3.7.1/FAQ 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/FAQ 2018-11-19 19:01:33.000000000 +0000 @@ -1,5 +1,5 @@ DigiTemp Frequently Asked Questions -Copyright 1996-2015 by Brian C. Lane +Copyright 1996-2018 by Brian C. Lane http://www.brianlane.com http://www.digitemp.com diff -Nru digitemp-3.7.1/Makefile digitemp-3.7.2/Makefile --- digitemp-3.7.1/Makefile 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/Makefile 2018-11-19 19:01:33.000000000 +0000 @@ -1,13 +1,13 @@ # # Makefile for DigiTemp # -# Copyright 1996-2015 by Brian C. Lane -# See COPYING for GNU Public License +# Copyright 1996-2018 by Brian C. Lane +# See COPYING for GNU General Public License # # Please note that this Makefile *needs* GNU make. BSD make won't do. # -VERSION = 3.7.1 +VERSION=$(shell awk '/Version:/ { print $$2 }' digitemp.spec) SRCDIR = $(CURDIR) VPATH = $(SRCDIR) @@ -136,6 +136,22 @@ gzip -9 v$(VERSION).tar @echo "The archive is in v$(VERSION).tar.gz" +rpmlog: + @git log --pretty="format:- %s (%ae)" v$(VERSION).. |sed -e 's/@.*)/)/' | grep -v "Merge pull request" + +bumpver: + @NEWSUBVER=$$((`echo $(VERSION) |cut -d . -f 3` + 1)) ; \ + NEWVERSION=`echo $(VERSION).$$NEWSUBVER |cut -d . -f 1,2,4` ; \ + DATELINE="* `date "+%a %b %d %Y"` `git config user.name` <`git config user.email`> - $$NEWVERSION-1" ; \ + cl=`grep -n %changelog digitemp.spec |cut -d : -f 1` ; \ + tail --lines=+$$(($$cl + 1)) digitemp.spec > speclog ; \ + (head -n $$cl digitemp.spec ; echo "$$DATELINE" ; make --quiet rpmlog 2>/dev/null ; echo ""; cat speclog) > digitemp.spec.new ; \ + mv digitemp.spec.new digitemp.spec ; rm -f speclog ; \ + sed -i "s/Version:.*$(VERSION)/Version: $$NEWVERSION/" digitemp.spec ; \ + sed -i "s/$(VERSION)/$$NEWVERSION/" README ; \ + sed -i "s/$(VERSION)/$$NEWVERSION/" COPYRIGHT ; \ + sed -i "s/$(VERSION)/$$NEWVERSION/" ./src/digitemp.h + # Build the source distribution source: archive diff -Nru digitemp-3.7.1/perl/maxplot digitemp-3.7.2/perl/maxplot --- digitemp-3.7.1/perl/maxplot 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/perl/maxplot 2018-11-19 19:01:33.000000000 +0000 @@ -168,7 +168,7 @@ # Now all the temps are in dottemp -- it might be better to read it line # by line for bigger files? -# Initalize the initial variables - I should use a list for this +# Initialize the initial variables - I should use a list for this $x = $hmargin; $_= $dottemp[0]; @_ = split( " ", $_ ); diff -Nru digitemp-3.7.1/README digitemp-3.7.2/README --- digitemp-3.7.1/README 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/README 2018-11-19 19:01:33.000000000 +0000 @@ -1,5 +1,5 @@ ---------------------------------------------------------------------------- - DigiTemp v3.7.1 for Linux (c)1996-2015 by Brian C. Lane + DigiTemp v3.7.2 for Linux (c)1996-2018 by Brian C. Lane ============================================================================ Thank you for using DigiTemp for Linux. If you have any problems or @@ -33,7 +33,7 @@ If you had my 1-wire setup (hub and sensors) you would see this: DigiTemp v3.3.0 Copyright 1996-2004 by Brian C. Lane - GNU Public License v2.0 - http://www.brianlane.com + GNU General Public License v2.0 - http://www.brianlane.com Turning off all DS2409 Couplers ... Searching the 1-Wire LAN @@ -66,7 +66,7 @@ Again, if you were using the same 1-wire lan as I am you would see: DigiTemp v3.3.0 Copyright 1996-2004 by Brian C. Lane - GNU Public License v2.0 - http://www.brianlane.com + GNU General Public License v2.0 - http://www.brianlane.com Jan 11 08:33:41 Sensor 0 C: 22.50 F: 72.50 Jan 11 08:33:42 Sensor 1 C: 31.44 F: 88.59 Jan 11 08:33:43 Sensor 2 C: 21.56 F: 70.81 @@ -178,7 +178,7 @@ device connected, even if it isn't a sensor that DigiTemp supports. DigiTemp v3.3.0 Copyright 1996-2003 by Brian C. Lane - GNU Public License v2.0 - http://www.brianlane.com + GNU General Public License v2.0 - http://www.brianlane.com Turning off all DS2409 Couplers Devices on the Main LAN @@ -211,7 +211,8 @@ ------------------- To log temperatures to a logfile instead of to the console you use the --l command line option. I have a cron job that runs every 30 minutes and +-l command line option. The logfile name may use strftime format to generate +the filename. I have a cron job that runs every 30 minutes and logs the temperatures to a file called /var/log/temperature. The cron entry look like this: @@ -232,7 +233,13 @@ into a spreadsheet program. The data is output in Centigrade when -o2 is used and Fahrenheit when -o3 is used. - The other option is to use a format specifier string. To do this you pass + Using -o4 or -o5 will output all the sensor readings on a single line like: +1476177670 23.22 1.33 12.69 + + Like -o2 and -o3 except the first number is the elapsed time since +1970-01-01 00:00:00 (unixtime). + +The other option is to use a format specifier string. To do this you pass the string as the argument to -o, like this: -o"%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F" @@ -260,7 +267,7 @@ the output looks like this: DigiTemp v3.3.0 Copyright 1996-2003 by Brian C. Lane - GNU Public License v2.0 - http://www.brianlane.com + GNU General Public License v2.0 - http://www.brianlane.com Jan 11 16:56:00 Sensor 6 VDD: 4.70 AD: 1.46 C: 27.94 @@ -329,6 +336,12 @@ This outputs the data as tab separated Centigrade readings to a file named data1.txt in the current directory. + To log continously every 10 seconds into files named with current date: + + digitemp -a -d10 -n0 -o4 -ltemperature-%Y%m%d.txt + + This outputs the data as tab separated Centigrade readings to files named +temperature-20161011.txt, temperature-20161011.txt, ... in the current directory. Web scripts ----------- @@ -444,7 +457,7 @@ Version 2.5 adds compilation under Solaris. A new log option of %R has been added to output the serial number in hex in the logging output string. -The quiet -q option now quiets down the 1-Wire walk and initalize routine so +The quiet -q option now quiets down the 1-Wire walk and initialize routine so that only the important information is output. Version 2.4 fixes the problems (finally!) with the DS18B20 and DS1822 @@ -456,9 +469,9 @@ Version 2.x.x removes support for the old adapter (based on the one described in App. Note 74 from Dallas Semiconductor. Version 1.3 still -supports the older adapters and is now also released under the GNU public -license). This new version uses the DS9097-U adapter available from Dallas -Semiconductor. You can order them from their iButton webpage at +supports the older adapters and is now also released under the GNU General +Public License). This new version uses the DS9097-U adapter available from +Dallas Semiconductor. You can order them from their iButton webpage at www.ibutton.com This adapter is more expensive but is easier to program and support higher diff -Nru digitemp-3.7.1/rrdb/log_temp digitemp-3.7.2/rrdb/log_temp --- digitemp-3.7.1/rrdb/log_temp 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/rrdb/log_temp 2018-11-19 19:01:33.000000000 +0000 @@ -23,7 +23,7 @@ # your root directory or specify the configuration file using -c filename # on the digitemp command line in the reading variable below. -# Get the current temperatures, digitemp has been previously initalized with +# Get the current temperatures, digitemp has been previously initialized with # digitemp -i -s /dev/ttyS0 -o2 -a # Run it in quiet mode, output is 0\tsensor#1\tsensor#2\tsensor#3 diff -Nru digitemp-3.7.1/rrdb/README digitemp-3.7.2/rrdb/README --- digitemp-3.7.1/rrdb/README 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/rrdb/README 2018-11-19 19:01:33.000000000 +0000 @@ -24,6 +24,6 @@ The suggested initialization sets up digitemp to output the temperature in Centigrade and the conversion to Fahrenheit. The -o option passed to - digitemp when it is initalized controls how the temperature is output. + digitemp when it is initialized controls how the temperature is output. diff -Nru digitemp-3.7.1/src/digitemp.c digitemp-3.7.2/src/digitemp.c --- digitemp-3.7.1/src/digitemp.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/src/digitemp.c 2018-11-19 19:01:33.000000000 +0000 @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- DigiTemp - Copyright 1996-2015 by Brian C. Lane + Copyright 1996-2018 by Brian C. Lane All Rights Reserved This program is free software; you can redistribute it and/or modify it @@ -19,7 +19,7 @@ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA digitemp -w Walk the LAN & show all - digitemp -i Initalize .digitemprc file + digitemp -i Initialize .digitemprc file digitemp -I Initialize .digitemprc w/sorted serial #s digitemp -s/dev/ttyS0 Set serial port (required) digitemp -cdigitemp.conf Configuration File @@ -41,8 +41,10 @@ Logfile formats: 1 = (default) - 1 line per sensor, time, C, F 1 line for each sample, elapsed time, sensor #1, #2, ... tab seperated - 2 = Reading in C - 3 = Reading in F + 2 = (seconds since start of measurement) & Reading in C + 3 = (seconds since start of measurement) & Reading in F + 4 = Unixtime(seconds since 1970-01-01 00:00:00) & Reading in C + 5 = Unixtime(seconds since 1970-01-01 00:00:00) & Reading in F The format string uses strftime tokens plus 6 special ones for digitemp - %s for sensor #, %C for centigrade, @@ -65,10 +67,8 @@ #if !defined(AIX) && !defined(SOLARIS) && !defined(FREEBSD) && !defined(DARWIN) #include #endif /* !AIX and !SOLARIS and !FREEBSD and !DARWIN */ -#include #include #include -#include #include #include #include @@ -148,6 +148,8 @@ printf("\nLogfile formats: 1 = One line per sensor, time, C, F (default)\n"); printf(" 2 = One line per sample, elapsed time, temperature in C\n"); printf(" 3 = Same as #2, except temperature is in F\n"); + printf(" 4 = Same as #2, except elapsed time since (1970-01-01 00:00:00)\n"); + printf(" 5 = Same as #4, except temperature is in F\n"); printf(" #2 and #3 have the data separated by tabs, suitable for import\n"); printf(" into a spreadsheet or other graphing software.\n"); printf("\n The format string uses strftime tokens plus 5 special ones for\n"); @@ -159,6 +161,7 @@ printf(" The counter format string has 2 special specifiers:\n"); printf(" %%n is the counter # and %%C is the count in decimal.\n"); printf(" The humidity format uses %%h for the humidity in percent\n\n"); + printf(" The logfile may contain strftime pattern to format the filename\n"); } @@ -498,14 +501,19 @@ int log_string( char *line ) { int fd=0; - + char time_log_file[1024]; if( log_file[0] != 0 ) - { - if( (fd = open( log_file, O_CREAT | O_WRONLY | O_APPEND, + { + time_t now = time(NULL); + + /* Update time_log_file name according to current time and logfile format */ + strftime(time_log_file, sizeof(log_file) - 1, log_file, gmtime(&now)); + + if( (fd = open( time_log_file, O_CREAT | O_WRONLY | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ) ) == -1 ) { - printf("Error opening logfile: %s\n", log_file ); + printf("Error opening logfile: %s\n", time_log_file ); return -1; } if( write( fd, line, strlen( line ) ) == -1) @@ -602,11 +610,13 @@ switch( log_type ) { /* Multiple Centigrade temps per line */ - case 2: sprintf( temp, "\t%3.2f", temp_c ); + case 2: + case 4: sprintf( temp, "\t%3.2f", temp_c ); break; /* Multiple Fahrenheit temps per line */ - case 3: sprintf( temp, "\t%3.2f", c2f(temp_c) ); + case 3: + case 5: sprintf( temp, "\t%3.2f", c2f(temp_c) ); break; default: @@ -664,67 +674,49 @@ char temp[80]; int i; - if( log_file[0] != 0 ) + /* Log and/or print the scratchpad diagnostics */ + switch( sensor_family ) { - switch( sensor_family ) - { - case DS1820_FAMILY: - sprintf( temp, " Temperature : 0x%02X\n", scratchpad[1] ); - sprintf( temp, " Sign : 0x%02X\n", scratchpad[2] ); - sprintf( temp, " TH : 0x%02X\n", scratchpad[3] ); - sprintf( temp, " TL : 0x%02X\n", scratchpad[4] ); - sprintf( temp, " Remain : 0x%02X\n", scratchpad[7] ); - sprintf( temp, " Count Per C : 0x%02X\n", scratchpad[8] ); - sprintf( temp, " CRC : 0x%02X\n", scratchpad[9] ); - break; - - case DS18B20_FAMILY: - case DS1822_FAMILY: - case DS28EA00_FAMILY: - sprintf( temp, " Temp. LSB : 0x%02X\n", scratchpad[1] ); - sprintf( temp, " Temp. MSB : 0x%02X\n", scratchpad[2] ); - sprintf( temp, " TH : 0x%02X\n", scratchpad[3] ); - sprintf( temp, " TL : 0x%02X\n", scratchpad[4] ); - sprintf( temp, " Config Reg. : 0x%02X\n", scratchpad[5] ); - sprintf( temp, " CRC : 0x%02X\n", scratchpad[9] ); - break; - - case DS2422_FAMILY: - case DS2423_FAMILY: - - break; - } /* sensor_family switch */ - } else { - switch( sensor_family ) - { - case DS1820_FAMILY: - printf(" Temperature : 0x%02X\n", scratchpad[1] ); - printf(" Sign : 0x%02X\n", scratchpad[2] ); - printf(" TH : 0x%02X\n", scratchpad[3] ); - printf(" TL : 0x%02X\n", scratchpad[4] ); - printf(" Remain : 0x%02X\n", scratchpad[7] ); - printf(" Count Per C : 0x%02X\n", scratchpad[8] ); - printf(" CRC : 0x%02X\n", scratchpad[9] ); - break; - - case DS18B20_FAMILY: - case DS1822_FAMILY: - case DS28EA00_FAMILY: - printf( " Temp. LSB : 0x%02X\n", scratchpad[1] ); - printf( " Temp. MSB : 0x%02X\n", scratchpad[2] ); - printf( " TH : 0x%02X\n", scratchpad[3] ); - printf( " TL : 0x%02X\n", scratchpad[4] ); - printf( " Config Reg. : 0x%02X\n", scratchpad[5] ); - printf( " CRC : 0x%02X\n", scratchpad[9] ); - break; - - case DS2422_FAMILY: - case DS2423_FAMILY: + case DS1820_FAMILY: + sprintf( temp, " Temperature : 0x%02X\n", scratchpad[1] ); + log_string( temp ); + sprintf( temp, " Sign : 0x%02X\n", scratchpad[2] ); + log_string( temp ); + sprintf( temp, " TH : 0x%02X\n", scratchpad[3] ); + log_string( temp ); + sprintf( temp, " TL : 0x%02X\n", scratchpad[4] ); + log_string( temp ); + sprintf( temp, " Remain : 0x%02X\n", scratchpad[7] ); + log_string( temp ); + sprintf( temp, " Count Per C : 0x%02X\n", scratchpad[8] ); + log_string( temp ); + sprintf( temp, " CRC : 0x%02X\n", scratchpad[9] ); + log_string( temp ); + break; + + case DS18B20_FAMILY: + case DS1822_FAMILY: + case DS28EA00_FAMILY: + sprintf( temp, " Temp. LSB : 0x%02X\n", scratchpad[1] ); + log_string( temp ); + sprintf( temp, " Temp. MSB : 0x%02X\n", scratchpad[2] ); + log_string( temp ); + sprintf( temp, " TH : 0x%02X\n", scratchpad[3] ); + log_string( temp ); + sprintf( temp, " TL : 0x%02X\n", scratchpad[4] ); + log_string( temp ); + sprintf( temp, " Config Reg. : 0x%02X\n", scratchpad[5] ); + log_string( temp ); + sprintf( temp, " CRC : 0x%02X\n", scratchpad[9] ); + log_string( temp ); + break; - break; - } /* sensor_family switch */ - } /* if log_file */ - + case DS2422_FAMILY: + case DS2423_FAMILY: + + break; + } /* sensor_family switch */ + /* Dump the complete contents of the scratchpad */ for( i = 0; i < 10; i++ ) { @@ -869,12 +861,14 @@ switch( log_type ) { /* Multiple Centigrade temps per line */ - case 2: sprintf( temp, "\t%3.2f", temp_c ); + case 2: + case 4: sprintf( temp, "\t%3.2f", temp_c ); log_string( temp ); break; /* Multiple Fahrenheit temps per line */ - case 3: sprintf( temp, "\t%3.2f", c2f(temp_c) ); + case 3: + case 5: sprintf( temp, "\t%3.2f", c2f(temp_c) ); log_string( temp ); break; @@ -900,9 +894,11 @@ switch( log_type ) { /* Multiple Centigrade temps per line */ - case 2: + case 2: + case 4: /* Multiple Fahrenheit temps per line */ - case 3: sprintf( temp, "\t%3.2f", (double) 0 ); + case 3: + case 5: sprintf( temp, "\t%3.2f", (double) 0 ); log_string( temp ); break; @@ -952,7 +948,9 @@ { /* Multiple Centigrade temps per line */ case 2: - case 3: sprintf( temp, "\t%ld", counter_value ); + case 3: + case 4: + case 5: sprintf( temp, "\t%ld", counter_value ); log_string( temp ); break; @@ -961,7 +959,7 @@ break; } /* switch( log_type ) */ } - } + } } else if( sensor_family == DS2423_FAMILY ) { /* Read Pages 14, 15 */ for( page=14; page<=15; page++ ) @@ -973,7 +971,9 @@ { /* Multiple Centigrade temps per line */ case 2: - case 3: sprintf( temp, "\t%ld", counter_value ); + case 3: + case 4: + case 5: sprintf( temp, "\t%ld", counter_value ); log_string( temp ); break; @@ -982,7 +982,7 @@ break; } /* switch( log_type ) */ } - } + } } return FALSE; @@ -1020,14 +1020,16 @@ switch( log_type ) { /* Multiple Centigrade temps per line */ - case 2: sprintf( temp, "\t%02x,%02x", pio>>8, pio&0xff ); + case 2: + case 4: sprintf( temp, "\t%02x,%02x", pio>>8, pio&0xff ); break; /* Multiple Fahrenheit temps per line */ - case 3: sprintf( temp, "\t%02x,%02x", pio>>8, pio&0xff); + case 3: + case 5: sprintf( temp, "\t%02x,%02x", pio>>8, pio&0xff); break; - default: + default: sprintf( time_format, "%%b %%d %%H:%%M:%%S Sensor %d PIO: %02x,%02x, PIO-A: %s%s", sensor, pio>>8, pio&0xff, ((pio&0x1000)!=0)? // Port A latch: there was a change (((pio&0x0400)!=0)? @@ -1072,55 +1074,62 @@ ----------------------------------------------------------------------- */ int read_ds2438( int sensor_family, int sensor ) { - double temperature; + double temp_c; float vdd, ad; char temp[1024], time_format[160]; time_t mytime; int cad = 0; + int try; + int result = FALSE; - - if( sensor_family == DS2438_FAMILY ) + for( try = 0; try < MAX_READ_TRIES; try++ ) { - temperature = Get_Temperature(0); + /* Read the temperature */ + temp_c = Get_Temperature(0); + if (temp_c == -999.0) + return result; - /* Read Vdd */ - vdd = Volt_Reading(0, 1, &cad); - - /* Read A/D */ - ad = Volt_Reading(0, 0, NULL); - - mytime = time(NULL); - if( mytime ) + /* Read Vdd, the supply voltage */ + if( (vdd = Volt_Reading(0, 1, &cad)) != -1.0 ) { - /* Log the temperature */ - switch( log_type ) + /* Read A/D reading from the humidity sensor */ + if( (ad = Volt_Reading(0, 0, NULL)) != -1.0 ) { - /* Multiple Centigrade temps per line */ - case 2: sprintf( temp, "\t%3.2f", temperature ); - break; - - /* Multiple Fahrenheit temps per line */ - case 3: sprintf( temp, "\t%3.2f", c2f(temperature) ); - break; - - default: - sprintf( time_format, "%%b %%d %%H:%%M:%%S Sensor %d VDD: %0.2f AD: %0.2f CAD: %d C: %0.2f", sensor, vdd, ad, cad, temperature ); - /* Handle the time format tokens */ - strftime( temp, 1024, time_format, localtime( &mytime ) ); - strcat( temp, "\n" ); - break; - } /* switch( log_type ) */ - } else { - sprintf( temp, "Time Error\n" ); + result = TRUE; + break; + } } - /* Log it to stdout, logfile or both */ - log_string( temp ); + owTouchReset(0); + msDelay(read_time); } - return FALSE; + /* Log the temperature */ + mytime = time(NULL); + switch( log_type ) + { + /* Multiple Centigrade temps per line */ + case 2: sprintf(temp, "\t%3.2f", temp_c); + break; + + /* Multiple Fahrenheit temps per line */ + case 3: sprintf(temp, "\t%3.2f", c2f(temp_c)); + break; + + default: + sprintf(time_format, "%%b %%d %%H:%%M:%%S Sensor %d VDD: %0.2f AD: %0.2f CAD: %d C: %0.2f", sensor, vdd, ad, cad, temp_c); + /* Handle the time format tokens */ + strftime(temp, 1024, time_format, localtime(&mytime)); + strcat(temp, "\n"); + break; + } /* switch( log_type ) */ + + /* Log it to stdout, logfile or both */ + log_string(temp); + + return TRUE; } @@ -1174,35 +1183,34 @@ double temp_c; /* Converted temperature in degrees C */ float sup_voltage, /* Supply voltage in volts */ hum_voltage, /* Humidity sensor voltage in volts */ - humidity; /* Calculated humidity in %RH */ + humidity = 0.0; /* Calculated humidity in %RH */ unsigned char TempSN[8]; int try; + int result = FALSE; for( try = 0; try < MAX_READ_TRIES; try++ ) { + /* Read the temperature */ + temp_c = Get_Temperature(0); + if (temp_c == -999.0) + return result; + /* Read Vdd, the supply voltage */ if( (sup_voltage = Volt_Reading(0, 1, NULL)) != -1.0 ) { /* Read A/D reading from the humidity sensor */ if( (hum_voltage = Volt_Reading(0, 0, NULL)) != -1.0 ) { - /* Read the temperature */ - temp_c = Get_Temperature(0); - /* Convert the measured voltage to humidity */ humidity = (((hum_voltage/sup_voltage) - 0.16) * 161.29) / (1.0546 - (0.00216 * temp_c)); - if( humidity > 100.0 ) - humidity = 100.0; - else if( humidity < 0.0 ) - humidity = 0.0; - - /* Log the temperature and humidity */ - owSerialNum( 0, &TempSN[0], TRUE ); - log_humidity( sensor, temp_c, humidity, TempSN ); + if( humidity > 100.0 ) + humidity = 100.0; + else if( humidity < 0.0 ) + humidity = 0.0; - /* Good conversion finished */ - return TRUE; + result = TRUE; + break; } } @@ -1210,7 +1218,11 @@ msDelay(read_time); } - return FALSE; + /* Log the temperature and humidity */ + owSerialNum( 0, &TempSN[0], TRUE ); + log_humidity( sensor, temp_c, humidity, TempSN ); + + return result; } @@ -1417,23 +1429,24 @@ status = read_counter( sensor_family, sensor ); break; - case DS2438_FAMILY: - // What type is it? - { - int page; - for( page=3; page<8; page++) - { - get_ibl_type( 0, page, 0); - }} - if( opts & OPT_DS2438 ) - { - status = read_ds2438( sensor_family, sensor ); - } else { - status = read_humidity( sensor_family, sensor ); - } - break; - } - + case DS2438_FAMILY: + // What type is it? + { + int page; + for( page=3; page<8; page++) + { + get_ibl_type( 0, page, 0); + } + } + if( opts & OPT_DS2438 ) + { + status = read_ds2438( sensor_family, sensor ); + } else { + status = read_humidity( sensor_family, sensor ); + } + break; + } + return status; } @@ -1507,21 +1520,26 @@ { ptr = strtok( NULL, " \t\n" ); strncpy( serial_port, ptr, sizeof(serial_port)-1 ); + serial_port[sizeof(serial_port)-1] = 0x00; } else if( strncasecmp( "LOG_TYPE", ptr, 8 ) == 0 ) { ptr = strtok( NULL, " \t\n"); log_type = atoi( ptr ); } else if( strncasecmp( "LOG_FORMAT", ptr, 10 ) == 0 ) { ptr = strtok( NULL, "\"\n"); strncpy( temp_format, ptr, sizeof(temp_format)-1 ); + temp_format[sizeof(temp_format)-1] = 0x00; } else if( strncasecmp( "CNT_FORMAT", ptr, 10 ) == 0 ) { ptr = strtok( NULL, "\"\n"); strncpy( counter_format, ptr, sizeof(counter_format)-1 ); + counter_format[sizeof(counter_format)-1] = 0x00; } else if( strncasecmp( "HUM_FORMAT", ptr, 10 ) == 0 ) { ptr = strtok( NULL, "\"\n"); strncpy( humidity_format, ptr, sizeof(humidity_format)-1 ); + humidity_format[sizeof(humidity_format)-1] = 0x00; } else if( strncasecmp( "LOG", ptr, 3 ) == 0 ) { ptr = strtok( NULL, " \t\n" ); strncpy( log_file, ptr, sizeof(log_file)-1 ); + log_file[sizeof(log_file)-1] = 0x00; } else if( strncasecmp( "FAIL_TIME", ptr, 9 ) == 0 ) { } else if( strncasecmp( "READ_TIME", ptr, 9 ) == 0 ) { @@ -1546,7 +1564,12 @@ /* Main LAN sensors */ ptr = strtok( NULL, " \t\n" ); sensors = atoi( ptr ); - + if ( sensors >= sensor_list->max ) { + fprintf( stderr, "Error, too many ROM entries. Check SENSORS value.\n"); + fclose( fp ); + return -1; + } + /* Read the 8 byte ROM address */ for( x = 0; x < 8; x++ ) { @@ -2038,7 +2061,7 @@ /* Free up the coupler list */ free_coupler(0); - /* Initalize the coupler pointer */ + /* Initialize the coupler pointer */ coupler_end = coupler_top; if( !(opts & OPT_QUIET) ) @@ -2393,6 +2416,7 @@ case 'c': if( optarg ) /* Configuration file */ { strncpy( conf_file, optarg, sizeof( conf_file ) - 1 ); + conf_file[sizeof(conf_file)-1] = 0x00; } break; @@ -2402,7 +2426,7 @@ case 'w': opts |= OPT_WALK; /* Walk the LAN */ break; - case 'i': opts |= OPT_INIT; /* Initalize the s#'s */ + case 'i': opts |= OPT_INIT; /* Initialize the s#'s */ break; case 'r': tmp_read_time = atoi(optarg); /* Read delay in mS */ @@ -2414,12 +2438,14 @@ case 's': if(optarg) /* Serial port */ { strncpy( tmp_serial_port, optarg, sizeof(tmp_serial_port) - 1 ); + tmp_serial_port[sizeof(tmp_serial_port) - 1] = 0x00; } break; case 'l': if(optarg) /* Log Filename */ { strncpy( tmp_log_file, optarg, sizeof( tmp_log_file ) - 1); + tmp_log_file[sizeof( tmp_log_file ) - 1] = 0x00; } break; @@ -2456,10 +2482,12 @@ tmp_log_type = atoi(optarg); } else { /* Not a nuber, get the string */ - if( strlen( optarg ) > sizeof(tmp_temp_format)-1 ) + if( strlen( optarg ) > sizeof(tmp_temp_format)-1 ) { printf("Temperature format string too long! > %d\n", (int) sizeof(tmp_temp_format)-1); - else + } else { strncpy( tmp_temp_format, optarg, sizeof(tmp_temp_format)-1 ); + tmp_temp_format[sizeof(tmp_temp_format)-1] = 0x00; + } tmp_log_type=0; } } @@ -2467,19 +2495,23 @@ case 'O': if(optarg) /* Counter Logfile format */ { - if( strlen( optarg ) > sizeof(tmp_counter_format)-1 ) + if( strlen( optarg ) > sizeof(tmp_counter_format)-1 ) { printf("Counter format string too long! > %d\n", (int) sizeof(tmp_counter_format)-1); - else + } else { strncpy( tmp_counter_format, optarg, sizeof(tmp_counter_format)-1 ); + tmp_counter_format[sizeof(tmp_counter_format)-1] = 0x00; + } } break; case 'H': if(optarg) /* Humidity Logfile format */ { - if( strlen( optarg ) > sizeof(tmp_humidity_format)-1 ) + if( strlen( optarg ) > sizeof(tmp_humidity_format)-1 ) { printf("Humidity format string too long! > %d\n", (int) sizeof(tmp_humidity_format)-1); - else + } else { strncpy( tmp_humidity_format, optarg, sizeof(tmp_humidity_format)-1 ); + tmp_humidity_format[sizeof(tmp_humidity_format)-1] = 0x00; + } } break; @@ -2514,10 +2546,12 @@ if (tmp_serial_port[0] != 0) { strncpy( serial_port, tmp_serial_port, sizeof(serial_port)-1 ); + serial_port[sizeof(serial_port)-1] = 0x00; } if (tmp_log_file[0] != 0) { strncpy( log_file, tmp_log_file, sizeof(log_file)-1 ); + log_file[sizeof(log_file)-1] = 0x00; } if (tmp_log_type != -1) { @@ -2525,15 +2559,18 @@ if ( tmp_log_type == 0 ) { strncpy( temp_format, tmp_temp_format, sizeof(temp_format)-1 ); + temp_format[sizeof(temp_format)-1] = 0x00; } } if( tmp_counter_format[0] != 0 ) { strncpy( counter_format, tmp_counter_format, sizeof(counter_format)-1 ); + counter_format[sizeof(counter_format)-1] = 0x00; } if( tmp_humidity_format[0] != 0 ) { strncpy( humidity_format, tmp_humidity_format, sizeof(humidity_format)-1 ); + humidity_format[sizeof(humidity_format)-1] = 0x00; } /* Show the copyright banner? */ @@ -2617,7 +2654,7 @@ /* ------------------------------------------------------------------*/ - /* Should we initalize the sensors? */ + /* Should we initialize the sensors? */ /* This should store the serial numbers to the .digitemprc file */ if( opts & OPT_INIT ) { @@ -2643,7 +2680,13 @@ /* Record the starting time */ - start_time = time(NULL); + switch (log_type) { + case 4: + case 5: start_time = 0; /* Relative to 1970-01-01 00:00:00 (Unixtime) */ + break; + default: start_time = time(NULL); /* Relative to now */ + break; + } /* Sample the prescribed number of times, 0=infinity */ for( x = 0;num_samples==0 || x < num_samples; x++ ) @@ -2657,7 +2700,9 @@ start of the line */ case 2: - case 3: sprintf(temp, "%ld", elapsed_time ); + case 3: + case 4: + case 5: sprintf(temp, "%ld", elapsed_time ); log_string( temp ); break; default: @@ -2683,7 +2728,9 @@ start of the line */ case 2: - case 3: log_string( "\n" ); + case 3: + case 4: + case 5: log_string( "\n" ); break; default: break; diff -Nru digitemp-3.7.1/src/digitemp.h digitemp-3.7.2/src/digitemp.h --- digitemp-3.7.1/src/digitemp.h 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/src/digitemp.h 2018-11-19 19:01:33.000000000 +0000 @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- DigiTemp - Copyright 1996-2015 by Brian C. Lane + Copyright 1996-2018 by Brian C. Lane All Rights Reserved This program is free software; you can redistribute it and/or modify it @@ -18,7 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA ----------------------------------------------------------------------- */ -#define BANNER_1 "DigiTemp v3.7.1 Copyright 1996-2015 by Brian C. Lane\n" +#define BANNER_1 "DigiTemp v3.7.2 Copyright 1996-2018 by Brian C. Lane\n" #define BANNER_2 "GNU General Public License v2.0 - http://www.digitemp.com\n" #define BANNER_3 "Compiled for %s\n\n" diff -Nru digitemp-3.7.1/userial/ad26.c digitemp-3.7.2/userial/ad26.c --- digitemp-3.7.1/userial/ad26.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/ad26.c 2018-11-19 19:01:33.000000000 +0000 @@ -266,9 +266,10 @@ } +/* Return the temperature (in C) or -999.0 if there was a problem */ double Get_Temperature(int portnum) { - double ret=-1.0; + double ret=-999.0; uchar send_block[50]; int send_cnt=0; int i; @@ -294,7 +295,7 @@ send_block[send_cnt++] = 0x00; if(!owBlock(portnum,FALSE,send_block,send_cnt)) - return FALSE; + return ret; send_cnt = 0; } diff -Nru digitemp-3.7.1/userial/ds2490/owtran.c digitemp-3.7.2/userial/ds2490/owtran.c --- digitemp-3.7.1/userial/ds2490/owtran.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/ds2490/owtran.c 2018-11-19 19:01:33.000000000 +0000 @@ -42,7 +42,7 @@ // 1-Wire Net with an optional reset at the begining of communication. // The result is returned in the same buffer. // -// 'do_reset' - cause a owTouchReset to occure at the begining of +// 'do_reset' - cause a owTouchReset to occur at the begining of // communication TRUE(1) or not FALSE(0) // 'tran_buf' - pointer to a block of unsigned // chars of length 'TranferLength' that will be sent diff -Nru digitemp-3.7.1/userial/ds9097/owerr.c digitemp-3.7.2/userial/ds9097/owerr.c --- digitemp-3.7.1/userial/ds9097/owerr.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/ds9097/owerr.c 2018-11-19 19:01:33.000000000 +0000 @@ -136,7 +136,7 @@ // // Arguments: int err - the error code you wish to raise. // int lineno - DEBUG only - the line number where it was raised - // char* filename - DEBUG only - the file name where it occured. + // char* filename - DEBUG only - the file name where it occurred. // void owRaiseError(int err, int lineno, char* filename) { @@ -267,7 +267,7 @@ /*097*/ "Failed to create a challenge on the coprocessor.", /*098*/ "Transaction Incomplete: service data was not valid.", /*099*/ "Transaction Incomplete: service data was not updated.", - /*100*/ "Unrecoverable, catastrophic service failure occured.", + /*100*/ "Unrecoverable, catastrophic service failure occurred.", /*101*/ "Load First Secret from scratchpad data failed.", /*102*/ "Failed to match signature of user's service data." }; diff -Nru digitemp-3.7.1/userial/ds9097/owtran.c digitemp-3.7.2/userial/ds9097/owtran.c --- digitemp-3.7.1/userial/ds9097/owtran.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/ds9097/owtran.c 2018-11-19 19:01:33.000000000 +0000 @@ -42,7 +42,7 @@ // 1-Wire Net with an optional reset at the begining of communication. // The result is returned in the same buffer. // -// 'do_reset' - cause a owTouchReset to occure at the begining of +// 'do_reset' - cause a owTouchReset to occur at the begining of // communication TRUE(1) or not FALSE(0) // 'tran_buf' - pointer to a block of unsigned // chars of length 'TranferLength' that will be sent diff -Nru digitemp-3.7.1/userial/ds9097u/owllu.c digitemp-3.7.2/userial/ds9097u/owllu.c --- digitemp-3.7.1/userial/ds9097u/owllu.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/ds9097u/owllu.c 2018-11-19 19:01:33.000000000 +0000 @@ -139,7 +139,7 @@ else OWERROR(OWERROR_WRITECOM_FAILED); - // an error occured so re-sync with DS2480 + // an error occurred so re-sync with DS2480 DS2480Detect(portnum); return FALSE; @@ -199,7 +199,7 @@ else OWERROR(OWERROR_WRITECOM_FAILED); - // an error occured so re-sync with DS2480 + // an error occurred so re-sync with DS2480 DS2480Detect(portnum); return 0; @@ -289,7 +289,7 @@ else OWERROR(OWERROR_WRITECOM_FAILED); - // an error occured so re-sync with DS2480 + // an error occurred so re-sync with DS2480 DS2480Detect(portnum); return 0; @@ -547,7 +547,7 @@ else OWERROR(OWERROR_WRITECOM_FAILED); - // an error occured so re-sync with DS2480 + // an error occurred so re-sync with DS2480 DS2480Detect(portnum); return FALSE; diff -Nru digitemp-3.7.1/userial/ds9097u/ownetu.c digitemp-3.7.2/userial/ds9097u/ownetu.c --- digitemp-3.7.1/userial/ds9097u/ownetu.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/ds9097u/ownetu.c 2018-11-19 19:01:33.000000000 +0000 @@ -300,7 +300,7 @@ else OWERROR(OWERROR_WRITECOM_FAILED); - // an error occured so re-sync with DS2480 + // an error occurred so re-sync with DS2480 DS2480Detect(portnum); // reset the search diff -Nru digitemp-3.7.1/userial/ds9097u/owtrnu.c digitemp-3.7.2/userial/ds9097u/owtrnu.c --- digitemp-3.7.1/userial/ds9097u/owtrnu.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/ds9097u/owtrnu.c 2018-11-19 19:01:33.000000000 +0000 @@ -86,7 +86,7 @@ // // 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to // indicate the symbolic port number. -// 'do_reset' - cause a owTouchReset to occure at the begining of +// 'do_reset' - cause a owTouchReset to occur at the begining of // communication TRUE(1) or not FALSE(0) // 'tran_buf' - pointer to a block of unsigned // chars of length 'tran_len' that will be sent @@ -159,7 +159,7 @@ else OWERROR(OWERROR_WRITECOM_FAILED); - // an error occured so re-sync with DS2480 + // an error occurred so re-sync with DS2480 DS2480Detect(portnum); return FALSE; diff -Nru digitemp-3.7.1/userial/owerr.c digitemp-3.7.2/userial/owerr.c --- digitemp-3.7.1/userial/owerr.c 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/owerr.c 2018-11-19 19:01:33.000000000 +0000 @@ -136,7 +136,7 @@ // // Arguments: int err - the error code you wish to raise. // int lineno - DEBUG only - the line number where it was raised - // char* filename - DEBUG only - the file name where it occured. + // char* filename - DEBUG only - the file name where it occurred. // void owRaiseError(int err, int lineno, char* filename) { @@ -267,7 +267,7 @@ /*097*/ "Failed to create a challenge on the coprocessor.", /*098*/ "Transaction Incomplete: service data was not valid.", /*099*/ "Transaction Incomplete: service data was not updated.", - /*100*/ "Unrecoverable, catastrophic service failure occured.", + /*100*/ "Unrecoverable, catastrophic service failure occurred.", /*101*/ "Load First Secret from scratchpad data failed.", /*102*/ "Failed to match signature of user's service data." }; diff -Nru digitemp-3.7.1/userial/ownet.h digitemp-3.7.2/userial/ownet.h --- digitemp-3.7.1/userial/ownet.h 2015-12-12 22:21:37.000000000 +0000 +++ digitemp-3.7.2/userial/ownet.h 2018-11-19 19:01:33.000000000 +0000 @@ -87,17 +87,13 @@ #define SMALLINT uchar #endif -#ifdef SOLARIS -#include -#include -#endif - - //--------------------------------------------------------------// // Common Includes to ownet applications //--------------------------------------------------------------// #include +#include +#include //--------------------------------------------------------------//