Hi, I've been working with 1-Wire Thermochron iButtons DS1921G#F50 for temperature logging and also started to develop some script for easy handling. But before I complain about some anomalies I found, I would like to thank you very much for owfs in the first place! It is a great project.
While testing my scripts I found out that, when writing a time value to clock/udate and reading it immediately afterwards, the returned value differs to the written value. This seems to be depending on the local time zone and whether it's daylight saving time or not. My environment variable TZ usually reads "Europe/Berlin". In the following example there's a difference of 3600 seconds i.e. 1 hour between the two values. $ ./owwrite -s 3000 21.D5542E000000/clock/udate 1352387000; ./owread -s 3000 21.D5542E000000/clock/udate 1352383400 Looking at the source code, I discovered that the function mktime is used to convert a struct tm to time_t. However mktime uses the local time zone which explains the time shift. The following workaround makes the time shift disappear: just set the TZ environment variable to UTC when invoking the server. TZ=UTC ./owserver -u -p 3000 There's a function timegm which is basically the opposite part to gmtime. The latter is already used in the code when writing a udate value to the iButton. In my opinion timegm would be more suitable than mktime. I developed a patch - see attachment - to fix this issue. I hope you find it useful. Best regards Clemens Egger -- Center for Biomedicine EURAC research Drususallee 1, I-39100 Bozen t +39 0471 055 524 [email protected]<mailto:[email protected]> - www.eurac.edu<outbind://79/www.eurac.edu>
patch3.2_utc_issue_timegm_insteadof_mktime
Description: patch3.2_utc_issue_timegm_insteadof_mktime
------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________ Owfs-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/owfs-developers
