I'm getting data from a sensor in the form of UDP packets. The manual provides the form for these packets, but I'm having trouble understanding how to interpret the timestamp. It's described as being an unsigned long that is 4 bytes in length (e.g. 'a07245ba') that is supposed to be interpreted as 20-bits integer and 12-bits fraction. I'm also confused by the info "modulo 20 bits" that is included.
How do I go about interpreting these timestamps correctly?
I've tried simply interpreting the number in two parts using Python's "int('str', 16)" function ( e.g. int('a0724',16) and int('5ba',16) ) and then combining the two parts with a decimal ( e.g. '657188.1466 seconds' ). This seems to give me the proper units for the timestamp (seconds), as I've recorded ~10 seconds of data and the first and last timestamp are 10 seconds apart. However, the fraction part of the number seems incorrect. When I plot the data, the timestamp will jump forwards and back unexpectedly, which leads me to believe I'm interpreting the timestamp incorrectly.
Additionally, the timestamp I have interpreted is not relative to any expected values. The manual says it should either be returned as seconds since power on, or seconds since 1/1/2010. When checked, neither of these seems to be the case.
So the timestamp jumps unexpectedly up to 726162.71 seconds and then back down to 726126.125 seconds. The first four bytes are the timestamp:
datasample = np.array(['b1491fda 00001017 00040a88 00000000 0a 02 00c24d18 0076dd10 fd13fe3c 0032d8ce 0222c71a 01f0f0fa',
'b1492010 00001018 00040a88 00000000 0a 02 00c249aa 0076dbee fd148e86 0032dc34 02235336 01f0f3c8',
'b1492047 00001019 00040a88 00000000 0a 02 00c2463c 0076dacc fd151ed0 0032df9a 0223df52 01f0f696',
'b149207d 0000101a 00040a88 00000000 0a 02 00c248d0 0076da0a fd13fff4 003265b8 02239a24 01f0f3e0',
'b14920b4 0000101b 00040a88 00000000 0a 02 00c248d0 0076da0a fd13fff4 003265b8 02239a24 01f0f3e0',
'b14920eb 0000101c 00040a88 00000000 0a 02 00c1eed0 0076a812 fd148d00 0032b896 022396fe 01f0b4ac'],
dtype='|S98')
timesample = np.array([726161.4058, 726162.16, 726162.71, 726162.125, 726162.18, 726162.235 ])
Here's a sample of two data packets that are ~10 seconds apart:
datasample10 = np.array(['b1a2f9ea 000012ea 00040a88 00000000 0a 02 00c230d4 007671a6 fd1c2538 002b512e 021b9f7c 01f14944',
'b1a39a8e 000015db 00040a88 00000000 0a 02 00c1d26c 0076b032 fd1c3554 002d51b2 021bd5a0 01f0cd92'],
dtype='|S98')
timesample10 = np.array([727599.2538, 727609.2702])