Deciphering hex coded timestamp from a fingerprint machine (zkemkeeper/ZEM560)

非 Y 不嫁゛ 提交于 2020-08-06 05:03:12

问题


I've been working on some raw data obtained from a fingerprint machine(zkemkeeper/ZEM560). I found out that there is a sets of data written in hex and I believe it is a 4 bytes, little endian number of seconds from a certain date. Here some examples of the raw data, actual result and expected date(got from GUI). My purpose is to get the expected date from the raw data.

What I have tried was,

import datetime

sample_expected_date = datetime.datetime(2019, 11, 29, 20, 45, 22).timestamp()
sample_raw_data = int(''.join('E2 E8 24 26'.split(' ')[::-1]), 16)
offset = sample_expected_date - sample_raw_data

raw_data = ['E2 E8 24 26', 'C9 1A 26 26', '44 A7 28 26',
            '3A 16 2A 26', 'BD 5D 4C 26', '9F 0E 4F 26',
            '25 60 50 26', '12 03 53 26', '24 ED 77 26',
            'C2 3E 79 26', '21 82 7A 26', '46 D7 9C 26',
            'DE 28 9E 26', 'A1 C0 A4 26', '32 12 A6 26']

date = {}
for raw in raw_data:
    date[raw] = datetime.datetime.fromtimestamp(int(''.join(raw.split(' ')[::-1]), 16) + offset)

for i in date.items():
    print(i)

I use the same offset to get the expected date for every other entries. I noticed that there are some discrepancies between the result I got and the expected date.

 Raw Data             Result            Expected Date
E2 E8 24 26    2019-11-29 20:45:22    2019-11-29 20:45:22
C9 1A 26 26    2019-11-30 18:30:33    2019-11-30 18:30:33
44 A7 28 26    2019-12-02 16:54:28    2019-12-01 16:54:28
3A 16 2A 26    2019-12-03 19:00:10    2019-12-02 19:00:10

BD 5D 4C 26    2019-12-29 19:02:21    2019-12-28 19:02:21
9F 0E 4F 26    2019-12-31 20:01:35    2019-12-30 20:01:35
25 60 50 26    2020-01-01 20:01:41    2020-12-31 20:01:41
12 03 53 26    2020-01-03 20:01:22    2020-01-02 20:01:22

24 ED 77 26    2020-01-31 20:01:40    2020-01-30 20:01:40
C2 3E 79 26    2020-02-01 20:02:10    2020-01-31 20:02:10
21 82 7A 26    2020-02-02 19:01:53    2020-02-01 19:01:53

46 D7 9C 26    2020-02-28 20:02:14    2020-02-27 20:02:14
DE 28 9E 26    2020-02-29 20:02:38    2020-02-28 20:02:38
A1 C0 A4 26    2020-03-05 20:03:45    2020-03-02 20:03:45
32 12 A6 26    2020-03-06 20:04:02    2020-03-03 20:04:02

The problem starts in :-

  • December with 1 day over
  • January with 1 day over
  • February with 1 day over
  • Mac with 3 days over

I guess the raw data always consider every months is 31 days.

Is there any idea/suggestion/explanation/guide for me to find the correct date?

来源:https://stackoverflow.com/questions/62828838/deciphering-hex-coded-timestamp-from-a-fingerprint-machine-zkemkeeper-zem560

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!