2

An external device sends me regularly timestamps which I cannot translate. The have the following format:

31.12.2012 12:00:00 = 3B 3E C0 00

31.12.2012 12:00:01 = 3B 3E C0 01

31.12.2012 12:00:10 = 3B 3E C0 0A

31.12.2012 12:01:00 = 3B 3E C0 40

31.12.2012 13:00:00 = 3B 3E D0 00

31.12.2012 12:30:00 - 3B 3E C7 80 

31.12.2012 12:30:59 - 3B 3E C7 BB 

31.12.2012 12:44:59 - 3B 3E CB 3B 

31.12.2012 12:45:00 - 3B 3E CB 40

31.13.2013 12:30:00 - 3F 3E C7 80

I have no idea how this timestamp is encoded, it's not the regular unix timestamp. It looks like the LSB contains the seconds, but it is not always like this (compare with 12:00:10). Does anybody has an idea how to solve this problem?

lenniep
  • 679
  • 4
  • 11
  • 27

1 Answers1

4

I don't understand what's odd about the 12:00:10 example, 0x0A equals 10. The 12:01:00 one though looks a bit weird:

12:01:00 3B 3E C0 40

That 40 in binary is 0100 0000 - my guess is that the last 6 bits are for seconds, which is enough to hold 0-59.

To be sure you'll have to supply data for different minute values.

The date also seems to be stored in portions of the bytes:

31 binary is 11111 12 binary is 1100

Looking at the additional data, my best guess is:

3B 3E C0 40 = 
0011 1011 0011 1110 1100 0000 1000 0000
yyyy yyMM MMdd dddh hhhh mmmm mmss ssss

001110 (the remaining bits) should be the year, but that value is 14 in decimal. Best wait till tomorrow so you have data for 2013 :-)

C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72
  • thanks, that was a good hint... it looks like you are right, here is some more data: 31.12.2012 - 12:30:00 - 3B 3E C7 80 31.12.2012 - 12:30:59 - 3B 3E C7 BB 31.12.2012 - 12:44:59 - 3B 3E CB 3B 31.12.2012 - 12:45:00 - 3B 3E CB 40 – lenniep Dec 31 '12 at 10:27
  • I took the liberty to add those to your original post. – C.Evenhuis Dec 31 '12 at 10:41
  • They all seem to match, I've updated my answer, leaving only the year value. – C.Evenhuis Dec 31 '12 at 10:51
  • thank you very much, I have just verified it. I have added an additional timestamp for 2013 to my original post. – lenniep Dec 31 '12 at 10:56
  • They now start with 3F, which equals 0011 1111, adding 1 to the mysterious year part (the last 2 bits being part of the month). It looks like year 0 is 1998. – C.Evenhuis Dec 31 '12 at 10:57