Hi Paul, any feedback for me regarding this patch?
Best regards, Clemens Egger > -----Original Message----- > From: Egger Clemens > Sent: Wednesday, 23 January, 2013 1:16 PM > To: OWFS Developer's list > Subject: Patch - DS1921 Thermochron iButton - reading udate values > depends on local time zone > > Hi, > > working with the DS1921 Thermochron iButton I noticed that, when writing a > time value to clock/udate and reading it immediately afterwards, the > returned value differs notably to the written value. This is dependent 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 to fix this issue, see attachment. > > BTW: I already submitted this patch last year Nov 8 to this list, but I never > got > any feedback - just in case this sounds familiar. > > Best regards > Clemens Egger ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ Owfs-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/owfs-developers
